Merged dev-tools-plugin
This commit is contained in:
62
plugins/devtoolsplugin/devtoolsplugin.cpp
Normal file
62
plugins/devtoolsplugin/devtoolsplugin.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#include "devtoolsplugin.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "logmodel.h"
|
||||||
|
#include "logdialog.h"
|
||||||
|
|
||||||
|
std::shared_ptr<LogModel> model;
|
||||||
|
QtMessageHandler previousHandler;
|
||||||
|
|
||||||
|
void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||||
|
{
|
||||||
|
previousHandler(type, context, message);
|
||||||
|
|
||||||
|
if(!model)
|
||||||
|
model = std::make_shared<LogModel>();
|
||||||
|
model->log(type, context.file, context.line, context.function, context.category, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void registerMessageHandler()
|
||||||
|
{
|
||||||
|
previousHandler = qInstallMessageHandler(myMessageHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_COREAPP_STARTUP_FUNCTION(registerMessageHandler)
|
||||||
|
|
||||||
|
DevToolsPlugin::DevToolsPlugin(QObject *parent) :
|
||||||
|
ZeiterfassungPlugin(parent)
|
||||||
|
{
|
||||||
|
qDebug() << "called";
|
||||||
|
|
||||||
|
static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations"));
|
||||||
|
|
||||||
|
if(m_translator.load(QLocale(), QStringLiteral("devtoolsplugin"), QStringLiteral("_"), dir))
|
||||||
|
{
|
||||||
|
if(!QCoreApplication::installTranslator(&m_translator))
|
||||||
|
{
|
||||||
|
qWarning() << "could not install translation devtoolsplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "could not load translation devtoolsplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsPlugin::attachTo(MainWindow &mainWindow)
|
||||||
|
{
|
||||||
|
auto dialog = new LogDialog(&mainWindow);
|
||||||
|
dialog->setModel(model.get());
|
||||||
|
mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/devtoolsplugin/images/dev-tools.png")),
|
||||||
|
tr("Show log"), dialog, &QDialog::open);
|
||||||
|
}
|
22
plugins/devtoolsplugin/devtoolsplugin.h
Normal file
22
plugins/devtoolsplugin/devtoolsplugin.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include "zeiterfassungplugin.h"
|
||||||
|
|
||||||
|
class Q_DECL_EXPORT DevToolsPlugin : public ZeiterfassungPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "devtoolsplugin.json")
|
||||||
|
Q_INTERFACES(ZeiterfassungPlugin)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DevToolsPlugin(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
// ZeiterfassungPlugin interface
|
||||||
|
void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTranslator m_translator;
|
||||||
|
};
|
0
plugins/devtoolsplugin/devtoolsplugin.json
Normal file
0
plugins/devtoolsplugin/devtoolsplugin.json
Normal file
40
plugins/devtoolsplugin/devtoolsplugin.pro
Normal file
40
plugins/devtoolsplugin/devtoolsplugin.pro
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
QT += core network gui widgets
|
||||||
|
|
||||||
|
TARGET = devtoolsplugin
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
CONFIG += shared c++14
|
||||||
|
|
||||||
|
DESTDIR = $${OUT_PWD}/../../bin/plugins/zeiterfassung
|
||||||
|
|
||||||
|
LIBS += -L$$OUT_PWD/../../lib -lzeiterfassungcorelib -lzeiterfassungguilib
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/../../zeiterfassungcorelib $$PWD/../../zeiterfassungguilib
|
||||||
|
DEPENDPATH += $$PWD/../../zeiterfassungcorelib $$PWD/../../zeiterfassungguilib
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT
|
||||||
|
|
||||||
|
HEADERS += devtoolsplugin.h \
|
||||||
|
logmodel.h \
|
||||||
|
logdialog.h
|
||||||
|
|
||||||
|
SOURCES += devtoolsplugin.cpp \
|
||||||
|
logmodel.cpp \
|
||||||
|
logdialog.cpp
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
logdialog.ui
|
||||||
|
|
||||||
|
RESOURCES += devtoolsplugin_resources.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += translations/devtoolsplugin_en.ts \
|
||||||
|
translations/devtoolsplugin_de.ts
|
||||||
|
|
||||||
|
OTHER_FILES += devtoolsplugin.json
|
||||||
|
|
||||||
|
include(../../lrelease.pri)
|
||||||
|
|
||||||
|
COMPILED_TRANSLATIONS += $${OUT_PWD}/translations/devtoolsplugin_en.qm \
|
||||||
|
$${OUT_PWD}/translations/devtoolsplugin_de.qm
|
||||||
|
|
||||||
|
include(../copy_translations.pri)
|
5
plugins/devtoolsplugin/devtoolsplugin_resources.qrc
Normal file
5
plugins/devtoolsplugin/devtoolsplugin_resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/zeiterfassung/plugins/devtoolsplugin">
|
||||||
|
<file>images/dev-tools.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
plugins/devtoolsplugin/images/dev-tools.png
Normal file
BIN
plugins/devtoolsplugin/images/dev-tools.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
19
plugins/devtoolsplugin/logdialog.cpp
Normal file
19
plugins/devtoolsplugin/logdialog.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "logdialog.h"
|
||||||
|
#include "ui_logdialog.h"
|
||||||
|
|
||||||
|
LogDialog::LogDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::LogDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDialog::~LogDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogDialog::setModel(QAbstractItemModel *model)
|
||||||
|
{
|
||||||
|
ui->treeView->setModel(model);
|
||||||
|
}
|
24
plugins/devtoolsplugin/logdialog.h
Normal file
24
plugins/devtoolsplugin/logdialog.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef LOGDIALOG_H
|
||||||
|
#define LOGDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class QAbstractItemModel;
|
||||||
|
|
||||||
|
namespace Ui { class LogDialog; }
|
||||||
|
|
||||||
|
class LogDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LogDialog(QWidget *parent = 0);
|
||||||
|
~LogDialog();
|
||||||
|
|
||||||
|
void setModel(QAbstractItemModel *model);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::LogDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGDIALOG_H
|
67
plugins/devtoolsplugin/logdialog.ui
Normal file
67
plugins/devtoolsplugin/logdialog.ui
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LogDialog</class>
|
||||||
|
<widget class="QDialog" name="LogDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>694</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Log</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="treeView"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>LogDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>LogDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
80
plugins/devtoolsplugin/logmodel.cpp
Normal file
80
plugins/devtoolsplugin/logmodel.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#include "logmodel.h"
|
||||||
|
|
||||||
|
LogModel::LogModel(QObject *parent) :
|
||||||
|
QAbstractListModel(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogModel::log(QtMsgType type, const char *fileName, int lineNumber, const char *functionName, const char *categoryName, const QString &message)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), m_entries.count(), m_entries.count());
|
||||||
|
m_entries.append(Entry { QDateTime::currentDateTime(), type, fileName, lineNumber, functionName, categoryName, message });
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
int LogModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
return m_entries.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int LogModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LogModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(index.row() < m_entries.count());
|
||||||
|
const auto &entry = m_entries.at(index.row());
|
||||||
|
|
||||||
|
switch(role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::EditRole:
|
||||||
|
switch(index.column())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
switch(entry.type)
|
||||||
|
{
|
||||||
|
case QtDebugMsg: return tr("Debug");
|
||||||
|
case QtWarningMsg: return tr("Warning");
|
||||||
|
case QtCriticalMsg: return tr("Critical");
|
||||||
|
case QtFatalMsg: return tr("Fatal");
|
||||||
|
case QtInfoMsg: return tr("Info");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 1: return entry.dateTime.toString(QStringLiteral("dd.MM.yyyy HH:mm:ss.zzz"));
|
||||||
|
case 2: return entry.functionName;
|
||||||
|
case 3: return entry.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LogModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
switch(orientation)
|
||||||
|
{
|
||||||
|
case Qt::Horizontal:
|
||||||
|
switch(role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::EditRole:
|
||||||
|
switch(section)
|
||||||
|
{
|
||||||
|
case 0: return tr("Type");
|
||||||
|
case 1: return tr("Timestamp");
|
||||||
|
case 2: return tr("Function");
|
||||||
|
case 3: return tr("Message");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qt_noop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
39
plugins/devtoolsplugin/logmodel.h
Normal file
39
plugins/devtoolsplugin/logmodel.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef LOGMODEL_H
|
||||||
|
#define LOGMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <qlogging.h>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
class LogModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LogModel(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
void log(QtMsgType type, const char *fileName, int lineNumber, const char *functionName, const char *categoryName, const QString &message);
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
||||||
|
int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Entry
|
||||||
|
{
|
||||||
|
QDateTime dateTime;
|
||||||
|
QtMsgType type;
|
||||||
|
const char *fileName;
|
||||||
|
int lineNumber;
|
||||||
|
const char *functionName;
|
||||||
|
const char *categoryName;
|
||||||
|
QString message;
|
||||||
|
};
|
||||||
|
|
||||||
|
QList<Entry> m_entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGMODEL_H
|
57
plugins/devtoolsplugin/translations/devtoolsplugin_de.ts
Normal file
57
plugins/devtoolsplugin/translations/devtoolsplugin_de.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="de_DE">
|
||||||
|
<context>
|
||||||
|
<name>DevToolsPlugin</name>
|
||||||
|
<message>
|
||||||
|
<source>Show log</source>
|
||||||
|
<translation>Log anzeigen</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>LogDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>Log</source>
|
||||||
|
<translation>Log</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>LogModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Type</source>
|
||||||
|
<translation>Typ</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Timestamp</source>
|
||||||
|
<translation>Zeitpunkt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Function</source>
|
||||||
|
<translation>Funktion</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message</source>
|
||||||
|
<translation>Nachricht</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Debug</source>
|
||||||
|
<translation>Debug</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Warning</source>
|
||||||
|
<translation>Warnung</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Critical</source>
|
||||||
|
<translation>Kritisch</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fatal</source>
|
||||||
|
<translation>Fatal</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Info</source>
|
||||||
|
<translation>Info</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
57
plugins/devtoolsplugin/translations/devtoolsplugin_en.ts
Normal file
57
plugins/devtoolsplugin/translations/devtoolsplugin_en.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>DevToolsPlugin</name>
|
||||||
|
<message>
|
||||||
|
<source>Show log</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>LogDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>Log</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>LogModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Type</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Timestamp</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Function</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Debug</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Warning</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Critical</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fatal</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Info</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
@@ -1,6 +1,7 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += advancedviewplugin \
|
SUBDIRS += advancedviewplugin \
|
||||||
|
devtoolsplugin \
|
||||||
lunchmealplugin \
|
lunchmealplugin \
|
||||||
presenceplugin \
|
presenceplugin \
|
||||||
reportsplugin \
|
reportsplugin \
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -32,7 +34,7 @@ struct {
|
|||||||
QTranslator zeiterfassungguilibTranslator;
|
QTranslator zeiterfassungguilibTranslator;
|
||||||
} translators;
|
} translators;
|
||||||
|
|
||||||
QVector<ZeiterfassungPlugin*> plugins;
|
QVector<std::shared_ptr<QPluginLoader> > pluginLoaders;
|
||||||
|
|
||||||
bool loadAndInstallTranslator(QTranslator &translator, const QString &filename)
|
bool loadAndInstallTranslator(QTranslator &translator, const QString &filename)
|
||||||
{
|
{
|
||||||
@@ -270,44 +272,25 @@ bool loadPlugins(QSplashScreen &splashScreen)
|
|||||||
).absoluteFilePath(QStringLiteral("zeiterfassung"))
|
).absoluteFilePath(QStringLiteral("zeiterfassung"))
|
||||||
);
|
);
|
||||||
|
|
||||||
for(const auto &fileInfo : dir.entryInfoList(QDir::Files))
|
for(const auto &fileInfo : dir.entryInfoList(QDir::Files | QDir::NoSymLinks))
|
||||||
{
|
{
|
||||||
if(fileInfo.isSymLink())
|
|
||||||
{
|
|
||||||
qWarning() << "skipping" << fileInfo.fileName() << "because symlink";
|
|
||||||
continue; // to skip unix so symlinks
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!QLibrary::isLibrary(fileInfo.filePath()))
|
if(!QLibrary::isLibrary(fileInfo.filePath()))
|
||||||
{
|
{
|
||||||
qWarning() << "skipping" << fileInfo.fileName() << "because no QLibrary";
|
qWarning() << "skipping" << fileInfo.fileName() << "because no QLibrary";
|
||||||
continue; // to skip windows junk files
|
continue; // to skip windows junk files
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "loading" << fileInfo.fileName();
|
auto pluginLoader = std::make_shared<QPluginLoader>(fileInfo.filePath());
|
||||||
|
if(!pluginLoader->load())
|
||||||
QPluginLoader loader(fileInfo.filePath());
|
|
||||||
if(!loader.load())
|
|
||||||
{
|
{
|
||||||
QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load plugin %0!"),
|
QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Could not load plugin %0!"),
|
||||||
QCoreApplication::translate("main", "Could not load plugin %0!").arg(fileInfo.fileName()) %
|
QCoreApplication::translate("main", "Could not load plugin %0!").arg(fileInfo.fileName()) %
|
||||||
"\n\n" % loader.errorString());
|
"\n\n" % pluginLoader->errorString());
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto plugin = qobject_cast<ZeiterfassungPlugin*>(loader.instance());
|
pluginLoaders.append(pluginLoader);
|
||||||
|
|
||||||
if(!plugin)
|
|
||||||
{
|
|
||||||
QMessageBox::warning(&splashScreen, QCoreApplication::translate("main", "Plugin not valid %0!"),
|
|
||||||
QCoreApplication::translate("main", "Plugin not valid %0!").arg(fileInfo.fileName()) %
|
|
||||||
"\n\n" % loader.errorString());
|
|
||||||
ok = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.append(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -370,8 +353,13 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow mainWindow(settings, erfassung, userInfo, stripFactory);
|
MainWindow mainWindow(settings, erfassung, userInfo, stripFactory);
|
||||||
splashScreen.finish(&mainWindow);
|
splashScreen.finish(&mainWindow);
|
||||||
|
|
||||||
for(auto plugin : plugins)
|
for(auto &pluginLoader : pluginLoaders)
|
||||||
plugin->attachTo(mainWindow);
|
if(auto plugin = qobject_cast<ZeiterfassungPlugin*>(pluginLoader->instance()))
|
||||||
|
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();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user