Skip to content
Snippets Groups Projects
Commit b8cc14bc authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[j.1] rm dark style (#871); follow-up on mask canvas resizing (!2281) (Closes #871)

Merging branch 'j.1'  into 'main'.

See merge request !2283
parents fe0e98d1 1ce17303
No related branches found
No related tags found
1 merge request!2283rm dark style (#871); follow-up on mask canvas resizing (!2281)
Pipeline #126397 failed
......@@ -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);
......
......@@ -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()
......
......@@ -49,7 +49,6 @@ public slots:
void onPresentationChange(bool pixelized);
private:
void repaintScene();
void setZoomToROI();
MaskGraphicsScene* m_scene;
......
......@@ -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()
......
......@@ -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);
}
......@@ -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
......
......@@ -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>
......@@ -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
/* 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;
}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment