Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 76 additions & 27 deletions profile_manager/profile_manager_dialog.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
from collections import defaultdict
from functools import partial
from pathlib import Path
from typing import Literal, Optional

from qgis.core import QgsApplication
from qgis.PyQt import QtWidgets, uic
from qgis.PyQt.QtCore import QSize, Qt
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QDialog, QListWidget, QMessageBox, QTreeWidget
from qgis.PyQt.QtCore import QSize, Qt, QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import (
QDialog,
QDialogButtonBox,
QListWidget,
QMessageBox,
QTreeWidget,
)

# plugin
from profile_manager.__about__ import DIR_PLUGIN_ROOT
from profile_manager.__about__ import DIR_PLUGIN_ROOT, __uri_homepage__
from profile_manager.gui.mdl_profiles import ProfileListModel
from profile_manager.gui.name_profile_dialog import NameProfileDialog
from profile_manager.gui.utils import data_sources_as_tree, plugins_as_items
Expand Down Expand Up @@ -37,21 +44,55 @@ def __init__(self, profile_manager, parent=None):

self.__profile_manager = profile_manager
self.__everything_is_checked = False

self.profile_mdl = ProfileListModel(self)
self.qdt_export_profile_cbx.setModel(self.profile_mdl)
self.export_qdt_button.clicked.connect(self.export_qdt_handler)
self.export_qdt_button.setEnabled(False)
self.qdt_file_widget.fileChanged.connect(self._qdt_export_dir_changed)

self.comboBoxNamesSource.setModel(self.profile_mdl)
self.comboBoxNamesTarget.setModel(self.profile_mdl)
self.btn_standard_buttons.button(
QDialogButtonBox.StandardButton.Help
).setToolTip(self.tr("Open documentation"))

# tabs icons
self.tabWidget.setTabIcon(0, QgsApplication.getThemeIcon("user.svg"))
self.tabWidget.setTabIcon(1, QgsApplication.getThemeIcon("sync_views.svg"))
self.tabWidget.setTabIcon(
2,
QIcon(str(DIR_PLUGIN_ROOT.joinpath("resources", "images", "logo_qdt.svg"))),
)

# tab0: profiles
self.createProfileButton.setIcon(
QIcon(QgsApplication.iconPath("mActionAdd.svg"))
)
self.copyProfileButton.setIcon(
QIcon(QgsApplication.getThemeIcon("mActionEditCopy.svg"))
)
self.editProfileButton.setIcon(
QIcon(QgsApplication.getThemeIcon("mActionToggleEditing.svg"))
)
self.removeProfileButton.setIcon(
QIcon(QgsApplication.iconPath("mActionDeleteSelected.svg"))
)
self.list_profiles.setModel(self.profile_mdl)
self.setFixedSize(self.size())
self.list_profiles.setIconSize(QSize(15, 15))

self.__setup_connections()

# tab1: import/export
self.tabWidget_2.setTabIcon(
0, QgsApplication.getThemeIcon("mActionDataSourceManager.svg")
)
self.tabWidget_2.setTabIcon(
1, QgsApplication.getThemeIcon("mActionShowPluginManager.svg")
)
self.tabWidget_2.setTabIcon(
2, QgsApplication.getThemeIcon("iconClassBrowserConsole.svg")
)
self.removeThingsButton.setIcon(
QgsApplication.getThemeIcon("mActionRemoveSelectedFeature.svg")
)
self.importThingsButton.setIcon(
QgsApplication.getThemeIcon("mActionSharingImport.svg")
)
# tab1.0: data sources
self.comboBoxNamesSource.setModel(self.profile_mdl)
self.comboBoxNamesTarget.setModel(self.profile_mdl)
# making sure that the combo boxes are set up correctly
self.comboBoxNamesSource.currentTextChanged.emit(
self.comboBoxNamesSource.currentText()
Expand All @@ -60,15 +101,12 @@ def __init__(self, profile_manager, parent=None):
self.comboBoxNamesTarget.currentText()
)

# tabs icons
self.tabWidget.setTabIcon(0, QgsApplication.getThemeIcon("user.svg"))
self.tabWidget.setTabIcon(
1, QgsApplication.getThemeIcon("mActionSharingImport.svg")
)
self.tabWidget.setTabIcon(
2,
QIcon(str(DIR_PLUGIN_ROOT.joinpath("resources", "images", "logo_qdt.svg"))),
)
# tab2: QDT export
self.qdt_export_profile_cbx.setModel(self.profile_mdl)

self.export_qdt_button.setEnabled(False)

self.__setup_connections()

def __setup_connections(self):
"""Set up connections"""
Expand All @@ -81,7 +119,18 @@ def __setup_connections(self):
self.editProfileButton.clicked.connect(self.__rename_profile)
self.copyProfileButton.clicked.connect(self.__copy_profile)

self.closeButton.rejected.connect(self.reject)
self.btn_standard_buttons.rejected.connect(self.reject)
self.btn_standard_buttons.button(
QDialogButtonBox.StandardButton.Help
).clicked.connect(
partial(
QDesktopServices.openUrl,
QUrl(__uri_homepage__),
)
)

self.export_qdt_button.clicked.connect(self.export_qdt_handler)
self.qdt_file_widget.fileChanged.connect(self._qdt_export_dir_changed)

# checkbox
self.checkBox_checkAll.stateChanged.connect(self.__toggle_all_items)
Expand Down Expand Up @@ -109,13 +158,13 @@ def __setup_connections(self):
)
checkboxes = [
self.bookmark_check,
self.checkBox_checkAll,
self.customization_check,
self.favourites_check,
self.expressions_check,
self.models_check,
self.scripts_check,
self.styles_check,
self.expressions_check,
self.checkBox_checkAll,
self.customization_check,
]
for checkbox in checkboxes:
checkbox.stateChanged.connect(self.__conditionally_enable_import_buttons)
Expand Down
197 changes: 114 additions & 83 deletions profile_manager/profile_manager_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>701</width>
<height>503</height>
<width>739</width>
<height>473</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,13 +17,19 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_profiles">
<attribute name="title">
Expand Down Expand Up @@ -265,84 +271,109 @@
</widget>
<widget class="QWidget" name="tab_models">
<attribute name="title">
<string>Other (Import only)</string>
<string>Other...</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="bookmark_check">
<property name="text">
<string>Bookmarks</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="favourites_check">
<property name="text">
<string>Favourites</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="models_check">
<property name="text">
<string>Models</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="scripts_check">
<property name="text">
<string>Scripts</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="styles_check">
<property name="text">
<string>Styles + Labels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="customization_check">
<property name="text">
<string>UI Customization (e.g. hidden toolbar icons)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="expressions_check">
<property name="text">
<string>Expressions</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
<widget class="QFrame" name="frame_3">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>491</width>
<height>441</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="bookmark_check">
<property name="text">
<string>Bookmarks</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="favourites_check">
<property name="text">
<string>Favourites</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="models_check">
<property name="text">
<string>Models</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="scripts_check">
<property name="text">
<string>Scripts</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="styles_check">
<property name="text">
<string>Styles + Labels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="customization_check">
<property name="text">
<string>UI Customization (e.g. hidden toolbar icons)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="expressions_check">
<property name="text">
<string>Expressions</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QLabel" name="blb_other_import_only">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>591</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>Those items can only be imported.</string>
</property>
</widget>
</widget>
</widget>
</item>
Expand Down Expand Up @@ -472,9 +503,9 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="closeButton">
<widget class="QDialogButtonBox" name="btn_standard_buttons">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
Expand Down