improve loading for indigator config ui

--in order for all indicators infrastructure to
load the plugin correctly the configuration and
the component elements of ViewPart::Indicator
must be loaded first correctly and afterwards
the relevant Indicators to follow
pull/5/head
Michail Vourlakos 6 years ago
parent 0b90411b1d
commit 9a464226bd

@ -44,7 +44,7 @@ Indicator::Indicator(Latte::View *parent)
connect(this, &Indicator::enabledForAppletsChanged, this, &Indicator::saveConfig);
connect(this, &Indicator::paddingChanged, this, &Indicator::saveConfig);
connect(this, &Indicator::reversedChanged, this, &Indicator::saveConfig);
connect(this, &Indicator::typeChanged, this, &Indicator::saveConfig);
connect(this, &Indicator::pluginChanged, this, &Indicator::saveConfig);
connect(m_view, &Latte::View::latteTasksArePresentChanged, this, &Indicator::latteTasksArePresentChanged);
@ -148,6 +148,21 @@ void Indicator::setPadding(float 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;
@ -182,6 +197,10 @@ 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;
@ -191,7 +210,10 @@ void Indicator::load(QString type)
updateScheme();
updateComponent();
emit typeChanged();
emit pluginChanged();
//! create all indicators with the new type
setPluginIsReady(true);
} else if (type!="org.kde.latte.indicator.default") {
setType("org.kde.latte.indicator.default");
}
@ -211,8 +233,6 @@ void Indicator::updateComponent()
if (prevComponent) {
prevComponent->deleteLater();
}
emit componentChanged();
}
void Indicator::loadPlasmaComponent()
@ -299,8 +319,6 @@ void Indicator::updateScheme()
if (prevConfiguration) {
prevConfiguration->deleteLater();
}
emit configurationChanged();
}
void Indicator::loadConfig()

@ -51,19 +51,20 @@ class Indicator: public QObject
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(bool reversed READ reversed WRITE setReversed NOTIFY reversedChanged)
Q_PROPERTY(float padding READ padding WRITE setPadding NOTIFY paddingChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY pluginChanged)
/**
* Configuration object: each config key will be a writable property of this object. property bindings work.
*/
Q_PROPERTY(QObject *configuration READ configuration NOTIFY configurationChanged)
Q_PROPERTY(QObject *configuration READ configuration NOTIFY pluginChanged)
Q_PROPERTY(QQmlComponent *component READ component NOTIFY componentChanged)
Q_PROPERTY(QQmlComponent *component READ component NOTIFY pluginChanged)
Q_PROPERTY(QQmlComponent *plasmaComponent READ plasmaComponent NOTIFY plasmaComponentChanged)
public:
@ -79,6 +80,8 @@ public:
bool latteTasksArePresent();
bool providesConfigUi() const;
bool pluginIsReady();
bool reversed() const;
void setReversed(bool reversed);
@ -98,21 +101,21 @@ public slots:
Q_INVOKABLE void configUiFor(QString type, QQuickItem *parent);
signals:
void componentChanged();
void configurationChanged();
void enabledChanged();
void enabledForAppletsChanged();
void latteTasksArePresentChanged();
void paddingChanged();
void plasmaComponentChanged();
void pluginChanged();
void pluginIsReadyChanged();
void providesConfigUiChanged();
void reversedChanged();
void typeChanged();
private:
void loadConfig();
void saveConfig();
void setPluginIsReady(bool ready);
void setProvidesConfigUi(bool provides);
void loadPlasmaComponent();
@ -122,6 +125,7 @@ private:
private:
bool m_enabled{true};
bool m_enabledForApplets{true};
bool m_pluginIsReady{false};
bool m_providesConfigUi{true};
bool m_reversed{false};

@ -25,7 +25,7 @@ Item{
id: indicatorBridge
anchors.fill: parent
property bool appletIsValid: true
property bool appletIsValid: true
readonly property bool active: appletIsValid &&
((indicators.isEnabled

@ -31,7 +31,7 @@ Item{
readonly property QtObject configuration: latteView && latteView.indicator ? latteView.indicator.configuration : null
readonly property bool isEnabled: latteView && latteView.indicator ? latteView.indicator.enabled : false
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 bool reversed: latteView && latteView.indicator ? latteView.indicator.reversed : false
readonly property real padding: latteView && latteView.indicator ? latteView.indicator.padding: 0.08
@ -62,6 +62,7 @@ Item{
active: managerIndicator.isEnabled
readonly property bool isBackground: true
readonly property bool isForeground: false
readonly property Item bridge: AppletIndicator.Bridge{
appletIsValid: false
}

@ -613,7 +613,7 @@ PlasmaComponents.Page {
Connections {
target: latteView.indicator
onTypeChanged: latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions);
onPluginChanged: latteView.indicator.configUiFor(latteView.indicator.type, indicatorSpecificOptions);
}
}
}

Loading…
Cancel
Save