Skip to content

Commit

Permalink
Allow users to force auto-push and manage time interval via project c…
Browse files Browse the repository at this point in the history
…onfiguration
  • Loading branch information
nirvn committed Feb 28, 2024
1 parent 5f28f08 commit 579e5ec
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
18 changes: 18 additions & 0 deletions qfieldsync/gui/project_configuration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def __init__(self, parent=None):
)
self.singleLayerRadioButton.toggled.connect(self.baseMapTypeChanged)

self.forceAutoPush.clicked.connect(self.onForceAutoPushClicked)

self.attachmentDirsListWidget.itemChanged.connect(self.onItemChanged)
self.event_eater = EventEater()
self.attachmentDirsListWidget.installEventFilter(self.event_eater)
Expand Down Expand Up @@ -191,6 +193,14 @@ def reloadProject(self):
self.__project_configuration.layer_action_preference == "offline"
)

self.forceAutoPush.setChecked(self.__project_configuration.force_auto_push)
self.forceAutoPushInterval.setEnabled(
self.__project_configuration.force_auto_push
)
self.forceAutoPushInterval.setValue(
self.__project_configuration.force_auto_push_interval_mins
)

attachment_dirs = [*self.preferences.value("attachmentDirs")]
attachment_dirs.append("")

Expand Down Expand Up @@ -279,6 +289,11 @@ def apply(self):
"online" if self.preferOnlineLayersRadioButton.isChecked() else "offline"
)

self.__project_configuration.force_auto_push = self.forceAutoPush.isChecked()
self.__project_configuration.force_auto_push_interval_mins = (
self.forceAutoPushInterval.value()
)

v = QLibraryInfo.version()
match_flag = (
Qt.MatchRegularExpression
Expand All @@ -290,6 +305,9 @@ def apply(self):
keys[item.text()] = 1
self.preferences.set_value("attachmentDirs", list(keys.keys()))

def onForceAutoPushClicked(self, checked):
self.forceAutoPushInterval.setEnabled(checked)

def onLayerActionPreferenceChanged(self):
"""Triggered when prefer online or offline radio buttons have been changed"""
prefer_online = self.preferOnlineLayersRadioButton.isChecked()
Expand Down
45 changes: 45 additions & 0 deletions qfieldsync/ui/project_configuration_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,51 @@
</widget>
</item>
<item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="forceAutoPush">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatically push pending changes on the following interval</string>
</property>
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="forceAutoPushInterval">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string> minutes</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2880</number>
</property>
<property name="value">
<number>30</number>
</property>
<property name="showClearButton">
<bool>true</bool>
</property>
<property name="clearValue">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down

0 comments on commit 579e5ec

Please sign in to comment.