Skip to content
Merged
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
1 change: 1 addition & 0 deletions launcher/resources/multimc/index.theme
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Icon Theme]
Name=multimc
Comment=Default Icons
FollowsColorScheme=true
Inherits=default
Directories=8x8,16x16,22x22,24x24,32x32,32x32/instances,48x48,50x50/instances,64x64,128x128/instances,256x256,scalable,scalable/instances

Expand Down
26 changes: 26 additions & 0 deletions launcher/resources/pe_blue/pe_blue.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
<RCC version="1.0">
<qresource prefix="/icons/pe_blue">
<file>index.theme</file>
<!-- KDE names used by ThemedIcons::aliases(); retain the original names below. -->
<file alias="scalable/help-about.svg">scalable/about.svg</file>
<file alias="scalable/user-identity.svg">scalable/accounts.svg</file>
<file alias="scalable/preferences-desktop-theme.svg">scalable/appearance.svg</file>
<file alias="scalable/tools-report-bug.svg">scalable/bug.svg</file>
<file alias="scalable/system-software-update.svg">scalable/checkupdate.svg</file>
<file alias="scalable/edit-copy.svg">scalable/copy.svg</file>
<file alias="scalable/utilities-terminal.svg">scalable/custom-commands.svg</file>
<file alias="scalable/edit-delete.svg">scalable/delete.svg</file>
<file alias="scalable/document-export.svg">scalable/export.svg</file>
<file alias="scalable/applications-development.svg">scalable/externaltools.svg</file>
<file alias="scalable/help-contents.svg">scalable/help.svg</file>
<file alias="scalable/configure.svg">scalable/instance-settings.svg</file>
<file alias="scalable/media-playback-start.svg">scalable/launch.svg</file>
<file alias="scalable/text-x-log.svg">scalable/log.svg</file>
<file alias="scalable/list-add.svg">scalable/new.svg</file>
<file alias="scalable/news-subscribe.svg">scalable/news.svg</file>
<file alias="scalable/view-pim-notes.svg">scalable/notes.svg</file>
<file alias="scalable/preferences-system-network-proxy.svg">scalable/proxy.svg</file>
<file alias="scalable/view-refresh.svg">scalable/refresh.svg</file>
<file alias="scalable/edit-rename.svg">scalable/rename.svg</file>
<file alias="scalable/camera-photo.svg">scalable/screenshots.svg</file>
<file alias="scalable/preferences-system.svg">scalable/settings.svg</file>
<file alias="scalable/insert-link.svg">scalable/shortcut.svg</file>
<file alias="scalable/folder-open.svg">scalable/viewfolder.svg</file>

<file>scalable/about.svg</file>
<file>scalable/accounts.svg</file>
<file>scalable/bug.svg</file>
Expand Down
26 changes: 26 additions & 0 deletions launcher/resources/pe_colored/pe_colored.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
<RCC version="1.0">
<qresource prefix="/icons/pe_colored">
<file>index.theme</file>
<!-- KDE names used by ThemedIcons::aliases(); retain the original names below. -->
<file alias="scalable/help-about.svg">scalable/about.svg</file>
<file alias="scalable/user-identity.svg">scalable/accounts.svg</file>
<file alias="scalable/preferences-desktop-theme.svg">scalable/appearance.svg</file>
<file alias="scalable/tools-report-bug.svg">scalable/bug.svg</file>
<file alias="scalable/system-software-update.svg">scalable/checkupdate.svg</file>
<file alias="scalable/edit-copy.svg">scalable/copy.svg</file>
<file alias="scalable/utilities-terminal.svg">scalable/custom-commands.svg</file>
<file alias="scalable/edit-delete.svg">scalable/delete.svg</file>
<file alias="scalable/document-export.svg">scalable/export.svg</file>
<file alias="scalable/applications-development.svg">scalable/externaltools.svg</file>
<file alias="scalable/help-contents.svg">scalable/help.svg</file>
<file alias="scalable/configure.svg">scalable/instance-settings.svg</file>
<file alias="scalable/media-playback-start.svg">scalable/launch.svg</file>
<file alias="scalable/text-x-log.svg">scalable/log.svg</file>
<file alias="scalable/list-add.svg">scalable/new.svg</file>
<file alias="scalable/news-subscribe.svg">scalable/news.svg</file>
<file alias="scalable/view-pim-notes.svg">scalable/notes.svg</file>
<file alias="scalable/preferences-system-network-proxy.svg">scalable/proxy.svg</file>
<file alias="scalable/view-refresh.svg">scalable/refresh.svg</file>
<file alias="scalable/edit-rename.svg">scalable/rename.svg</file>
<file alias="scalable/camera-photo.svg">scalable/screenshots.svg</file>
<file alias="scalable/preferences-system.svg">scalable/settings.svg</file>
<file alias="scalable/insert-link.svg">scalable/shortcut.svg</file>
<file alias="scalable/folder-open.svg">scalable/viewfolder.svg</file>

