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

New setting to toggle visibility of non-cloud packaging toolbar buttons, hide by default #553

Merged
merged 3 commits into from
Jan 3, 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
6 changes: 3 additions & 3 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ jobs:
--osgeo-password ${OSGEO_PASSWORD} \
--asset-path qfieldsync/libqfieldsync.whl

- name: Release
- name: Package
if: ${{ github.event_name == 'pull_request' }}
run: |
qgis-plugin-ci package dev \
qgis-plugin-ci package 0.1 \
--asset-path qfieldsync/libqfieldsync.whl

- uses: actions/upload-artifact@v3
with:
name: qfieldsync-plugin
path: qfieldsync.dev.zip
path: qfieldsync.0.1.zip
package:
runs-on: ubuntu-22.04
env:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: 📜 Documentation
on:
pull_request_target:
types:
- closed
- labeled
jobs:
backport:
runs-on: ubuntu-latest
name: Create documentation task
if: contains(github.event.pull_request.labels.*.name, 'needs documentation')
steps:
- name: Create task
run: |
curl -i -X POST \
'https://api.clickup.com/api/v2/list/900400532890/task' \
-H 'Authorization: ${{ secrets.CLICKUP_TOKEN}}' \
-H 'Content-Type: application/json' \
-d '{
"name": "${{ github.context.payload.pull_request.title }}",
"description": "Coming from pull request ${{ github.context.payload.pull_request.url }}",
"tags": [
"qfield"
],
"status": "Open"
}'
1 change: 1 addition & 0 deletions qfieldsync/core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self):
self.add_setting(
String("importDirectory", Scope.Global, str(home.joinpath("QField/import")))
)
self.add_setting(Bool("showPackagingActions", Scope.Global, False))
self.add_setting(String("importDirectoryProject", Scope.Project, None))
self.add_setting(Dictionary("dirsToCopy", Scope.Project, {}))
self.add_setting(Stringlist("attachmentDirs", Scope.Project, ["DCIM"]))
Expand Down
4 changes: 3 additions & 1 deletion qfieldsync/gui/preferences_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@


class PreferencesWidget(WidgetUi, QgsOptionsPageWidget, SettingDialog):
def __init__(self, parent=None):
def __init__(self, qfieldSync, parent=None):
self.qfieldSync = qfieldSync
preferences = Preferences()
SettingDialog.__init__(self, setting_manager=preferences)
super().__init__(parent, setting_manager=preferences)
Expand All @@ -54,3 +55,4 @@ def __init__(self, parent=None):

def apply(self):
self.set_values_from_widgets()
self.qfieldSync.update_button_visibility()
65 changes: 48 additions & 17 deletions qfieldsync/qfield_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ def createWidget(self, parent):


class QFieldSyncOptionsFactory(QgsOptionsWidgetFactory):
def __init__(self):
def __init__(self, qfieldSync):
super(QgsOptionsWidgetFactory, self).__init__()
self.qfieldSync = qfieldSync

def icon(self):
return QIcon(
os.path.join(os.path.dirname(__file__), "resources", "qfield_logo.svg")
)

def createWidget(self, parent):
return PreferencesWidget(parent)
return PreferencesWidget(self.qfieldSync, parent)


class QFieldSync(object):
Expand Down Expand Up @@ -125,15 +126,15 @@ def __init__(self, iface):
self.offline_editing = QgsOfflineEditing()
self.preferences = Preferences()

QgsProject.instance().readProject.connect(self.update_button_enabled_status)
QgsProject.instance().cleared.connect(self.update_button_enabled_status)
QgsProject.instance().readProject.connect(self.update_action_enabled_status)
QgsProject.instance().cleared.connect(self.update_action_enabled_status)

# store warnings from last run
self.last_action_warnings = []

self.network_manager = CloudNetworkAccessManager(self.iface.mainWindow())
self.network_manager.projects_cache.projects_updated.connect(
self.update_button_enabled_status
self.update_action_enabled_status
)

self.cloud_item_provider = QFieldCloudItemProvider(self.network_manager)
Expand Down Expand Up @@ -264,19 +265,36 @@ def initGui(self):
parent=self.iface.mainWindow(),
)

