diff --git a/App/main.cpp b/App/main.cpp index fa937be782381ef4bab78e364677a6d75a10804b..8ade38d3632cc82be7e73bbbc0f5feca868cc055 100644 --- a/App/main.cpp +++ b/App/main.cpp @@ -70,9 +70,6 @@ int main(int argc, char* argv[]) ApplicationSettings applicationSettings; - auto style = applicationSettings.styleToUse(); - applicationSettings.loadStyle(style); - QString dir = GUI::Path::appDataFolder(); if (!QDir().exists(dir)) QDir().mkpath(dir); diff --git a/GUI/View/Canvas/MaskEditorCanvas.cpp b/GUI/View/Canvas/MaskEditorCanvas.cpp index a96619cad653a80a3ab3f21681df28f5110a6daa..9e4f86ba6334c6900053f4e7c54ccd9b9972a6d2 100644 --- a/GUI/View/Canvas/MaskEditorCanvas.cpp +++ b/GUI/View/Canvas/MaskEditorCanvas.cpp @@ -54,7 +54,7 @@ void MaskEditorCanvas::updateMaskCanvas(Data2DItem* data2DItem, QItemSelectionMo m_scene->associateItems(data2DItem, data2DItem->getOrCreateMaskModel(), selModel); - repaintScene(); + m_scene->updateSize(m_view->size()); m_statusLabel->addPlot(m_scene->colorMap()); } @@ -90,18 +90,12 @@ void MaskEditorCanvas::onPresentationChange(bool pixelized) m_data2DItem->setInterpolated(m_backup_interpolated); } } - repaintScene(); if (auto* container = m_data2DItem->maskContainerItem()) for (MaskItem* mask : container->modifiableMaskItems()) mask->setIsVisible(!pixelized && mask->wasVisible()); } -void MaskEditorCanvas::repaintScene() -{ - m_scene->updateSize(m_view->size()); // TODO replace by proper repaint command -} - //! Saves plot into project directory. void MaskEditorCanvas::onSavePlotRequest() diff --git a/GUI/View/Canvas/MaskEditorCanvas.h b/GUI/View/Canvas/MaskEditorCanvas.h index 29230a109c97775a01f0035e42cedf441306133b..210b69c7865ff5ecf75cf200b30e88f22b7086d5 100644 --- a/GUI/View/Canvas/MaskEditorCanvas.h +++ b/GUI/View/Canvas/MaskEditorCanvas.h @@ -49,7 +49,6 @@ public slots: void onPresentationChange(bool pixelized); private: - void repaintScene(); void setZoomToROI(); MaskGraphicsScene* m_scene; diff --git a/GUI/View/Main/ActionManager.cpp b/GUI/View/Main/ActionManager.cpp index d97a76d0c52b06a2b91a33bd611d7bba61d3afe8..2daa85627a623cd3080a676eb7e2dae35bc1f404 100644 --- a/GUI/View/Main/ActionManager.cpp +++ b/GUI/View/Main/ActionManager.cpp @@ -230,30 +230,6 @@ void ActionManager::onAboutToShowSettingsMenu() connect(checkBox, &QCheckBox::toggled, [](bool b) { appSettings->setCreateNewProjectOnStartup(b); }); m_settingsMenu->addAction(action); - - m_settingsMenu->addSeparator(); - - auto* styleMenu = m_settingsMenu->addMenu("Interface Style"); - auto* styleGroup = new QButtonGroup(this); - styleGroup->setExclusive(true); - const auto addStyleAction = [styleGroup, styleMenu](const QString& text, - ApplicationSettings::Style style) { - auto* action = new QWidgetAction(styleMenu); - auto* radioButton = new QRadioButton(text, styleMenu); - radioButton->setStyleSheet(""); - action->setDefaultWidget(radioButton); - radioButton->setChecked(appSettings->currentStyle() == style); - connect(radioButton, &QRadioButton::toggled, [style] { - appSettings->setStyleToUse(style); - appSettings->loadStyle(style); - }); - action->setCheckable(true); - styleGroup->addButton(radioButton); - styleMenu->addAction(action); - }; - - addStyleAction("Light style", ApplicationSettings::Style::light); - addStyleAction("Dark style", ApplicationSettings::Style::dark); } void ActionManager::onAboutToShowViewMenu() diff --git a/GUI/View/Widget/ApplicationSettings.cpp b/GUI/View/Widget/ApplicationSettings.cpp index 73e23e9d12219b7736008c9f4d3bd77c3cb1c2bc..d4ac6e62633a130ac97a719bf9c8cf9ab5a66324 100644 --- a/GUI/View/Widget/ApplicationSettings.cpp +++ b/GUI/View/Widget/ApplicationSettings.cpp @@ -22,7 +22,6 @@ namespace { const QString S_CREATE_NEW_PROJECT_ON_STARTUP = "CreateNewProjectOnStartup"; -const QString S_STYLE = "UiStyle"; const QString S_SIZE = "Size"; const QString S_POS = "Pos"; const QString S_SINGLE_SAMPLE_MODE = "SingleSampleMode"; @@ -32,9 +31,21 @@ const QString S_SINGLE_SAMPLE_MODE = "SingleSampleMode"; ApplicationSettings* appSettings; //!< global pointer to _the_ instance ApplicationSettings::ApplicationSettings() - : m_currentStyle(ApplicationSettings::Style::light) { appSettings = this; + + QFile base(":/styles/Base.stylesheet"); + base.open(QFile::ReadOnly); + QString stylesheet = base.readAll(); + qApp->setStyleSheet(stylesheet); + + QPalette styleSheetPalette = qApp->style()->standardPalette(); + styleSheetPalette.setColor(QPalette::Text, Qt::black); + styleSheetPalette.setColor(QPalette::WindowText, Qt::black); + styleSheetPalette.setColor(QPalette::Base, Qt::white); + styleSheetPalette.setColor(QPalette::AlternateBase, QColor(255, 255, 255).darker(105)); + styleSheetPalette.setColor(QPalette::Dark, QColor(255, 255, 255).darker(110)); + QApplication::setPalette(styleSheetPalette); } bool ApplicationSettings::useNativeFileDialog() const @@ -56,16 +67,6 @@ void ApplicationSettings::setCreateNewProjectOnStartup(bool b) QSettings().setValue(S_CREATE_NEW_PROJECT_ON_STARTUP, b); } -ApplicationSettings::Style ApplicationSettings::styleToUse() const -{ - return static_cast<Style>(QSettings().value(S_STYLE, static_cast<int>(Style::light)).toInt()); -} - -void ApplicationSettings::setStyleToUse(Style style) -{ - QSettings().setValue(S_STYLE, static_cast<int>(style)); -} - void ApplicationSettings::saveWindowSizeAndPos(const QWidget* w) { ASSERT(!w->objectName().isEmpty()); @@ -85,42 +86,3 @@ void ApplicationSettings::loadWindowSizeAndPos(QWidget* w) if (settings.contains(S_POS + "/" + w->objectName())) w->move(settings.value(S_POS + "/" + w->objectName()).toPoint()); } - -void ApplicationSettings::loadStyle(ApplicationSettings::Style style) -{ - QFile base(":/styles/Base.stylesheet"); - base.open(QFile::ReadOnly); - QString stylesheet = base.readAll(); - - if (style == ApplicationSettings::Style::light) { - QFile f(":/styles/Light.stylesheet"); - f.open(QFile::ReadOnly); - stylesheet += f.readAll(); - } else if (style == ApplicationSettings::Style::dark) { - QFile f(":/styles/Dark.stylesheet"); - f.open(QFile::ReadOnly); - stylesheet += f.readAll(); - } else - ASSERT_NEVER; - - m_currentStyle = style; - QPalette styleSheetPalette = qApp->style()->standardPalette(); - - // -- init palette for later usage; could be improved by parsing the stylesheet - if (m_currentStyle == ApplicationSettings::Style::light) { - styleSheetPalette.setColor(QPalette::Text, Qt::black); - styleSheetPalette.setColor(QPalette::WindowText, Qt::black); - styleSheetPalette.setColor(QPalette::Base, Qt::white); - styleSheetPalette.setColor(QPalette::AlternateBase, QColor(255, 255, 255).darker(105)); - styleSheetPalette.setColor(QPalette::Dark, QColor(255, 255, 255).darker(110)); - } else if (m_currentStyle == ApplicationSettings::Style::dark) { - styleSheetPalette.setColor(QPalette::Text, QColor(213, 220, 223)); - styleSheetPalette.setColor(QPalette::WindowText, QColor(213, 220, 223)); - styleSheetPalette.setColor(QPalette::Base, QColor(43, 50, 54)); - styleSheetPalette.setColor(QPalette::AlternateBase, QColor(43, 50, 54).darker(130)); - styleSheetPalette.setColor(QPalette::Dark, QColor(43, 50, 54).darker(120)); - } - QApplication::setPalette(styleSheetPalette); - qApp->setStyleSheet(""); - qApp->setStyleSheet(stylesheet); -} diff --git a/GUI/View/Widget/ApplicationSettings.h b/GUI/View/Widget/ApplicationSettings.h index 27995a6b9b6061ee8831aea344be6f3e13daf457..4820c52f7b6ad3f8876f7fe6a7490e693a2c692b 100644 --- a/GUI/View/Widget/ApplicationSettings.h +++ b/GUI/View/Widget/ApplicationSettings.h @@ -23,24 +23,14 @@ //! contains settings which may be user editable in the future. class ApplicationSettings { public: - enum class Style { light, dark }; - ApplicationSettings(); bool useNativeFileDialog() const; bool createNewProjectOnStartup() const; void setCreateNewProjectOnStartup(bool b); - Style styleToUse() const; - void setStyleToUse(Style style); void saveWindowSizeAndPos(const QWidget* w); void loadWindowSizeAndPos(QWidget* w); - - void loadStyle(ApplicationSettings::Style style); - ApplicationSettings::Style currentStyle() { return m_currentStyle; } - -private: - ApplicationSettings::Style m_currentStyle; }; extern ApplicationSettings* appSettings; //!< global pointer to the single instance diff --git a/GUI/gui.qrc b/GUI/gui.qrc index 0842d4c65bb3b77e3a18b0bbe2023ddf88e72e71..1f3c5dadddede4a2ad7df2386ae9b9d0c9f48144 100644 --- a/GUI/gui.qrc +++ b/GUI/gui.qrc @@ -123,7 +123,5 @@ <file>images/warning_16x16.png</file> <file>images/warning_64x64.png</file> <file>styles/Base.stylesheet</file> - <file>styles/Dark.stylesheet</file> - <file>styles/Light.stylesheet</file> </qresource> </RCC> diff --git a/GUI/styles/Base.stylesheet b/GUI/styles/Base.stylesheet index 9825cfb9499064c3dab198db0eb23d9b13e8e0b5..e0a017e140834efe609e9d8d12f4fded526a668d 100644 --- a/GUI/styles/Base.stylesheet +++ b/GUI/styles/Base.stylesheet @@ -575,3 +575,44 @@ ScientificSpinBox::down-button:pressed { background-color: rgba(100, 100, 100, 20%); } + + + +QWidget{ + color: palette(text); +} + +QTextEdit, QLineEdit, QSpinBox, ScientificSpinBox, QDoubleSpinBox, DoubleSpinBox, QComboBox, QTabWidget, +QDockWidget, QListView, QTableView, QTableWidget, QHeaderView, QProgressBar, QSlider, QScrollBar, +QToolBar, QPushButton { + background-color: white; +} + +::disabled{ + color: rgb(200,200,200); +} + +QRadioButton::indicator:checked { + background-color: rgba(100,100,100,40%); +} + +QCheckBox::indicator:checked { + background-color: rgba(100,100,100,40%); +} + +SampleView LayerOrientedSampleEditor QScrollArea LayerForm QLabel{ + color: black; +} + +SampleView LayerOrientedSampleEditor QScrollArea LayerForm QCheckBox{ + color: black; +} + +SampleView LayerOrientedSampleEditor QScrollArea LayerForm QToolButton{ + color: black; + background-color: "transparent"; +} + +SampleView LayerOrientedSampleEditor QScrollArea LayerForm QPushButton{ + color: black; +} \ No newline at end of file diff --git a/GUI/styles/Dark.stylesheet b/GUI/styles/Dark.stylesheet deleted file mode 100644 index 7e0aede71f4a871a2affb4a184d9583a0706c581..0000000000000000000000000000000000000000 --- a/GUI/styles/Dark.stylesheet +++ /dev/null @@ -1,25 +0,0 @@ -/* Set The Background Color Of All Common Controls To The Darker Version Of the Background Color*/ -QTextEdit, QLineEdit, QSpinBox, ScientificSpinBox, QDoubleSpinBox, QComboBox, QTabWidget,QDockWidget, QListView, QTableView, QTableWidget, QHeaderView, QProgressBar, QSlider, QScrollBar{ - background-color: palette(dark); -} -/* Set The Text Color Of All Controls In Pseudo State Disabled*/ -::disabled{ - color: dimgray; -} -/* In Dark Theme Text Color is A Bright White Color*/ -/* This Color Would Clash With The Background Color Of The LayerItems*/ -/* Therefore We Set The Text Color Of Controls Inside The LayerForms To Black*/ -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QCheckBox{ - color: black; -} -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QToolButton{ - color: black; - background-color: transparent; -} - -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QPushButton{ - color: black; -} -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QLabel{ - color: black; -} diff --git a/GUI/styles/Light.stylesheet b/GUI/styles/Light.stylesheet deleted file mode 100644 index 2d046721d2e7603f4887d6b93f761953975bd76d..0000000000000000000000000000000000000000 --- a/GUI/styles/Light.stylesheet +++ /dev/null @@ -1,38 +0,0 @@ -QWidget{ - color: palette(text); -} - -QTextEdit, QLineEdit, QSpinBox, ScientificSpinBox, QDoubleSpinBox, DoubleSpinBox, QComboBox, QTabWidget, -QDockWidget, QListView, QTableView, QTableWidget, QHeaderView, QProgressBar, QSlider, QScrollBar, -QToolBar, QPushButton { - background-color: white; -} - -::disabled{ - color: rgb(200,200,200); -} - -QRadioButton::indicator:checked { - background-color: rgba(100,100,100,40%); -} - -QCheckBox::indicator:checked { - background-color: rgba(100,100,100,40%); -} - -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QLabel{ - color: black; -} - -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QCheckBox{ - color: black; -} - -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QToolButton{ - color: black; - background-color: "transparent"; -} - -SampleView LayerOrientedSampleEditor QScrollArea LayerForm QPushButton{ - color: black; -} \ No newline at end of file