From c6007fefc6dc99d71484c410a1c05289f51b6ee6 Mon Sep 17 00:00:00 2001 From: Johnny Sequeira Date: Wed, 25 Sep 2024 11:26:49 -0600 Subject: [PATCH 01/10] Adding the option for specify the project title on the exported packaged QField project --- qfieldsync/gui/package_dialog.py | 9 +++++++-- qfieldsync/ui/package_dialog.ui | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 39c95e07..475bf86e 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -42,7 +42,7 @@ from libqfieldsync.project import ProjectConfiguration from libqfieldsync.project_checker import ProjectChecker from libqfieldsync.utils.file_utils import fileparts -from libqfieldsync.utils.qgis import get_project_title +from libqfieldsync.utils.qgis import open_project from qgis.core import Qgis, QgsApplication, QgsProject from qgis.PyQt.QtCore import QDir, Qt, QUrl from qgis.PyQt.QtGui import QIcon @@ -73,7 +73,8 @@ def __init__(self, iface, project, offline_editing, parent=None): self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) - self.project_lbl.setText(get_project_title(self.project)) + self.original_title_project = project.title() + self.new_project_title.setText(self.original_title_project) self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( self.package_project @@ -168,6 +169,8 @@ def package_project(self): self.qfield_preferences.set_value("exportDirectoryProject", export_folder) self.dirsToCopyWidget.save_settings() + self.project.setTitle(self.new_project_title.text()) + offline_convertor = OfflineConverter( self.project, export_folder, @@ -189,6 +192,8 @@ def package_project(self): try: QApplication.setOverrideCursor(Qt.WaitCursor) offline_convertor.convert() + self.project.setTitle(self.original_title_project) + open_project(self.project.fileName()) self.do_post_offline_convert_action(True) except Exception as err: self.do_post_offline_convert_action(False) diff --git a/qfieldsync/ui/package_dialog.ui b/qfieldsync/ui/package_dialog.ui index 4f423b7d..23d8028f 100644 --- a/qfieldsync/ui/package_dialog.ui +++ b/qfieldsync/ui/package_dialog.ui @@ -22,7 +22,7 @@ - <html><head/><body><p><span style=" font-weight:600;">Project:</span></p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Exported Project Title:</span></p></body></html> Qt::RichText @@ -30,7 +30,7 @@ - + 0 From cbd025dd7792b7d01f472432bfe6b3e7cd85e5f1 Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:24:22 -0600 Subject: [PATCH 02/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 475bf86e..6a4d3546 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -73,7 +73,7 @@ def __init__(self, iface, project, offline_editing, parent=None): self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) - self.original_title_project = project.title() + self.original_project_title = project.title() self.new_project_title.setText(self.original_title_project) self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( From c32b0049c9dd79b0a4b662596ba212fc8e52fdc8 Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:24:47 -0600 Subject: [PATCH 03/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 6a4d3546..ef732a12 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -74,7 +74,7 @@ def __init__(self, iface, project, offline_editing, parent=None): self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) self.original_project_title = project.title() - self.new_project_title.setText(self.original_title_project) + self.packaged_project_title.setText(self.original_title_project) self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( self.package_project From 7fed37b8dc09f74492cc5dd30d7a9d0182c6ee86 Mon Sep 17 00:00:00 2001 From: Johnny Sequeira Date: Fri, 4 Oct 2024 20:21:26 -0600 Subject: [PATCH 04/10] Adding line edit for specify the project name, and improve the synchronization of packaged projects --- qfieldsync/gui/package_dialog.py | 19 +++++-- qfieldsync/gui/synchronize_dialog.py | 4 +- qfieldsync/ui/package_dialog.ui | 75 +++++++++++++++++----------- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index ef732a12..a190df74 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -42,7 +42,7 @@ from libqfieldsync.project import ProjectConfiguration from libqfieldsync.project_checker import ProjectChecker from libqfieldsync.utils.file_utils import fileparts -from libqfieldsync.utils.qgis import open_project +from libqfieldsync.utils.qgis import open_project, make_temp_qgis_file from qgis.core import Qgis, QgsApplication, QgsProject from qgis.PyQt.QtCore import QDir, Qt, QUrl from qgis.PyQt.QtGui import QIcon @@ -70,11 +70,15 @@ def __init__(self, iface, project, offline_editing, parent=None): self.iface = iface self.offliner = QgisCoreOffliner(offline_editing=offline_editing) self.project = project + self.original_project_path = self.project.fileName() self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) self.original_project_title = project.title() - self.packaged_project_title.setText(self.original_title_project) + self.packaged_project_title.setText(self.original_project_title) + self.packaged_project_name.setText(self.project.baseName()) + self.tmp_project = make_temp_qgis_file(self.project) + self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( self.package_project @@ -169,7 +173,13 @@ def package_project(self): self.qfield_preferences.set_value("exportDirectoryProject", export_folder) self.dirsToCopyWidget.save_settings() - self.project.setTitle(self.new_project_title.text()) + tmp_path = os.path.dirname(self.tmp_project) + + new_project_path = os.path.join( + tmp_path, f"{self.packaged_project_name.text()}.qgs" + ) + self.project.write(new_project_path) + self.project.setFileName(new_project_path) offline_convertor = OfflineConverter( self.project, @@ -192,8 +202,7 @@ def package_project(self): try: QApplication.setOverrideCursor(Qt.WaitCursor) offline_convertor.convert() - self.project.setTitle(self.original_title_project) - open_project(self.project.fileName()) + open_project(self.original_project_path) self.do_post_offline_convert_action(True) except Exception as err: self.do_post_offline_convert_action(False) diff --git a/qfieldsync/gui/synchronize_dialog.py b/qfieldsync/gui/synchronize_dialog.py index 401b4062..e34c9845 100644 --- a/qfieldsync/gui/synchronize_dialog.py +++ b/qfieldsync/gui/synchronize_dialog.py @@ -113,7 +113,9 @@ def start_synchronization(self): self.offline_editing.synchronize() project_config = ProjectConfiguration(QgsProject.instance()) - original_path = Path(project_config.original_project_path or "") + original_path = Path( + current_path or project_config.original_project_path or "" + ) if not original_path.exists(): answer = QMessageBox.warning( diff --git a/qfieldsync/ui/package_dialog.ui b/qfieldsync/ui/package_dialog.ui index 23d8028f..9f9da392 100644 --- a/qfieldsync/ui/package_dialog.ui +++ b/qfieldsync/ui/package_dialog.ui @@ -7,7 +7,7 @@ 0 0 599 - 570 + 700 @@ -15,34 +15,53 @@ - - - 0 + + + bold - - - - <html><head/><body><p><span style=" font-weight:600;">Exported Project Title:</span></p></body></html> - - - Qt::RichText - - - - - - - - 0 - 0 - - - - - - - - + + <html><head/><body><p><span style=" font-weight:600;">Packaged Project Name</span></p></body></html> + + + Qt::RichText + + + + + + + + 0 + 0 + + + + + + + + + + + <p><span style=" font-weight:600;">Packaged Project Title</span></p> + + + Qt::RichText + + + + + + + + 0 + 0 + + + + + + From c0e8891973886e917e76d9d9a3fe7fffbe21f181 Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:25:29 -0600 Subject: [PATCH 05/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index a190df74..559b0af8 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -74,8 +74,7 @@ def __init__(self, iface, project, offline_editing, parent=None): self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) - self.original_project_title = project.title() - self.packaged_project_title.setText(self.original_project_title) + self.packaged_project_title.setText(get_project_title(self.project)) self.packaged_project_name.setText(self.project.baseName()) self.tmp_project = make_temp_qgis_file(self.project) From d2ad20802f334e268b419b85733f36560a526458 Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:26:45 -0600 Subject: [PATCH 06/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 559b0af8..e834a099 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -70,7 +70,7 @@ def __init__(self, iface, project, offline_editing, parent=None): self.iface = iface self.offliner = QgisCoreOffliner(offline_editing=offline_editing) self.project = project - self.original_project_path = self.project.fileName() + self._original_project_path = self.project.fileName() self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) From e3e66361f7541fbd58822ee3ee54496a9fd8b34e Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:41:28 -0600 Subject: [PATCH 07/10] Update qfieldsync/ui/package_dialog.ui Co-authored-by: Ivan Ivanov --- qfieldsync/ui/package_dialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/ui/package_dialog.ui b/qfieldsync/ui/package_dialog.ui index 9f9da392..97edb2a2 100644 --- a/qfieldsync/ui/package_dialog.ui +++ b/qfieldsync/ui/package_dialog.ui @@ -28,7 +28,7 @@ - + 0 From b29d3e75c3588a6dcf18360b20eecce01df483e5 Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:46:59 -0600 Subject: [PATCH 08/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index e834a099..6d290cc4 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -76,7 +76,7 @@ def __init__(self, iface, project, offline_editing, parent=None): self.__project_configuration = ProjectConfiguration(self.project) self.packaged_project_title.setText(get_project_title(self.project)) self.packaged_project_name.setText(self.project.baseName()) - self.tmp_project = make_temp_qgis_file(self.project) + self.tmp_project_filename = make_temp_qgis_file(self.project) self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( From 8310d13c3a4639f10fbe64d54cab80d2578138ab Mon Sep 17 00:00:00 2001 From: Johnny <77129293+SeqLaz@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:49:09 -0600 Subject: [PATCH 09/10] Update qfieldsync/gui/package_dialog.py Co-authored-by: Ivan Ivanov --- qfieldsync/gui/package_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 6d290cc4..f3579f4a 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -172,7 +172,7 @@ def package_project(self): self.qfield_preferences.set_value("exportDirectoryProject", export_folder) self.dirsToCopyWidget.save_settings() - tmp_path = os.path.dirname(self.tmp_project) + tmp_project_filepath = Path(self.tmp_project_filename).parent new_project_path = os.path.join( tmp_path, f"{self.packaged_project_name.text()}.qgs" From 218fc89faef64c45d8da4d665a3869926525979a Mon Sep 17 00:00:00 2001 From: Johnny Sequeira Date: Thu, 10 Oct 2024 17:01:07 -0600 Subject: [PATCH 10/10] Moving the Packaged Project Filename and Title to libqfieldsync --- qfieldsync/gui/package_dialog.py | 17 ++++------------- qfieldsync/ui/package_dialog.ui | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index f3579f4a..7664be8b 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -42,7 +42,7 @@ from libqfieldsync.project import ProjectConfiguration from libqfieldsync.project_checker import ProjectChecker from libqfieldsync.utils.file_utils import fileparts -from libqfieldsync.utils.qgis import open_project, make_temp_qgis_file +from libqfieldsync.utils.qgis import get_project_title from qgis.core import Qgis, QgsApplication, QgsProject from qgis.PyQt.QtCore import QDir, Qt, QUrl from qgis.PyQt.QtGui import QIcon @@ -70,13 +70,11 @@ def __init__(self, iface, project, offline_editing, parent=None): self.iface = iface self.offliner = QgisCoreOffliner(offline_editing=offline_editing) self.project = project - self._original_project_path = self.project.fileName() self.qfield_preferences = Preferences() self.dirsToCopyWidget = DirsToCopyWidget() self.__project_configuration = ProjectConfiguration(self.project) + self.packaged_project_filename.setText(self.project.baseName()) self.packaged_project_title.setText(get_project_title(self.project)) - self.packaged_project_name.setText(self.project.baseName()) - self.tmp_project_filename = make_temp_qgis_file(self.project) self.button_box.button(QDialogButtonBox.Save).setText(self.tr("Create")) self.button_box.button(QDialogButtonBox.Save).clicked.connect( @@ -172,17 +170,11 @@ def package_project(self): self.qfield_preferences.set_value("exportDirectoryProject", export_folder) self.dirsToCopyWidget.save_settings() - tmp_project_filepath = Path(self.tmp_project_filename).parent - - new_project_path = os.path.join( - tmp_path, f"{self.packaged_project_name.text()}.qgs" - ) - self.project.write(new_project_path) - self.project.setFileName(new_project_path) - offline_convertor = OfflineConverter( self.project, export_folder, + self.packaged_project_filename.text(), + self.packaged_project_title.text(), area_of_interest, area_of_interest_crs, self.qfield_preferences.value("attachmentDirs"), @@ -201,7 +193,6 @@ def package_project(self): try: QApplication.setOverrideCursor(Qt.WaitCursor) offline_convertor.convert() - open_project(self.original_project_path) self.do_post_offline_convert_action(True) except Exception as err: self.do_post_offline_convert_action(False) diff --git a/qfieldsync/ui/package_dialog.ui b/qfieldsync/ui/package_dialog.ui index 97edb2a2..8458b867 100644 --- a/qfieldsync/ui/package_dialog.ui +++ b/qfieldsync/ui/package_dialog.ui @@ -20,7 +20,7 @@ bold - <html><head/><body><p><span style=" font-weight:600;">Packaged Project Name</span></p></body></html> + <p><span style=" font-weight:600;">Packaged Project Name</span></p> Qt::RichText