self.push_action = self.add_action(
self.push_action_toolbar = self.add_action(
QIcon(os.path.join(os.path.dirname(__file__), "resources/package.svg")),
text=self.tr("Package for QField"),
callback=self.show_package_dialog,
parent=self.iface.mainWindow(),
separator_before=True,
add_to_menu=False,
)
self.push_action_menu = self.add_action(
QIcon(os.path.join(os.path.dirname(__file__), "resources/package.svg")),
text=self.tr("Package for QField"),
callback=self.show_package_dialog,
parent=self.iface.mainWindow(),
separator_before=True,
add_to_toolbar=False,
)

self.sync_action = self.add_action(
self.sync_action_toolbar = self.add_action(
QIcon(os.path.join(os.path.dirname(__file__), "resources/synchronize.svg")),
text=self.tr("Synchronize from QField"),
callback=self.show_synchronize_dialog,
parent=self.iface.mainWindow(),
add_to_menu=False,
)
self.sync_action_menu = self.add_action(
QIcon(os.path.join(os.path.dirname(__file__), "resources/synchronize.svg")),
text=self.tr("Synchronize from QField"),
callback=self.show_synchronize_dialog,
parent=self.iface.mainWindow(),
add_to_toolbar=False,
)

self.add_action(
Expand All @@ -288,7 +306,6 @@ def initGui(self):
text=self.tr("Configure Current Project"),
callback=self.show_project_configuration_dialog,
parent=self.iface.mainWindow(),
separator_before=True,
)

self.add_action(
Expand All @@ -315,11 +332,12 @@ def initGui(self):
self.iface.registerProjectPropertiesWidgetFactory(
self.project_properties_factory
)
self.options_factory = QFieldSyncOptionsFactory()
self.options_factory = QFieldSyncOptionsFactory(self)
self.options_factory.setTitle(self.tr("QField"))
self.iface.registerOptionsWidgetFactory(self.options_factory)

self.update_button_enabled_status()
self.update_button_visibility()
self.update_action_enabled_status()

def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
Expand Down Expand Up @@ -396,7 +414,7 @@ def show_package_dialog(self):
self.push_dlg.show()

self.push_dlg.finished.connect(self.push_dialog_finished)
self.update_button_enabled_status()
self.update_action_enabled_status()

def show_project_configuration_dialog(self):
"""
Expand Down Expand Up @@ -453,17 +471,28 @@ def clear_last_action_warnings(self):
def push_dialog_finished(self):
"""
When the push dialog is closed, make sure it's no longer
enabled before entering update_button_enabled_status()
enabled before entering update_action_enabled_status()
"""
try:
self.push_dlg.setEnabled(False)
except RuntimeError:
pass
self.update_button_enabled_status()
self.update_action_enabled_status()

def update_button_visibility(self):
"""
Will update the plugin toolbar buttons according to open dialog and project properties.
"""
self.push_action_toolbar.setVisible(
self.preferences.value("showPackagingActions")
)
self.sync_action_toolbar.setVisible(
self.preferences.value("showPackagingActions")
)

def update_button_enabled_status(self):
def update_action_enabled_status(self):
"""
Will update the plugin buttons according to open dialog and project properties.
Will update the plugin actions according to open dialog and project properties.
"""
if self.network_manager.projects_cache.is_currently_open_project_cloud_local:
self.cloud_synchronize_action.setEnabled(True)
Expand All @@ -476,9 +505,11 @@ def update_button_enabled_status(self):
dialog_is_enabled = False

if self.offline_editing.isOfflineProject() or dialog_is_enabled:
self.push_action.setEnabled(False)
self.push_action_toolbar.setEnabled(False)
self.push_action_menu.setEnabled(False)
else:
self.push_action.setEnabled(True)
self.push_action_toolbar.setEnabled(True)
self.push_action_menu.setEnabled(True)

def get_qfield_action(self) -> QAction:
actions = self.iface.pluginMenu().actions()
Expand Down
10 changes: 10 additions & 0 deletions qfieldsync/ui/preferences_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
<item row="2" column="1">
<widget class="QgsFileWidget" name="exportDirectory"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="showPackagingActions">
<property name="text">
<string>Show packaging actions in the toolbar</string>
</property>
<property name="toolTip">
<string>Store QFieldCloud credentials and automatically sign in on QGIS startup.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
Loading