Skip to content

Commit

Permalink
Merge #320 [stable-3.14] nmc/0000-Dark_Mode_Disabled_New
Browse files Browse the repository at this point in the history
  • Loading branch information
memurats committed Oct 30, 2024
2 parents 506dab0 + 2621d88 commit cff4483
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
27 changes: 27 additions & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ int main(int argc, char **argv)

OCC::Application app(argc, argv);

//NMC customization: enforce our palette to avoid dark mode colors
QPalette palette = app.palette();

palette.setColor(QPalette::WindowText, QColor(0, 0, 0));
palette.setColor(QPalette::Button, QColor(236, 236, 236));
palette.setColor(QPalette::Light, QColor(255, 255, 255));
palette.setColor(QPalette::Midlight, QColor(245, 245, 245));
palette.setColor(QPalette::Dark, QColor(191, 191, 191));
palette.setColor(QPalette::Mid, QColor(168, 168, 168));
palette.setColor(QPalette::Text, QColor(0, 0, 0));
palette.setColor(QPalette::BrightText, QColor(255, 255, 255));
palette.setColor(QPalette::ButtonText, QColor(0, 0, 0));
palette.setColor(QPalette::Base, QColor(255, 255, 255));
palette.setColor(QPalette::Window, QColor(236, 236, 236));
palette.setColor(QPalette::Shadow, QColor(0, 0, 0));
palette.setColor(QPalette::Highlight, QColor(179, 215, 255));
palette.setColor(QPalette::HighlightedText, QColor(0, 0, 0));
palette.setColor(QPalette::Link, QColor(0, 104, 218));
palette.setColor(QPalette::LinkVisited, QColor(255, 0, 255));
palette.setColor(QPalette::AlternateBase, QColor(245, 245, 245));
palette.setColor(QPalette::NoRole, QColor(0, 0, 0));
palette.setColor(QPalette::ToolTipBase, QColor(255, 255, 255));
palette.setColor(QPalette::ToolTipText, QColor(0, 0, 0));
palette.setColor(QPalette::PlaceholderText, QColor(0, 0, 0));

app.setPalette(palette);

#ifndef Q_OS_WIN
signal(SIGPIPE, SIG_IGN);
#endif
Expand Down
24 changes: 13 additions & 11 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,9 @@ double Theme::getColorDarkness(const QColor &color)

bool Theme::isDarkColor(const QColor &color)
{
return getColorDarkness(color) > 0.5;
//return getColorDarkness(color) > 0.5;
Q_UNUSED(color)
return false;
}

QColor Theme::getBackgroundAwareLinkColor(const QColor &backgroundColor)
Expand Down Expand Up @@ -951,16 +953,16 @@ void Theme::connectToPaletteSignal()

bool Theme::darkMode()
{
connectToPaletteSignal();
switch (qGuiApp->styleHints()->colorScheme())
{
case Qt::ColorScheme::Dark:
return true;
case Qt::ColorScheme::Light:
return false;
case Qt::ColorScheme::Unknown:
return Theme::isDarkColor(QGuiApplication::palette().window().color());
}
// connectToPaletteSignal();
// switch (qGuiApp->styleHints()->colorScheme())
// {
// case Qt::ColorScheme::Dark:
// return true;
// case Qt::ColorScheme::Light:
// return false;
// case Qt::ColorScheme::Unknown:
// return Theme::isDarkColor(QGuiApplication::palette().window().color());
// }

return false;
}
Expand Down
12 changes: 8 additions & 4 deletions test/testtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ private slots:

const auto iconPath = OCC::Theme::hidpiFileName(iconName + ".png", backgroundColor, &paintDevice);

QCOMPARE(iconPath, ":/client/theme/white/" + iconName + ".png");
// QCOMPARE(iconPath, ":/client/theme/white/" + iconName + ".png");
Q_UNUSED(iconPath)
}

void testHidpiFileName_lightBackground_returnPathToBlackIcon()
Expand All @@ -72,7 +73,8 @@ private slots:

const auto iconPath = OCC::Theme::hidpiFileName(iconName + ".png", backgroundColor, &paintDevice);

QCOMPARE(iconPath, ":/client/theme/white/" + iconName + "@2x.png");
// QCOMPARE(iconPath, ":/client/theme/white/" + iconName + "@2x.png");
Q_UNUSED(iconPath)
}

void testIsDarkColor_nextcloudBlue_returnTrue()
Expand All @@ -81,7 +83,8 @@ private slots:

const auto result = OCC::Theme::isDarkColor(color);

QCOMPARE(result, true);
// QCOMPARE(result, true);
Q_UNUSED(result)
}

void testIsDarkColor_lightColor_returnFalse()
Expand All @@ -99,7 +102,8 @@ private slots:

const auto result = OCC::Theme::isDarkColor(color);

QCOMPARE(result, true);
// QCOMPARE(result, true);
Q_UNUSED(result)
}

void testIsHidpi_hidpi_returnTrue()
Expand Down

0 comments on commit cff4483

Please sign in to comment.