<file>scalable/about.svg</file>
<file>scalable/accounts.svg</file>
<file>scalable/bug.svg</file>
Expand Down
26 changes: 26 additions & 0 deletions launcher/resources/pe_dark/pe_dark.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
<RCC version="1.0">
<qresource prefix="/icons/pe_dark">
<file>index.theme</file>
<!-- KDE names used by ThemedIcons::aliases(); retain the original names below. -->
<file alias="scalable/help-about.svg">scalable/about.svg</file>
<file alias="scalable/user-identity.svg">scalable/accounts.svg</file>
<file alias="scalable/preferences-desktop-theme.svg">scalable/appearance.svg</file>
<file alias="scalable/tools-report-bug.svg">scalable/bug.svg</file>
<file alias="scalable/system-software-update.svg">scalable/checkupdate.svg</file>
<file alias="scalable/edit-copy.svg">scalable/copy.svg</file>
<file alias="scalable/utilities-terminal.svg">scalable/custom-commands.svg</file>
<file alias="scalable/edit-delete.svg">scalable/delete.svg</file>
<file alias="scalable/document-export.svg">scalable/export.svg</file>
<file alias="scalable/applications-development.svg">scalable/externaltools.svg</file>
<file alias="scalable/help-contents.svg">scalable/help.svg</file>
<file alias="scalable/configure.svg">scalable/instance-settings.svg</file>
<file alias="scalable/media-playback-start.svg">scalable/launch.svg</file>
<file alias="scalable/text-x-log.svg">scalable/log.svg</file>
<file alias="scalable/list-add.svg">scalable/new.svg</file>
<file alias="scalable/news-subscribe.svg">scalable/news.svg</file>
<file alias="scalable/view-pim-notes.svg">scalable/notes.svg</file>
<file alias="scalable/preferences-system-network-proxy.svg">scalable/proxy.svg</file>
<file alias="scalable/view-refresh.svg">scalable/refresh.svg</file>
<file alias="scalable/edit-rename.svg">scalable/rename.svg</file>
<file alias="scalable/camera-photo.svg">scalable/screenshots.svg</file>
<file alias="scalable/preferences-system.svg">scalable/settings.svg</file>
<file alias="scalable/insert-link.svg">scalable/shortcut.svg</file>
<file alias="scalable/folder-open.svg">scalable/viewfolder.svg</file>

<file>scalable/about.svg</file>
<file>scalable/accounts.svg</file>
<file>scalable/bug.svg</file>
Expand Down
26 changes: 26 additions & 0 deletions launcher/resources/pe_light/pe_light.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
<RCC version="1.0">
<qresource prefix="/icons/pe_light">
<file>index.theme</file>
<!-- KDE names used by ThemedIcons::aliases(); retain the original names below. -->
<file alias="scalable/help-about.svg">scalable/about.svg</file>
<file alias="scalable/user-identity.svg">scalable/accounts.svg</file>
<file alias="scalable/preferences-desktop-theme.svg">scalable/appearance.svg</file>
<file alias="scalable/tools-report-bug.svg">scalable/bug.svg</file>
<file alias="scalable/system-software-update.svg">scalable/checkupdate.svg</file>
<file alias="scalable/edit-copy.svg">scalable/copy.svg</file>
<file alias="scalable/utilities-terminal.svg">scalable/custom-commands.svg</file>
<file alias="scalable/edit-delete.svg">scalable/delete.svg</file>
<file alias="scalable/document-export.svg">scalable/export.svg</file>
<file alias="scalable/applications-development.svg">scalable/externaltools.svg</file>
<file alias="scalable/help-contents.svg">scalable/help.svg</file>
<file alias="scalable/configure.svg">scalable/instance-settings.svg</file>
<file alias="scalable/media-playback-start.svg">scalable/launch.svg</file>
<file alias="scalable/text-x-log.svg">scalable/log.svg</file>
<file alias="scalable/list-add.svg">scalable/new.svg</file>
<file alias="scalable/news-subscribe.svg">scalable/news.svg</file>
<file alias="scalable/view-pim-notes.svg">scalable/notes.svg</file>
<file alias="scalable/preferences-system-network-proxy.svg">scalable/proxy.svg</file>
<file alias="scalable/view-refresh.svg">scalable/refresh.svg</file>
<file alias="scalable/edit-rename.svg">scalable/rename.svg</file>
<file alias="scalable/camera-photo.svg">scalable/screenshots.svg</file>
<file alias="scalable/preferences-system.svg">scalable/settings.svg</file>
<file alias="scalable/insert-link.svg">scalable/shortcut.svg</file>
<file alias="scalable/folder-open.svg">scalable/viewfolder.svg</file>

