improve vastly user interaction with indicators uis

work/spdx
Michail Vourlakos 4 years ago
parent 810fd7e3cd
commit c777fca05a

@ -147,12 +147,32 @@ void Factory::reload(const QString &indicatorPath)
&& (metadata.pluginId() != "org.kde.latte.plasma") && (metadata.pluginId() != "org.kde.latte.plasma")
&& (metadata.pluginId() != "org.kde.latte.plasmatabstyle")) { && (metadata.pluginId() != "org.kde.latte.plasmatabstyle")) {
//! find correct alphabetical position
int newPos = -1;
if (!m_customPluginIds.contains(metadata.pluginId())) {
for (int i=0; i<m_customPluginNames.count(); ++i) {
if (QString::compare(metadata.name(), m_customPluginNames[i], Qt::CaseInsensitive)<=0) {
newPos = i;
break;
}
}
}
if (!m_customPluginIds.contains(metadata.pluginId())) { if (!m_customPluginIds.contains(metadata.pluginId())) {
m_customPluginIds << metadata.pluginId(); if (newPos == -1) {
m_customPluginIds << metadata.pluginId();
} else {
m_customPluginIds.insert(newPos, metadata.pluginId());
}
} }
if (!m_customPluginNames.contains(metadata.name())) { if (!m_customPluginNames.contains(metadata.name())) {
m_customPluginNames << metadata.name(); if (newPos == -1) {
m_customPluginNames << metadata.name();
} else {
m_customPluginNames.insert(newPos, metadata.name());
}
} }
} }

@ -151,6 +151,21 @@ void Indicator::setPluginIsReady(bool ready)
emit pluginIsReadyChanged(); emit pluginIsReadyChanged();
} }
int Indicator::index(const QString &type)
{
if (type == "org.kde.latte.default") {
return 0;
} else if (type == "org.kde.latte.plasma") {
return 1;
} else if (type == "org.kde.latte.plasmatabstyle") {
return 2;
} else if (customPluginIds().contains(type)){
return 3 + customPluginIds().indexOf(type);
}
return -1;
}
QString Indicator::type() const QString Indicator::type() const
{ {
return m_type; return m_type;

@ -101,6 +101,8 @@ public:
bool pluginIsReady(); bool pluginIsReady();
int index(const QString &type);
QString type() const; QString type() const;
void setType(QString type); void setType(QString type);

@ -22,6 +22,7 @@
// local // local
#include "primaryconfigview.h" #include "primaryconfigview.h"
#include "../view.h" #include "../view.h"
#include "../indicator/indicator.h"
#include "../../lattecorona.h" #include "../../lattecorona.h"
#include "../../indicator/factory.h" #include "../../indicator/factory.h"
@ -70,7 +71,6 @@ int IndicatorUiManager::index(const QString &type)
return -1; return -1;
} }
void IndicatorUiManager::setParentItem(QQuickItem *parentItem) void IndicatorUiManager::setParentItem(QQuickItem *parentItem)
{ {
m_parentItem = parentItem; m_parentItem = parentItem;
@ -89,13 +89,32 @@ void IndicatorUiManager::hideAllUi()
} }
} }
void IndicatorUiManager::showNextIndicator()
{
if (!m_parentItem) {
return;
}
if (auto *metaObject = m_parentItem->metaObject()) {
int methodIndex = metaObject->indexOfMethod("showNextIndicator()");
if (methodIndex == -1) {
qDebug() << "indicator parent page function showNextIndicator() was not found...";
return;
}
QMetaMethod method = metaObject->method(methodIndex);
method.invoke(m_parentItem);
}
}
void IndicatorUiManager::ui(const QString &type, Latte::View *view) void IndicatorUiManager::ui(const QString &type, Latte::View *view)
{ {
if (!m_parentItem) { if (!m_parentItem) {
return; return;
} }
hideAllUi(); // hideAllUi();
int typeIndex = index(type); int typeIndex = index(type);
@ -106,7 +125,9 @@ void IndicatorUiManager::ui(const QString &type, Latte::View *view)
//! config ui has already been created and can be provided again //! config ui has already been created and can be provided again
QQuickItem *qmlItem = qobject_cast<QQuickItem*>(m_uidata[typeIndex].ui->rootObject()); QQuickItem *qmlItem = qobject_cast<QQuickItem*>(m_uidata[typeIndex].ui->rootObject());
if (qmlItem) { if (qmlItem) {
qmlItem->setVisible(true); qmlItem->setParentItem(m_parentItem);
showNextIndicator();
//qmlItem->setVisible(true);
} }
return; return;
} }
@ -133,12 +154,29 @@ void IndicatorUiManager::ui(const QString &type, Latte::View *view)
uidata.ui->rootContext()->setContextProperty(QStringLiteral("indicator"), view->indicator()); uidata.ui->rootContext()->setContextProperty(QStringLiteral("indicator"), view->indicator());
uidata.ui->completeInitialization(); uidata.ui->completeInitialization();
int newTypeIndex = view->indicator()->index(type);
int newPos = -1;
for (int i=0; i<m_uidata.count(); ++i) {
int oldTypeIndex = view->indicator()->index(m_uidata[i].type);
if (oldTypeIndex > newTypeIndex) {
newPos = i;
break;
}
}
if (newPos == -1) {
m_uidata << uidata;
} else {
m_uidata.insert(newPos, uidata);
}
QQuickItem *qmlItem = qobject_cast<QQuickItem*>(uidata.ui->rootObject()); QQuickItem *qmlItem = qobject_cast<QQuickItem*>(uidata.ui->rootObject());
if (qmlItem) { if (qmlItem) {
qmlItem->setParentItem(m_parentItem); qmlItem->setParentItem(m_parentItem);
showNextIndicator();
} }
m_uidata << uidata;
} }
} }
} }

