mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 10:50:30 +03:00
refactor:colorizerSupport moved to View::Effects
--renamed also from colorizerSupport to colorizerEnabled
This commit is contained in:
parent
3de7993b8d
commit
885e438143
@ -690,21 +690,6 @@ void DockView::setBlockAnimations(bool block)
|
||||
emit blockAnimationsChanged();
|
||||
}
|
||||
|
||||
bool DockView::colorizerSupport() const
|
||||
{
|
||||
return m_colorizerSupport;
|
||||
}
|
||||
|
||||
void DockView::setColorizerSupport(bool support)
|
||||
{
|
||||
if (m_colorizerSupport == support) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_colorizerSupport = support;
|
||||
emit colorizerSupportChanged();
|
||||
}
|
||||
|
||||
bool DockView::themeHasShadow() const
|
||||
{
|
||||
return PanelShadows::self()->enabled();
|
||||
|
@ -67,7 +67,6 @@ class DockView : public PlasmaQuick::ContainmentView
|
||||
Q_PROPERTY(bool alternativesIsShown READ alternativesIsShown NOTIFY alternativesIsShownChanged)
|
||||
Q_PROPERTY(bool behaveAsPlasmaPanel READ behaveAsPlasmaPanel WRITE setBehaveAsPlasmaPanel NOTIFY behaveAsPlasmaPanelChanged)
|
||||
Q_PROPERTY(bool blockAnimations READ blockAnimations WRITE setBlockAnimations NOTIFY blockAnimationsChanged)
|
||||
Q_PROPERTY(bool colorizerSupport READ colorizerSupport WRITE setColorizerSupport NOTIFY colorizerSupportChanged)
|
||||
Q_PROPERTY(bool contextMenuIsShown READ contextMenuIsShown NOTIFY contextMenuIsShownChanged)
|
||||
Q_PROPERTY(bool dockWinBehavior READ dockWinBehavior WRITE setDockWinBehavior NOTIFY dockWinBehaviorChanged)
|
||||
//! Because Latte uses animations, changing to edit mode it may be different than
|
||||
@ -130,9 +129,6 @@ public:
|
||||
bool blockAnimations() const;
|
||||
void setBlockAnimations(bool block);
|
||||
|
||||
bool colorizerSupport() const;
|
||||
void setColorizerSupport(bool support);
|
||||
|
||||
bool contextMenuIsShown() const;
|
||||
|
||||
bool dockWinBehavior() const;
|
||||
@ -240,7 +236,6 @@ signals:
|
||||
void alignmentChanged();
|
||||
void behaveAsPlasmaPanelChanged();
|
||||
void blockAnimationsChanged();
|
||||
void colorizerSupportChanged();
|
||||
void contextMenuIsShownChanged();
|
||||
void currentScreenChanged();
|
||||
void dockLocationChanged();
|
||||
@ -292,7 +287,6 @@ private:
|
||||
bool m_alternativesIsShown{false};
|
||||
bool m_behaveAsPlasmaPanel{false};
|
||||
bool m_blockAnimations{false};
|
||||
bool m_colorizerSupport{false};
|
||||
bool m_dockWinBehavior{true};
|
||||
bool m_inDelete{false};
|
||||
bool m_inEditMode{false};
|
||||
|
@ -59,6 +59,22 @@ void Effects::init()
|
||||
connect(this, SIGNAL(innerShadowChanged()), m_view->corona(), SIGNAL(availableScreenRectChanged()));
|
||||
}
|
||||
|
||||
bool Effects::colorizerEnabled() const
|
||||
{
|
||||
return m_colorizerEnabled;
|
||||
}
|
||||
|
||||
void Effects::setColorizerEnabled(bool enabled)
|
||||
{
|
||||
if (m_colorizerEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_colorizerEnabled = enabled;
|
||||
emit colorizerEnabledChanged();
|
||||
}
|
||||
|
||||
|
||||
bool Effects::drawShadows() const
|
||||
{
|
||||
return m_drawShadows;
|
||||
|
@ -37,6 +37,7 @@ namespace View {
|
||||
class Effects: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool colorizerEnabled READ colorizerEnabled WRITE setColorizerEnabled NOTIFY colorizerEnabledChanged)
|
||||
Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged)
|
||||
Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged)
|
||||
|
||||
@ -52,6 +53,9 @@ public:
|
||||
Effects(DockView *parent);
|
||||
virtual ~Effects();
|
||||
|
||||
bool colorizerEnabled() const;
|
||||
void setColorizerEnabled(bool enabled);
|
||||
|
||||
bool drawShadows() const;
|
||||
void setDrawShadows(bool draw);
|
||||
|
||||
@ -77,6 +81,7 @@ public slots:
|
||||
void updateEnabledBorders();
|
||||
|
||||
signals:
|
||||
void colorizerEnabledChanged();
|
||||
void drawShadowsChanged();
|
||||
void drawEffectsChanged();
|
||||
void enabledBordersChanged();
|
||||
@ -88,6 +93,7 @@ private slots:
|
||||
void init();
|
||||
|
||||
private:
|
||||
bool m_colorizerEnabled{false};
|
||||
bool m_drawShadows{true};
|
||||
bool m_drawEffects{false};
|
||||
bool m_forceDrawCenteredBorders{false};
|
||||
|
@ -174,8 +174,6 @@ void Layout::initToCorona(DockCorona *corona)
|
||||
{
|
||||
m_corona = corona;
|
||||
|
||||
connect(this, &Layout::dockColorizerSupportChanged, m_corona->layoutManager(), &LayoutManager::updateColorizerSupport);
|
||||
|
||||
foreach (auto containment, m_corona->containments()) {
|
||||
if (m_corona->layoutManager()->memoryUsage() == Dock::SingleLayout) {
|
||||
addContainment(containment);
|
||||
@ -852,7 +850,7 @@ void Layout::containmentDestroyed(QObject *cont)
|
||||
emit m_corona->docksCountChanged();
|
||||
emit m_corona->availableScreenRectChanged();
|
||||
emit m_corona->availableScreenRegionChanged();
|
||||
emit dockColorizerSupportChanged();
|
||||
emit viewColorizerChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -995,7 +993,7 @@ void Layout::addDock(Plasma::Containment *containment, bool forceOnPrimary, int
|
||||
connect(containment, &Plasma::Containment::appletCreated, this, &Layout::appletCreated);
|
||||
}
|
||||
|
||||
connect(dockView, &DockView::colorizerSupportChanged, this, &Layout::dockColorizerSupportChanged);
|
||||
connect(dockView->effects(), &View::Effects::colorizerEnabledChanged, this, &Layout::viewColorizerChanged);
|
||||
|
||||
//! Qt 5.9 creates a crash for this in wayland, that is why the check is used
|
||||
//! but on the other hand we need this for copy to work correctly and show
|
||||
@ -1006,7 +1004,7 @@ void Layout::addDock(Plasma::Containment *containment, bool forceOnPrimary, int
|
||||
|
||||
m_dockViews[containment] = dockView;
|
||||
|
||||
emit dockColorizerSupportChanged();
|
||||
emit viewColorizerChanged();
|
||||
emit m_corona->docksCountChanged();
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,6 @@ signals:
|
||||
void backgroundChanged();
|
||||
void colorChanged();
|
||||
void disableBordersForMaximizedWindowsChanged();
|
||||
void dockColorizerSupportChanged();
|
||||
void fileChanged();
|
||||
void lastUsedActivityChanged();
|
||||
void launchersChanged();
|
||||
@ -167,6 +166,7 @@ signals:
|
||||
void versionChanged();
|
||||
void showInMenuChanged();
|
||||
void textColorChanged();
|
||||
void viewColorizerChanged();
|
||||
|
||||
//! used from DockView(s) in order to exist only one each time that has the highest priority
|
||||
//! to use the global shortcuts activations
|
||||
|
@ -198,6 +198,19 @@ QString LayoutManager::defaultLayoutName() const
|
||||
return presetName;
|
||||
}
|
||||
|
||||
bool LayoutManager::hasColorizer() const
|
||||
{
|
||||
foreach (auto layout, m_activeLayouts) {
|
||||
for (const auto *view : *layout->dockViews()) {
|
||||
if (view->effects()->colorizerEnabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LayoutManager::layoutExists(QString layoutName) const
|
||||
{
|
||||
return m_layouts.contains(layoutName);
|
||||
@ -644,6 +657,16 @@ void LayoutManager::hideAllDocks()
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutManager::addLayout(Layout *layout)
|
||||
{
|
||||
if (!m_activeLayouts.contains(layout)) {
|
||||
m_activeLayouts.append(layout);
|
||||
layout->initToCorona(m_corona);
|
||||
|
||||
connect(layout, &Layout::viewColorizerChanged, this, &LayoutManager::viewColorizerChanged);
|
||||
}
|
||||
}
|
||||
|
||||
bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage)
|
||||
{
|
||||
if (m_activeLayouts.size() > 0 && currentLayoutName() == layoutName && previousMemoryUsage == -1) {
|
||||
@ -747,9 +770,7 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage)
|
||||
}
|
||||
|
||||
Layout *newLayout = new Layout(this, fixedLPath, fixedLayoutName);
|
||||
m_activeLayouts.append(newLayout);
|
||||
newLayout->initToCorona(m_corona);
|
||||
|
||||
addLayout(newLayout);
|
||||
loadLatteLayout(fixedLPath);
|
||||
|
||||
emit activeLayoutsChanged();
|
||||
@ -901,9 +922,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans)
|
||||
|
||||
if (newLayout) {
|
||||
qDebug() << "ACTIVATING ORPHANED LAYOUT ::::: " << layoutForOrphans;
|
||||
|
||||
m_activeLayouts.append(newLayout);
|
||||
newLayout->initToCorona(m_corona);
|
||||
addLayout(newLayout);
|
||||
newLayout->importToCorona();
|
||||
}
|
||||
}
|
||||
@ -916,8 +935,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans)
|
||||
|
||||
if (newLayout) {
|
||||
qDebug() << "ACTIVATING LAYOUT ::::: " << layoutName;
|
||||
m_activeLayouts.append(newLayout);
|
||||
newLayout->initToCorona(m_corona);
|
||||
addLayout(newLayout);
|
||||
newLayout->importToCorona();
|
||||
|
||||
if (newLayout->isOriginalLayout() && m_corona->universalSettings()->showInfoWindow()) {
|
||||
@ -1183,30 +1201,6 @@ void LayoutManager::showInfoWindow(QString info, int duration, QStringList activ
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutManager::updateColorizerSupport()
|
||||
{
|
||||
bool enable{false};
|
||||
|
||||
foreach (auto layout, m_activeLayouts) {
|
||||
for (const auto *view : *layout->dockViews()) {
|
||||
if (view->colorizerSupport()) {
|
||||
enable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
m_corona->universalSettings()->enableActivitiesModel();
|
||||
} else {
|
||||
m_corona->universalSettings()->disableActivitiesModel();
|
||||
}
|
||||
}
|
||||
|
||||
//! it is used just in order to provide translations for the presets
|
||||
void LayoutManager::ghostForTranslatedPresets()
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
void syncActiveLayoutsToOriginalFiles();
|
||||
|
||||
bool dockViewExists(DockView *view) const;
|
||||
bool hasColorizer() const;
|
||||
bool layoutExists(QString layoutName) const;
|
||||
|
||||
QString shouldSwitchToLayout(QString activityId);
|
||||
@ -111,7 +112,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void showAboutDialog();
|
||||
void updateColorizerSupport();
|
||||
|
||||
void hideLatteSettingsDialog();
|
||||
Q_INVOKABLE void showLatteSettingsDialog(int page = Latte::Dock::LayoutPage);
|
||||
@ -133,6 +133,7 @@ signals:
|
||||
void launchersSignalsChanged();
|
||||
void layoutsChanged();
|
||||
void menuLayoutsChanged();
|
||||
void viewColorizerChanged();
|
||||
|
||||
void currentLayoutIsSwitching(QString layoutName);
|
||||
|
||||
@ -142,6 +143,7 @@ private slots:
|
||||
void syncMultipleLayoutsToActivities(QString layoutForOrphans = QString());
|
||||
|
||||
private:
|
||||
void addLayout(Layout *layout);
|
||||
void cleanupOnStartup(QString path); //!remove deprecated or oldstyle config options
|
||||
void clearUnloadedContainmentsFromLinkedFile(QStringList containmentsIds, bool bypassChecks = false);
|
||||
void confirmDynamicSwitch();
|
||||
|
@ -19,8 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "universalsettings.h"
|
||||
#include "dockcorona.h"
|
||||
|
||||
#include "layoutmanager.h"
|
||||
#include "sortedactivitiesmodel.h"
|
||||
|
||||
#include <QDir>
|
||||
@ -42,6 +41,8 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
|
||||
m_config(config),
|
||||
m_universalGroup(KConfigGroup(config, QStringLiteral("UniversalSettings")))
|
||||
{
|
||||
m_corona = qobject_cast<DockCorona *>(parent);
|
||||
|
||||
connect(this, &UniversalSettings::canDisableBordersChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::currentLayoutNameChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::downloadWindowSizeChanged, this, &UniversalSettings::saveConfig);
|
||||
@ -153,6 +154,9 @@ void UniversalSettings::load()
|
||||
//! load configuration
|
||||
loadConfig();
|
||||
|
||||
//! connections with other classes
|
||||
connect(m_corona->layoutManager(), &LayoutManager::viewColorizerChanged, this, &UniversalSettings::reconsiderActivitiesModel);
|
||||
|
||||
//! load global shortcuts badges at startup
|
||||
initGlobalShortcutsWatcher();
|
||||
parseGlobalShortcuts();
|
||||
@ -530,6 +534,15 @@ void UniversalSettings::disableActivitiesModel()
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalSettings::reconsiderActivitiesModel()
|
||||
{
|
||||
if (m_corona->layoutManager()->hasColorizer()) {
|
||||
enableActivitiesModel();
|
||||
} else {
|
||||
disableActivitiesModel();
|
||||
}
|
||||
}
|
||||
|
||||
float UniversalSettings::luminasFromFile(QString imageFile, int edge)
|
||||
{
|
||||
enableActivitiesModel();
|
||||
|
@ -21,8 +21,11 @@
|
||||
#ifndef UNIVERSALSETTINGS_H
|
||||
#define UNIVERSALSETTINGS_H
|
||||
|
||||
#include "dockcorona.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QPointer>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KSharedConfig>
|
||||
@ -100,8 +103,6 @@ public:
|
||||
|
||||
QAbstractItemModel *runningActivitiesModel() const;
|
||||
void setRunningActivitiesModel(SortedActivitiesModel *model);
|
||||
void enableActivitiesModel();
|
||||
void disableActivitiesModel();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE QString splitterIconPath();
|
||||
@ -130,10 +131,13 @@ private slots:
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
|
||||
void reconsiderActivitiesModel();
|
||||
void shortcutsFileChanged(const QString &file);
|
||||
|
||||
private:
|
||||
void cleanupSettings();
|
||||
void enableActivitiesModel();
|
||||
void disableActivitiesModel();
|
||||
|
||||
void initGlobalShortcutsWatcher();
|
||||
//! access user set global shortcuts for activate entries
|
||||
@ -172,6 +176,8 @@ private:
|
||||
|
||||
SortedActivitiesModel *m_runningActivitiesModel{nullptr};
|
||||
|
||||
QPointer<DockCorona> m_corona;
|
||||
|
||||
friend class LayoutManager;
|
||||
friend class DockCorona;
|
||||
};
|
||||
|
@ -95,13 +95,6 @@ Item{
|
||||
value: root.editMode ? false : root.behaveAsPlasmaPanel
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property: "colorizerSupport"
|
||||
when: dock
|
||||
value: root.forceColorizer && plasmoid.configuration.solidBackgroundForMaximized
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property: "dockTransparency"
|
||||
@ -109,23 +102,6 @@ Item{
|
||||
value: root.currentPanelTransparency
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property: "drawShadows"
|
||||
when: dock && dock.effects
|
||||
value: root.drawShadowsExternal && (!root.inStartup || inForceHiding || inTempHiding)
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property: "drawEffects"
|
||||
when: dock && dock.effects
|
||||
value: Latte.WindowSystem.compositingActive &&
|
||||
(((root.blurEnabled && root.useThemePanel)
|
||||
|| (root.blurEnabled && root.forceSolidPanel && dock.visibility.existsWindowMaximized && Latte.WindowSystem.compositingActive))
|
||||
&& (!root.inStartup || inForceHiding || inTempHiding))
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property: "fontPixelSize"
|
||||
@ -140,19 +116,6 @@ Item{
|
||||
value: root.editMode
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property:"innerShadow"
|
||||
when: dock && dock.effects
|
||||
value: {
|
||||
if (editModeVisual.editAnimationEnded && !root.behaveAsPlasmaPanel) {
|
||||
return root.editShadow;
|
||||
} else {
|
||||
return root.panelShadow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock
|
||||
property: "maxLength"
|
||||
@ -175,6 +138,43 @@ Item{
|
||||
value: root.panelAlignment
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property: "colorizerEnabled"
|
||||
when: dock && dock.effects
|
||||
value: root.forceColorizer && plasmoid.configuration.solidBackgroundForMaximized
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property: "drawEffects"
|
||||
when: dock && dock.effects
|
||||
value: Latte.WindowSystem.compositingActive &&
|
||||
(((root.blurEnabled && root.useThemePanel)
|
||||
|| (root.blurEnabled && root.forceSolidPanel && dock.visibility.existsWindowMaximized && Latte.WindowSystem.compositingActive))
|
||||
&& (!root.inStartup || inForceHiding || inTempHiding))
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property: "drawShadows"
|
||||
when: dock && dock.effects
|
||||
value: root.drawShadowsExternal && (!root.inStartup || inForceHiding || inTempHiding)
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.effects ? dock.effects : null
|
||||
property:"innerShadow"
|
||||
when: dock && dock.effects
|
||||
value: {
|
||||
if (editModeVisual.editAnimationEnded && !root.behaveAsPlasmaPanel) {
|
||||
return root.editShadow;
|
||||
} else {
|
||||
return root.panelShadow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binding{
|
||||
target: dock && dock.visibility ? dock.visibility : null
|
||||
property: "enabledDynamicBackground"
|
||||
|
Loading…
x
Reference in New Issue
Block a user