diff --git a/app/view/indicator/indicator.cpp b/app/view/indicator/indicator.cpp index defedde7..67051f02 100644 --- a/app/view/indicator/indicator.cpp +++ b/app/view/indicator/indicator.cpp @@ -1,460 +1,439 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "indicator.h" // local #include "indicatorinfo.h" #include "../view.h" #include "../../lattecorona.h" #include "../../indicator/factory.h" #include "../../../liblatte2/types.h" // Qt #include // KDE #include #include #include #include namespace Latte { namespace ViewPart { Indicator::Indicator(Latte::View *parent) : QObject(parent), m_view(parent), m_info(new IndicatorPart::Info(this)), m_resources(new IndicatorPart::Resources(this)) { m_corona = qobject_cast(m_view->corona()); loadConfig(); connect(this, &Indicator::enabledChanged, this, &Indicator::saveConfig); - connect(this, &Indicator::enabledForAppletsChanged, this, &Indicator::saveConfig); - connect(this, &Indicator::paddingChanged, this, &Indicator::saveConfig); connect(this, &Indicator::pluginChanged, this, &Indicator::saveConfig); connect(m_view, &Latte::View::latteTasksArePresentChanged, this, &Indicator::latteTasksArePresentChanged); connect(m_view, &Latte::View::indicatorPluginChanged, [this](const QString &indicatorId) { if (m_corona && m_corona->indicatorFactory()->isCustomType(indicatorId)) { emit customPluginsChanged(); } }); connect(m_view, &Latte::View::indicatorPluginRemoved, [this](const QString &indicatorId) { if (m_corona && m_type == indicatorId && !m_corona->indicatorFactory()->pluginExists(indicatorId)) { setType("org.kde.latte.default"); } if (m_corona && m_corona->indicatorFactory()->isCustomType(indicatorId)) { emit customPluginsChanged(); } }); load(m_type); loadPlasmaComponent(); } Indicator::~Indicator() { if (m_component) { m_component->deleteLater(); } if (m_configLoader) { m_configLoader->deleteLater(); } if (m_configuration) { m_configuration->deleteLater(); } if (m_info) { m_info->deleteLater(); } } bool Indicator::enabled() const { return m_enabled; } void Indicator::setEnabled(bool enabled) { if (m_enabled == enabled) { return; } m_enabled = enabled; emit enabledChanged(); } bool Indicator::enabledForApplets() const { return m_enabledForApplets; } void Indicator::setEnabledForApplets(bool enabled) { if (m_enabledForApplets == enabled) { return; } m_enabledForApplets = enabled; emit enabledForAppletsChanged(); } bool Indicator::latteTasksArePresent() { return m_view->latteTasksArePresent(); } bool Indicator::providesConfigUi() const { return m_providesConfigUi; } void Indicator::setProvidesConfigUi(bool provides) { if (m_providesConfigUi == provides) { return; } m_providesConfigUi = provides; emit providesConfigUiChanged(); } -float Indicator::padding() const -{ - return m_padding; -} - -void Indicator::setPadding(float padding) -{ - if (m_padding == padding) { - return; - } - - m_padding = padding; - emit paddingChanged(); -} - bool Indicator::pluginIsReady() { return m_pluginIsReady; } void Indicator::setPluginIsReady(bool ready) { if (m_pluginIsReady == ready) { return; } m_pluginIsReady = ready; emit pluginIsReadyChanged(); } QString Indicator::type() const { return m_type; } void Indicator::setType(QString type) { if (m_type == type) { return; } load(type); } QString Indicator::customType() const { return m_customType; } void Indicator::setCustomType(QString type) { if (m_customType == type) { return; } m_customType = type; emit customPluginChanged(); } int Indicator::customPluginsCount() const { return m_corona->indicatorFactory()->customPluginsCount(); } QString Indicator::uiPath() const { return m_corona->indicatorFactory()->uiPath(m_type); } QStringList Indicator::customPluginIds() const { return m_corona->indicatorFactory()->customPluginIds(); } QStringList Indicator::customPluginNames() const { return m_corona->indicatorFactory()->customPluginNames(); } QStringList Indicator::customLocalPluginIds() const { return m_corona->indicatorFactory()->customLocalPluginIds(); } IndicatorPart::Info *Indicator::info() const { return m_info; } IndicatorPart::Resources *Indicator::resources() const { return m_resources; } QQmlComponent *Indicator::component() const { return m_component; } QQmlComponent *Indicator::plasmaComponent() const { return m_plasmaComponent; } QObject *Indicator::configuration() const { return m_configuration; } void Indicator::load(QString type) { KPluginMetaData metadata = m_corona->indicatorFactory()->metadata(type); if (metadata.isValid()) { bool state{m_enabled}; //! remove all previous indicators setPluginIsReady(false); m_metadata = metadata; m_type = type; QString path = m_metadata.fileName(); m_pluginPath = path.remove("metadata.desktop"); if (m_corona && m_corona->indicatorFactory()->isCustomType(type)) { setCustomType(type); } updateScheme(); updateComponent(); emit pluginChanged(); //! create all indicators with the new type setPluginIsReady(true); } else if (type!="org.kde.latte.default") { qDebug() << " Indicator metadata are not valid : " << type; setType("org.kde.latte.default"); } } void Indicator::updateComponent() { auto prevComponent = m_component; QString uiPath = m_metadata.value("X-Latte-MainScript"); if (!uiPath.isEmpty()) { uiPath = m_pluginPath + "package/" + uiPath; m_component = new QQmlComponent(m_view->engine(), uiPath); } if (prevComponent) { prevComponent->deleteLater(); } } void Indicator::loadPlasmaComponent() { auto prevComponent = m_plasmaComponent; KPluginMetaData metadata = m_corona->indicatorFactory()->metadata("org.kde.latte.plasma"); QString uiPath = metadata.value("X-Latte-MainScript"); if (!uiPath.isEmpty()) { QString path = metadata.fileName(); path = path.remove("metadata.desktop"); uiPath = path + "package/" + uiPath; m_plasmaComponent = new QQmlComponent(m_view->engine(), uiPath); } if (prevComponent) { prevComponent->deleteLater(); } emit plasmaComponentChanged(); } void Indicator::configUiFor(QString type, QQuickItem *parent) { if (m_lastCreatedConfigUi) { delete m_lastCreatedConfigUi; m_lastCreatedConfigUi = nullptr; } auto prevConfigUi = m_lastCreatedConfigUi; KPluginMetaData metadata; if (m_metadata.pluginId() == type) { metadata = m_metadata; } else { metadata = m_corona->indicatorFactory()->metadata(type); } if (metadata.isValid()) { QString uiPath = metadata.value("X-Latte-ConfigUi"); if (!uiPath.isEmpty()) { m_lastCreatedConfigUi = new KDeclarative::QmlObjectSharedEngine(parent); m_lastCreatedConfigUi->setTranslationDomain(QLatin1String("latte_indicator_") + m_metadata.pluginId()); m_lastCreatedConfigUi->setInitializationDelayed(true); uiPath = m_pluginPath + "package/" + uiPath; m_lastCreatedConfigUi->setSource(QUrl::fromLocalFile(uiPath)); m_lastCreatedConfigUi->rootContext()->setContextProperty(QStringLiteral("dialog"), parent); m_lastCreatedConfigUi->rootContext()->setContextProperty(QStringLiteral("indicator"), this); m_lastCreatedConfigUi->completeInitialization(); QQuickItem *qmlItem = qobject_cast(m_lastCreatedConfigUi->rootObject()); qmlItem->setParentItem(parent); setProvidesConfigUi(true); } else { setProvidesConfigUi(false); } } } void Indicator::unloadIndicators() { setPluginIsReady(false); } void Indicator::updateScheme() { auto prevConfigLoader = m_configLoader; auto prevConfiguration = m_configuration; QString xmlPath = m_metadata.value("X-Latte-ConfigXml"); if (!xmlPath.isEmpty()) { QFile file(m_pluginPath + "package/" + xmlPath); m_configLoader = new KConfigLoader(m_view->containment()->config().group("Indicator").group(m_metadata.pluginId()), &file); m_configuration = new KDeclarative::ConfigPropertyMap(m_configLoader, this); } else { m_configLoader = nullptr; m_configuration = nullptr; } if (prevConfigLoader) { prevConfigLoader->deleteLater(); } if (prevConfiguration) { prevConfiguration->deleteLater(); } } void Indicator::addIndicator() { QFileDialog *fileDialog = new QFileDialog(nullptr , i18nc("add indicator", "Add Indicator") , QDir::homePath() , QStringLiteral("indicator.latte")); fileDialog->setFileMode(QFileDialog::AnyFile); fileDialog->setAcceptMode(QFileDialog::AcceptOpen); fileDialog->setDefaultSuffix("indicator.latte"); QStringList filters; filters << QString(i18nc("add indicator file", "Latte Indicator") + "(*.indicator.latte)"); fileDialog->setNameFilters(filters); connect(fileDialog, &QFileDialog::finished, fileDialog, &QFileDialog::deleteLater); connect(fileDialog, &QFileDialog::fileSelected, this, [&](const QString & file) { qDebug() << "Trying to import indicator file ::: " << file; m_corona->indicatorFactory()->importIndicatorFile(file); }); fileDialog->open(); } void Indicator::downloadIndicator() { //! call asynchronously in order to not crash when view settings window //! loses focus and it closes QTimer::singleShot(0, [this]() { m_corona->indicatorFactory()->downloadIndicator(); }); } void Indicator::removeIndicator(QString pluginId) { //! call asynchronously in order to not crash when view settings window //! loses focus and it closes QTimer::singleShot(0, [this, pluginId]() { m_corona->indicatorFactory()->removeIndicator(pluginId); }); } void Indicator::loadConfig() { auto config = m_view->containment()->config().group("Indicator"); m_customType = config.readEntry("customType", QString()); m_enabled = config.readEntry("enabled", true); - m_enabledForApplets = config.readEntry("enabledForApplets", true); - m_padding = config.readEntry("padding", (float)0.08); m_type = config.readEntry("type", "org.kde.latte.default"); } void Indicator::saveConfig() { auto config = m_view->containment()->config().group("Indicator"); config.writeEntry("customType", m_customType); config.writeEntry("enabled", m_enabled); - config.writeEntry("enabledForApplets", m_enabledForApplets); - config.writeEntry("padding", m_padding); config.writeEntry("type", m_type); config.sync(); } } } diff --git a/app/view/indicator/indicator.h b/app/view/indicator/indicator.h index 64b9d3ff..c15a15c2 100644 --- a/app/view/indicator/indicator.h +++ b/app/view/indicator/indicator.h @@ -1,195 +1,187 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef VIEWINDICATOR_H #define VIEWINDICATOR_H // local #include "indicatorinfo.h" #include "indicatorresources.h" // Qt #include #include #include #include #include // KDE #include #include namespace KDeclarative { class ConfigPropertyMap; class QmlObjectSharedEngine; } namespace Latte { class Corona; class View; } namespace Latte { namespace ViewPart { class Indicator: public QObject { Q_OBJECT Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool enabledForApplets READ enabledForApplets WRITE setEnabledForApplets NOTIFY enabledForAppletsChanged) Q_PROPERTY(bool latteTasksArePresent READ latteTasksArePresent NOTIFY latteTasksArePresentChanged) Q_PROPERTY(bool pluginIsReady READ pluginIsReady NOTIFY pluginIsReadyChanged) Q_PROPERTY(bool providesConfigUi READ providesConfigUi NOTIFY providesConfigUiChanged) - Q_PROPERTY(float padding READ padding WRITE setPadding NOTIFY paddingChanged) - Q_PROPERTY(QString type READ type WRITE setType NOTIFY pluginChanged) Q_PROPERTY(QString customType READ customType NOTIFY customPluginChanged) /* Custom plugins */ Q_PROPERTY(int customPluginsCount READ customPluginsCount NOTIFY customPluginsChanged) Q_PROPERTY(QStringList customPluginIds READ customPluginIds NOTIFY customPluginsChanged) Q_PROPERTY(QStringList customPluginNames READ customPluginNames NOTIFY customPluginsChanged) Q_PROPERTY(QStringList customLocalPluginIds READ customLocalPluginIds NOTIFY customPluginsChanged) /** * Configuration object: each config key will be a writable property of this object. property bindings work. */ Q_PROPERTY(QObject *configuration READ configuration NOTIFY pluginChanged) Q_PROPERTY(QQmlComponent *component READ component NOTIFY pluginChanged) Q_PROPERTY(QQmlComponent *plasmaComponent READ plasmaComponent NOTIFY plasmaComponentChanged) /** * Information provided from the indicator itself */ Q_PROPERTY(Latte::ViewPart::IndicatorPart::Info *info READ info NOTIFY infoChanged) /** * Resources provided from the indicator itself */ Q_PROPERTY(Latte::ViewPart::IndicatorPart::Resources *resources READ resources NOTIFY resourcesChanged) public: Indicator(Latte::View *parent); virtual ~Indicator(); bool enabled() const; void setEnabled(bool enabled); bool enabledForApplets() const; void setEnabledForApplets(bool enabled); bool latteTasksArePresent(); bool providesConfigUi() const; bool pluginIsReady(); - float padding() const; - void setPadding(float padding); - QString type() const; void setType(QString type); QString uiPath() const; QString customType() const; int customPluginsCount() const; QStringList customPluginIds() const; QStringList customPluginNames() const; QStringList customLocalPluginIds() const; IndicatorPart::Info *info() const; IndicatorPart::Resources *resources() const; QObject *configuration() const; QQmlComponent *component() const; QQmlComponent *plasmaComponent() const; void load(QString type); void unloadIndicators(); public slots: Q_INVOKABLE void configUiFor(QString type, QQuickItem *parent); Q_INVOKABLE void addIndicator(); Q_INVOKABLE void downloadIndicator(); Q_INVOKABLE void removeIndicator(QString pluginId); signals: void customPluginsChanged(); void enabledChanged(); void enabledForAppletsChanged(); void customPluginChanged(); void infoChanged(); void latteTasksArePresentChanged(); - void paddingChanged(); void plasmaComponentChanged(); void pluginChanged(); void pluginIsReadyChanged(); void providesConfigUiChanged(); void resourcesChanged(); private: void loadConfig(); void saveConfig(); void setPluginIsReady(bool ready); void setProvidesConfigUi(bool provides); void setCustomType(QString type); void loadPlasmaComponent(); void updateComponent(); void updateScheme(); private: bool m_enabled{true}; bool m_enabledForApplets{true}; bool m_pluginIsReady{false}; bool m_providesConfigUi{true}; - float m_padding{0.08}; - QString m_pluginPath; QString m_type{"org.kde.latte.default"}; QString m_customType; QPointer m_component; QPointer m_plasmaComponent; QPointer m_configUi; QPointer m_configLoader; QPointer m_corona; QPointer m_view; KPluginMetaData m_metadata; QPointer m_info; QPointer m_resources; QPointer m_configuration; QPointer m_lastCreatedConfigUi; }; } } #endif diff --git a/containment/package/contents/ui/applet/indicator/Bridge.qml b/containment/package/contents/ui/applet/indicator/Bridge.qml index 9e52538c..b6f4d80a 100644 --- a/containment/package/contents/ui/applet/indicator/Bridge.qml +++ b/containment/package/contents/ui/applet/indicator/Bridge.qml @@ -1,100 +1,98 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.latte 0.2 as Latte Item{ id: indicatorBridge anchors.fill: parent property bool appletIsValid: true readonly property bool active: appletIsValid && ((indicators.isEnabled && appletItem.communicatorAlias.activeIndicatorEnabled - && indicators.enabledForApplets) - || (!indicators.enabledForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive)) + && indicators.info.enabledForApplets) + || (!indicators.info.enabledForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive)) /* Indicators Properties in order use them*/ readonly property bool isTask: false readonly property bool isApplet: true readonly property bool isEmptySpace: false /*since 0.9.3*/ readonly property bool isLauncher: false readonly property bool isStartup: false readonly property bool isWindow: false readonly property bool isActive: appletIsValid ? appletItem.isActive : false readonly property bool isGroup: false readonly property bool isHovered: appletIsValid ? appletMouseArea.containsMouse : false readonly property bool isMinimized: false readonly property bool isPressed: appletIsValid ? appletMouseArea.pressed : false readonly property bool inAttention: false readonly property bool inRemoving: false readonly property bool isSquare: appletIsValid ? appletItem.isSquare : true readonly property bool hasActive: isActive readonly property bool hasMinimized: false readonly property bool hasShown: false readonly property int windowsCount: 0 readonly property int windowsMinimizedCount: 0 readonly property int currentIconSize: root.iconSize readonly property int maxIconSize: root.maxIconSize readonly property real scaleFactor: appletIsValid ? appletItem.wrapperAlias.zoomScale : 1 readonly property real panelOpacity: root.currentPanelOpacity readonly property color shadowColor: root.appShadowColorSolid readonly property bool animationsEnabled: root.animationsEnabled readonly property real durationTime: root.durationTime readonly property bool progressVisible: false /*since 0.9.2*/ readonly property real progress: 0 /*since 0.9.2*/ readonly property int screenEdgeMargin: root.localScreenEdgeMargin /*since 0.10*/ - readonly property bool usePlasmaTabsStyle: !indicators.enabledForApplets - readonly property QtObject palette: colorizerManager.applyTheme //!icon colors property color iconBackgroundColor: { if (appletIsValid) { return isSquare ? appletItem.wrapperAlias.overlayIconLoader.backgroundColor : colorizerManager.buttonFocusColor; } return "black"; } property color iconGlowColor:{ if (appletIsValid) { return isSquare ? appletItem.wrapperAlias.overlayIconLoader.glowColor : colorizerManager.focusGlowColor; } return "white"; } //! grouped options readonly property Item shared: indicators readonly property QtObject configuration: indicators.configuration readonly property QtObject resources: indicators.resources } diff --git a/containment/package/contents/ui/applet/indicator/Loader.qml b/containment/package/contents/ui/applet/indicator/Loader.qml index cb745c0d..2a727c6a 100644 --- a/containment/package/contents/ui/applet/indicator/Loader.qml +++ b/containment/package/contents/ui/applet/indicator/Loader.qml @@ -1,91 +1,91 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte Loader { id: indicatorLoader anchors.bottom: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined anchors.top: (plasmoid.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined anchors.left: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined anchors.right: (plasmoid.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined anchors.horizontalCenter: root.isHorizontal ? parent.horizontalCenter : undefined anchors.verticalCenter: root.isVertical ? parent.verticalCenter : undefined active: level.bridge && level.bridge.active && (level.isBackground || (level.isForeground && indicators.info.providesFrontLayer)) sourceComponent: { - if (!indicators.enabledForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { + if (!indicators.info.enabledForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { return indicators.plasmaStyleComponent; } return indicators.indicatorComponent; } width: { if (root.isHorizontal) { if (canBeHovered) { return appletItem.wrapperAlias.zoomScale * visualLockedWidth; } return appletWrapper.width + appletItem.internalWidthMargins; } else { return appletItem.wrapperAlias.width; } } height: { if (root.isVertical) { if (canBeHovered) { return appletItem.wrapperAlias.zoomScale * visualLockedHeight; } return appletWrapper.height + appletItem.internalHeightMargins; } else { return appletItem.wrapperAlias.height; } } readonly property bool locked: appletItem.lockZoom || root.zoomFactor === 1 property real visualLockedWidth: root.iconSize + appletItem.internalWidthMargins property real visualLockedHeight: root.iconSize + appletItem.internalHeightMargins //! Communications !// property Item level Connections { target: appletItem enabled: indicators.info.needsMouseEventCoordinates onMousePressed: { var fixedPos = indicatorLoader.mapFromItem(appletItem, x, y); level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), button); } onMouseReleased: { var fixedPos = indicatorLoader.mapFromItem(appletItem, x, y); level.mouseReleased(Math.round(fixedPos.x), Math.round(fixedPos.y), button); } } } diff --git a/containment/package/contents/ui/indicators/Manager.qml b/containment/package/contents/ui/indicators/Manager.qml index 07a08180..87b5a7c6 100644 --- a/containment/package/contents/ui/indicators/Manager.qml +++ b/containment/package/contents/ui/indicators/Manager.qml @@ -1,173 +1,191 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte import "../applet/indicator" as AppletIndicator Item{ id: managerIndicator readonly property QtObject configuration: latteView && latteView.indicator ? latteView.indicator.configuration : null readonly property QtObject resources: latteView && latteView.indicator ? latteView.indicator.resources : null readonly property bool isEnabled: latteView && latteView.indicator ? (latteView.indicator.enabled && latteView.indicator.pluginIsReady) : false - readonly property bool enabledForApplets: latteView && latteView.indicator ? latteView.indicator.enabledForApplets : true - readonly property real padding: Math.max(info.minLengthPadding, latteView && latteView.indicator ? latteView.indicator.padding : 0.08) + readonly property real padding: Math.max(info.minLengthPadding, info.lengthPadding) readonly property string type: latteView && latteView.indicator ? latteView.indicator.type : "org.kde.latte.default" readonly property bool infoLoaded: metricsLoader.active && metricsLoader.item readonly property Component plasmaStyleComponent: latteView && latteView.indicator ? latteView.indicator.plasmaComponent : null readonly property Component indicatorComponent: latteView && latteView.indicator ? latteView.indicator.component : null readonly property Item info: Item{ + readonly property bool enabledForApplets: infoLoaded && metricsLoader.item.hasOwnProperty("enabledForApplets") + && metricsLoader.item.enabledForApplets + readonly property bool needsIconColors: infoLoaded && metricsLoader.item.hasOwnProperty("needsIconColors") && metricsLoader.item.needsIconColors readonly property bool needsMouseEventCoordinates: infoLoaded && metricsLoader.item.hasOwnProperty("needsMouseEventCoordinates") && metricsLoader.item.needsMouseEventCoordinates readonly property bool providesFrontLayer: infoLoaded && metricsLoader.item.hasOwnProperty("providesFrontLayer") && metricsLoader.item.providesFrontLayer readonly property bool providesHoveredAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesHoveredAnimation") && metricsLoader.item.providesHoveredAnimation readonly property bool providesClickedAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesClickedAnimation") && metricsLoader.item.providesClickedAnimation readonly property int extraMaskThickness: { if (infoLoaded && metricsLoader.item.hasOwnProperty("extraMaskThickness")) { return metricsLoader.item.extraMaskThickness; } return 0; } readonly property real minThicknessPadding: { if (infoLoaded && metricsLoader.item.hasOwnProperty("minThicknessPadding")) { return metricsLoader.item.minThicknessPadding; } return 0; } readonly property real minLengthPadding: { if (infoLoaded && metricsLoader.item.hasOwnProperty("minLengthPadding")) { return metricsLoader.item.minLengthPadding; } return 0; } + readonly property real lengthPadding: { + if (infoLoaded && metricsLoader.item.hasOwnProperty("lengthPadding")) { + return metricsLoader.item.lengthPadding; + } + + return 0.08; + } + readonly property real appletLengthPadding: { if (infoLoaded && metricsLoader.item.hasOwnProperty("appletLengthPadding")) { return metricsLoader.item.appletLengthPadding; } return -1; } readonly property variant svgPaths: infoLoaded && metricsLoader.item.hasOwnProperty("svgImagePaths") ? metricsLoader.item.svgImagePaths : [] onSvgPathsChanged: latteView.indicator.resources.setSvgImagePaths(svgPaths); } //! Metrics and values provided from an invisible indicator Loader{ id: metricsLoader opacity: 0 active: managerIndicator.isEnabled readonly property Item level: AppletIndicator.LevelOptions { isBackground: true bridge: AppletIndicator.Bridge{ appletIsValid: false } } sourceComponent: managerIndicator.indicatorComponent } - //! Bindings in order to inform View::Indicator::Info + //! Bindings in order to inform View::Indicator + Binding{ + target: latteView && latteView.indicator ? latteView.indicator : null + property:"enabledForApplets" + when: latteView && latteView.indicator + value: managerIndicator.info.enabledForApplets + } + + //! Bindings in order to inform View::Indicator::Info Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"needsIconColors" when: latteView && latteView.indicator value: managerIndicator.info.needsIconColors } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"needsMouseEventCoordinates" when: latteView && latteView.indicator value: managerIndicator.info.needsMouseEventCoordinates } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"providesClickedAnimation" when: latteView && latteView.indicator value: managerIndicator.info.providesClickedAnimation } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"providesHoveredAnimation" when: latteView && latteView.indicator value: managerIndicator.info.providesHoveredAnimation } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"providesFrontLayer" when: latteView && latteView.indicator value: managerIndicator.info.providesFrontLayer } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"extraMaskThickness" when: latteView && latteView.indicator value: managerIndicator.info.extraMaskThickness } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"minLengthPadding" when: latteView && latteView.indicator value: managerIndicator.info.minLengthPadding } Binding{ target: latteView && latteView.indicator ? latteView.indicator.info : null property:"minThicknessPadding" when: latteView && latteView.indicator value: managerIndicator.info.minThicknessPadding } } diff --git a/containment/package/contents/ui/layouts/indicator/Bridge.qml b/containment/package/contents/ui/layouts/indicator/Bridge.qml index 06351d7e..68d426b3 100644 --- a/containment/package/contents/ui/layouts/indicator/Bridge.qml +++ b/containment/package/contents/ui/layouts/indicator/Bridge.qml @@ -1,81 +1,79 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.latte 0.2 as Latte Item{ id: indicatorBridge anchors.fill: parent readonly property bool active: true /* Indicators Properties in order use them*/ readonly property bool isTask: false readonly property bool isApplet: false readonly property bool isEmptySpace: true /*since 0.9.3*/ readonly property bool isLauncher: false readonly property bool isStartup: false readonly property bool isWindow: false readonly property bool isActive: false readonly property bool isGroup: false readonly property bool isHovered: false readonly property bool isMinimized: false readonly property bool isPressed: mainArea.pressed readonly property bool inAttention: false readonly property bool inRemoving: false readonly property bool isSquare: false readonly property bool hasActive: false readonly property bool hasMinimized: false readonly property bool hasShown: false readonly property int windowsCount: 0 readonly property int windowsMinimizedCount: 0 readonly property int currentIconSize: root.iconSize readonly property int maxIconSize: root.maxIconSize readonly property real scaleFactor: 1 readonly property real panelOpacity: root.currentPanelOpacity readonly property color shadowColor: root.appShadowColorSolid readonly property bool animationsEnabled: root.animationsEnabled readonly property real durationTime: root.durationTime readonly property bool progressVisible: false /*since 0.9.2*/ readonly property real progress: 0 /*since 0.9.2*/ readonly property int screenEdgeMargin: 0 /*since 0.10*/ - readonly property bool usePlasmaTabsStyle: !indicators.enabledForApplets - readonly property QtObject palette: colorizerManager.applyTheme //!icon colors property color iconBackgroundColor: "brown" property color iconGlowColor: "pink" //! grouped options readonly property Item shared: indicators readonly property QtObject configuration: indicators.configuration readonly property QtObject resources: indicators.resources } diff --git a/declarativeimports/components/IndicatorItem.qml b/declarativeimports/components/IndicatorItem.qml index 511bb435..14d7b663 100644 --- a/declarativeimports/components/IndicatorItem.qml +++ b/declarativeimports/components/IndicatorItem.qml @@ -1,61 +1,73 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 Item { readonly property Item level: parent && parent.hasOwnProperty("level") ? parent.level : null readonly property Item indicator: parent && parent.hasOwnProperty("level") ? parent.level.bridge : null //! indicator is using main colors from icon e.g. unity style property bool needsIconColors: false //! indicator is using the mouse events coordinates e.g. for animations property bool needsMouseEventCoordinates: false //! indicator provides also foreground layer that should be drawn on top of the Items icons property bool providesFrontLayer: false //! indicator provides its own hovering animations. Latte should not provide //! any hovering animation in that case property bool providesHoveredAnimation: false //! indicator provides its own clicked animations. Latte should not provide //! any clicked animation in that case property bool providesClickedAnimation: false + //! this indicator will draw its own indicators for applets + //! [since v0.10.0] + property bool enabledForApplets: true + //! this indicator visuals go out of the regular mask thickness and this variable sets //! the pixels needed outside of the mask thickness e.g. a glow property int extraMaskThickness: 0 //! this indicator specifies a minimum thickness padding in order to be drawn correctly. //! Values below the specified value are ignored. This value is a percentage, //! e.g 0.06 -> 6% property real minThicknessPadding: 0 //! this indicator specifies a minimum length padding in order to be drawn correctly. //! Values below the specified value are ignored. This value is a percentage, //! e.g 0.06 -> 6% property real minLengthPadding: 0 //! this indicator specifies a different padding value for applets. This value is a percentage, - //! -1, means disabled and the regular padding is used + //! -1, means disabled and the regular length padding is used //! 0.06 -> 6% //! [since v0.9.2] property real appletLengthPadding: -1 + //! this indicator specifies how much is going to be the items regular length padding + //! as long as other more specialized paddings such as appletLengthPadding are not + //! applied. This value is a percentage, + //! e.g 0.06 -> 6% + //! [since v0.10.0] + property real lengthPadding: 0.08 + + //! svg image paths either from plasma theme or local files relevant to indicator "ui" directory //! in order to reduce resources usage property var svgImagePaths: [] } diff --git a/indicators/default/package/config/config.qml b/indicators/default/package/config/config.qml index 808782c2..b12f3e0f 100644 --- a/indicators/default/package/config/config.qml +++ b/indicators/default/package/config/config.qml @@ -1,241 +1,294 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.2 as Latte import org.kde.latte.components 1.0 as LatteComponents ColumnLayout { id: root Layout.fillWidth: true LatteComponents.SubHeader { text: i18nc("active indicator style","Style For Active") } RowLayout { Layout.fillWidth: true spacing: 2 property int indicatorType: indicator.configuration.activeStyle readonly property int buttonsCount: 2 readonly property int buttonSize: (dialog.optionsWidth - (spacing * buttonsCount-1)) / buttonsCount ExclusiveGroup { id: activeIndicatorTypeGroup onCurrentChanged: { if (current.checked) { indicator.configuration.activeStyle = current.indicatorType; } } } PlasmaComponents.Button { Layout.minimumWidth: parent.buttonSize Layout.maximumWidth: Layout.minimumWidth text: i18nc("line indicator","Line") checked: parent.indicatorType === indicatorType checkable: true exclusiveGroup: activeIndicatorTypeGroup tooltip: i18n("Show a line indicator for active items") readonly property int indicatorType: 0 /*Line*/ } PlasmaComponents.Button { Layout.minimumWidth: parent.buttonSize Layout.maximumWidth: Layout.minimumWidth text: i18nc("dot indicator", "Dot") checked: parent.indicatorType === indicatorType checkable: true exclusiveGroup: activeIndicatorTypeGroup tooltip: i18n("Show a dot indicator for active items") readonly property int indicatorType: 1 /*Dot*/ } } LatteComponents.HeaderSwitch { id: glowEnabled Layout.fillWidth: true Layout.minimumHeight: implicitHeight Layout.bottomMargin: units.smallSpacing checked: indicator.configuration.glowEnabled level: 2 text: i18n("Glow") tooltip: i18n("Enable/disable indicator glow") onPressed: { indicator.configuration.glowEnabled = !indicator.configuration.glowEnabled; } } RowLayout { Layout.fillWidth: true spacing: 2 enabled: indicator.configuration.glowEnabled property int option: indicator.configuration.glowApplyTo readonly property int buttonsCount: 2 readonly property int buttonSize: (dialog.optionsWidth - (spacing * buttonsCount-1)) / buttonsCount ExclusiveGroup { id: glowGroup onCurrentChanged: { if (current.checked) indicator.configuration.glowApplyTo = current.option } } PlasmaComponents.Button { Layout.minimumWidth: parent.buttonSize Layout.maximumWidth: Layout.minimumWidth text: i18nc("glow only to active task/applet indicators","On Active") checked: parent.option === option checkable: true exclusiveGroup: glowGroup tooltip: i18n("Add glow only to active task/applet indicator") readonly property int option: 1 /*OnActive*/ } PlasmaComponents.Button { Layout.minimumWidth: parent.buttonSize Layout.maximumWidth: Layout.minimumWidth text: i18nc("glow to all task/applet indicators","All") checked: parent.option === option checkable: true exclusiveGroup: glowGroup tooltip: i18n("Add glow to all task/applet indicators") readonly property int option: 2 /*All*/ } } RowLayout { Layout.fillWidth: true spacing: 2 enabled: indicator.configuration.glowEnabled PlasmaComponents.Label { Layout.minimumWidth: implicitWidth horizontalAlignment: Text.AlignLeft Layout.rightMargin: units.smallSpacing text: i18n("Opacity") } LatteComponents.Slider { id: glowOpacitySlider Layout.fillWidth: true leftPadding: 0 value: indicator.configuration.glowOpacity * 100 from: 0 to: 100 stepSize: 5 wheelEnabled: false function updateGlowOpacity() { if (!pressed) indicator.configuration.glowOpacity = value/100; } onPressedChanged: { updateGlowOpacity(); } Component.onCompleted: { valueChanged.connect(updateGlowOpacity); } Component.onDestruction: { valueChanged.disconnect(updateGlowOpacity); } } PlasmaComponents.Label { text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(glowOpacitySlider.value) horizontalAlignment: Text.AlignRight Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 } } + LatteComponents.SubHeader { + text: i18n("Padding") + } + + RowLayout { + Layout.fillWidth: true + spacing: units.smallSpacing + + PlasmaComponents.Label { + text: i18n("Length") + horizontalAlignment: Text.AlignLeft + } + + LatteComponents.Slider { + id: lengthIntMarginSlider + Layout.fillWidth: true + + value: Math.round(indicator.configuration.lengthPadding * 100) + from: 0 + to: maxMargin + stepSize: 1 + wheelEnabled: false + + readonly property int maxMargin: 80 + + onPressedChanged: { + if (!pressed) { + indicator.configuration.lengthPadding = value / 100; + } + } + } + + PlasmaComponents.Label { + text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(currentValue) + horizontalAlignment: Text.AlignRight + Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 + Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 + + readonly property int currentValue: lengthIntMarginSlider.value + } + } + ColumnLayout { spacing: 0 visible: indicator.latteTasksArePresent LatteComponents.SubHeader { enabled: indicator.configuration.glowApplyTo!==0/*None*/ text: i18n("Tasks") } LatteComponents.CheckBoxesColumn { LatteComponents.CheckBox { Layout.maximumWidth: dialog.optionsWidth text: i18n("Different color for minimized windows") checked: indicator.configuration.minimizedTaskColoredDifferently onClicked: { indicator.configuration.minimizedTaskColoredDifferently = checked; } } LatteComponents.CheckBox { Layout.maximumWidth: dialog.optionsWidth text: i18n("Show an extra dot for grouped windows when active") checked: indicator.configuration.extraDotOnActive tooltip: i18n("Grouped windows show both a line and a dot when one of them is active and the Line Active Indicator is enabled") enabled: indicator.configuration.activeStyle === 0 /*Line*/ onClicked: { indicator.configuration.extraDotOnActive = checked; } } } } LatteComponents.SubHeader { enabled: indicator.configuration.glowApplyTo!==0/*None*/ text: i18n("Options") } + LatteComponents.CheckBox { + Layout.maximumWidth: dialog.optionsWidth + text: i18n("Show indicators for applets") + checked: indicator.configuration.enabledForApplets + tooltip: i18n("Indicators are shown for applets") + + onClicked: { + indicator.configuration.enabledForApplets = !indicator.configuration.enabledForApplets; + } + } + LatteComponents.CheckBox { Layout.maximumWidth: dialog.optionsWidth text: i18n("Reverse indicator style") checked: indicator.configuration.reversed onClicked: { indicator.configuration.reversed = !indicator.configuration.reversed; } } } diff --git a/indicators/default/package/config/main.xml b/indicators/default/package/config/main.xml index f792cf4c..13e79ad6 100644 --- a/indicators/default/package/config/main.xml +++ b/indicators/default/package/config/main.xml @@ -1,45 +1,51 @@ 0 false false false + + true + 2 true 0.35 + + 0.08 + false diff --git a/indicators/default/package/ui/main.qml b/indicators/default/package/ui/main.qml index 99dbbba3..dc5c8949 100644 --- a/indicators/default/package/ui/main.qml +++ b/indicators/default/package/ui/main.qml @@ -1,317 +1,320 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.latte 0.2 as Latte import org.kde.latte.components 1.0 as LatteComponents LatteComponents.IndicatorItem{ id: root extraMaskThickness: reversedEnabled && glowEnabled ? 1.7 * (factor * indicator.maxIconSize) : 0 + enabledForApplets: indicator && indicator.configuration ? indicator.configuration.enabledForApplets : true + lengthPadding: indicator && indicator.configuration ? indicator.configuration.lengthPadding : 0.08 + readonly property real factor: 0.08 readonly property int size: factor * indicator.currentIconSize readonly property int screenEdgeMargin: plasmoid.location === PlasmaCore.Types.Floating || reversedEnabled ? 0 : indicator.screenEdgeMargin property real textColorBrightness: colorBrightness(theme.textColor) property color isActiveColor: theme.buttonFocusColor property color minimizedColor: { if (minimizedTaskColoredDifferently) { return (textColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7)); } return isActiveColor; } property color notActiveColor: indicator.isMinimized ? minimizedColor : isActiveColor //! Common Options readonly property bool reversedEnabled: indicator.configuration.reversed //! Configuration Options readonly property bool extraDotOnActive: indicator.configuration.extraDotOnActive readonly property bool minimizedTaskColoredDifferently: indicator.configuration.minimizedTaskColoredDifferently readonly property int activeStyle: indicator.configuration.activeStyle //!glow options readonly property bool glowEnabled: indicator.configuration.glowEnabled readonly property bool glow3D: indicator.configuration.glow3D readonly property int glowApplyTo: indicator.configuration.glowApplyTo readonly property real glowOpacity: indicator.configuration.glowOpacity /*Rectangle{ anchors.fill: parent border.width: 1 border.color: "yellow" color: "transparent" opacity:0.6 }*/ function colorBrightness(color) { return colorBrightnessFromRGB(color.r * 255, color.g * 255, color.b * 255); } // formula for brightness according to: // https://www.w3.org/TR/AERT/#color-contrast function colorBrightnessFromRGB(r, g, b) { return (r * 299 + g * 587 + b * 114) / 1000 } Item{ id: mainIndicatorElement width: flowItem.width height: flowItem.height Flow{ id: flowItem flow: plasmoid.formFactor === PlasmaCore.Types.Vertical ? Flow.TopToBottom : Flow.LeftToRight LatteComponents.GlowPoint{ id:firstPoint opacity: { if (indicator.isEmptySpace) { return 0; } if (indicator.isTask) { return indicator.isLauncher || (indicator.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 } if (indicator.isApplet) { return (indicator.isActive || activeAndReverseAnimation.running) ? 1 : 0 } } basicColor: indicator.isActive || (indicator.isGroup && indicator.hasShown) ? root.isActiveColor : root.notActiveColor size: root.size glow3D: glow3D animation: Math.max(1.65*3*units.longDuration,indicator.durationTime*3*units.longDuration) location: plasmoid.location glowOpacity: root.glowOpacity contrastColor: indicator.shadowColor attentionColor: theme.negativeTextColor roundCorners: true showAttention: indicator.inAttention showGlow: { if (glowEnabled && (glowApplyTo === 2 /*All*/ || showAttention )) return true; else if (glowEnabled && glowApplyTo === 1 /*OnActive*/ && indicator.hasActive) return true; else return false; } showBorder: glowEnabled && glow3D property int stateWidth: indicator.isGroup ? root.width - secondPoint.width : root.width - spacer.width property int stateHeight: indicator.isGroup ? root.height - secondPoint.height : root.height - spacer.height property int animationTime: indicator.durationTime* (0.7*units.longDuration) property bool isActive: indicator.hasActive || indicator.isActive property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical property real scaleFactor: indicator.scaleFactor function updateInitialSizes(){ if(root){ if(vertical) width = root.size; else height = root.size; if(vertical && isActive && activeStyle === 0 /*Line*/) height = stateHeight; else height = root.size; if(!vertical && isActive && activeStyle === 0 /*Line*/) width = stateWidth; else width = root.size; } } onIsActiveChanged: { if (activeStyle === 0 /*Line*/) activeAndReverseAnimation.start(); } onScaleFactorChanged: { if(!activeAndReverseAnimation.running && !vertical && isActive && activeStyle === 0 /*Line*/){ width = stateWidth; } else if (!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/){ height = stateHeight; } } onStateWidthChanged:{ if(!activeAndReverseAnimation.running && !vertical && isActive && activeStyle === 0 /*Line*/) width = stateWidth; } onStateHeightChanged:{ if(!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/) height = stateHeight; } onVerticalChanged: updateInitialSizes(); Component.onCompleted: { updateInitialSizes(); if (indicator) { indicator.onCurrentIconSizeChanged.connect(updateInitialSizes); } } Component.onDestruction: { if (indicator) { indicator.onCurrentIconSizeChanged.disconnect(updateInitialSizes); } } NumberAnimation{ id: activeAndReverseAnimation target: firstPoint property: plasmoid.formFactor === PlasmaCore.Types.Vertical ? "height" : "width" to: indicator.hasActive && activeStyle === 0 /*Line*/ ? (plasmoid.formFactor === PlasmaCore.Types.Vertical ? firstPoint.stateHeight : firstPoint.stateWidth) : root.size duration: firstPoint.animationTime easing.type: Easing.InQuad onStopped: firstPoint.updateInitialSizes() } } Item{ id:spacer width: secondPoint.visible ? 0.5*root.size : 0 height: secondPoint.visible ? 0.5*root.size : 0 } LatteComponents.GlowPoint{ id:secondPoint width: visible ? root.size : 0 height: width size: root.size glow3D: glow3D animation: Math.max(1.65*3*units.longDuration,indicator.durationTime*3*units.longDuration) location: plasmoid.location glowOpacity: root.glowOpacity contrastColor: indicator.shadowColor showBorder: glowEnabled && glow3D basicColor: state2Color roundCorners: true showGlow: glowEnabled && glowApplyTo === 2 /*All*/ visible: ( indicator.isGroup && ((extraDotOnActive && activeStyle === 0) /*Line*/ || activeStyle === 1 /*Dot*/ || !indicator.hasActive) ) ? true: false //when there is no active window property color state1Color: indicator.hasShown ? root.isActiveColor : root.minimizedColor //when there is active window property color state2Color: indicator.hasMinimized ? root.minimizedColor : root.isActiveColor } } states: [ State { name: "left" when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !reversedEnabled) || (plasmoid.location === PlasmaCore.Types.RightEdge && reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:parent.left; right:undefined;} } PropertyChanges{ target: mainIndicatorElement anchors.leftMargin: root.screenEdgeMargin; anchors.rightMargin: 0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "bottom" when: (plasmoid.location === PlasmaCore.Types.Floating || (plasmoid.location === PlasmaCore.Types.BottomEdge && !reversedEnabled) || (plasmoid.location === PlasmaCore.Types.TopEdge && reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } PropertyChanges{ target: mainIndicatorElement anchors.leftMargin: 0; anchors.rightMargin: 0; anchors.topMargin:0; anchors.bottomMargin: root.screenEdgeMargin; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "top" when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !reversedEnabled) || (plasmoid.location === PlasmaCore.Types.BottomEdge && reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:parent.top; bottom:undefined; left:undefined; right:undefined;} } PropertyChanges{ target: mainIndicatorElement anchors.leftMargin: 0; anchors.rightMargin: 0; anchors.topMargin: root.screenEdgeMargin; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "right" when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !reversedEnabled) || (plasmoid.location === PlasmaCore.Types.LeftEdge && reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:undefined; right:parent.right;} } PropertyChanges{ target: mainIndicatorElement anchors.leftMargin: 0; anchors.rightMargin: root.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } } ] } }// number of windows indicator diff --git a/indicators/org.kde.latte.plasma/package/config/config.qml b/indicators/org.kde.latte.plasma/package/config/config.qml index a43fad45..ef0af8eb 100644 --- a/indicators/org.kde.latte.plasma/package/config/config.qml +++ b/indicators/org.kde.latte.plasma/package/config/config.qml @@ -1,57 +1,115 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.latte 0.2 as Latte import org.kde.latte.components 1.0 as LatteComponents ColumnLayout { id: root Layout.fillWidth: true + LatteComponents.SubHeader { + text: i18n("Padding") + } + + RowLayout { + Layout.fillWidth: true + spacing: units.smallSpacing + + PlasmaComponents.Label { + text: i18n("Length") + horizontalAlignment: Text.AlignLeft + } + + LatteComponents.Slider { + id: lengthIntMarginSlider + Layout.fillWidth: true + + value: Math.round(indicator.configuration.lengthPadding * 100) + from: 0 + to: maxMargin + stepSize: 1 + wheelEnabled: false + + readonly property int maxMargin: 80 + + onPressedChanged: { + if (!pressed) { + indicator.configuration.lengthPadding = value / 100; + } + } + } + + PlasmaComponents.Label { + text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(currentValue) + horizontalAlignment: Text.AlignRight + Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 + Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 + + readonly property int currentValue: lengthIntMarginSlider.value + } + } + + LatteComponents.SubHeader { + text: i18n("Options") + } + LatteComponents.CheckBoxesColumn { Layout.topMargin: 1.5 * units.smallSpacing LatteComponents.CheckBox { Layout.maximumWidth: dialog.optionsWidth text: i18n("Reverse indicator style") checked: indicator.configuration.reversed onClicked: { indicator.configuration.reversed = !indicator.configuration.reversed; } } LatteComponents.CheckBox { Layout.maximumWidth: dialog.optionsWidth text: i18n("Growing circle animation when clicked") checked: indicator.configuration.clickedAnimationEnabled onClicked: { indicator.configuration.clickedAnimationEnabled = !indicator.configuration.clickedAnimationEnabled; } } + + LatteComponents.CheckBox { + Layout.maximumWidth: dialog.optionsWidth + text: i18n("Show indicators for applets") + checked: indicator.configuration.enabledForApplets + tooltip: i18n("Indicators are shown for applets") + + onClicked: { + indicator.configuration.enabledForApplets = !indicator.configuration.enabledForApplets; + } + } } } diff --git a/indicators/org.kde.latte.plasma/package/config/main.xml b/indicators/org.kde.latte.plasma/package/config/main.xml index 8b88f024..22eb5c57 100644 --- a/indicators/org.kde.latte.plasma/package/config/main.xml +++ b/indicators/org.kde.latte.plasma/package/config/main.xml @@ -1,16 +1,22 @@ false false - + + + true + + + 0.08 + diff --git a/indicators/org.kde.latte.plasma/package/ui/BackLayer.qml b/indicators/org.kde.latte.plasma/package/ui/BackLayer.qml index e9596480..462ad1a0 100644 --- a/indicators/org.kde.latte.plasma/package/ui/BackLayer.qml +++ b/indicators/org.kde.latte.plasma/package/ui/BackLayer.qml @@ -1,110 +1,110 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte PlasmaCore.FrameSvgItem { id: frame property string basePrefix: "normal" - imagePath: indicator.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" + imagePath: root.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" rotation: root.reversedEnabled ? 180 : 0 opacity: 1 //state === "hovered" ? 0.9 : 1 prefix: { - if (indicator.usePlasmaTabsStyle) { + if (root.usePlasmaTabsStyle) { if (!indicator.isActive) { return ""; } if (plasmoid.location === PlasmaCore.Types.LeftEdge) { return "west-active-tab"; } if (plasmoid.location === PlasmaCore.Types.TopEdge) { return "north-active-tab"; } if (plasmoid.location === PlasmaCore.Types.RightEdge) { return "east-active-tab"; } if (plasmoid.location === PlasmaCore.Types.BottomEdge) { return "south-active-tab"; } return "south-active-tab"; } else { return root.taskPrefix(basePrefix); } } states: [ State { name: "launcher" when: indicator.isLauncher || (indicator.isApplet && !indicator.isActive) PropertyChanges { target: frame basePrefix: "" } }, State { name: "hovered" when: indicator.isHovered && frame.hasElementPrefix("hover") PropertyChanges { target: frame basePrefix: "hover" } }, State { name: "attention" when: indicator.inAttention PropertyChanges { target: frame basePrefix: "attention" } }, State { name: "minimized" when: indicator.isMinimized PropertyChanges { target: frame basePrefix: "minimized" } }, State { name: "active" when: indicator.isActive PropertyChanges { target: frame basePrefix: "focus" } } ] } diff --git a/indicators/org.kde.latte.plasma/package/ui/main.qml b/indicators/org.kde.latte.plasma/package/ui/main.qml index c43e9bb2..af46f1ad 100644 --- a/indicators/org.kde.latte.plasma/package/ui/main.qml +++ b/indicators/org.kde.latte.plasma/package/ui/main.qml @@ -1,121 +1,129 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte import org.kde.latte.components 1.0 as LatteComponents LatteComponents.IndicatorItem { id: root needsMouseEventCoordinates: true providesClickedAnimation: clickedAnimationEnabled //providesHoveredAnimation: true providesFrontLayer: true svgImagePaths: ["widgets/tasks"] + enabledForApplets: configurationIsReady && indicator.configuration.clickedAnimationEnabled !== undefined ? + indicator.configuration.enabledForApplets : true + lengthPadding: configurationIsReady && indicator.configuration.clickedAnimationEnabled !== undefined ? + indicator.configuration.lengthPadding : 0.08 + //! config options - readonly property bool clickedAnimationEnabled: indicator && indicator.configuration + readonly property bool clickedAnimationEnabled: configurationIsReady && indicator.configuration.clickedAnimationEnabled !== undefined && indicator.configuration.clickedAnimationEnabled - readonly property bool reversedEnabled: indicator && indicator.configuration + readonly property bool reversedEnabled: configurationIsReady && indicator.configuration.reversed !== undefined && indicator.configuration.reversed + readonly property bool usePlasmaTabsStyle: false + readonly property bool configurationIsReady: indicator && indicator.configuration + //! Background Layer Loader{ id: backLayer anchors.fill: parent anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? indicator.screenEdgeMargin : 0 anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? indicator.screenEdgeMargin : 0 anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? indicator.screenEdgeMargin : 0 anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? indicator.screenEdgeMargin : 0 active: level.isBackground && !indicator.isEmptySpace sourceComponent: BackLayer{} } /* progress overlay for BackLayer*/ /* it is not added in the BackLayer because the BackLayer is rotated in some cases*/ Loader { anchors.fill: backLayer asynchronous: true active: level.isBackground && indicator.progressVisible sourceComponent: Item { id: background Item { anchors { top: parent.top left: parent.left bottom: parent.bottom } width: parent.width * (Math.min(indicator.progress, 100) / 100) clip: true PlasmaCore.FrameSvgItem { id: progressFrame width: background.width height: background.height imagePath: "widgets/tasks" prefix: root.taskPrefix("progress").concat(root.taskPrefix("hover")) } } } } //! Foreground Layer to draw arrows Loader{ id: frontLayer anchors.fill: parent active: (level.isForeground && !indicator.isApplet && indicator.isGroup) || providesClickedAnimation sourceComponent: FrontLayer{} } function taskPrefix(prefix) { var effectivePrefix; if (plasmoid.location === PlasmaCore.Types.LeftEdge) { effectivePrefix = "west-" + prefix; } if (plasmoid.location === PlasmaCore.Types.TopEdge) { effectivePrefix = "north-" + prefix; } if (plasmoid.location === PlasmaCore.Types.RightEdge) { effectivePrefix = "east-" + prefix; } if (plasmoid.location === PlasmaCore.Types.BottomEdge) { effectivePrefix = "south-" + prefix; } return [effectivePrefix, prefix]; } } diff --git a/plasmoid/package/contents/ui/indicators/Manager.qml b/plasmoid/package/contents/ui/indicators/Manager.qml index 1362ce2b..91bca174 100644 --- a/plasmoid/package/contents/ui/indicators/Manager.qml +++ b/plasmoid/package/contents/ui/indicators/Manager.qml @@ -1,64 +1,65 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte import "options" as IndicatorOptions import "styles" as IndicatorStyles import "../task/indicator" as TaskIndicator Item{ id: managerIndicator readonly property Item configuration: explicitOptions readonly property QtObject resources: null readonly property bool isEnabled: true readonly property string type: "org.kde.latte.default" readonly property Component indicatorComponent: latteStyleIndicator readonly property Item info: Item{ readonly property bool needsIconColors: false readonly property bool needsMouseEventCoordinates: false readonly property bool providesFrontLayer: false readonly property bool providesHoveredAnimation: false readonly property bool providesClickedAnimation: false readonly property int extraMaskThickness: 0 + readonly property real lengthPadding: 0.08 readonly property real minThicknessPadding: 0 readonly property real minLengthPadding:0 } IndicatorOptions.Latte { id : explicitOptions } //! Indicators Components Component { id: latteStyleIndicator IndicatorStyles.LatteIndicator{} } } diff --git a/plasmoid/package/contents/ui/task/indicator/Bridge.qml b/plasmoid/package/contents/ui/task/indicator/Bridge.qml index 9507a89a..2c8b0cc3 100644 --- a/plasmoid/package/contents/ui/task/indicator/Bridge.qml +++ b/plasmoid/package/contents/ui/task/indicator/Bridge.qml @@ -1,94 +1,92 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte import "../../indicators/options" as TaskIndicator Item { id: indicatorBridge property bool taskIsValid: true readonly property bool active: indicators ? indicators.isEnabled : false readonly property bool locked: taskIsValid ? (inAttentionAnimation || inNewWindowAnimation) : false /* Indicators Properties in order for indicators to use them*/ readonly property bool isTask: true readonly property bool isApplet: false readonly property bool isEmptySpace: false /*since 0.9.3*/ readonly property bool isLauncher: taskIsValid ? taskItem.isLauncher : true readonly property bool isStartup: taskIsValid ? taskItem.isStartup : false readonly property bool isWindow: taskIsValid ? taskItem.isWindow : false readonly property bool isActive: taskIsValid ? (taskItem.hasActive || (root.showPreviews && (taskItem.isWindow || taskItem.isGroupParent) && windowsPreviewDlg.activeItem && (windowsPreviewDlg.activeItem === taskItem)) ) : false readonly property bool isGroup: taskIsValid ? taskItem.isGroupParent : false readonly property bool isHovered: taskIsValid ? taskItem.containsMouse : false readonly property bool isMinimized: taskIsValid ? taskItem.isMinimized : false readonly property bool isPressed: taskIsValid ? taskItem.pressed : false readonly property bool inAttention: taskIsValid ? taskItem.inAttention : false readonly property bool inRemoving: taskIsValid ? taskItem.inRemoveStage : false readonly property bool isSquare: true readonly property bool hasActive: taskIsValid ? taskItem.hasActive : false readonly property bool hasMinimized: taskIsValid? taskItem.hasMinimized : false readonly property bool hasShown: taskIsValid ? taskItem.hasShown : false readonly property int windowsCount: taskIsValid ? taskItem.windowsCount : 0 readonly property int windowsMinimizedCount: taskIsValid ? taskItem.windowsMinimizedCount : 0 readonly property int currentIconSize: root.iconSize readonly property int maxIconSize: root.maxIconSize readonly property real scaleFactor: taskIsValid ? taskItem.wrapperAlias.mScale : 1 readonly property real panelOpacity: root.currentPanelOpacity readonly property color shadowColor: root.appShadowColorSolid readonly property bool animationsEnabled: root.animationsEnabled readonly property real durationTime: root.durationTime readonly property bool progressVisible: wrapper.progressVisible /*since 0.9.2*/ readonly property real progress: wrapper.progress /*since 0.9.2*/ readonly property int screenEdgeMargin: root.screenEdgeMargin /*since 0.10*/ - readonly property bool usePlasmaTabsStyle: false - readonly property variant svgs: indicators ? indicators.svgs : [] readonly property QtObject palette: enforceLattePalette ? latteBridge.palette.applyTheme : theme //!icon colors property color iconBackgroundColor: taskIsValid ? taskItem.wrapperAlias.backgroundColor : "black" property color iconGlowColor: taskIsValid ? taskItem.wrapperAlias.glowColor : "white" //! grouped options readonly property Item shared: indicators ? indicators : emptyOptions readonly property QtObject configuration: indicators ? indicators.configuration : null readonly property QtObject resources: indicators ? indicators.resources : null Item{id: emptyOptions} } diff --git a/shell/package/contents/configuration/pages/EffectsConfig.qml b/shell/package/contents/configuration/pages/EffectsConfig.qml index 4fee1b7d..993bfa2c 100644 --- a/shell/package/contents/configuration/pages/EffectsConfig.qml +++ b/shell/package/contents/configuration/pages/EffectsConfig.qml @@ -1,572 +1,498 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import QtQuick.Dialogs 1.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.2 as Latte import org.kde.latte.components 1.0 as LatteComponents import "../../controls" as LatteExtraControls PlasmaComponents.Page { Layout.maximumWidth: content.width + content.Layout.leftMargin * 2 Layout.maximumHeight: content.height + units.smallSpacing * 2 ColumnLayout { id: content width: (dialog.appliedWidth - units.smallSpacing * 2) - Layout.leftMargin * 2 spacing: dialog.subGroupSpacing anchors.horizontalCenter: parent.horizontalCenter Layout.leftMargin: units.smallSpacing * 2 //! BEGIN: Shadows ColumnLayout { Layout.fillWidth: true Layout.topMargin: units.smallSpacing spacing: units.smallSpacing LatteComponents.HeaderSwitch { id: showAppletShadow Layout.fillWidth: true Layout.minimumHeight: implicitHeight Layout.topMargin: units.smallSpacing checked: plasmoid.configuration.shadows !== Latte.Types.NoneShadow text: i18n("Shadows") tooltip: i18n("Enable/disable applet shadows") onPressed: { if(plasmoid.configuration.shadows !== Latte.Types.AllAppletsShadow){ plasmoid.configuration.shadows = Latte.Types.AllAppletsShadow; } else { plasmoid.configuration.shadows = Latte.Types.NoneShadow; } } } ColumnLayout { Layout.leftMargin: units.smallSpacing * 2 Layout.rightMargin: units.smallSpacing * 2 spacing: 0 RowLayout{ enabled: showAppletShadow.checked PlasmaComponents.Label { enabled: showAppletShadow.checked text: i18n("Size") horizontalAlignment: Text.AlignLeft } LatteComponents.Slider { id: shadowSizeSlider Layout.fillWidth: true enabled: showAppletShadow.checked value: plasmoid.configuration.shadowSize from: 0 to: 100 stepSize: 5 wheelEnabled: false function updateShadowSize() { if (!pressed) plasmoid.configuration.shadowSize = value; } onPressedChanged: { updateShadowSize(); } Component.onCompleted: { valueChanged.connect(updateShadowSize); } Component.onDestruction: { valueChanged.disconnect(updateShadowSize); } } PlasmaComponents.Label { enabled: showAppletShadow.checked text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(shadowSizeSlider.value) horizontalAlignment: Text.AlignRight Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 } } RowLayout{ enabled: showAppletShadow.checked PlasmaComponents.Label { enabled: showAppletShadow.checked text: i18n("Opacity") horizontalAlignment: Text.AlignLeft } LatteComponents.Slider { id: shadowOpacitySlider Layout.fillWidth: true value: plasmoid.configuration.shadowOpacity from: 0 to: 100 stepSize: 5 wheelEnabled: false function updateShadowOpacity() { if (!pressed) plasmoid.configuration.shadowOpacity = value; } onPressedChanged: { updateShadowOpacity(); } Component.onCompleted: { valueChanged.connect(updateShadowOpacity); } Component.onDestruction: { valueChanged.disconnect(updateShadowOpacity); } } PlasmaComponents.Label { enabled: showAppletShadow.checked text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(shadowOpacitySlider.value) horizontalAlignment: Text.AlignRight Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 } } LatteComponents.SubHeader { isFirstSubCategory: true text: i18n("Color") } RowLayout { id: shadowColorRow Layout.fillWidth: true spacing: 2 enabled: showAppletShadow.checked readonly property string defaultShadow: "080808" readonly property string themeShadow: { var strC = String(theme.textColor); return strC.indexOf("#") === 0 ? strC.substr(1) : strC; } ExclusiveGroup { id: shadowColorGroup property bool inStartup: true onCurrentChanged: { if (inStartup) { return; } if (current === defaultShadowBtn) { plasmoid.configuration.shadowColorType = Latte.Types.DefaultColorShadow; } else if (current === themeShadowBtn) { plasmoid.configuration.shadowColorType = Latte.Types.ThemeColorShadow; } else if (current === userShadowBtn) { plasmoid.configuration.shadowColorType = Latte.Types.UserColorShadow; } } Component.onCompleted: inStartup = false; } PlasmaComponents.Button { id: defaultShadowBtn Layout.fillWidth: true text: i18nc("default shadow", "Default") checked: plasmoid.configuration.shadowColorType === Latte.Types.DefaultColorShadow checkable: true exclusiveGroup: shadowColorGroup tooltip: i18n("Default shadow for applets") } PlasmaComponents.Button { id: themeShadowBtn Layout.fillWidth: true text: i18nc("theme shadow", "Theme") checked: plasmoid.configuration.shadowColorType === Latte.Types.ThemeColorShadow checkable: true exclusiveGroup: shadowColorGroup tooltip: i18n("Shadow from theme color palette") } //overlayed button PlasmaComponents.Button { id: userShadowBtn Layout.fillWidth: true height: parent.height text: " " checkable: true checked: plasmoid.configuration.shadowColorType === Latte.Types.UserColorShadow tooltip: i18n("Use set shadow color") exclusiveGroup: shadowColorGroup Rectangle{ anchors.fill: parent anchors.margins: 1.5*units.smallSpacing color: "#" + plasmoid.configuration.shadowColor; opacity: shadowColorRow.enabled ? 1 : 0.6 Rectangle{ anchors.fill: parent color: "transparent" border.width: 1 border.color: theme.textColor opacity: parent.opacity - 0.4 } MouseArea{ anchors.fill: parent onClicked: { shadowColorGroup.current = userShadowBtn; viewConfig.setSticker(true); colorDialogLoader.showDialog = true; } } } Loader{ id:colorDialogLoader property bool showDialog: false active: showDialog sourceComponent: ColorDialog { title: i18n("Please choose shadow color") showAlphaChannel: false onAccepted: { //console.log("You chose: " + String(color)); var strC = String(color); if (strC.indexOf("#") === 0) { plasmoid.configuration.shadowColor = strC.substr(1); } colorDialogLoader.showDialog = false; viewConfig.setSticker(false); } onRejected: { colorDialogLoader.showDialog = false; viewConfig.setSticker(false); } Component.onCompleted: { color = String("#" + plasmoid.configuration.shadowColor); visible = true; } } } } } } } //! END: Shadows //! BEGIN: Animations ColumnLayout { Layout.fillWidth: true Layout.topMargin: units.smallSpacing spacing: units.smallSpacing LatteComponents.HeaderSwitch { id: animationsHeader Layout.fillWidth: true Layout.minimumHeight: implicitHeight Layout.topMargin: units.smallSpacing checked: plasmoid.configuration.animationsEnabled text: i18n("Animations") tooltip: i18n("Enable/disable all animations") onPressed: { plasmoid.configuration.animationsEnabled = !plasmoid.configuration.animationsEnabled; } } ColumnLayout { Layout.leftMargin: units.smallSpacing * 2 Layout.rightMargin: units.smallSpacing * 2 spacing: 0 enabled: plasmoid.configuration.animationsEnabled LatteComponents.SubHeader { isFirstSubCategory: true text: i18n("Speed") } ColumnLayout { Layout.fillWidth: true spacing: 0 RowLayout { Layout.fillWidth: true spacing: 2 property int duration: plasmoid.configuration.durationTime ExclusiveGroup { id: animationsGroup onCurrentChanged: { if (current.checked) plasmoid.configuration.durationTime = current.duration } } PlasmaComponents.Button { Layout.fillWidth: true text: i18n("x1") checked: parent.duration === duration checkable: true exclusiveGroup: animationsGroup readonly property int duration: 3 } PlasmaComponents.Button { Layout.fillWidth: true text: i18n("x2") checked: parent.duration === duration checkable: true exclusiveGroup: animationsGroup readonly property int duration: 2 } PlasmaComponents.Button { Layout.fillWidth: true text: i18n("x3") checked: parent.duration === duration checkable: true exclusiveGroup: animationsGroup readonly property int duration: 1 } } } } } //! END: Animations //! BEGIN: Active Indicator General Settings ColumnLayout{ spacing: units.smallSpacing LatteComponents.HeaderSwitch { id: indicatorsSwitch Layout.fillWidth: true Layout.minimumHeight: implicitHeight checked: latteView.indicator.enabled text: i18n("Indicators") tooltip: i18n("Enable/disable indicators") onPressed: { latteView.indicator.enabled = !latteView.indicator.enabled; } } ColumnLayout { Layout.leftMargin: units.smallSpacing * 2 Layout.rightMargin: units.smallSpacing * 2 spacing: units.smallSpacing enabled: indicatorsSwitch.checked LatteComponents.SubHeader { text: i18n("Style") } RowLayout { Layout.fillWidth: true spacing: 2 property string type: latteView.indicator.type ExclusiveGroup { id: indicatorStyleGroup onCurrentChanged: { if (current.checked) { if (current === customIndicator.button) { latteView.indicator.type = customIndicator.type } else { latteView.indicator.type = current.type } } } } PlasmaComponents.Button { id: latteBtn Layout.fillWidth: true text: i18nc("latte indicator style", "Latte") checked: parent.type === type checkable: true exclusiveGroup: indicatorStyleGroup tooltip: i18n("Use Latte style for your indicators") readonly property string type: "org.kde.latte.default" } PlasmaComponents.Button { Layout.fillWidth: true text: i18nc("plasma indicator style", "Plasma") checked: parent.type === type checkable: true exclusiveGroup: indicatorStyleGroup tooltip: i18n("Use Plasma style for your indicators") readonly property string type: "org.kde.latte.plasma" } LatteExtraControls.CustomIndicatorButton { id: customIndicator Layout.fillWidth: true implicitWidth: latteBtn.implicitWidth implicitHeight: latteBtn.implicitHeight checked: checkable ? parent.type === type : false buttonExclusiveGroup: indicatorStyleGroup comboBoxMinimumPopUpWidth: 1.5 * customIndicator.width } } - LatteComponents.SubHeader { - Layout.topMargin: units.smallSpacing - isFirstSubCategory: true - text: i18n("Paddings") - } - - RowLayout { + //! BEGIN: Indicator specific sub-options + ColumnLayout { + id: indicatorSpecificOptions Layout.fillWidth: true - spacing: units.smallSpacing - - PlasmaComponents.Label { - text: i18n("Length") - horizontalAlignment: Text.AlignLeft - } - - LatteComponents.Slider { - id: lengthIntMarginSlider - Layout.fillWidth: true - - value: Math.round(latteView.indicator.padding * 100) - from: 0 - to: maxMargin - stepSize: 1 - wheelEnabled: false - minimumInternalValue: latteView.indicator.info.minLengthPadding * 100 + Layout.topMargin: units.smallSpacing * 2 + spacing: 0 + visible: latteView.indicator.providesConfigUi + enabled: latteView.indicator.enabled - readonly property int maxMargin: 80 + readonly property int optionsWidth: dialog.optionsWidth - onPressedChanged: { - if (!pressed) { - latteView.indicator.padding = value / 100; - } - } + Component.onCompleted: { + latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions); } - PlasmaComponents.Label { - text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(currentValue) - horizontalAlignment: Text.AlignRight - Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4 - Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4 - - readonly property int currentValue: Math.max(lengthIntMarginSlider.minimumInternalValue, lengthIntMarginSlider.value) + Connections { + target: latteView.indicator + onPluginChanged: latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions); } } - - LatteComponents.SubHeader { - Layout.topMargin: units.smallSpacing - isFirstSubCategory: true - text: i18n("Options") - } - - LatteComponents.CheckBoxesColumn { - LatteComponents.CheckBox { - Layout.maximumWidth: dialog.optionsWidth - text: i18n("Show indicators for applets") - checked: latteView.indicator.enabledForApplets - tooltip: i18n("Indicators are shown for applets") - - onClicked: { - latteView.indicator.enabledForApplets = !latteView.indicator.enabledForApplets; - } - } - } - } - } - //! END: Active Indicator General Settings - - //! BEGIN: Indicator specific sub-options - ColumnLayout { - Layout.fillWidth: true - Layout.topMargin: units.smallSpacing - spacing: units.smallSpacing - visible: latteView.indicator.providesConfigUi - enabled: latteView.indicator.enabled - - LatteComponents.Header { - text: i18n("%0 Indicator Options").arg(indicatorStyleGroup.current === customIndicator.button ? customIndicator.buttonText : indicatorStyleGroup.current.text) - } - - ColumnLayout { - id: indicatorSpecificOptions - Layout.fillWidth: true - Layout.leftMargin: units.smallSpacing * 2 - Layout.rightMargin: units.smallSpacing * 2 - spacing: 0 - readonly property int optionsWidth: dialog.optionsWidth - - Component.onCompleted: { - latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions); - } - - Connections { - target: latteView.indicator - onPluginChanged: latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions); - } + //! END: Indicator specific sub-options } } - //! END: Indicator specific sub-options + //! END: Active Indicator General Settings } }