<file>scalable/about.svg</file>
<file>scalable/accounts.svg</file>
<file>scalable/bug.svg</file>
Expand Down
6 changes: 4 additions & 2 deletions launcher/ui/pages/global/AppearancePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ AppearancePage::AppearancePage(QWidget* parent)
QDir().mkpath(ThemedIcons::userDirectory());
DesktopServices::openDirectory(ThemedIcons::userDirectory(), true);
});
connect(ui->iconsReloadButton, &QPushButton::clicked, this,
&AppearancePage::loadIconThemes);
connect(ui->iconsReloadButton, &QPushButton::clicked, this, [this] {
ThemedIcons::reload();
loadIconThemes();
});
loadIconThemes();

updateIconPreview();
Expand Down
45 changes: 44 additions & 1 deletion launcher/ui/themes/AppearanceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <QDebug>
#include <QEvent>
#include <QPalette>
#include <QPixmapCache>
#include <QStyle>
#include <QTimer>
#include <QWidget>

#include <KColorSchemeManager>
#include <KStyleManager>
Expand All @@ -53,6 +57,10 @@ void AppearanceManager::stopSettingNewWindowColorsOnMac() {}

void AppearanceManager::initialize(KConfigSettingsObject* legacySettings)
{
// The style of the system, which a colour scheme may take the place of
// (see paletteChanged()).
m_systemStyle = QApplication::style()->objectName();

// The widget style the user chose, if KDE's platform theme is not doing
// that already.
KStyleManager::initStyle();
Expand Down Expand Up @@ -95,7 +103,10 @@ void AppearanceManager::setIconTheme(const QString& id)
const QString applied = ThemedIcons::setTheme(id);
m_settings->setIconTheme(applied);
m_settings->save();
emit iconsChanged();
// Left to the next turn of the event loop: the icon loader has just been
// made again, and what asks it for icons should not do so in the middle
// of the change (in a slot of the combo box that chose the theme).
QTimer::singleShot(0, this, [this] { refreshLooks(); });
}

bool AppearanceManager::eventFilter(QObject* watched, QEvent* event)
Expand All @@ -108,8 +119,40 @@ bool AppearanceManager::eventFilter(QObject* watched, QEvent* event)

void AppearanceManager::paletteChanged()
{
if (m_applyingStyle) {
return;
}

// A native style (macOS, Windows) paints its own colours, so a colour
// scheme of the user's shows half of the way on it. Fusion follows the
// palette; the system's style comes back with the system's scheme.
const bool custom =
!KColorSchemeManager::instance()->activeSchemeId().isEmpty();
const QString style = ColorSchemes::styleFor(
qApp->style()->objectName(), m_systemStyle, custom, m_styleOverridden);
if (!style.isEmpty()) {
m_applyingStyle = true;
const QPalette keep = qApp->palette();
QApplication::setStyle(style);
QApplication::setPalette(keep);
m_applyingStyle = false;
m_styleOverridden = custom;
}

const QPalette palette = qApp->palette();
ThemedIcons::setPalette(palette);
setTitlebarColorOfAllWindowsOnMac(palette.window().color());
refreshLooks();
}

