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

@ -51,19 +51,20 @@ class Indicator: public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool enabledForApplets READ enabledForApplets WRITE setEnabledForApplets NOTIFY enabledForAppletsChanged) Q_PROPERTY(bool enabledForApplets READ enabledForApplets WRITE setEnabledForApplets NOTIFY enabledForAppletsChanged)
Q_PROPERTY(bool latteTasksArePresent READ latteTasksArePresent NOTIFY latteTasksArePresentChanged) 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 providesConfigUi READ providesConfigUi NOTIFY providesConfigUiChanged)
Q_PROPERTY(bool reversed READ reversed WRITE setReversed NOTIFY reversedChanged) Q_PROPERTY(bool reversed READ reversed WRITE setReversed NOTIFY reversedChanged)
Q_PROPERTY(float padding READ padding WRITE setPadding NOTIFY paddingChanged) 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. * 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) Q_PROPERTY(QQmlComponent *plasmaComponent READ plasmaComponent NOTIFY plasmaComponentChanged)
public: public:
@ -79,6 +80,8 @@ public:
bool latteTasksArePresent(); bool latteTasksArePresent();
bool providesConfigUi() const; bool providesConfigUi() const;
bool pluginIsReady();
bool reversed() const; bool reversed() const;
void setReversed(bool reversed); void setReversed(bool reversed);
@ -98,21 +101,21 @@ public slots:
Q_INVOKABLE void configUiFor(QString type, QQuickItem *parent); Q_INVOKABLE void configUiFor(QString type, QQuickItem *parent);
signals: signals:
void componentChanged();
void configurationChanged();
void enabledChanged(); void enabledChanged();
void enabledForAppletsChanged(); void enabledForAppletsChanged();
void latteTasksArePresentChanged(); void latteTasksArePresentChanged();
void paddingChanged(); void paddingChanged();
void plasmaComponentChanged(); void plasmaComponentChanged();
void pluginChanged();
void pluginIsReadyChanged();
void providesConfigUiChanged(); void providesConfigUiChanged();
void reversedChanged(); void reversedChanged();
void typeChanged();
private: private:
void loadConfig(); void loadConfig();
void saveConfig(); void saveConfig();
void setPluginIsReady(bool ready);
void setProvidesConfigUi(bool provides); void setProvidesConfigUi(bool provides);
void loadPlasmaComponent(); void loadPlasmaComponent();
@ -122,6 +125,7 @@ private:
private: private:
bool m_enabled{true}; bool m_enabled{true};
bool m_enabledForApplets{true}; bool m_enabledForApplets{true};
bool m_pluginIsReady{false};
bool m_providesConfigUi{true}; bool m_providesConfigUi{true};
bool m_reversed{false}; bool m_reversed{false};

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

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

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

Loading…
Cancel
Save