@ -49,6 +49,7 @@ struct IndicatorUiData
{ {
QString type; QString type;
QString pluginPath; QString pluginPath;
QString name;
QPointer<Latte::View> view; QPointer<Latte::View> view;
QPointer<KDeclarative::QmlObjectSharedEngine> ui; QPointer<KDeclarative::QmlObjectSharedEngine> ui;
}; };
@ -68,11 +69,12 @@ public slots:
Q_INVOKABLE void setParentItem(QQuickItem *parentItem); Q_INVOKABLE void setParentItem(QQuickItem *parentItem);
Q_INVOKABLE void ui(const QString &type, Latte::View *view); Q_INVOKABLE void ui(const QString &type, Latte::View *view);
Q_INVOKABLE int index(const QString &type);
private: private:
bool contains(const QString &type); bool contains(const QString &type);
int index(const QString &type);
void hideAllUi(); void hideAllUi();
void showNextIndicator();
private: private:
QQuickItem *m_parentItem{nullptr}; QQuickItem *m_parentItem{nullptr};

@ -22,10 +22,12 @@ import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Controls 2.12 as QtQuickControls212
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.core 0.2 as LatteCore
import org.kde.latte.components 1.0 as LatteComponents import org.kde.latte.components 1.0 as LatteComponents
@ -35,468 +37,471 @@ import "../../controls" as LatteExtraControls
PlasmaComponents.Page { PlasmaComponents.Page {
Layout.maximumWidth: content.width + content.Layout.leftMargin * 2 Layout.maximumWidth: content.width + content.Layout.leftMargin * 2
Layout.maximumHeight: content.height + units.smallSpacing * 2 Layout.maximumHeight: content.height + units.smallSpacing
ColumnLayout { ColumnLayout {
id: content id: content
width: (dialog.appliedWidth - units.smallSpacing * 2) - Layout.leftMargin * 2 width: (dialog.appliedWidth - units.smallSpacing * 2) - Layout.leftMargin * 2
spacing: dialog.subGroupSpacing
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Layout.leftMargin: units.smallSpacing * 2 Layout.leftMargin: units.smallSpacing * 2
//! BEGIN: Shadows
ColumnLayout { ColumnLayout {
id: contentStatic
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: units.smallSpacing spacing: dialog.subGroupSpacing
spacing: units.smallSpacing
LatteComponents.HeaderSwitch { //! BEGIN: Shadows
id: showAppletShadow ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
Layout.topMargin: units.smallSpacing Layout.topMargin: units.smallSpacing
checked: plasmoid.configuration.appletShadowsEnabled spacing: units.smallSpacing
text: i18n("Shadows")
tooltip: i18n("Enable/disable applet shadows")
onPressed: plasmoid.configuration.appletShadowsEnabled = !plasmoid.configuration.appletShadowsEnabled; LatteComponents.HeaderSwitch {
} id: showAppletShadow
Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
Layout.topMargin: units.smallSpacing
ColumnLayout { checked: plasmoid.configuration.appletShadowsEnabled
Layout.leftMargin: units.smallSpacing * 2 text: i18n("Shadows")
Layout.rightMargin: units.smallSpacing * 2 tooltip: i18n("Enable/disable applet shadows")
spacing: 0
RowLayout{ onPressed: plasmoid.configuration.appletShadowsEnabled = !plasmoid.configuration.appletShadowsEnabled;
enabled: showAppletShadow.checked }
PlasmaComponents.Label { ColumnLayout {
enabled: showAppletShadow.checked Layout.leftMargin: units.smallSpacing * 2
text: i18n("Size") Layout.rightMargin: units.smallSpacing * 2
horizontalAlignment: Text.AlignLeft spacing: 0
}
LatteComponents.Slider { RowLayout{
id: shadowSizeSlider
Layout.fillWidth: true
enabled: showAppletShadow.checked enabled: showAppletShadow.checked
value: plasmoid.configuration.shadowSize PlasmaComponents.Label {
from: 0 enabled: showAppletShadow.checked
to: 100 text: i18n("Size")
stepSize: 5 horizontalAlignment: Text.AlignLeft
wheelEnabled: false
function updateShadowSize() {
if (!pressed)
plasmoid.configuration.shadowSize = value;
} }
onPressedChanged: { LatteComponents.Slider {
updateShadowSize(); id: shadowSizeSlider
} Layout.fillWidth: true
enabled: showAppletShadow.checked
Component.onCompleted: { value: plasmoid.configuration.shadowSize
valueChanged.connect(updateShadowSize); from: 0
} to: 100
stepSize: 5
wheelEnabled: false
Component.onDestruction: { function updateShadowSize() {
valueChanged.disconnect(updateShadowSize); if (!pressed)
} plasmoid.configuration.shadowSize = value;
} }
PlasmaComponents.Label { onPressedChanged: {
enabled: showAppletShadow.checked updateShadowSize();
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
}
}
Component.onCompleted: {
valueChanged.connect(updateShadowSize);
}
RowLayout{ Component.onDestruction: {
enabled: showAppletShadow.checked valueChanged.disconnect(updateShadowSize);
}
}
PlasmaComponents.Label { PlasmaComponents.Label {
enabled: showAppletShadow.checked enabled: showAppletShadow.checked
text: i18n("Opacity") text: i18nc("number in percentage, e.g. 85 %","%0 %").arg(shadowSizeSlider.value)
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignRight
Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4
}
} }
LatteComponents.Slider {
id: shadowOpacitySlider
Layout.fillWidth: true
value: plasmoid.configuration.shadowOpacity RowLayout{
from: 0 enabled: showAppletShadow.checked
to: 100
stepSize: 5
wheelEnabled: false
function updateShadowOpacity() { PlasmaComponents.Label {
if (!pressed) enabled: showAppletShadow.checked
plasmoid.configuration.shadowOpacity = value; text: i18n("Opacity")
horizontalAlignment: Text.AlignLeft
} }
onPressedChanged: { LatteComponents.Slider {
updateShadowOpacity(); id: shadowOpacitySlider
} Layout.fillWidth: true
Component.onCompleted: { value: plasmoid.configuration.shadowOpacity
valueChanged.connect(updateShadowOpacity); from: 0
} to: 100
stepSize: 5
wheelEnabled: false
Component.onDestruction: { function updateShadowOpacity() {
valueChanged.disconnect(updateShadowOpacity); if (!pressed)
} plasmoid.configuration.shadowOpacity = value;
} }
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 { onPressedChanged: {
isFirstSubCategory: true updateShadowOpacity();
text: i18n("Color") }
}
RowLayout { Component.onCompleted: {
id: shadowColorRow valueChanged.connect(updateShadowOpacity);
Layout.fillWidth: true }
spacing: 2
enabled: showAppletShadow.checked
readonly property string defaultShadow: "080808" Component.onDestruction: {
readonly property string themeShadow: { valueChanged.disconnect(updateShadowOpacity);
var strC = String(theme.textColor); }
}
return strC.indexOf("#") === 0 ? strC.substr(1) : strC; 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
}
} }
ExclusiveGroup { LatteComponents.SubHeader {
id: shadowColorGroup isFirstSubCategory: true
text: i18n("Color")
} }
PlasmaComponents.Button { RowLayout {
id: defaultShadowBtn id: shadowColorRow
Layout.fillWidth: true Layout.fillWidth: true
spacing: 2
enabled: showAppletShadow.checked
text: i18nc("default shadow", "Default") readonly property string defaultShadow: "080808"
checked: plasmoid.configuration.shadowColorType === type readonly property string themeShadow: {
checkable: false var strC = String(theme.textColor);
exclusiveGroup: shadowColorGroup
tooltip: i18n("Default shadow for applets")
readonly property int type: LatteContainment.Types.DefaultColorShadow return strC.indexOf("#") === 0 ? strC.substr(1) : strC;
}
onPressedChanged: { ExclusiveGroup {
if (pressed) { id: shadowColorGroup
plasmoid.configuration.shadowColorType = type;
}
} }
}
PlasmaComponents.Button { PlasmaComponents.Button {
id: themeShadowBtn id: defaultShadowBtn
Layout.fillWidth: true Layout.fillWidth: true
text: i18nc("theme shadow", "Theme") text: i18nc("default shadow", "Default")
checked: plasmoid.configuration.shadowColorType === type checked: plasmoid.configuration.shadowColorType === type
checkable: false checkable: false
exclusiveGroup: shadowColorGroup exclusiveGroup: shadowColorGroup
tooltip: i18n("Shadow from theme color palette") tooltip: i18n("Default shadow for applets")
readonly property int type: LatteContainment.Types.ThemeColorShadow readonly property int type: LatteContainment.Types.DefaultColorShadow
onPressedChanged: { onPressedChanged: {
if (pressed) { if (pressed) {
plasmoid.configuration.shadowColorType = type; plasmoid.configuration.shadowColorType = type;
}
} }
} }
}
//overlayed button PlasmaComponents.Button {
PlasmaComponents.Button { id: themeShadowBtn
id: userShadowBtn Layout.fillWidth: true
Layout.fillWidth: true
height: parent.height
text: " "
checkable: false text: i18nc("theme shadow", "Theme")
checked: plasmoid.configuration.shadowColorType === type checked: plasmoid.configuration.shadowColorType === type
tooltip: i18n("Use set shadow color") checkable: false
exclusiveGroup: shadowColorGroup exclusiveGroup: shadowColorGroup
tooltip: i18n("Shadow from theme color palette")
readonly property int type: LatteContainment.Types.UserColorShadow readonly property int type: LatteContainment.Types.ThemeColorShadow
onPressedChanged: { onPressedChanged: {
if (pressed) { if (pressed) {
plasmoid.configuration.shadowColorType = type; plasmoid.configuration.shadowColorType = type;
}
} }
} }
Rectangle{ //overlayed button
anchors.fill: parent PlasmaComponents.Button {
anchors.margins: 1.5*units.smallSpacing id: userShadowBtn
Layout.fillWidth: true
height: parent.height
text: " "
color: "#" + plasmoid.configuration.shadowColor; checkable: false
checked: plasmoid.configuration.shadowColorType === type
tooltip: i18n("Use set shadow color")
exclusiveGroup: shadowColorGroup
opacity: shadowColorRow.enabled ? 1 : 0.6 readonly property int type: LatteContainment.Types.UserColorShadow
Rectangle{ onPressedChanged: {
anchors.fill: parent if (pressed) {
color: "transparent" plasmoid.configuration.shadowColorType = type;
border.width: 1 }
border.color: theme.textColor
opacity: parent.opacity - 0.4
} }
MouseArea{ Rectangle{
anchors.fill: parent anchors.fill: parent
onClicked: { anchors.margins: 1.5*units.smallSpacing
shadowColorGroup.current = userShadowBtn;
viewConfig.setSticker(true); color: "#" + plasmoid.configuration.shadowColor;
colorDialogLoader.showDialog = true;
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{ Loader{
id:colorDialogLoader id:colorDialogLoader
property bool showDialog: false property bool showDialog: false
active: showDialog active: showDialog
sourceComponent: ColorDialog { sourceComponent: ColorDialog {
title: i18n("Please choose shadow color") title: i18n("Please choose shadow color")
showAlphaChannel: false showAlphaChannel: false
onAccepted: { onAccepted: {
//console.log("You chose: " + String(color)); //console.log("You chose: " + String(color));
var strC = String(color); var strC = String(color);
if (strC.indexOf("#") === 0) { if (strC.indexOf("#") === 0) {
plasmoid.configuration.shadowColor = strC.substr(1); plasmoid.configuration.shadowColor = strC.substr(1);
} }
colorDialogLoader.showDialog = false; colorDialogLoader.showDialog = false;
viewConfig.setSticker(false); viewConfig.setSticker(false);
} }
onRejected: { onRejected: {
colorDialogLoader.showDialog = false; colorDialogLoader.showDialog = false;
viewConfig.setSticker(false); viewConfig.setSticker(false);
} }
Component.onCompleted: { Component.onCompleted: {
color = String("#" + plasmoid.configuration.shadowColor); color = String("#" + plasmoid.configuration.shadowColor);
visible = true; visible = true;
}
} }
} }
} }
} }
} }
} }
} //! END: Shadows
//! END: Shadows
//! BEGIN: Animations //! BEGIN: Animations
ColumnLayout { ColumnLayout {
Layout.fillWidth: true
Layout.topMargin: units.smallSpacing
spacing: units.smallSpacing
LatteComponents.HeaderSwitch {
id: animationsHeader
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
Layout.topMargin: units.smallSpacing Layout.topMargin: units.smallSpacing
spacing: units.smallSpacing
checked: plasmoid.configuration.animationsEnabled LatteComponents.HeaderSwitch {
text: i18n("Animations") id: animationsHeader
tooltip: i18n("Enable/disable all animations") Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
onPressed: { Layout.topMargin: units.smallSpacing
plasmoid.configuration.animationsEnabled = !plasmoid.configuration.animationsEnabled;
}
}
ColumnLayout { checked: plasmoid.configuration.animationsEnabled
Layout.leftMargin: units.smallSpacing * 2 text: i18n("Animations")
Layout.rightMargin: units.smallSpacing * 2 tooltip: i18n("Enable/disable all animations")
spacing: 0
enabled: plasmoid.configuration.animationsEnabled
LatteComponents.SubHeader { onPressed: {
isFirstSubCategory: true plasmoid.configuration.animationsEnabled = !plasmoid.configuration.animationsEnabled;
text: i18n("Speed") }
} }
ColumnLayout { ColumnLayout {
Layout.fillWidth: true Layout.leftMargin: units.smallSpacing * 2
Layout.rightMargin: units.smallSpacing * 2
spacing: 0 spacing: 0
enabled: plasmoid.configuration.animationsEnabled
RowLayout { LatteComponents.SubHeader {
Layout.fillWidth: true isFirstSubCategory: true
spacing: 2 text: i18n("Speed")
}
property int duration: plasmoid.configuration.durationTime
ExclusiveGroup { ColumnLayout {
id: animationsGroup Layout.fillWidth: true
} spacing: 0
PlasmaComponents.Button { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("x1") spacing: 2
checked: parent.duration === duration
checkable: false
exclusiveGroup: animationsGroup
readonly property int duration: 3 property int duration: plasmoid.configuration.durationTime
onPressedChanged: { ExclusiveGroup {
if (pressed) { id: animationsGroup
plasmoid.configuration.durationTime = duration;
}
} }
}
PlasmaComponents.Button {
Layout.fillWidth: true
text: i18n("x2")
checked: parent.duration === duration
checkable: false
exclusiveGroup: animationsGroup
readonly property int duration: 2 PlasmaComponents.Button {
Layout.fillWidth: true
text: i18n("x1")
checked: parent.duration === duration
checkable: false
exclusiveGroup: animationsGroup
onPressedChanged: { readonly property int duration: 3
if (pressed) {
plasmoid.configuration.durationTime = duration; onPressedChanged: {
if (pressed) {
plasmoid.configuration.durationTime = duration;
}
} }
} }
} PlasmaComponents.Button {
PlasmaComponents.Button { Layout.fillWidth: true
Layout.fillWidth: true text: i18n("x2")
text: i18n("x3") checked: parent.duration === duration
checked: parent.duration === duration checkable: false
checkable: false exclusiveGroup: animationsGroup
exclusiveGroup: animationsGroup
readonly property int duration: 2
readonly property int duration: 1
onPressedChanged: {
onPressedChanged: { if (pressed) {
if (pressed) { plasmoid.configuration.durationTime = duration;
plasmoid.configuration.durationTime = duration; }
}
}
PlasmaComponents.Button {
Layout.fillWidth: true
text: i18n("x3")
checked: parent.duration === duration
checkable: false
exclusiveGroup: animationsGroup
readonly property int duration: 1
onPressedChanged: {
if (pressed) {
plasmoid.configuration.durationTime = duration;
}
} }
} }
} }
} }
} }
} }
} //! END: Animations
//! END: Animations
//! BEGIN: Active Indicator General Settings //! BEGIN: Active Indicator General Settings
ColumnLayout{ ColumnLayout{
spacing: units.smallSpacing spacing: units.smallSpacing
LatteComponents.HeaderSwitch { LatteComponents.HeaderSwitch {
id: indicatorsSwitch id: indicatorsSwitch
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: implicitHeight Layout.minimumHeight: implicitHeight
checked: latteView.indicator.enabled checked: latteView.indicator.enabled
text: i18n("Indicators") text: i18n("Indicators")
tooltip: i18n("Enable/disable indicators") tooltip: i18n("Enable/disable indicators")
onPressed: { onPressed: {
latteView.indicator.enabled = !latteView.indicator.enabled; latteView.indicator.enabled = !latteView.indicator.enabled;
}
} }
}
ColumnLayout { ColumnLayout {
Layout.leftMargin: units.smallSpacing * 2 Layout.leftMargin: units.smallSpacing * 2
Layout.rightMargin: units.smallSpacing * 2 Layout.rightMargin: units.smallSpacing * 2
spacing: units.smallSpacing spacing: units.smallSpacing
enabled: indicatorsSwitch.checked enabled: indicatorsSwitch.checked
/* LatteComponents.SubHeader { /* LatteComponents.SubHeader {
text: i18n("Style") text: i18n("Style")
}*/ }*/
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: tabBar.height Layout.minimumHeight: tabBar.height
PlasmaComponents.TabBar { PlasmaComponents.TabBar {
id: tabBar id: tabBar
width: parent.width width: parent.width
property string type: latteView.indicator.type property string type: latteView.indicator.type
PlasmaComponents.TabButton { PlasmaComponents.TabButton {
id: latteBtn id: latteBtn
text: i18nc("latte indicator style", "Latte") text: i18nc("latte indicator style", "Latte")
readonly property string type: "org.kde.latte.default" readonly property string type: "org.kde.latte.default"
onCheckedChanged: { onCheckedChanged: {
if (checked) { if (checked) {
latteView.indicator.type = type; latteView.indicator.type = type;
}
} }
} }
} PlasmaComponents.TabButton {
PlasmaComponents.TabButton { id: plasmaBtn
id: plasmaBtn text: i18nc("plasma indicator style", "Plasma")
text: i18nc("plasma indicator style", "Plasma") readonly property string type: "org.kde.latte.plasma"
readonly property string type: "org.kde.latte.plasma"
onCheckedChanged: {
onCheckedChanged: { if (checked) {
if (checked) { latteView.indicator.type = type;
latteView.indicator.type = type; }
} }
} }
}
PlasmaComponents.TabButton { PlasmaComponents.TabButton {
id: customBtn id: customBtn
onCheckedChanged: { onCheckedChanged: {
if (checked) { if (checked) {
customIndicator.onButtonIsPressed(); customIndicator.onButtonIsPressed();
}
} }
}
LatteExtraControls.CustomIndicatorButton { LatteExtraControls.CustomIndicatorButton {
id: customIndicator id: customIndicator
anchors.fill: parent anchors.fill: parent
implicitWidth: latteBtn.implicitWidth implicitWidth: latteBtn.implicitWidth
implicitHeight: latteBtn.implicitHeight implicitHeight: latteBtn.implicitHeight
checked: parent.checked checked: parent.checked
comboBoxMinimumPopUpWidth: 1.5 * customIndicator.width comboBoxMinimumPopUpWidth: 1.5 * customIndicator.width
}
} }
} }
}
Rectangle { Rectangle {
anchors.bottom: tabBar.bottom anchors.bottom: tabBar.bottom
anchors.left: tabBar.left anchors.left: tabBar.left
anchors.leftMargin: 2 anchors.leftMargin: 2
width: tabBar.width - 2*2 width: tabBar.width - 2*2
height: 2 height: 2
color: theme.textColor color: theme.textColor
opacity: 0.25 opacity: 0.25
}
} }
}
//! BEGIN: Indicator specific sub-options //! BEGIN: Indicator specific sub-options
ColumnLayout { /* ColumnLayout {
id: indicatorSpecificOptions id: indicatorSpecificOptions
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: units.smallSpacing * 2 Layout.topMargin: units.smallSpacing * 2
@ -526,10 +531,185 @@ PlasmaComponents.Page {
} }
} }
} }
}*/
//! END: Indicator specific sub-options
} }
//! END: Indicator specific sub-options
} }
} //! END: Active Indicator General Settings
//! END: Active Indicator General Settings } //Static properties column
}
ColumnLayout {
id: contentDynamic
Layout.fillWidth: true
height: pagesBackground.height - contentStatic.height - 3*units.smallSpacing
spacing: dialog.subGroupSpacing
Rectangle {
id: indicatorsBackground
Layout.fillWidth: true
Layout.minimumHeight: parent.height
Layout.leftMargin: units.smallSpacing * 2
Layout.rightMargin: units.smallSpacing * 2
color: "transparent"
PlasmaExtras.ScrollArea {
id: scrollArea
anchors.fill: parent
verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
flickableItem.flickableDirection: Flickable.VerticalFlick
QtQuickControls212.StackView {
id: indicatorsStackView
width: Math.max(currentItem.Layout.maximumWidth, currentItem.width)
height: Math.max(currentItem.Layout.maximumHeight, currentItem.height)
enabled: latteView.indicator.enabled
property bool forwardSliding: true
readonly property int optionsWidth: dialog.optionsWidth
readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
replaceEnter: Transition {
ParallelAnimation {
PropertyAnimation {
property: "x"
from: indicatorsStackView.forwardSliding ? -indicatorsBackground.width : indicatorsBackground.width
to: 0
duration: 350
}
PropertyAnimation {
property: "opacity"
from: 0
to: 1
duration: 350
}
}
}
replaceExit: Transition {
ParallelAnimation {
PropertyAnimation {
property: "x"
from: 0
to: indicatorsStackView.forwardSliding ? indicatorsBackground.width : -indicatorsBackground.width
duration: 350
}
PropertyAnimation {
property: "opacity"
from: 1
to: 0
duration: 350
}
}
}
}
}
Item {
id: hiddenIndicatorPage
anchors.fill: parent
visible: false
readonly property int optionsWidth: dialog.optionsWidth
readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
readonly property Item nextPage: indicatorsStackView.currentItem === page1 ? page2 : page1
readonly property Item previousPage: nextPage === page1 ? page2 : page1
function showNextIndicator() {
console.log("show next indicator in qml called, children:: " + children.length);
if (children.length===1) {
var nextIndicator = children[0];
if (nextIndicator && (!indicatorsStackView.currentItem || !indicatorsStackView.currentItem.isCurrent)) {
//!empty nextPage by moving its pages into hiddenPages
var childrenCount = nextPage.children.length;
for (var i=0; i<childrenCount; ++i) {
var previousIndicator = nextPage.children[0];
previousIndicator.visible = false;
previousIndicator.parent = hiddenPages;
}
nextIndicator.parent = nextPage;
nextIndicator.visible = true;
nextPage.type = latteView.indicator.type;
var currentIndex = -1;
if (indicatorsStackView.currentItem) {
currentIndex = viewConfig.indicatorUiManager.index(indicatorsStackView.currentItem.type);
}
var nextIndex = viewConfig.indicatorUiManager.index(latteView.indicator.type);
indicatorsStackView.forwardSliding = (nextIndex<currentIndex);
indicatorsStackView.replace(indicatorsStackView.currentItem, nextPage);
}
}
}
Component.onCompleted: {
viewConfig.indicatorUiManager.setParentItem(hiddenIndicatorPage);
viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
}
Connections {
target: latteView.indicator
onPluginChanged: viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
}
Connections {
target: viewConfig
onIsReadyChanged: {
if (viewConfig.isReady) {
viewConfig.indicatorUiManager.ui(latteView.indicator.type, latteView);
}
}
}
}
Item {
id: hidden
visible: false
ColumnLayout {
id: page1
width: indicatorsBackground.width
height: childrenRect.height
readonly property bool isCurrent: latteView.indicator.type === type
readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
readonly property int optionsWidth: dialog.optionsWidth
property string type: ""
}
ColumnLayout {
id: page2
width: indicatorsBackground.width
height: childrenRect.height
readonly property bool isCurrent: latteView.indicator.type === type
readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
readonly property int optionsWidth: dialog.optionsWidth
property string type: ""
}
ColumnLayout {
id: hiddenPages
width: indicatorsBackground.width
height: childrenRect.height
readonly property bool isCurrent: latteView.indicator.type === type
readonly property bool deprecatedOptionsAreHidden: true // @since 0.10.0
readonly property int optionsWidth: dialog.optionsWidth
property string type: ""
}
}
}
}//! END of Dynamic content
} //! END of ALL content
} }

Loading…
Cancel
Save