1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-02-23 06:40:39 +00:00

Implement add profile button (#158) (#179)

Currently the add profile action is inside of the profile dropdown list
as `+ Add profile` while edit and delete have their own buttons. This
commit moves the add profile action out of the dropdown into its own
button for UI consistency.
This commit is contained in:
Aidan Pieper 2019-02-07 20:28:01 -08:00 committed by Manuel Riel
parent 351b8370a7
commit f04354279f
8 changed files with 1126 additions and 1040 deletions

View file

@ -62,13 +62,30 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profileAddButton">
<property name="text">
<string>Add Profile</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/plus.svg</normaloff>:/icons/plus.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profileRenameButton">
<property name="toolTip">
<string>Rename Profile</string>
</property>
<property name="icon">
<iconset resource="../icons/collection.qrc">
<iconset>
<normaloff>:/icons/edit.svg</normaloff>:/icons/edit.svg</iconset>
</property>
<property name="iconSize">
@ -88,7 +105,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icons/collection.qrc">
<iconset>
<normaloff>:/icons/trash.svg</normaloff>:/icons/trash.svg</iconset>
</property>
</widget>
@ -111,7 +128,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>2</number>
</property>
<property name="documentMode">
<bool>false</bool>

View file

@ -16,5 +16,6 @@
<file>globe.svg</file>
<file>cloud-download.svg</file>
<file>terminal.svg</file>
<file>plus.svg</file>
</qresource>
</RCC>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1600 736v192q0 40-28 68t-68 28h-416v416q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-416h-416q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h416v-416q0-40 28-68t68-28h192q40 0 68 28t28 68v416h416q40 0 68 28t28 68z"/></svg>

After

Width:  |  Height:  |  Size: 354 B

View file

@ -16,5 +16,6 @@
<file>globe.svg</file>
<file>cloud-download.svg</file>
<file>terminal.svg</file>
<file>plus.svg</file>
</qresource>
</RCC>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1600 736v192q0 40-28 68t-68 28h-416v416q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-416h-416q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h416v-416q0-40 28-68t68-28h192q40 0 68 28t28 68v416h416q40 0 68 28t28 68z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 366 B

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -51,14 +51,13 @@ def __init__(self, parent=None):
self.app.backup_cancelled_event.connect(self.backup_cancelled_event)
# Init profile list
self.profileSelector.addItem(self.tr('+ Add New Profile'), None)
self.profileSelector.insertSeparator(2)
for profile in BackupProfileModel.select():
self.profileSelector.addItem(profile.name, profile.id)
self.profileSelector.setCurrentIndex(2)
self.profileSelector.setCurrentIndex(0)
self.profileSelector.currentIndexChanged.connect(self.profile_select_action)
self.profileRenameButton.clicked.connect(self.profile_rename_action)
self.profileDeleteButton.clicked.connect(self.profile_delete_action)
self.profileAddButton.clicked.connect(self.profile_add_action)
# OS-specific startup options:
if sys.platform != 'darwin':
@ -91,16 +90,6 @@ def _toggle_buttons(self, create_enabled=True):
self.cancelButton.repaint()
def profile_select_action(self, index):
if index == 0:
window = AddProfileWindow()
window.setParent(self, QtCore.Qt.Sheet)
window.show()
if window.exec_() and window.edited_profile:
self.profileSelector.addItem(window.edited_profile.name, window.edited_profile.id)
self.profileSelector.setCurrentIndex(self.profileSelector.count() - 1)
else:
self.profileSelector.setCurrentIndex(2)
self.current_profile = BackupProfileModel.get(id=self.profileSelector.currentData())
self.archiveTab.populate_from_profile()
self.repoTab.populate_from_profile()
@ -115,7 +104,7 @@ def profile_rename_action(self):
self.profileSelector.setItemText(self.profileSelector.currentIndex(), window.edited_profile.name)
def profile_delete_action(self):
if self.profileSelector.count() > 3:
if self.profileSelector.count() > 1:
to_delete = BackupProfileModel.get(id=self.profileSelector.currentData())
# Remove pending background jobs
@ -125,7 +114,17 @@ def profile_delete_action(self):
to_delete.delete_instance(recursive=True)
self.profileSelector.removeItem(self.profileSelector.currentIndex())
self.profile_select_action(1)
self.profile_select_action(0)
def profile_add_action(self):
window = AddProfileWindow()
window.setParent(self, QtCore.Qt.Sheet)
window.show()
if window.exec_() and window.edited_profile:
self.profileSelector.addItem(window.edited_profile.name, window.edited_profile.id)
self.profileSelector.setCurrentIndex(self.profileSelector.count() - 1)
else:
self.profileSelector.setCurrentIndex(self.profileSelector.currentIndex())
def backup_started_event(self):
self.set_status(progress_max=0)