add functionality to CustomIndicatorsButton

pull/5/head
Michail Vourlakos 6 years ago
parent 0a2bd9cc2d
commit fdd5c1eff3

@ -518,10 +518,8 @@ PlasmaComponents.Page {
implicitWidth: latteBtn.implicitWidth
implicitHeight: latteBtn.implicitHeight
checked: parent.type === type
checkable: true
checked: checkable ? parent.type === type : false
buttonExclusiveGroup: indicatorStyleGroup
buttonToolTip: i18n("Use %0 style for your indicators and download more custom indicators to use").arg(buttonText)
comboBoxMinimumPopUpWidth: 1.5 * customIndicator.width
}
}

@ -27,7 +27,10 @@ import org.kde.latte.components 1.0 as LatteComponents
LatteComponents.ComboBoxButton{
id: custom
checkable: true
buttonToolTip: checked ? i18n("Use %0 style for your indicators").arg(buttonText) :
i18n("Download indicator styles from the internet")
comboBoxTextRole: "name"
comboBoxIconRole: "icon"
comboBoxBlankSpaceForEmptyIcons: true
@ -37,12 +40,31 @@ LatteComponents.ComboBoxButton{
buttonText: "Unity"
property string type: "org.kde.latte.unity"
Component.onCompleted: reloadModel();
Component.onCompleted: {
reloadModel();
updateButtonInformation();
}
ListModel {
id: actionsModel
}
Connections{
target: latteView.indicator
onCustomPluginsCountChanged: custom.updateButtonInformation()
}
function updateButtonInformation() {
if (latteView.indicator.customPluginsCount === 0) {
custom.buttonText = i18n("Download");
custom.checkable = false;
} else {
custom.checkable = true;
custom.buttonText = actionsModel.get(0).name;
custom.type = actionsModel.get(0).pluginId;
}
}
function reloadModel() {
var actions = [];
@ -77,11 +99,11 @@ LatteComponents.ComboBoxButton{
function appendDefaults() {
//! add
var addElement = {pluginId: 'add:', name: 'Add Indicator...', icon: 'list-add'};
var addElement = {pluginId: 'add:', name: i18n('Add Indicator...'), icon: 'list-add'};
actionsModel.append(addElement);
//! download
var downloadElement = {pluginId: 'download:', name: 'Get New Indicators...', icon: 'favorites'};
var downloadElement = {pluginId: 'download:', name: i18n('Get New Indicators...'), icon: 'favorites'};
actionsModel.append(downloadElement);
}

Loading…
Cancel
Save