Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to force auto-push and manage time interval via project configuration #566

Merged
merged 2 commits into from
Feb 28, 2024
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
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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ future
transifex-client

# NOTE `libqfielsync` version should be defined in the `*.tar.gz` format, not `git+https://` to make `wheel` happy
libqfieldsync @ https://github.com/opengisch/libqfieldsync/archive/e3647e9b0fcbaf74cbb4c3f72bc8f34d99cb44e0.tar.gz
libqfieldsync @ https://github.com/opengisch/libqfieldsync/archive/3c0b0c4903d0a5e6944779d4d43a64e29542bd87.tar.gz
Loading