diff --git a/images/images.qrc b/images/images.qrc index d44bab7425..ac61d50c06 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -13,7 +13,8 @@ themes/qfield/nodpi/ic_3x3_grid_white_24dp.svg themes/qfield/nodpi/ic_digitizing_settings_black_24dp.svg - themes/qfield/nodpi/ic_undo_white_24dp.svg + themes/qfield/nodpi/ic_undo_black_24dp.svg + themes/qfield/nodpi/ic_redo_black_24dp.svg themes/qfield/nodpi/ic_flash_auto_black_24dp.svg themes/qfield/nodpi/ic_flash_on_black_24dp.svg themes/qfield/nodpi/ic_flash_off_black_24dp.svg @@ -531,8 +532,6 @@ themes/qfield/nodpi/ic_hide_green_48dp.svg themes/qfield/nodpi/ic_chevron_down.svg themes/qfield/nodpi/ic_chevron_up.svg - themes/qfield/nodpi/ic_undo.svg - themes/qfield/nodpi/ic_redo.svg themes/qfield/nodpi/ic_arrow_left_white_24dp.svg themes/qfield/nodpi/ic_opacity_black_24dp.svg themes/qfield/nodpi/ic_common_angle_white_24dp.svg diff --git a/images/themes/qfield/nodpi/ic_redo.svg b/images/themes/qfield/nodpi/ic_redo_black_24dp.svg similarity index 100% rename from images/themes/qfield/nodpi/ic_redo.svg rename to images/themes/qfield/nodpi/ic_redo_black_24dp.svg diff --git a/images/themes/qfield/nodpi/ic_undo.svg b/images/themes/qfield/nodpi/ic_undo_black_24dp.svg similarity index 100% rename from images/themes/qfield/nodpi/ic_undo.svg rename to images/themes/qfield/nodpi/ic_undo_black_24dp.svg diff --git a/images/themes/qfield/nodpi/ic_undo_white_24dp.svg b/images/themes/qfield/nodpi/ic_undo_white_24dp.svg deleted file mode 100644 index 247540e90f..0000000000 --- a/images/themes/qfield/nodpi/ic_undo_white_24dp.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/core/featurehistory.cpp b/src/core/featurehistory.cpp index 610df5caa8..df8bbbedf9 100644 --- a/src/core/featurehistory.cpp +++ b/src/core/featurehistory.cpp @@ -100,7 +100,6 @@ void FeatureHistory::onBeforeCommitChanges() QMap modifiedFeatures; QgsFeature f; - // ? is it possible to use the iterator in a less ugly way? something like normal `for ( QgsFeature &f : it ) {}` while ( featuresIt.nextFeature( f ) ) modifiedFeatures.insert( f.id(), f ); @@ -125,7 +124,7 @@ void FeatureHistory::onCommittedFeaturesAdded( const QString &localLayerId, cons return; } - qInfo() << "FeatureHistory::onCommittedFeaturesAdded: adding create committed features"; + qDebug() << "FeatureHistory::onCommittedFeaturesAdded: adding create committed features"; FeatureModifications modifications = mTempHistoryStep.take( vl->id() ); @@ -203,8 +202,8 @@ void FeatureHistory::onTimerTimeout() mTempHistoryStep.clear(); mRedoHistory.clear(); - emit isUndoEnabledChanged(); - emit isRedoEnabledChanged(); + emit isUndoAvailableChanged(); + emit isRedoAvailableChanged(); } QMap FeatureHistory::reverseModifications( QMap &modificationsByLayerId ) @@ -320,8 +319,6 @@ bool FeatureHistory::applyModifications( QMap &mo QgsMessageLog::logMessage( tr( "Failed to rollback undo featurue modifications in layer \"%1\"" ).arg( vl->name() ) ); } - // OGR error creating feature -4: failed to execute insert : UNIQUE constraint failed: area.fid - return false; } } @@ -348,8 +345,8 @@ bool FeatureHistory::undo() mRedoHistory.append( reversedModifications ); - emit isUndoEnabledChanged(); - emit isRedoEnabledChanged(); + emit isUndoAvailableChanged(); + emit isRedoAvailableChanged(); return true; } @@ -372,20 +369,20 @@ bool FeatureHistory::redo() mUndoHistory.append( reversedModifications ); - emit isUndoEnabledChanged(); - emit isRedoEnabledChanged(); + emit isUndoAvailableChanged(); + emit isRedoAvailableChanged(); return true; } -bool FeatureHistory::isUndoEnabled() +bool FeatureHistory::isUndoAvailable() { return !mUndoHistory.isEmpty(); } -bool FeatureHistory::isRedoEnabled() +bool FeatureHistory::isRedoAvailable() { return !mRedoHistory.isEmpty(); } diff --git a/src/core/featurehistory.h b/src/core/featurehistory.h index 2ec28eefb3..43c2c898e9 100644 --- a/src/core/featurehistory.h +++ b/src/core/featurehistory.h @@ -12,8 +12,8 @@ class FeatureHistory : public QObject { Q_OBJECT - Q_PROPERTY( bool isUndoEnabled READ isUndoEnabled NOTIFY isUndoEnabledChanged ) - Q_PROPERTY( bool isRedoEnabled READ isRedoEnabled NOTIFY isRedoEnabledChanged ) + Q_PROPERTY( bool isUndoAvailable READ isUndoAvailable NOTIFY isUndoAvailableChanged ) + Q_PROPERTY( bool isRedoAvailable READ isRedoAvailable NOTIFY isRedoAvailableChanged ) public: /** @@ -48,8 +48,38 @@ class FeatureHistory : public QObject //! Get the redo message to be show in the UI. NOTE should be called before calling \a redo. Q_INVOKABLE const QString redoMessage(); - bool isUndoEnabled(); - bool isRedoEnabled(); + bool isUndoAvailable(); + bool isRedoAvailable(); + + signals: + void isUndoAvailableChanged(); + void isRedoAvailableChanged(); + + private slots: + /** + * Monitors the current project for new layers. + * + * @param layers layers added + */ + void onLayersAdded( const QList &layers ); + + //! The project file has been changed + void onHomePathChanged(); + + //! Called when features are added on the layer + void onCommittedFeaturesAdded( const QString &localLayerId, const QgsFeatureList &addedFeatures ); + + //! Called after features are committed for deletion. + void onCommittedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds ); + + //! Called before features are committed. Used to prepare the old state of the features and store it in \a mHistry. + void onBeforeCommitChanges(); + + //! Called after features are committed. Used because the added features do not have FID before they are committed. + void onAfterCommitChanges(); + + //! Timer's timeout slot. Used to collect multiple feature changes (calls of \a onBeforeCommitChanges and \a onAfterCommitChanges) into one undo step. + void onTimerTimeout(); private: static const int sTimeoutMs = 50; @@ -89,36 +119,6 @@ class FeatureHistory : public QObject //! Layer ids being observed for changes. Should reset when the project is changed. Used to prevent double event listeners. QSet mObservedLayerIds; - - signals: - void isUndoEnabledChanged(); - void isRedoEnabledChanged(); - - private slots: - /** - * Monitors the current project for new layers. - * - * @param layers layers added - */ - void onLayersAdded( const QList &layers ); - - //! The project file has been changed - void onHomePathChanged(); - - //! Called when features are added on the layer - void onCommittedFeaturesAdded( const QString &localLayerId, const QgsFeatureList &addedFeatures ); - - //! Called after features are committed for deletion. - void onCommittedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds ); - - //! Called before features are committed. Used to prepare the old state of the features and store it in \a mHistry. - void onBeforeCommitChanges(); - - //! Called after features are committed. Used because the added features do not have FID before they are committed. - void onAfterCommitChanges(); - - //! Timer's timeout slot. Used to collect multiple feature changes (calls of \a onBeforeCommitChanges and \a onAfterCommitChanges) into one undo step. - void onTimerTimeout(); }; #endif // FEATUREHISTORY_H diff --git a/src/qml/QFieldCloudPopup.qml b/src/qml/QFieldCloudPopup.qml index 4f860eb633..47ada6d041 100644 --- a/src/qml/QFieldCloudPopup.qml +++ b/src/qml/QFieldCloudPopup.qml @@ -413,6 +413,7 @@ Popup { : qsTr('Reset project') enabled: cloudProjectsModel.layerObserver.deltaFileWrapper.count > 0 || cloudProjectsModel.layerObserver.deltaFileWrapper.hasError() icon.source: Theme.getThemeVectorIcon('ic_undo_white_24dp') + icon.color: "white" onClicked: { if (!cloudProjectsModel.layerObserver.deltaFileWrapper.hasError()) { diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 1f974fdb01..1b9db0dc24 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -1249,7 +1249,6 @@ ApplicationWindow { spacing: 4 QfToolButtonDrawer { - id: mainToolbarDrawer name: "digitizingDrawer" size: 48 round: true @@ -2121,10 +2120,11 @@ ApplicationWindow { bottomPadding: parent.topMargin QfToolButton { - icon.source: Theme.getThemeVectorIcon( "ic_undo" ) + icon.source: Theme.getThemeVectorIcon( "ic_undo_black_24dp" ) + iconColor: Theme.mainTextColor height: 48 width: 48 - enabled: featureHistory.isUndoEnabled + enabled: featureHistory.isUndoAvailable opacity: enabled ? 1 : 0.5 onClicked: { @@ -2140,10 +2140,11 @@ ApplicationWindow { } QfToolButton { - icon.source: Theme.getThemeVectorIcon( "ic_redo" ) + icon.source: Theme.getThemeVectorIcon( "ic_redo_black_24dp" ) + iconColor: Theme.mainTextColor height: 48 width: 48 - enabled: featureHistory.isRedoEnabled + enabled: featureHistory.isRedoAvailable opacity: enabled ? 1 : 0.5 onClicked: {