support file dialog for indicators

pull/5/head
Michail Vourlakos 6 years ago
parent 4c613a1d47
commit fd74397bae

@ -24,12 +24,15 @@
#include "../lattecorona.h"
#include "../indicator/factory.h"
// Qt
#include <QFileDialog>
// KDE
#include <KLocalizedString>
#include <KPluginMetaData>
#include <KDeclarative/ConfigPropertyMap>
#include <KDeclarative/QmlObjectSharedEngine>
namespace Latte {
namespace ViewPart {
@ -359,6 +362,31 @@ void Indicator::updateScheme()
}
}
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() << " indicator file ::: " << file;
});
fileDialog->open();
}
void Indicator::loadConfig()
{
auto config = m_view->containment()->config().group("Indicator");

@ -111,6 +111,7 @@ public:
public slots:
Q_INVOKABLE void configUiFor(QString type, QQuickItem *parent);
Q_INVOKABLE void addIndicator();
signals:
void customPluginsChanged();

@ -53,6 +53,17 @@ LatteComponents.ComboBoxButton{
onCustomPluginsCountChanged: custom.updateButtonInformation()
}
Connections{
target: custom.comboBox
onActivated: {
var item = actionsModel.get(index);
if (item.pluginId === "add:") {
latteView.indicator.addIndicator();
}
}
}
function updateButtonInformation() {
if (latteView.indicator.customPluginsCount === 0) {
custom.buttonText = i18n("Download");

Loading…
Cancel
Save