Skip to content

Commit

Permalink
Adding the option for specify the project title on the exported packa…
Browse files Browse the repository at this point in the history
…ged QField project
  • Loading branch information
SeqLaz committed Sep 25, 2024
1 parent 526dd43 commit c6007fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions qfieldsync/gui/package_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions qfieldsync/ui/package_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Project:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Exported Project Title:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="project_lbl">
<widget class="QLineEdit" name="new_project_title">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down

0 comments on commit c6007fe

Please sign in to comment.