void AppearanceManager::refreshLooks()
{
// Icons are drawn when they are needed, from the palette and the icon
// theme as they are then; what has to happen is that what is on the screen
// is drawn again, and that nothing is reused from before.
QPixmapCache::clear();
for (QWidget* widget : QApplication::allWidgets()) {
widget->update();
}
emit iconsChanged();
}
5 changes: 5 additions & 0 deletions launcher/ui/themes/AppearanceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <QColor>
#include <QObject>
#include <QString>
#include <QWindow>
#include <memory>

Expand Down Expand Up @@ -62,7 +63,11 @@ class AppearanceManager : public QObject
private:
void initialize(KConfigSettingsObject* legacySettings);
GlobalSettings* m_settings;
QString m_systemStyle;
bool m_styleOverridden = false;
bool m_applyingStyle = false;
void paletteChanged();
void refreshLooks();
void setTitlebarColorOfAllWindowsOnMac(QColor color);
void setTitlebarColorOnMac(WId windowId, QColor color);
void stopSettingNewWindowColorsOnMac();
Expand Down
22 changes: 22 additions & 0 deletions launcher/ui/themes/ColorSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QDirIterator>
#include <QFile>
#include <QFileInfo>
#include <QStringList>
#include <QSaveFile>
#include <QStandardPaths>

Expand Down Expand Up @@ -81,6 +82,27 @@ namespace ColorSchemes
return written;
}

bool isNativeStyle(const QString& style)
{
static const QStringList native{
QStringLiteral("macos"), QStringLiteral("macintosh"),
QStringLiteral("windowsvista"), QStringLiteral("windows11")};
return native.contains(style, Qt::CaseInsensitive);
}

QString styleFor(const QString& current, const QString& systemStyle,
bool customScheme, bool overridden)
{
if (customScheme && isNativeStyle(current)) {
return QStringLiteral("Fusion");
}
if (!customScheme && overridden && !systemStyle.isEmpty() &&
current.compare(systemStyle, Qt::CaseInsensitive) != 0) {
return systemStyle;
}
return QString();
}

bool importScheme(const QString& file, const QString& directory,
QString* error)
{
Expand Down
20 changes: 20 additions & 0 deletions launcher/ui/themes/ColorSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ namespace ColorSchemes
*/
QString idForLegacyTheme(const QString& theme);

/*!
* Whether \p style is the platform's own widget style. It paints with the
* colours of the system and ignores the palette of the application in
* places, so a colour scheme that is not the system's shows half of the
* way on it: dark panels with light buttons.
*/
bool isNativeStyle(const QString& style);

/*!
* The widget style that makes a colour scheme show completely, or an
* empty string if \p current is fine as it is.
*
* With a scheme of its own (\p customScheme) a native style is replaced
* by Fusion, which follows the palette. With the system's scheme again,
* the style that was replaced (\p overridden) is put back, which is
* \p systemStyle.
*/
QString styleFor(const QString& current, const QString& systemStyle,
bool customScheme, bool overridden);

/*!
* Adds a scheme of the user's to \p directory: copies \p file there, if it
* is a KDE colour scheme (a ".colors" file with colours in it). One of the
Expand Down
23 changes: 23 additions & 0 deletions launcher/ui/themes/ColorSchemes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ class ColorSchemesTest : public QObject
}
}

void test_ANativeStyleIsReplacedByFusionForASchemeOfItsOwn()
{
// a scheme of the user's on a native style: Fusion
QCOMPARE(ColorSchemes::styleFor("macos", "macos", true, false),
QString("Fusion"));
QCOMPARE(ColorSchemes::styleFor("windows11", "windows11", true, false),
QString("Fusion"));
// a style that follows the palette is left alone
QVERIFY(ColorSchemes::styleFor("Fusion", "macos", true, false)
.isEmpty());
// the system's scheme: nothing to do, unless the style was replaced
QVERIFY(ColorSchemes::styleFor("macos", "macos", false, false)
.isEmpty());
QCOMPARE(ColorSchemes::styleFor("Fusion", "macos", false, true),
QString("macos"));
// and it is not put back twice, or over a style that was chosen
QVERIFY(ColorSchemes::styleFor("macos", "macos", false, true)
.isEmpty());
QVERIFY(ColorSchemes::styleFor("Fusion", "", false, true).isEmpty());
QVERIFY(ColorSchemes::isNativeStyle("macOS"));
QVERIFY(!ColorSchemes::isNativeStyle("Fusion"));
}

void test_ASchemeOfTheUsersIsImported()
{
QTemporaryDir source;
Expand Down
Loading
Loading