Plugins now get stored in a QSet
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)
|
SettingsWidget *WeatherPlugin::settingsWidget(QWidget *parent) const
|
||||||
{
|
{
|
||||||
return new WeatherSettings(parent);
|
return new WeatherSettings(parent);
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,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) Q_DECL_OVERRIDE;
|
SettingsWidget *settingsWidget(QWidget *parent = Q_NULLPTR) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTranslator m_translator;
|
QTranslator m_translator;
|
||||||
|
@@ -34,7 +34,8 @@ struct {
|
|||||||
QTranslator zeiterfassungguilibTranslator;
|
QTranslator zeiterfassungguilibTranslator;
|
||||||
} translators;
|
} translators;
|
||||||
|
|
||||||
QVector<std::shared_ptr<QPluginLoader> > pluginLoaders;
|
QSet<std::shared_ptr<QPluginLoader> > pluginLoaders;
|
||||||
|
QSet<ZeiterfassungPlugin*> plugins;
|
||||||
|
|
||||||
bool loadAndInstallTranslator(QTranslator &translator, const QString &filename)
|
bool loadAndInstallTranslator(QTranslator &translator, const QString &filename)
|
||||||
{
|
{
|
||||||
@@ -290,7 +291,16 @@ bool loadPlugins(QSplashScreen &splashScreen)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginLoaders.append(pluginLoader);
|
if(auto plugin = qobject_cast<ZeiterfassungPlugin*>(pluginLoader->instance()))
|
||||||
|
{
|
||||||
|
pluginLoaders.insert(pluginLoader);
|
||||||
|
plugins.insert(plugin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Plugin not valid %0!"),
|
||||||
|
QCoreApplication::translate("main", "Plugin not valid %0!").arg(pluginLoader->fileName()) %
|
||||||
|
"\n\n" % pluginLoader->errorString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -350,16 +360,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
loadPlugins(splashScreen);
|
loadPlugins(splashScreen);
|
||||||
|
|
||||||
MainWindow mainWindow(settings, erfassung, userInfo, stripFactory);
|
MainWindow mainWindow(settings, erfassung, userInfo, stripFactory, plugins);
|
||||||
splashScreen.finish(&mainWindow);
|
splashScreen.finish(&mainWindow);
|
||||||
|
|
||||||
for(auto &pluginLoader : pluginLoaders)
|
for(auto &plugin : plugins)
|
||||||
if(auto plugin = qobject_cast<ZeiterfassungPlugin*>(pluginLoader->instance()))
|
plugin->attachTo(mainWindow);
|
||||||
plugin->attachTo(mainWindow);
|
|
||||||
else
|
|
||||||
QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Plugin not valid %0!"),
|
|
||||||
QCoreApplication::translate("main", "Plugin not valid %0!").arg(pluginLoader->fileName()) %
|
|
||||||
"\n\n" % pluginLoader->errorString());
|
|
||||||
|
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>647</width>
|
<width>340</width>
|
||||||
<height>162</height>
|
<height>164</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
<layout class="QVBoxLayout" stretch="0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelTitle">
|
<widget class="QLabel" name="labelTitle">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
@@ -33,35 +33,52 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<widget class="QLabel" name="labelLanguage">
|
<layout class="QFormLayout">
|
||||||
<property name="text">
|
<item row="0" column="0">
|
||||||
<string>Language:</string>
|
<widget class="QLabel" name="labelLanguage">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="buddy">
|
<string>Language:</string>
|
||||||
<cstring>comboBoxLanguage</cstring>
|
</property>
|
||||||
</property>
|
<property name="buddy">
|
||||||
</widget>
|
<cstring>comboBoxLanguage</cstring>
|
||||||
</item>
|
</property>
|
||||||
<item row="0" column="1">
|
</widget>
|
||||||
<widget class="QComboBox" name="comboBoxLanguage"/>
|
</item>
|
||||||
</item>
|
<item row="0" column="1">
|
||||||
<item row="1" column="0">
|
<widget class="QComboBox" name="comboBoxLanguage"/>
|
||||||
<widget class="QLabel" name="labelTheme">
|
</item>
|
||||||
<property name="text">
|
<item row="1" column="0">
|
||||||
<string>Theme:</string>
|
<widget class="QLabel" name="labelTheme">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="buddy">
|
<string>Theme:</string>
|
||||||
<cstring>comboBoxTheme</cstring>
|
</property>
|
||||||
</property>
|
<property name="buddy">
|
||||||
</widget>
|
<cstring>comboBoxTheme</cstring>
|
||||||
</item>
|
</property>
|
||||||
<item row="1" column="1">
|
</widget>
|
||||||
<widget class="QComboBox" name="comboBoxTheme"/>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBoxTheme"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@@ -28,13 +28,14 @@
|
|||||||
#include "replies/updatetimeassignmentreply.h"
|
#include "replies/updatetimeassignmentreply.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo,
|
MainWindow::MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo,
|
||||||
StripFactory &stripFactory, QWidget *parent) :
|
StripFactory &stripFactory, const QSet<ZeiterfassungPlugin*> &plugins, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
m_erfassung(erfassung),
|
m_erfassung(erfassung),
|
||||||
m_userInfo(userInfo),
|
m_userInfo(userInfo),
|
||||||
m_stripFactory(stripFactory),
|
m_stripFactory(stripFactory),
|
||||||
|
m_plugins(plugins),
|
||||||
m_currentStripWidget(Q_NULLPTR),
|
m_currentStripWidget(Q_NULLPTR),
|
||||||
m_timerId(-1)
|
m_timerId(-1)
|
||||||
{
|
{
|
||||||
|
@@ -18,6 +18,7 @@ class QBoxLayout;
|
|||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
class ZeiterfassungSettings;
|
class ZeiterfassungSettings;
|
||||||
class StripFactory;
|
class StripFactory;
|
||||||
|
class ZeiterfassungPlugin;
|
||||||
class StripsWidget;
|
class StripsWidget;
|
||||||
|
|
||||||
class ZEITERFASSUNGGUILIBSHARED_EXPORT MainWindow : public QMainWindow
|
class ZEITERFASSUNGGUILIBSHARED_EXPORT MainWindow : public QMainWindow
|
||||||
@@ -26,7 +27,7 @@ class ZEITERFASSUNGGUILIBSHARED_EXPORT MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo,
|
explicit MainWindow(ZeiterfassungSettings &settings, ZeiterfassungApi &erfassung, const GetUserInfoReply::UserInfo &userInfo,
|
||||||
StripFactory &stripFactory, QWidget *parent = Q_NULLPTR);
|
StripFactory &stripFactory, const QSet<ZeiterfassungPlugin*> &plugins, QWidget *parent = Q_NULLPTR);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
QMenu *menuFile() const;
|
QMenu *menuFile() const;
|
||||||
@@ -73,6 +74,7 @@ private:
|
|||||||
ZeiterfassungApi &m_erfassung;
|
ZeiterfassungApi &m_erfassung;
|
||||||
const GetUserInfoReply::UserInfo &m_userInfo;
|
const GetUserInfoReply::UserInfo &m_userInfo;
|
||||||
StripFactory &m_stripFactory;
|
StripFactory &m_stripFactory;
|
||||||
|
const QSet<ZeiterfassungPlugin*> &m_plugins;
|
||||||
|
|
||||||
std::unique_ptr<GetProjectsReply> m_getProjectsReply;
|
std::unique_ptr<GetProjectsReply> m_getProjectsReply;
|
||||||
|
|
||||||
|
@@ -17,7 +17,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) { Q_UNUSED(parent) return Q_NULLPTR; }
|
virtual SettingsWidget *settingsWidget(QWidget *parent = Q_NULLPTR) const { Q_UNUSED(parent) return Q_NULLPTR; }
|
||||||
};
|
};
|
||||||
|
|
||||||
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