Verified Commit 30019c4a authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

Use `uint` data type in accent color dbus interface

This is expected to slightly improve efficiency.
parent 51107d9a
Pipeline #223794 passed with stage
in 6 minutes and 50 seconds
......@@ -24,10 +24,15 @@ AccentColorService::AccentColorService(QObject *parent, const QList<QVariant> &)
dbus.registerService("org.kde.plasmashell.accentColor");
}
void AccentColorService::setAccentColor(const QString &accentColor)
void AccentColorService::setAccentColor(unsigned accentColor)
{
const QColor color = QColor::fromRgba(accentColor);
if (!color.isValid()) {
return;
}
m_settings->load();
if (QColor::isValidColor(accentColor) && m_settings->accentColorFromWallpaper()) {
if (m_settings->accentColorFromWallpaper()) {
const QString path =
QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes/%1.colors").arg(m_settings->colorScheme()));
......@@ -40,7 +45,7 @@ void AccentColorService::setAccentColor(const QString &accentColor)
// animation start event before we potentially trigger client side changes
QDBusConnection::sessionBus().call(msg);
m_settings->setAccentColor(accentColor);
m_settings->setAccentColor(color);
m_settings->save();
applyScheme(path, m_settings->config(), KConfig::Notify);
notifyKcmChange(GlobalChangeType::PaletteChanged);
......
......@@ -18,7 +18,7 @@ public:
explicit AccentColorService(QObject *parent, const QList<QVariant> &);
public Q_SLOTS:
void setAccentColor(const QString &color);
void setAccentColor(unsigned accentColor);
private:
ColorsSettings *m_settings;
......
......@@ -16,7 +16,7 @@
<arg name="output" type="s" direction="out"/>
</method>
<method name="color">
<arg name="output" type="s" direction="out"/>
<arg name="output" type="u" direction="out"/>
</method>
<signal name="colorChanged">
<arg name="changedColor" type="s" direction="out"/>
......
......@@ -36,7 +36,7 @@
DesktopView::DesktopView(Plasma::Corona *corona, QScreen *targetScreen)
: PlasmaQuick::ContainmentView(corona, nullptr)
, m_accentColor("transparent")
, m_accentColor(Qt::transparent)
, m_windowType(Desktop)
, m_shellSurface(nullptr)
{
......@@ -82,7 +82,7 @@ DesktopView::DesktopView(Plasma::Corona *corona, QScreen *targetScreen)
connect(static_cast<ShellCorona *>(corona), &ShellCorona::accentColorFromWallpaperEnabledChanged, this, &DesktopView::usedInAccentColorChanged);
connect(this, &DesktopView::usedInAccentColorChanged, this, [this] {
if (!usedInAccentColor()) {
m_accentColor = QStringLiteral("transparent");
m_accentColor = Qt::transparent;
Q_EMIT accentColorChanged(m_accentColor);
}
});
......@@ -152,12 +152,12 @@ bool DesktopView::usedInAccentColor() const
return static_cast<ShellCorona *>(corona())->accentColorFromWallpaperEnabled();
}
QString DesktopView::accentColor() const
QColor DesktopView::accentColor() const
{
return m_accentColor;
}
void DesktopView::setAccentColor(const QString &accentColor)
void DesktopView::setAccentColor(const QColor &accentColor)
{
if (accentColor == m_accentColor) {
return;
......@@ -444,12 +444,12 @@ void DesktopView::setupWaylandIntegration()
}
}
void DesktopView::setAccentColorFromWallpaper(const QString &accentColor)
void DesktopView::setAccentColorFromWallpaper(const QColor &accentColor)
{
if (!usedInAccentColor()) {
return;
}
QDBusMessage applyAccentColor = QDBusMessage::createMethodCall("org.kde.plasmashell.accentColor", "/AccentColor", "", "setAccentColor");
applyAccentColor << accentColor;
applyAccentColor << accentColor.rgba();
QDBusConnection::sessionBus().send(applyAccentColor);
}
......@@ -40,7 +40,7 @@ class DesktopView : public PlasmaQuick::ContainmentView
*/
Q_PROPERTY(bool usedInAccentColor READ usedInAccentColor NOTIFY usedInAccentColorChanged)
Q_PROPERTY(QString accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged)
Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged)
public:
enum WindowType {
......@@ -71,8 +71,8 @@ public:
bool usedInAccentColor() const;
QString accentColor() const;
void setAccentColor(const QString &);
QColor accentColor() const;
void setAccentColor(const QColor &);
WindowType windowType() const;
void setWindowType(WindowType type);
......@@ -104,16 +104,16 @@ Q_SIGNALS:
void candidateContainmentsChanged();
void geometryChanged();
void usedInAccentColorChanged();
void accentColorChanged(const QString &accentColor);
void accentColorChanged(const QColor &accentColor);
private:
void coronaPackageChanged(const KPackage::Package &package);
void ensureWindowType();
void setupWaylandIntegration();
void setAccentColorFromWallpaper(const QString &accentColor);
void setAccentColorFromWallpaper(const QColor &accentColor);
bool handleKRunnerTextInput(QKeyEvent *e);
QString m_accentColor;
QColor m_accentColor;
QPointer<PlasmaQuick::ConfigView> m_configView;
QPointer<QScreen> m_oldScreen;
QPointer<QScreen> m_screenToFollow;
......
......@@ -1503,13 +1503,13 @@ void ShellCorona::toggleDashboard()
setDashboardShown(!KWindowSystem::showingDesktop());
}
QString ShellCorona::color() const
QRgb ShellCorona::color() const
{
auto const primaryDesktopViewExists = m_desktopViewForScreen.contains(m_screenPool->primaryScreen());
if (primaryDesktopViewExists) {
return m_desktopViewForScreen[m_screenPool->primaryScreen()]->accentColor();
return m_desktopViewForScreen[m_screenPool->primaryScreen()]->accentColor().rgba();
}
return QStringLiteral("#00FFFFFF");
return QColor(Qt::transparent).rgba();
}
QString ShellCorona::evaluateScript(const QString &script)
......
......@@ -140,7 +140,7 @@ Q_SIGNALS:
// A preview for this containment has been rendered and saved to disk
void containmentPreviewReady(Plasma::Containment *containment, const QString &path);
void accentColorFromWallpaperEnabledChanged();
void colorChanged(const QString &color);
void colorChanged(const QColor &color);
public Q_SLOTS:
/**
......@@ -170,7 +170,7 @@ public Q_SLOTS:
void toggleWidgetExplorer();
QString evaluateScript(const QString &string);
void activateLauncherMenu();
QString color() const;
QRgb color() const;
QByteArray dumpCurrentLayoutJS() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment