Plugin settings (weather & lunch) #74
@@ -36,7 +36,7 @@ void WeatherPlugin::attachTo(MainWindow &mainWindow)
|
||||
mainWindow.statusBar()->addWidget(new WeatherWidget(mainWindow));
|
||||
}
|
||||
|
||||
SettingsWidget *WeatherPlugin::settingsWidget(QWidget *parent) const
|
||||
SettingsWidget *WeatherPlugin::settingsWidget(ZeiterfassungSettings &settings, QWidget *parent) const
|
||||
{
|
||||
return new WeatherSettings(parent);
|
||||
return new WeatherSettings(settings, parent);
|
||||
}
|
||||
|
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "zeiterfassungplugin.h"
|
||||
|
||||
class SettingsWidget;
|
||||
class ZeiterfassungSettings;
|
||||
|
||||
class Q_DECL_EXPORT WeatherPlugin : public ZeiterfassungPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -17,7 +20,7 @@ public:
|
||||
// ZeiterfassungPlugin interface
|
||||
void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE;
|
||||
|
||||
SettingsWidget *settingsWidget(QWidget *parent = Q_NULLPTR) const Q_DECL_OVERRIDE;
|
||||
SettingsWidget *settingsWidget(ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR) const Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QTranslator m_translator;
|
||||
|
@@ -4,8 +4,9 @@
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
|
||||
WeatherSettings::WeatherSettings(QWidget *parent) :
|
||||
SettingsWidget(parent)
|
||||
WeatherSettings::WeatherSettings(ZeiterfassungSettings &settings, QWidget *parent) :
|
||||
SettingsWidget(parent),
|
||||
m_settings(settings)
|
||||
{
|
||||
auto layout = new QFormLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
@@ -5,16 +5,21 @@
|
||||
|
||||
#include "settingswidget.h"
|
||||
|
||||
class ZeiterfassungSettings;
|
||||
|
||||
class WeatherSettings : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WeatherSettings(QWidget *parent = Q_NULLPTR);
|
||||
explicit WeatherSettings(ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR);
|
||||
|
||||
bool isValid(QString &message) const Q_DECL_OVERRIDE;
|
||||
|
||||
public Q_SLOTS:
|
||||
void apply() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
ZeiterfassungSettings &m_settings;
|
||||
};
|
||||
|
||||
#endif // WEATHERSETTINGS_H
|
||||
|
@@ -24,7 +24,7 @@ SettingsDialog::SettingsDialog(ZeiterfassungSettings &settings, const QSet<Zeite
|
||||
ui->comboBoxLanguage->addItem(tr("German"), QLocale::German);
|
||||
|
||||
{
|
||||
auto index = ui->comboBoxLanguage->findData(settings.language());
|
||||
auto index = ui->comboBoxLanguage->findData(m_settings.language());
|
||||
if(index == -1)
|
||||
QMessageBox::warning(this, tr("Invalid settings!"), tr("Invalid settings!") % "\n\n" % tr("Unknown language!"));
|
||||
ui->comboBoxLanguage->setCurrentIndex(index);
|
||||
@@ -35,9 +35,9 @@ SettingsDialog::SettingsDialog(ZeiterfassungSettings &settings, const QSet<Zeite
|
||||
for(const auto &entry : QDir(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("themes"))).entryInfoList(QStringList { QStringLiteral("*.qss") }, QDir::Files))
|
||||
ui->comboBoxTheme->addItem(entry.baseName(), entry.baseName());
|
||||
|
||||
if(!settings.theme().isEmpty())
|
||||
if(!m_settings.theme().isEmpty())
|
||||
{
|
||||
auto index = ui->comboBoxTheme->findData(settings.theme());
|
||||
auto index = ui->comboBoxTheme->findData(m_settings.theme());
|
||||
if(index == -1)
|
||||
QMessageBox::warning(this, tr("Invalid settings!"), tr("Invalid settings!") % "\n\n" % tr("Unknown theme!"));
|
||||
ui->comboBoxTheme->setCurrentIndex(index);
|
||||
@@ -45,7 +45,7 @@ SettingsDialog::SettingsDialog(ZeiterfassungSettings &settings, const QSet<Zeite
|
||||
|
||||
for(const auto plugin : plugins)
|
||||
{
|
||||
auto widget = plugin->settingsWidget(this);
|
||||
auto widget = plugin->settingsWidget(m_settings, this);
|
||||
if(!widget)
|
||||
continue;
|
||||
|
||||
@@ -63,8 +63,6 @@ SettingsDialog::~SettingsDialog()
|
||||
|
||||
void SettingsDialog::submit()
|
||||
{
|
||||
auto warning = false;
|
||||
|
||||
if(ui->comboBoxLanguage->currentIndex() == -1 ||
|
||||
ui->comboBoxTheme->currentIndex() == -1)
|
||||
{
|
||||
|
@@ -3,5 +3,11 @@
|
||||
ZeiterfassungPlugin::ZeiterfassungPlugin(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SettingsWidget *ZeiterfassungPlugin::settingsWidget(ZeiterfassungSettings &settings, QWidget *parent) const
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
Q_UNUSED(parent)
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
class MainWindow;
|
||||
class StripsWidget;
|
||||
class SettingsWidget;
|
||||
class ZeiterfassungSettings;
|
||||
|
||||
class ZEITERFASSUNGGUILIBSHARED_EXPORT ZeiterfassungPlugin : public QObject
|
||||
{
|
||||
@@ -17,7 +18,7 @@ public:
|
||||
|
||||
virtual void attachTo(MainWindow &mainWindow) { Q_UNUSED(mainWindow) }
|
||||
|
||||
virtual SettingsWidget *settingsWidget(QWidget *parent = Q_NULLPTR) const { Q_UNUSED(parent) return Q_NULLPTR; }
|
||||
virtual SettingsWidget *settingsWidget(ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR) const;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(ZeiterfassungPlugin, "dbsoftware.zeiterfassung.plugin/1.0")
|
||||
|
Reference in New Issue
Block a user