From 9bf1d52685a5edcdbc869527657ee43eee923ae6 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <qt-info@nokia.com> Date: Wed, 25 Nov 2009 18:44:54 +0100 Subject: [PATCH] Add option to override the UI color * Add -color option to core plugin which will override the base UI color for that session. Reviewed-by: thorbjorn --- src/plugins/coreplugin/Core.pluginspec | 3 +++ src/plugins/coreplugin/coreplugin.cpp | 14 +++++++++++++- src/plugins/coreplugin/coreplugin.h | 2 ++ src/plugins/coreplugin/mainwindow.cpp | 13 +++++++++++-- src/plugins/coreplugin/mainwindow.h | 4 ++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/Core.pluginspec b/src/plugins/coreplugin/Core.pluginspec index 9c965e09731..5055e98c5b9 100644 --- a/src/plugins/coreplugin/Core.pluginspec +++ b/src/plugins/coreplugin/Core.pluginspec @@ -12,4 +12,7 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General </license> <description>The core plugin for the Qt IDE.</description> <url>http://qt.nokia.com</url> + <argumentList> + <argument name="-color" parameter="color">Override selected UI color</argument> + </argumentList> </plugin> diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index ebcbb394b44..da2825ecf84 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -37,6 +37,7 @@ #include <extensionsystem/pluginmanager.h> #include <QtCore/QtPlugin> +#include <QtCore/QDebug> using namespace Core::Internal; @@ -58,9 +59,20 @@ CorePlugin::~CorePlugin() delete m_mainWindow; } +void CorePlugin::parseArguments(const QStringList &arguments) +{ + for (int i = 0; i < arguments.size() - 1; i++) { + if (arguments.at(i) == QLatin1String("-color")) { + const QString colorcode(arguments.at(i + 1)); + m_mainWindow->setOverrideColor(QColor(colorcode)); + i++; // skip the argument + } + } +} + bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) { - Q_UNUSED(arguments) + parseArguments(arguments); const bool success = m_mainWindow->init(errorMessage); if (success) { EditorManager *editorManager = m_mainWindow->editorManager(); diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h index 0f4360d471f..58e5958cc85 100644 --- a/src/plugins/coreplugin/coreplugin.h +++ b/src/plugins/coreplugin/coreplugin.h @@ -54,6 +54,8 @@ public slots: void remoteArgument(const QString&); private: + void parseArguments(const QStringList & arguments); + MainWindow *m_mainWindow; EditMode *m_editMode; }; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index ee3f214db44..f0727278ba2 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -228,6 +228,11 @@ void MainWindow::setSuppressNavigationWidget(bool suppress) m_navigationWidget->setSuppressed(suppress); } +void MainWindow::setOverrideColor(const QColor &color) +{ + m_overrideColor = color; +} + MainWindow::~MainWindow() { hide(); @@ -1103,7 +1108,10 @@ void MainWindow::readSettings() { m_settings->beginGroup(QLatin1String(settingsGroup)); - Utils::StyleHelper::setBaseColor(m_settings->value(QLatin1String(colorKey)).value<QColor>()); + if (m_overrideColor.isValid()) + Utils::StyleHelper::setBaseColor(m_overrideColor); + else + Utils::StyleHelper::setBaseColor(m_settings->value(QLatin1String(colorKey)).value<QColor>()); const QVariant geom = m_settings->value(QLatin1String(geometryKey)); if (geom.isValid()) { @@ -1126,7 +1134,8 @@ void MainWindow::writeSettings() { m_settings->beginGroup(QLatin1String(settingsGroup)); - m_settings->setValue(QLatin1String(colorKey), Utils::StyleHelper::baseColor()); + if (!(m_overrideColor.isValid() && Utils::StyleHelper::baseColor() == m_overrideColor)) + m_settings->setValue(QLatin1String(colorKey), Utils::StyleHelper::baseColor()); if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) { m_settings->setValue(QLatin1String(maxKey), (bool) (windowState() & Qt::WindowMaximized)); diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 7b8510c5e0f..3c83e073055 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -35,6 +35,7 @@ #include "eventfilteringmainwindow.h" #include <QtCore/QMap> +#include <QtGui/QColor> QT_BEGIN_NAMESPACE class QSettings; @@ -121,6 +122,8 @@ public: void setSuppressNavigationWidget(bool suppress); + void setOverrideColor(const QColor &color); + signals: void windowActivated(); @@ -219,6 +222,7 @@ private: #endif QToolButton *m_toggleSideBarButton; + QColor m_overrideColor; }; } // namespace Internal -- GitLab