Skip to content
Open
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
16 changes: 14 additions & 2 deletions profile_manager/profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,29 @@ def change_target_profile(self, profile_name: str):
self.target_data_sources = collect_data_sources(self.target_qgis_ini_file)
self.target_plugins = collect_plugin_names(self.target_qgis_ini_file)

def make_backup(self, profile_name: str) -> Optional[str]:
def make_backup(self, profile_name: str, backup_dir: str) -> Optional[str]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snennis The backup_dir should be optionnal. make_backup is used outside qdt export and there will be an regression.

IMHO we should make it optional and use default value self.backup_dir if not defined.

What do you think @kannes ?

"""Creates a backup of the specified profile.

Args:
profile_name (str): Name of the profile to back up
backup_dir (str): Directory where backup should be stored

Returns:
str: A message if an error occured.
"""
######################################################################
backup_path = Path(backup_dir)

if not backup_path.exists():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't exists it should be created. What do you think @kannes ?

QgsMessageLog.logMessage(
f"invalid backup path: {backup_dir}",
"Profile Manager",
level=Qgis.MessageLevel.Info,
)
# return ?
######################################################################
ts = int(time.time())
target_path = self.backup_path / str(ts)
target_path = backup_path / str(ts)
source_path = qgis_profiles_path() / profile_name
QgsMessageLog.logMessage(
f"Backing up profile {profile_name!r} to {target_path!r}",
Expand Down
8 changes: 7 additions & 1 deletion profile_manager/profile_manager_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ def _set_qdt_profile_infos(self, qdt_profile_infos: QDTProfileInfos) -> None:
def export_qdt_handler(self) -> None:
"""Export selected profile as QDT profile"""
profile_path = self.qdt_file_widget.filePath()
if profile_path:
backup_path = (
self.qdt_backup_file_widget.filePath()
) # NEW sets backup_path from Widget
if profile_path and backup_path: # NEW check for both
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my remark for the parameter backup_path in make_backup. We should be able to left the path empty. In this case default value from profile manager will be used Path.home() / "QGIS Profile Manager Backup")

source_profile_name = self.qdt_export_profile_cbx.currentText()
make = self.__profile_manager.make_backup(
source_profile_name, backup_path
) # NEW idk how to name it tbh
export_profile_for_qdt(
profile_name=source_profile_name,
export_path=Path(profile_path),
Expand Down
146 changes: 80 additions & 66 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>808</width>
<height>673</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -20,7 +20,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_profiles">
<attribute name="title">
Expand Down Expand Up @@ -350,7 +350,56 @@
<string>QDT Export</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="7" column="2">
<widget class="QLineEdit" name="qdt_qgis_max_version_edit"/>
</item>
<item row="13" column="0" colspan="4">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="0" colspan="4">
<widget class="QPushButton" name="export_qdt_button">
<property name="text">
<string>Export</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="qdt_qgis_min_version_edit"/>
</item>
<item row="0" column="2">
<widget class="QgsFileWidget" name="qdt_file_widget">
<property name="storageMode">
<enum>QgsFileWidget::GetDirectory</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QTextEdit" name="qdt_description_edit"/>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="qdt_email_edit"/>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="qdt_inactive_plugin_export_checkbox">
<property name="text">
<string>Export inactive plugins</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="qdt_version_edit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="qdt_profile_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
Expand All @@ -363,107 +412,72 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="qdt_qgis_min_version_label">
<item row="0" column="0">
<widget class="QLabel" name="lbl_export_folder">
<property name="text">
<string>QGIS min. version</string>
<string>Export folder</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="qdt_description_label">
<item row="9" column="0">
<widget class="QCheckBox" name="qdt_clear_export_folder_checkbox">
<property name="text">
<string>Description</string>
<string>Clear export folder</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="qdt_export_profile_cbx"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="qdt_email_label">
<item row="6" column="0">
<widget class="QLabel" name="qdt_qgis_min_version_label">
<property name="text">
<string>Email</string>
<string>QGIS min. version</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="qdt_email_edit"/>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="qdt_version_edit"/>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="qdt_clear_export_folder_checkbox">
<item row="7" column="0">
<widget class="QLabel" name="qdt_qgis_max_version_label">
<property name="text">
<string>Clear export folder</string>
<string>QGIS max. version</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="qdt_qgis_min_version_edit"/>
</item>
<item row="11" column="0" colspan="3">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="qdt_inactive_plugin_export_checkbox">
<item row="4" column="0">
<widget class="QLabel" name="qdt_email_label">
<property name="text">
<string>Export inactive plugins</string>
<string>Email</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="qdt_version_label">
<property name="text">
<string>Version</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QPushButton" name="export_qdt_button">
<item row="3" column="0">
<widget class="QLabel" name="qdt_description_label">
<property name="text">
<string>Export</string>
<string>Description</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="qdt_qgis_max_version_label">
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="qdt_export_profile_cbx"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>QGIS max. version</string>
<string>Backup folder</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="qdt_qgis_max_version_edit"/>
</item>
<item row="2" column="1">
<widget class="QTextEdit" name="qdt_description_edit"/>
</item>
<item row="0" column="1">
<widget class="QgsFileWidget" name="qdt_file_widget">
<item row="1" column="2">
<widget class="QgsFileWidget" name="qdt_backup_file_widget">
<property name="storageMode">
<enum>QgsFileWidget::GetDirectory</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_export_folder">
<property name="text">
<string>Export folder</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down
Loading