Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.14] nmc/0000-Dark_Mode_Disabled_New #308

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)

set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(NMC_RCC_FILE "nmctheme_v1.rcc")
configure_file(${CMAKE_SOURCE_DIR}/${NMC_RCC_FILE} "${BIN_OUTPUT_DIRECTORY}/${NMC_RCC_FILE}" COPYONLY)

include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)

set(QT_VERSION_MAJOR "6")
Expand Down Expand Up @@ -341,6 +344,7 @@ configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
if(BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
install(FILES nmctheme_v1.rcc DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
elseif(BUILD_CLIENT)
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
Expand Down
Binary file added nmctheme_v1.rcc
Binary file not shown.
8 changes: 8 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Svg Qml Quick Qui
find_package(KF6Archive REQUIRED)
find_package(KF6GuiAddons)

#NMC change, its needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

if (NOT TARGET Qt::GuiPrivate)
message(FATAL_ERROR "Could not find GuiPrivate component of Qt. It might be shipped as a separate package, please check that.")
endif()
Expand Down Expand Up @@ -251,6 +254,10 @@ set(client_SRCS
wizard/linklabel.cpp
)

file(GLOB NMC_FILES "nmcgui/*")
set(NMC_SRCS ${NMC_FILES})
list(APPEND client_SRCS ${NMC_SRCS})

if (WITH_WEBENGINE)
list(APPEND client_SRCS
wizard/webviewpage.h
Expand Down Expand Up @@ -618,6 +625,7 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES ${VISUAL_ELEMENTS} DESTINATION bin/visualelements)
install(FILES "${theme_dir}/${APPLICATION_EXECUTABLE}.VisualElementsManifest.xml" DESTINATION bin)
install(FILES ${client_I18N} DESTINATION i18n)
install(FILES ${CMAKE_SOURCE_DIR}/nmctheme_v1.rcc DESTINATION bin)
endif()

# we may not add MACOSX_BUNDLE here, if not building one
Expand Down
38 changes: 38 additions & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ int main(int argc, char **argv)
qputenv("QML_IMPORT_PATH", (QDir::currentPath() + QStringLiteral("/qml")).toLatin1());
#endif

bool resourceLoaded = false;
const QString currentPath = QDir::currentPath();
if(Utility::isMac())
{
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators("/Applications/MagentaCLOUD.app/Contents/Resources/nmctheme_v1.rcc"));
}
else if(Utility::isWindows() || !resourceLoaded)
{
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators(currentPath + "/nmctheme_v1.rcc"));
}

Q_INIT_RESOURCE(resources);
Q_INIT_RESOURCE(theme);

Expand Down Expand Up @@ -84,6 +95,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