From cee8a52ca4b948a628e83520c8b71e9781de3878 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 9 Jan 2017 21:32:59 +0100 Subject: [PATCH] ui: Added checkbox to enable/disable animations to preferences --- bin/app/user/ApplicationSettings_template.xml | 2 ++ src/lib/settings/ApplicationSettings.cpp | 10 ++++++++++ src/lib/settings/ApplicationSettings.h | 3 +++ src/lib_gui/qt/element/QtCodeNavigateable.cpp | 6 ++++-- src/lib_gui/qt/view/QtGraphView.cpp | 3 ++- .../QtProjectWizzardContentPreferences.cpp | 8 ++++++++ .../QtProjectWizzardContentPreferences.h | 1 + 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/bin/app/user/ApplicationSettings_template.xml b/bin/app/user/ApplicationSettings_template.xml index d4a6bc3f..b559d836 100644 --- a/bin/app/user/ApplicationSettings_template.xml +++ b/bin/app/user/ApplicationSettings_template.xml @@ -18,6 +18,8 @@ + + diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 370807fc..8b2e5dc9 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -89,6 +89,16 @@ void ApplicationSettings::setFontSize(int fontSize) setValue("application/font_size", fontSize); } +bool ApplicationSettings::getUseAnimations() const +{ + return getValue("application/use_animations", true); +} + +void ApplicationSettings::setUseAnimations(bool useAnimations) +{ + setValue("application/use_animations", useAnimations); +} + FilePath ApplicationSettings::getColorSchemePath() const { FilePath defaultPath(ResourcePaths::getColorSchemesPath() + "bright.xml"); diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index 6d69dc00..82161691 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -41,6 +41,9 @@ public: int getFontSizeStd() const; void setFontSizeStd(const int fontSizeStd); + bool getUseAnimations() const; + void setUseAnimations(bool useAnimations); + int getWindowBaseWidth() const; int getWindowBaseHeight() const; diff --git a/src/lib_gui/qt/element/QtCodeNavigateable.cpp b/src/lib_gui/qt/element/QtCodeNavigateable.cpp index 4a199c4f..6e5abe19 100644 --- a/src/lib_gui/qt/element/QtCodeNavigateable.cpp +++ b/src/lib_gui/qt/element/QtCodeNavigateable.cpp @@ -4,6 +4,8 @@ #include #include +#include "settings/ApplicationSettings.h" + QtCodeNavigateable::~QtCodeNavigateable() { } @@ -40,7 +42,7 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated( if (scrollBar && (value > 50 || value < -50)) { - if (animated) + if (animated && ApplicationSettings::getInstance()->getUseAnimations()) { QPropertyAnimation* anim = new QPropertyAnimation(scrollBar, "value"); anim->setDuration(300); @@ -87,7 +89,7 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percent, bool anima int value = scrollHeight * scrollFactor; - if (animated) + if (animated && ApplicationSettings::getInstance()->getUseAnimations()) { QPropertyAnimation* anim = new QPropertyAnimation(scrollBar, "value"); anim->setDuration(300); diff --git a/src/lib_gui/qt/view/QtGraphView.cpp b/src/lib_gui/qt/view/QtGraphView.cpp index 6307648e..f02c9763 100644 --- a/src/lib_gui/qt/view/QtGraphView.cpp +++ b/src/lib_gui/qt/view/QtGraphView.cpp @@ -14,6 +14,7 @@ #include "component/controller/helper/GraphPostprocessor.h" #include "component/view/GraphViewStyle.h" #include "settings/ColorScheme.h" +#include "settings/ApplicationSettings.h" #include "utility/messaging/type/MessageDeactivateEdge.h" #include "utility/ResourcePaths.h" @@ -276,7 +277,7 @@ void QtGraphView::doRebuildGraph( m_activeNode.reset(); } - if (params.animatedTransition) + if (params.animatedTransition && ApplicationSettings::getInstance()->getUseAnimations()) { createTransition(); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index 21cb45b3..0b884782 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -57,6 +57,10 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) } connect(m_colorSchemes, SIGNAL(activated(int)), this, SLOT(colorSchemeChanged(int))); + // animations + m_useAnimations = addCheckBox("Animations", "Enable animations", + "Enable/disable animations throughout the user interface.", layout, row); + // logging m_loggingEnabled = addCheckBox("Logging", "Enable console and file logging", "Save log files and show log information in the console.", layout, row); @@ -173,6 +177,8 @@ void QtProjectWizzardContentPreferences::load() } } + m_useAnimations->setChecked(appSettings->getUseAnimations()); + m_loggingEnabled->setChecked(appSettings->getLoggingEnabled()); m_verboseIndexerLoggingEnabled->setChecked(appSettings->getVerboseIndexerLoggingEnabled()); m_verboseIndexerLoggingEnabled->setEnabled(m_loggingEnabled->isChecked()); @@ -205,6 +211,8 @@ void QtProjectWizzardContentPreferences::save() appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]); m_oldColorSchemeIndex = -1; + appSettings->setUseAnimations(m_useAnimations->isChecked()); + appSettings->setLoggingEnabled(m_loggingEnabled->isChecked()); appSettings->setVerboseIndexerLoggingEnabled(m_verboseIndexerLoggingEnabled->isChecked()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h index 9a6482d3..4ed2e945 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h @@ -50,6 +50,7 @@ private: QComboBox* m_colorSchemes; std::vector m_colorSchemePaths; int m_oldColorSchemeIndex; + QCheckBox* m_useAnimations; QCheckBox* m_loggingEnabled; QCheckBox* m_verboseIndexerLoggingEnabled;