# HG changeset patch # User Chris Cannam # Date 1560436501 -3600 # Node ID de41a11cabc24cacbfd4726caed6e9f6ea812a02 # Parent f9110e5afca14aea25793d4f9900d76abf06f7c4 Add opportunistic-editing toggle diff -r f9110e5afca1 -r de41a11cabc2 view/Pane.cpp --- a/view/Pane.cpp Thu Jun 13 15:05:25 2019 +0100 +++ b/view/Pane.cpp Thu Jun 13 15:35:01 2019 +0100 @@ -2189,8 +2189,9 @@ return; } - if (mode == ViewManager::NavigateMode || - mode == ViewManager::EditMode) { + if (mode == ViewManager::EditMode || + (mode == ViewManager::NavigateMode && + m_manager->getOpportunisticEditingEnabled())) { Layer *layer = getInteractionLayer(); if (layer && layer->isLayerEditable()) { diff -r f9110e5afca1 -r de41a11cabc2 view/ViewManager.cpp --- a/view/ViewManager.cpp Thu Jun 13 15:05:25 2019 +0100 +++ b/view/ViewManager.cpp Thu Jun 13 15:35:01 2019 +0100 @@ -47,6 +47,7 @@ m_alignMode(false), m_overlayMode(StandardOverlays), m_zoomWheelsEnabled(true), + m_opportunisticEditingEnabled(true), m_showCentreLine(true), m_illuminateLocalFeatures(true), m_showWorkTitle(false), @@ -749,6 +750,15 @@ } void +ViewManager::setOpportunisticEditingEnabled(bool enabled) +{ + if (m_opportunisticEditingEnabled != enabled) { + m_opportunisticEditingEnabled = enabled; + emit opportunisticEditingEnabledChanged(); + } +} + +void ViewManager::setShowCentreLine(bool show) { if (m_showCentreLine != show) { diff -r f9110e5afca1 -r de41a11cabc2 view/ViewManager.h --- a/view/ViewManager.h Thu Jun 13 15:05:25 2019 +0100 +++ b/view/ViewManager.h Thu Jun 13 15:35:01 2019 +0100 @@ -245,6 +245,24 @@ void setZoomWheelsEnabled(bool enable); bool getZoomWheelsEnabled() const { return m_zoomWheelsEnabled; } + /** + * Enable or disable opportunistic editing. This allows certain + * edits while not in edit modes - e.g. double-click on an item + * while in navigate mode to open an edit dialog. It is enabled by + * default, but it may be undesirable if the application is + * intended to be "read-only". + * + * This setting makes no difference to behaviour when actually in + * editing modes. + * + * Unlike some other options, this is considered to be + * application-build-specific and is not restored from settings. + */ + void setOpportunisticEditingEnabled(bool enable); + bool getOpportunisticEditingEnabled() const { + return m_opportunisticEditingEnabled; + } + void setGlobalDarkBackground(bool dark); bool getGlobalDarkBackground() const; @@ -303,6 +321,9 @@ /** Emitted when the zoom wheels have been toggled. */ void zoomWheelsEnabledChanged(); + /** Emitted when editing-enabled has been toggled. */ + void opportunisticEditingEnabledChanged(); + /** Emitted when any loggable activity has occurred. */ void activity(QString); @@ -366,6 +387,7 @@ OverlayMode m_overlayMode; bool m_zoomWheelsEnabled; + bool m_opportunisticEditingEnabled; bool m_showCentreLine; bool m_illuminateLocalFeatures; bool m_showWorkTitle;