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