Mercurial > hg > svgui
changeset 1468:de41a11cabc2
Add opportunistic-editing toggle
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2019 15:35:01 +0100 |
parents | f9110e5afca1 |
children | 11a150e65ee1 ac0a8addabcf |
files | view/Pane.cpp view/ViewManager.cpp view/ViewManager.h |
diffstat | 3 files changed, 35 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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()) {
--- 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) {
--- 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;