2014-11-03 15:12:54 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
2014-11-03 15:12:54 +00:00
|
|
|
#include "previewbutton.h"
|
|
|
|
#include "previewbridge.h"
|
|
|
|
#include "previewclient.h"
|
|
|
|
#include "previewsettings.h"
|
|
|
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
#include <QPainter>
|
2014-11-03 15:12:54 +00:00
|
|
|
|
|
|
|
namespace KDecoration2
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Preview
|
|
|
|
{
|
|
|
|
|
|
|
|
PreviewButtonItem::PreviewButtonItem(QQuickItem* parent)
|
|
|
|
: QQuickPaintedItem(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewButtonItem::~PreviewButtonItem() = default;
|
|
|
|
|
|
|
|
void PreviewButtonItem::setType(int type)
|
|
|
|
{
|
|
|
|
setType(KDecoration2::DecorationButtonType(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::setType(KDecoration2::DecorationButtonType type)
|
|
|
|
{
|
|
|
|
if (m_type == type) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_type = type;
|
|
|
|
emit typeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
KDecoration2::DecorationButtonType PreviewButtonItem::type() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewBridge *PreviewButtonItem::bridge() const
|
|
|
|
{
|
|
|
|
return m_bridge.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::setBridge(PreviewBridge *bridge)
|
|
|
|
{
|
|
|
|
if (m_bridge == bridge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_bridge = bridge;
|
|
|
|
emit bridgeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings *PreviewButtonItem::settings() const
|
|
|
|
{
|
|
|
|
return m_settings.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::setSettings(Settings *settings)
|
|
|
|
{
|
|
|
|
if (m_settings == settings) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_settings = settings;
|
|
|
|
emit settingsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PreviewButtonItem::typeAsInt() const
|
|
|
|
{
|
|
|
|
return int(m_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::componentComplete()
|
|
|
|
{
|
|
|
|
QQuickPaintedItem::componentComplete();
|
|
|
|
createButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::createButton()
|
|
|
|
{
|
|
|
|
if (m_type == KDecoration2::DecorationButtonType::Custom || m_decoration || !m_settings || !m_bridge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_decoration = m_bridge->createDecoration(this);
|
|
|
|
if (!m_decoration) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto client = m_bridge->lastCreatedClient();
|
|
|
|
client->setMinimizable(true);
|
|
|
|
client->setMaximizable(true);
|
|
|
|
client->setActive(false);
|
2014-12-09 15:07:27 +00:00
|
|
|
client->setProvidesContextHelp(true);
|
2014-11-03 15:12:54 +00:00
|
|
|
m_decoration->setSettings(m_settings->settings());
|
|
|
|
m_decoration->init();
|
|
|
|
m_button = m_bridge->createButton(m_decoration, m_type);
|
|
|
|
connect(this, &PreviewButtonItem::widthChanged, this, &PreviewButtonItem::syncGeometry);
|
|
|
|
connect(this, &PreviewButtonItem::heightChanged, this, &PreviewButtonItem::syncGeometry);
|
|
|
|
syncGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::syncGeometry()
|
|
|
|
{
|
|
|
|
if (!m_button) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_button->setGeometry(QRect(0, 0, width(), height()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewButtonItem::paint(QPainter *painter)
|
|
|
|
{
|
|
|
|
if (!m_button) {
|
|
|
|
return;
|
|
|
|
}
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
QRect size { 0, 0, (int)width(), (int)height() };
|
|
|
|
m_button->paint(painter, size);
|
|
|
|
painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
|
|
|
painter->fillRect(size, m_color);
|
|
|
|
}
|
|
|
|
|
2019-10-29 22:04:15 +00:00
|
|
|
void PreviewButtonItem::setColor(const QColor &color)
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
{
|
|
|
|
m_color = color;
|
|
|
|
m_color.setAlpha(127);
|
|
|
|
update();
|
2014-11-03 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|