From: Konrad Rosenbaum Date: Sat, 9 Jul 2016 22:55:55 +0000 (+0200) Subject: move more stuff to commonlib and make session manager more powerful X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=71a0c97c7a03e7fc8e8660a10240ea800b020638;p=web%2Fkonrad%2Fsmoke.git move more stuff to commonlib and make session manager more powerful --- diff --git a/Makefile b/Makefile index 784629c..1168e00 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ server: wob client: wob taurus tzone wbase cd iface && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) - cd cfglib && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) + cd commonlib && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) cd sesscli && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) cd src && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) cd mainapp && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) diff --git a/commonlib/commonexport.h b/commonlib/commonexport.h new file mode 100644 index 0000000..921f2ca --- /dev/null +++ b/commonlib/commonexport.h @@ -0,0 +1,8 @@ + +#include + +#ifndef MAGICSMOKE_COMMON_LIB_BUILD +#define MAGICSMOKE_COMMON_EXPORT Q_DECL_EXPORT +#else +#define MAGICSMOKE_COMMON_EXPORT Q_DECL_IMPORT +#endif diff --git a/commonlib/commonlib.pri b/commonlib/commonlib.pri new file mode 100644 index 0000000..8b3f2c5 --- /dev/null +++ b/commonlib/commonlib.pri @@ -0,0 +1,10 @@ +#Include PRI for the config library + +LIBS += -lmagicsmoke-common +INCLUDEPATH += $$PWD/../commonlib $$PWD/../commonlib/crypto $$PWD/../commonlib/widgets $$PWD/../commonlib/misc $$PWD/../commonlib/templates +QT += gui widgets + +include($$PWD/../iface/iface.pri) +include($$PWD/../taurus/zip.pri) +include($$PWD/../taurus/elam.pri) +include($$PWD/../taurus/aurora.pri) diff --git a/commonlib/commonlib.pro b/commonlib/commonlib.pro new file mode 100644 index 0000000..b739fe9 --- /dev/null +++ b/commonlib/commonlib.pro @@ -0,0 +1,36 @@ +#Project File for MagicSmoke Config Classes +# (c) Konrad Rosenbaum, 2016 + +#basics +TEMPLATE = lib +VERSION = 0.1 +TARGET = magicsmoke-common + +include(../basics.pri) +include(../iface/iface.pri) +include(../taurus/zip.pri) +include(../taurus/elam.pri) +include(../taurus/aurora.pri) + +#Localization +TRANSLATIONS = \ + smoke-common_de.ts \ + smoke-common_en.ts + +#main source files +HEADERS += configdialog.h mapplication.h +SOURCES += configdialog.cpp mapplication.cpp +INCLUDEPATH += . +DEPENDPATH += $$INCLUDEPATH + +include(crypto/crypto.pri) +include(widgets/widgets.pri) +include(misc/misc.pri) +include(templates/templates.pri) + + +#make sure exports are ok +DEFINES += MAGICSMOKE_COMMON_LIB_BUILD=1 + +#make sure the correct Qt DLLs are used +QT += gui widgets network printsupport diff --git a/src/dialogs/configdialog.cpp b/commonlib/configdialog.cpp similarity index 99% rename from src/dialogs/configdialog.cpp rename to commonlib/configdialog.cpp index 6b03e50..d4aab14 100644 --- a/src/dialogs/configdialog.cpp +++ b/commonlib/configdialog.cpp @@ -1,5 +1,5 @@ // -// C++ Implementation: mainwindow +// C++ Implementation: config dialog // // Description: // @@ -11,7 +11,7 @@ // #include "keygen.h" -#include "main.h" +#include "mapplication.h" #include "configdialog.h" #include "office.h" #include "listview.h" @@ -410,7 +410,7 @@ void MConfigDialog::defaultProfile() void MConfigDialog::changeLang() { - choseLanguage(); + MApplication::choseLanguage(); } void MConfigDialog::exportKey() @@ -553,7 +553,7 @@ void MConfigDialog::serverProbe() QNetworkAccessManager man; connect(&man,SIGNAL(finished(QNetworkReply*)),&loop,SLOT(quit())); QTimer::singleShot(30000,&loop,SLOT(quit())); - connect(&man,SIGNAL(sslErrors(QNetworkReply*,const QList&)), this,SLOT(sslErrors(QNetworkReply*,QList))); + connect(&man,SIGNAL(sslErrors(QNetworkReply*,const QList&)), this,SLOT(sslErrors(QNetworkReply*,QList))); if(useproxy->isChecked()) man.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,proxyname->text(),proxyport->value(),proxyuser->text(),proxypass->text())); //query server diff --git a/src/dialogs/configdialog.h b/commonlib/configdialog.h similarity index 92% rename from src/dialogs/configdialog.h rename to commonlib/configdialog.h index 6200948..5a75635 100644 --- a/src/dialogs/configdialog.h +++ b/commonlib/configdialog.h @@ -27,8 +27,10 @@ class QTableView; class MSslExceptions; +#include "commonexport.h" + /**login and profile configuration window*/ -class MConfigDialog:public QDialog +class MAGICSMOKE_COMMON_EXPORT MConfigDialog:public QDialog { Q_OBJECT public: @@ -79,7 +81,7 @@ class MConfigDialog:public QDialog class QComboBox; class QLineEdit; -class MAppStyleDialog:public QDialog +class MAGICSMOKE_COMMON_EXPORT MAppStyleDialog:public QDialog { Q_OBJECT public: diff --git a/src/crypto/crypto.pri b/commonlib/crypto/crypto.pri similarity index 100% rename from src/crypto/crypto.pri rename to commonlib/crypto/crypto.pri diff --git a/src/crypto/hmac.cpp b/commonlib/crypto/hmac.cpp similarity index 100% rename from src/crypto/hmac.cpp rename to commonlib/crypto/hmac.cpp diff --git a/src/crypto/hmac.h b/commonlib/crypto/hmac.h similarity index 96% rename from src/crypto/hmac.h rename to commonlib/crypto/hmac.h index fc177c7..f2c8ddd 100644 --- a/src/crypto/hmac.h +++ b/commonlib/crypto/hmac.h @@ -15,8 +15,10 @@ #include +#include "commonexport.h" + /**Calculate a cryptographic HMAC (used by authentication algorithm)*/ -class SMHmac +class MAGICSMOKE_COMMON_EXPORT SMHmac { public: /**constructs an object that calculates HMACs*/ diff --git a/src/crypto/keygen.cpp b/commonlib/crypto/keygen.cpp similarity index 100% rename from src/crypto/keygen.cpp rename to commonlib/crypto/keygen.cpp diff --git a/src/crypto/keygen.h b/commonlib/crypto/keygen.h similarity index 79% rename from src/crypto/keygen.h rename to commonlib/crypto/keygen.h index b822974..92df7eb 100644 --- a/src/crypto/keygen.h +++ b/commonlib/crypto/keygen.h @@ -19,7 +19,9 @@ class QLabel; class QPushButton; -class MKeyGen:public QDialog +#include "commonexport.h" + +class MAGICSMOKE_COMMON_EXPORT MKeyGen:public QDialog { Q_OBJECT public: @@ -38,7 +40,7 @@ class MKeyGen:public QDialog void updateProps(); }; -class EFilter:public QObject +class MAGICSMOKE_COMMON_EXPORT EFilter:public QObject { Q_OBJECT public: @@ -60,7 +62,7 @@ class EFilter:public QObject }; //shortcut: -QByteArray getRandom(int); -int getEntropy(); +MAGICSMOKE_COMMON_EXPORT QByteArray getRandom(int); +MAGICSMOKE_COMMON_EXPORT int getEntropy(); #endif diff --git a/commonlib/mapplication.cpp b/commonlib/mapplication.cpp new file mode 100644 index 0000000..e82efc5 --- /dev/null +++ b/commonlib/mapplication.cpp @@ -0,0 +1,466 @@ +// +// C++ Implementation: main +// +// Description: Main Program +// +// +// Author: Konrad Rosenbaum , (C) 2007-2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "configdialog.h" +#include "debug.h" +#include "barcode-plugin.h" +#include "hmac.h" +#include "keygen.h" +#include "mapplication.h" +// #include "login.h" +#include "msinterface.h" +#include +#include "misc.h" +#include +#include "boxwrapper.h" + +QString MApplication::choseLanguage(bool warn) +{ + QString lang=QSettings().value("lang","--").toString(); + if(lang=="--"){ + lang=QLocale::system().name(); + } + int cur=0; + QStringList langs; + langs<<"C - default"; + QStringList files=QDir(QApplication::applicationDirPath()).entryList(QStringList()<<"smoke_*.qm", QDir::Files, QDir::Name); + for(int i=0;isetMinimumDuration(0); + pd->show(); + } + ~MProgressWrapperGui() + { + if(pd)pd->deleteLater(); + pd=0; + } + virtual void setLabelText(QString l) + { + pd->setLabelText(l); + } + virtual void setCancelButtonText(QString t) + { + pd->setCancelButtonText(t); + } + virtual void cancel() + { + pd->cancel(); + } + virtual void setRange(int mi,int ma) + { + pd->setRange(mi,ma); + } + virtual void setValue(int v) + { + pd->setValue(v); + } +}; + +#ifndef HOMEPAGE_BASEURL +#define HOMEPAGE_BASEURL "http://smoke.silmor.de" +#endif + +void MApplication::aboutMS() +{ + QMessageBox mb; + mb.setIconPixmap(QPixmap(":/icon.png")); + mb.setWindowTitle(tr("About MagicSmoke")); + MSInterface*ifc=MSInterface::instance(); + mb.setText(tr( "

MagicSmoke v. %1

" + "© Konrad Rosenbaum, 2007-2013
" + "© Peter Keller, 2007-2008
" + "protected under the GNU GPL v.3 or at your option any newer

" + "See also the MagicSmoke Homepage.

" + "This version was compiled from repository '%3' revision '%4'.

" + "The current application data base path is '%5'.") + .arg(MSInterface::staticVersionInfo(WOb::VersionHR)) //%1 + .arg(HOMEPAGE_BASEURL) //%2 + .arg(MSInterface::staticVersionInfo(WOb::VersionRootURL)) //%3 + .arg(MSInterface::staticVersionInfo(WOb::VersionNumber)) //%4 + .arg(ifc?ifc->dataDir(): dataDir()) + ); + mb.setStandardButtons(QMessageBox::Ok); + mb.exec(); +} + +void MApplication::versionDlg() +{ + QMessageBox mb; + mb.setIconPixmap(QPixmap(":/icon.png")); + mb.setWindowTitle(tr("MagicSmoke Version Information")); + TimeZoneLib::TZFile tzf=TimeStamp::defaultZoneFile(); + auto unknown=[](const QString&s)->QString{if(s.isEmpty())return "(unknown)";else return "'"+s+"'";}; + mb.setText(tr( "

MagicSmoke Version %3

" + "" + "" + "" + "" + "" + "" + "
Repository:%1
Revision:%2
Modification State:%4
Commit Time:%5
Committer:%6

\n" + "

Libraries

\n" + "" + "" + "" + "" + "" + "" + "
WOC:%7
%8
PACK Library:%9
%10
Qt:%11
ELAM:%12
Time Zone Default:%13 in directory %14
version %15
Time Zone Built-In:%16 (library: %17)
" + ) + .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionRootURL))) // %1 + .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionNumber))) //%2 + .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionHR))) //%3 + .arg(MSInterface::staticVersionInfo(WOb::VersionLocallyModified)) //%4 + .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionTime))) //%5 + .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionAuthor))) //&6 + .arg(htmlize(MSInterface::staticWocVersionInfo(WOb::VersionRootURL))) //%7 + .arg(htmlize(MSInterface::staticWocVersionInfo(WOb::VersionNumber))) + .arg(htmlize(WInterface::staticLibraryVersionInfo(WOb::VersionRootURL))) //%9 + .arg(htmlize(WInterface::staticLibraryVersionInfo(WOb::VersionNumber))) + .arg(htmlize(QT_VERSION_STR)) //%11 + .arg(htmlize(ELAM::versionInfo())) //%12 + .arg(unknown(tzf.name())) //%13 + .arg(unknown(tzf.dirName())) + .arg(unknown(tzf.version())) + .arg(TimeZoneLib::TZFile::builtinVersion()) //%16 + .arg(TimeZoneLib::TZFile::libraryVersion()) //%17 + ); + mb.setStandardButtons(QMessageBox::Ok); + mb.exec(); +} + + +struct HelpUrl { + enum Type {None, Item, Separator} type=None; + QString label,url; + HelpUrl(Type t,QString l,QString u=QString()):type(t),label(l),url(u){} +}; +static QList helpUrl; + +static void loadHelpUrlFile(const QString&fname) +{ + QFile fd(fname); + QList urls; + //try to open + if(fd.open(QIODevice::ReadOnly)){ + //read config + QDomDocument doc; + doc.setContent(&fd); + QDomNodeList nl=doc.documentElement().childNodes(); + for(int i=0;i0 && urls.size()>0)helpUrl.append(HelpUrl(HelpUrl::Separator,"")); + helpUrl.append(urls); +} + +void MApplication::initHelpUrl() +{ + //check file exists, if not initialize it + loadHelpUrlFile(dataDir()+"/helpMenu.xml"); + loadHelpUrlFile(applicationDirPath()+"/helpMenu.xml"); + //fallback + if(helpUrl.size()<1) + helpUrl<addSeparator()->setText(helpUrl[i].label); + }else{ + QAction*a=m->addAction(helpUrl[i].label,map,SLOT(map())); + map->setMapping(a,i); + } + } + m->addSeparator(); + m->addAction("About &MagicSmoke",qApp,SLOT(aboutMS())); + m->addAction("About &Qt",qApp,SLOT(aboutQt())); + m->addAction("&Version Info",qApp,SLOT(versionDlg())); + return m; +} + +static inline QUrl convHelpUrl(QUrl s) +{ + if(s.scheme()=="default"){ + static const QString ad=QApplication::applicationDirPath()+"/doc/"; + if(QFile(ad+"index.html").exists()) + return QUrl::fromLocalFile(ad+s.path()); + else + //TODO: allow different versions? + return HOMEPAGE_BASEURL "/doc/" + s.path(); + } + else return s; +} + + + +void MApplication::help() +{ + qDebug()<<"Opening default help..."; + QDesktopServices::openUrl(convHelpUrl(QUrl("default:/index.html"))); +} + +void MApplication::help(int idx) +{ + if(idx<0 || idx>=helpUrl.size()){ + help(); + return; + } + QUrl u=convHelpUrl(helpUrl[idx].url); + qDebug()<<"Opening help:"<MProgressWrapper*{ + return new MProgressWrapperGui(label,button); + }); + + //check parameters +// qDebug()<<"arguments"<load(prog+"_"+lang,lpath[i]); + QString msg=QString("...loading %1_%2 from %3 ...%4") + .arg(prog).arg(lang) + .arg(lpath[i]) + .arg(ok?"ok":"failed"); + qDebug("%s",msg.toLatin1().data()); + if(ok)return; + } +} + +void MApplication::initLanguage() +{ + //try to find appropriate locale + QString lang=QSettings().value("lang","--").toString(); + if(lang=="--"){ + lang=choseLanguage(false); + } + qDebug("Loading language %s",lang.toLatin1().data()); + //load Qt translation + loadTranslation(qttrans=new QTranslator(this),lang,"qt"); + installTranslator(qttrans); + //load magicSmoke translation + loadTranslation(mstrans=new QTranslator(this),lang,"smoke"); + installTranslator(mstrans); + //load Pack translation + QTranslator*xtrans; + loadTranslation(xtrans=new QTranslator(this),lang,"qwbase"); + installTranslator(xtrans); + //detect and load remaining modules + QStringList files=QDir(applicationDirPath()).entryList(QStringList()<<"smoke-*.qm",QDir::Files|QDir::Readable,QDir::Name); + QStringList loaded, modules; + // --> stage 1: find modules + for(auto file:files){ + QString m=file.split('_').value(0); + if(!m.isEmpty() && !modules.contains(m)) + modules.append(m); + } + // --> stage 2: go through modules and load + for(auto mod:modules){ + loadTranslation(xtrans=new QTranslator(this),lang,mod); + installTranslator(xtrans); + } + //defaults + if(lang!="--"&&lang!=""){ + QLocale::setDefault(lang); +#ifndef Q_OS_WIN + setenv("LANG",lang.toLatin1().data(),1); + }else{ + setenv("LANG","C",1); +#endif + } +} + +void MApplication::initialize() +{ + //load the correct style + setMyStyle(); + //initialize log file + initDebug(dataDir()); + //init localization and profiles + initLanguage(); + initProfile(); + //init help menu layout + initHelpUrl(); + //init updater + initUpdater(); + //init plugins + MBarcodeHub::instance()->initialize(); +} + +void MApplication::initUpdater() +{ + updater=new Aurora(applicationDirPath()+"/magicsmoke.xml",this); + connect(updater,SIGNAL(newVersionAvailable(QString)),this,SLOT(updateReadyDownload(QString))); + connect(updater,SIGNAL(readyForInstallation()),this,SLOT(updaterReadyInstall())); + connect(updater,SIGNAL(installationFinished()),this,SLOT(updaterCompleted())); + connect(updater,SIGNAL(downloadFailed()),this,SLOT(updaterFailed())); + connect(updater,SIGNAL(installationFailed()),this,SLOT(updaterFailed())); + //we ignore all errors that happen prior to successful verification, since they + //would create too much noise +} + +void MApplication::updateReadyDownload(const QString& v) +{ + qDebug()<<"Asking for Download permission"; + QMessageBox::StandardButton r=QMessageBox::question(0,tr("New Update"),tr("A new version of MagicSmoke is available. Do you want to download the new version %1?").arg(v),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); + if(r==QMessageBox::Yes) + updater->startDownload(); +} + +void MApplication::updaterReadyInstall() +{ + QMessageBox::Button r=QMessageBox::question(0,tr("New Update"),tr("A new version of MagicSmoke is ready for installation. Do you want to install?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); + if(r==QMessageBox::Yes) + updater->startInstallation(); +} + +void MApplication::updaterCompleted() +{ + QMessageBox::information(0,tr("Update Complete"),tr("A new version of MagicSmoke has been installed. It will be used the next time you start MagicSmoke.")); +} + +void MApplication::updaterFailed() +{ + QMessageBox::warning(0,tr("Update Failed"),tr("An update of MagicSmoke failed.")); +} + +QString MApplication::dataDir() +{ + return MSInterface::appDataDir(); +} + +void MApplication::initProfile() +{ + //check/generate profile + if(!QSettings().childGroups().contains("profiles")){ + QMessageBox::warning(0,translate("initprofile","Initial Profile Warning"), translate("initprofile","You need a profile to work with Magic Smoke. Please create one now.")); + MConfigDialog().exec(); + } +} diff --git a/commonlib/mapplication.h b/commonlib/mapplication.h new file mode 100644 index 0000000..eb17647 --- /dev/null +++ b/commonlib/mapplication.h @@ -0,0 +1,94 @@ +// +// C++ Interface: main +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007-2014 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MAPP_H +#define MAGICSMOKE_MAPP_H + +#include +#include + +#include "commonexport.h" + +class QMenu; +class EFilter; +namespace AuroraUpdater{class Aurora;}; +///Main application object of MagicSmoke +class MAGICSMOKE_COMMON_EXPORT MApplication:public QApplication +{ + Q_OBJECT + public: + ///create MagicSmoke application + MApplication(int&ac,char**av); + + ///return the standard help menu + static QMenu*helpMenu(); + + ///shortcut: the main function + static int realmain(int,char**); + /**contains the directory that is used for external data storage*/ + static QString dataDir(); + /**show a dialog to change the language*/ + static QString choseLanguage(bool warn=true); + + ///override the data directory + ///- call it before any of the init functions + ///- never call this while a session is active! + static void setDataDir(QString); + ///override the configuration directory + ///- call this before initialize + ///- on Windows and MacOS, this also switches the settings mode to ini-files + static void setConfigDir(QString); + public slots: + ///complete initialization: style, language, data dir + void initialize(); + ///set the configured application style + void setMyStyle(); + ///initialize the localization + void initLanguage(); + ///initialize the profiles + void initProfile(); + + ///show about dialog + void aboutMS(); + ///show version info + void versionDlg(); + ///start a browser with the help page + void help(); + private slots: + ///jump to a specific help page + void help(int); + + ///initialize the help menu from config files + void initHelpUrl(); + + ///initialize the updater + void initUpdater(); + + ///updater is ready for download + void updateReadyDownload(const QString&); + ///updater is ready for install + void updaterReadyInstall(); + ///update complete + void updaterCompleted(); + ///something failed for the updater + void updaterFailed(); + + private: + EFilter *ef=nullptr; + QTranslator*qttrans=nullptr,*mstrans=nullptr; + AuroraUpdater::Aurora*updater=nullptr; +}; + +///return the instance of the MApplication +#define mApp (qobject_cast(qApp)) + +#endif diff --git a/src/misc/barcode-plugin.cpp b/commonlib/misc/barcode-plugin.cpp similarity index 100% rename from src/misc/barcode-plugin.cpp rename to commonlib/misc/barcode-plugin.cpp diff --git a/src/misc/barcode-plugin.h b/commonlib/misc/barcode-plugin.h similarity index 91% rename from src/misc/barcode-plugin.h rename to commonlib/misc/barcode-plugin.h index dbeb6b3..ee6034f 100644 --- a/src/misc/barcode-plugin.h +++ b/commonlib/misc/barcode-plugin.h @@ -13,11 +13,7 @@ #ifndef MAGICSMOKE_BARCODE_PLUGIN_H #define MAGICSMOKE_BARCODE_PLUGIN_H -#ifdef MAGICSMOKE_LIB_BUILD -#define MAGICSMOKE_EXPORT Q_DECL_EXPORT -#else -#define MAGICSMOKE_EXPORT Q_DECL_IMPORT -#endif +#include "commonexport.h" #include #include @@ -27,7 +23,7 @@ class QTabWidget; ///Scanner Configuration Dialog -class MAGICSMOKE_EXPORT MBarcodeConfiguration:public QDialog +class MAGICSMOKE_COMMON_EXPORT MBarcodeConfiguration:public QDialog { Q_OBJECT public: @@ -43,7 +39,7 @@ class MAGICSMOKE_EXPORT MBarcodeConfiguration:public QDialog }; ///base class of actual scanner implementations -class MAGICSMOKE_EXPORT MBarcodeScanner:public QObject +class MAGICSMOKE_COMMON_EXPORT MBarcodeScanner:public QObject { Q_OBJECT public: @@ -70,7 +66,7 @@ class MAGICSMOKE_EXPORT MBarcodeScanner:public QObject }; ///base class of barcode scanner plugins -class MAGICSMOKE_EXPORT MBarcodePlugin +class MAGICSMOKE_COMMON_EXPORT MBarcodePlugin { public: virtual ~MBarcodePlugin(); @@ -84,7 +80,7 @@ class MAGICSMOKE_EXPORT MBarcodePlugin ///central barcode scanner hub, this is used by widgets that require barcodes, ///plugins report (indirectly) to the hub -class MAGICSMOKE_EXPORT MBarcodeHub:public QObject +class MAGICSMOKE_COMMON_EXPORT MBarcodeHub:public QObject { Q_OBJECT public: diff --git a/src/misc/code39.cpp b/commonlib/misc/code39.cpp similarity index 100% rename from src/misc/code39.cpp rename to commonlib/misc/code39.cpp diff --git a/src/misc/code39.h b/commonlib/misc/code39.h similarity index 88% rename from src/misc/code39.h rename to commonlib/misc/code39.h index 7d515f9..8a4a6d7 100644 --- a/src/misc/code39.h +++ b/commonlib/misc/code39.h @@ -13,7 +13,9 @@ #include #include +#include "commonexport.h" + /**Takes a string and converts it into a code-39 bar code. Code-39 allows letters (case-insensitive), digits, spaces and the special chars "-.$/+%". The bar code pixmap will be 1 pixel high and 16 pixels wide for each character (plus start/stop character and checksum character) - it needs to be scaled up to fit the intended size.*/ -QImage code39(QString); +MAGICSMOKE_COMMON_EXPORT QImage code39(QString); diff --git a/src/misc/debug.cpp b/commonlib/misc/debug.cpp similarity index 95% rename from src/misc/debug.cpp rename to commonlib/misc/debug.cpp index f2f92a8..986074f 100644 --- a/src/misc/debug.cpp +++ b/commonlib/misc/debug.cpp @@ -11,7 +11,7 @@ // #include "debug.h" -#include "main.h" +// #include "main.h" #include #include @@ -33,13 +33,12 @@ static void mymsghandler(QtMsgType,const QMessageLogContext&, const QString&msg) #endif } -void initDebug() +void initDebug(const QString&dataDir) { if(QCoreApplication::instance()->arguments().contains("-nolog")){ qDebug()<<"-nolog argument was given, will not create a log file"; } //create new log file - const QString&dataDir=MApplication::dataDir(); QDir(dataDir).mkpath("debuglog"); mylogFile=new QFile(dataDir+"/debuglog/log-"+QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss.zzz")+".txt"); //...open it diff --git a/src/misc/debug.h b/commonlib/misc/debug.h similarity index 74% rename from src/misc/debug.h rename to commonlib/misc/debug.h index a95db1e..cff5546 100644 --- a/src/misc/debug.h +++ b/commonlib/misc/debug.h @@ -13,6 +13,8 @@ #ifndef MAGICSMOKE_DEBUG_H #define MAGICSMOKE_DEBUG_H -void initDebug(); +#include "commonexport.h" + +MAGICSMOKE_COMMON_EXPORT void initDebug(const QString&dataDir); #endif diff --git a/src/misc/domiterator.h b/commonlib/misc/domiterator.h similarity index 94% rename from src/misc/domiterator.h rename to commonlib/misc/domiterator.h index 5161c53..15759e7 100644 --- a/src/misc/domiterator.h +++ b/commonlib/misc/domiterator.h @@ -11,7 +11,9 @@ #ifndef SMOKE_DOM_ITERATOR_H #define SMOKE_DOM_ITERATOR_H -class QDomNodeIterator +#include "commonexport.h" + +class MAGICSMOKE_COMMON_EXPORT QDomNodeIterator { int pos; const QDomNodeList&container; diff --git a/src/misc/dommodel.cpp b/commonlib/misc/dommodel.cpp similarity index 100% rename from src/misc/dommodel.cpp rename to commonlib/misc/dommodel.cpp diff --git a/src/misc/dommodel.h b/commonlib/misc/dommodel.h similarity index 98% rename from src/misc/dommodel.h rename to commonlib/misc/dommodel.h index 6086fe7..6b37a03 100644 --- a/src/misc/dommodel.h +++ b/commonlib/misc/dommodel.h @@ -19,6 +19,8 @@ #include +#include "commonexport.h" + class QDomNode; class QDomDocument; @@ -30,7 +32,7 @@ typedef std::function MDomModelFunctor; The model holds a copy of the DOM tree, so the original is not changed even if the model changes. You can retrieve a current copy of the model's DOM tree by calling domDocument(). This model can not carry application specific user data. It is only editable through its specialized node methods.*/ -class MDomItemModel:public QAbstractItemModel +class MAGICSMOKE_COMMON_EXPORT MDomItemModel:public QAbstractItemModel { Q_OBJECT DECLARE_DPTR(d); diff --git a/src/misc/misc.pri b/commonlib/misc/misc.pri similarity index 100% rename from src/misc/misc.pri rename to commonlib/misc/misc.pri diff --git a/src/misc/sclock.cpp b/commonlib/misc/sclock.cpp similarity index 100% rename from src/misc/sclock.cpp rename to commonlib/misc/sclock.cpp diff --git a/src/misc/sclock.h b/commonlib/misc/sclock.h similarity index 87% rename from src/misc/sclock.h rename to commonlib/misc/sclock.h index 6fbb7de..6e80b8a 100644 --- a/src/misc/sclock.h +++ b/commonlib/misc/sclock.h @@ -15,12 +15,13 @@ #include +#include "commonexport.h" class QMenu; class QAction; -class MServerClock:public QLabel +class MAGICSMOKE_COMMON_EXPORT MServerClock:public QLabel { Q_OBJECT public: diff --git a/src/misc/waitcursor.cpp b/commonlib/misc/waitcursor.cpp similarity index 100% rename from src/misc/waitcursor.cpp rename to commonlib/misc/waitcursor.cpp diff --git a/src/misc/waitcursor.h b/commonlib/misc/waitcursor.h similarity index 87% rename from src/misc/waitcursor.h rename to commonlib/misc/waitcursor.h index f1082cf..29aecdb 100644 --- a/src/misc/waitcursor.h +++ b/commonlib/misc/waitcursor.h @@ -13,8 +13,10 @@ #ifndef MAGICSMOKE_WAITCURSOR_H #define MAGICSMOKE_WAITCURSOR_H +#include "commonexport.h" + /**simple class to show a busy-cursor while an instance of it exists*/ -class WaitCursor +class MAGICSMOKE_COMMON_EXPORT WaitCursor { public: /**displays a wait cursor (Qt::WaitCursor)*/ diff --git a/src/templates/labeldlg.cpp b/commonlib/templates/labeldlg.cpp similarity index 100% rename from src/templates/labeldlg.cpp rename to commonlib/templates/labeldlg.cpp diff --git a/src/templates/labeldlg.h b/commonlib/templates/labeldlg.h similarity index 95% rename from src/templates/labeldlg.h rename to commonlib/templates/labeldlg.h index 5bd0e4b..e3c18f5 100644 --- a/src/templates/labeldlg.h +++ b/commonlib/templates/labeldlg.h @@ -13,6 +13,8 @@ #ifndef MAGICSMOKE_LABELDLG_H #define MAGICSMOKE_LABELDLG_H +#include "commonexport.h" + #include #include #include @@ -26,7 +28,7 @@ class QPrinter; class QLabel; ///access to the label specific configuration -class MLabelConfig +class MAGICSMOKE_COMMON_EXPORT MLabelConfig { public: ///shows the configuration dialog @@ -130,13 +132,13 @@ class MLabelConfig friend QDataStream&operator<<(QDataStream&,const MLabelConfig&); friend QDataStream&operator>>(QDataStream&,MLabelConfig&); }; -QDataStream &operator<<(QDataStream &out, const MLabelConfig &myObj); -QDataStream &operator>>(QDataStream &in, MLabelConfig &myObj); +MAGICSMOKE_COMMON_EXPORT QDataStream &operator<<(QDataStream &out, const MLabelConfig &myObj); +MAGICSMOKE_COMMON_EXPORT QDataStream &operator>>(QDataStream &in, MLabelConfig &myObj); Q_DECLARE_METATYPE(MLabelConfig); ///dialog that allows to select which labels on a sheet of paper are used -class MLabelDialog:public QDialog +class MAGICSMOKE_COMMON_EXPORT MLabelDialog:public QDialog { Q_OBJECT public: @@ -199,7 +201,7 @@ class MLabelDialog:public QDialog ///Dialog that allows to configure details on how to print a label. -class MLabelPrintDialog:public QDialog +class MAGICSMOKE_COMMON_EXPORT MLabelPrintDialog:public QDialog { Q_OBJECT public: diff --git a/src/templates/odtrender.cpp b/commonlib/templates/odtrender.cpp similarity index 100% rename from src/templates/odtrender.cpp rename to commonlib/templates/odtrender.cpp diff --git a/src/templates/odtrender.h b/commonlib/templates/odtrender.h similarity index 91% rename from src/templates/odtrender.h rename to commonlib/templates/odtrender.h index cf99d14..25ba593 100644 --- a/src/templates/odtrender.h +++ b/commonlib/templates/odtrender.h @@ -17,15 +17,16 @@ #include #include "templates.h" +#include "commonexport.h" class MOdtRendererPrivate; class QFile; -extern const QString OdfTemplateNS; -extern const QString OdfTemplatePrefix; +MAGICSMOKE_COMMON_EXPORT extern const QString OdfTemplateNS; +MAGICSMOKE_COMMON_EXPORT extern const QString OdfTemplatePrefix; /**abstract base class for all ODT rendering classes*/ -class MOdtRenderer +class MAGICSMOKE_COMMON_EXPORT MOdtRenderer { public: /**instantiates a renderer loaded from template file*/ @@ -74,7 +75,7 @@ class MOdtRenderer }; /**generic class that implements MOdtRenderer by calling signals; the signals must be connected using a direct or blocking connection; if any of them is not used it will behave as if the variable/loop did not exist*/ -class MOdtSignalRenderer:public QObject,public MOdtRenderer +class MAGICSMOKE_COMMON_EXPORT MOdtSignalRenderer:public QObject,public MOdtRenderer { Q_OBJECT public: diff --git a/src/templates/office.cpp b/commonlib/templates/office.cpp similarity index 100% rename from src/templates/office.cpp rename to commonlib/templates/office.cpp diff --git a/src/templates/office.h b/commonlib/templates/office.h similarity index 90% rename from src/templates/office.h rename to commonlib/templates/office.h index 6c7286b..3af1de7 100644 --- a/src/templates/office.h +++ b/commonlib/templates/office.h @@ -23,12 +23,14 @@ void printOfficeFile(QString fname); #include +#include "commonexport.h" + class QComboBox; class QCheckBox; class QLineEdit; /**configuration dialog for OpenOffice access*/ -class MOfficeConfig:public QDialog +class MAGICSMOKE_COMMON_EXPORT MOfficeConfig:public QDialog { Q_OBJECT public: diff --git a/commonlib/templates/templates.pri b/commonlib/templates/templates.pri new file mode 100644 index 0000000..6cc1d4f --- /dev/null +++ b/commonlib/templates/templates.pri @@ -0,0 +1,13 @@ +HEADERS += \ + $$PWD/odtrender.h \ + $$PWD/ticketrender.h \ + $$PWD/office.h \ + $$PWD/labeldlg.h + +SOURCES += \ + $$PWD/odtrender.cpp \ + $$PWD/ticketrender.cpp \ + $$PWD/office.cpp \ + $$PWD/labeldlg.cpp + +INCLUDEPATH += $$PWD diff --git a/src/templates/ticketrender.cpp b/commonlib/templates/ticketrender.cpp similarity index 100% rename from src/templates/ticketrender.cpp rename to commonlib/templates/ticketrender.cpp diff --git a/src/templates/ticketrender.h b/commonlib/templates/ticketrender.h similarity index 87% rename from src/templates/ticketrender.h rename to commonlib/templates/ticketrender.h index 10e2023..5e2a408 100644 --- a/src/templates/ticketrender.h +++ b/commonlib/templates/ticketrender.h @@ -25,8 +25,10 @@ class MOVoucher; class QPaintDevice; class QPainter; +#include "commonexport.h" + /**base class that describes labels*/ -class MLabel +class MAGICSMOKE_COMMON_EXPORT MLabel { public: /**constructs the label*/ @@ -39,7 +41,7 @@ class MLabel }; /**base class for all label rendering classes*/ -class MLabelRenderer +class MAGICSMOKE_COMMON_EXPORT MLabelRenderer { public: /**instantiates a renderer loaded from template file*/ @@ -61,7 +63,7 @@ class MLabelRenderer }; /**convenience class: renders vouchers directly*/ -class MVoucherRenderer:public MLabelRenderer +class MAGICSMOKE_COMMON_EXPORT MVoucherRenderer:public MLabelRenderer { public: MVoucherRenderer(MTemplate f); @@ -69,7 +71,7 @@ class MVoucherRenderer:public MLabelRenderer }; /**convenience class: renders vouchers directly*/ -class MTicketRenderer:public MLabelRenderer +class MAGICSMOKE_COMMON_EXPORT MTicketRenderer:public MLabelRenderer { public: MTicketRenderer(MTemplate f); diff --git a/src/widgets/barcodeline.cpp b/commonlib/widgets/barcodeline.cpp similarity index 100% rename from src/widgets/barcodeline.cpp rename to commonlib/widgets/barcodeline.cpp diff --git a/src/widgets/barcodeline.h b/commonlib/widgets/barcodeline.h similarity index 89% rename from src/widgets/barcodeline.h rename to commonlib/widgets/barcodeline.h index dccda13..dcabc8c 100644 --- a/src/widgets/barcodeline.h +++ b/commonlib/widgets/barcodeline.h @@ -15,7 +15,9 @@ #include -class MBarcodeLine:public QLineEdit +#include "commonexport.h" + +class MAGICSMOKE_COMMON_EXPORT MBarcodeLine:public QLineEdit { Q_OBJECT public: diff --git a/src/widgets/centbox.cpp b/commonlib/widgets/centbox.cpp similarity index 100% rename from src/widgets/centbox.cpp rename to commonlib/widgets/centbox.cpp diff --git a/src/widgets/centbox.h b/commonlib/widgets/centbox.h similarity index 88% rename from src/widgets/centbox.h rename to commonlib/widgets/centbox.h index 80a42dd..80e9c23 100644 --- a/src/widgets/centbox.h +++ b/commonlib/widgets/centbox.h @@ -17,7 +17,9 @@ #include #include -class MCentSpinBox:public QAbstractSpinBox +#include "commonexport.h" + +class MAGICSMOKE_COMMON_EXPORT MCentSpinBox:public QAbstractSpinBox { Q_OBJECT public: @@ -44,7 +46,7 @@ class MCentSpinBox:public QAbstractSpinBox QRegExpValidator mvalid; }; -class MCentDialog:public QDialog +class MAGICSMOKE_COMMON_EXPORT MCentDialog:public QDialog { Q_OBJECT public: diff --git a/src/widgets/eventview.cpp b/commonlib/widgets/eventview.cpp similarity index 100% rename from src/widgets/eventview.cpp rename to commonlib/widgets/eventview.cpp diff --git a/src/widgets/eventview.h b/commonlib/widgets/eventview.h similarity index 90% rename from src/widgets/eventview.h rename to commonlib/widgets/eventview.h index 6fa58e5..d336860 100644 --- a/src/widgets/eventview.h +++ b/commonlib/widgets/eventview.h @@ -17,8 +17,10 @@ #include +#include "commonexport.h" + ///Event Viewer -class MEventView:public QTextBrowser +class MAGICSMOKE_COMMON_EXPORT MEventView:public QTextBrowser { Q_OBJECT public: diff --git a/src/widgets/listview.cpp b/commonlib/widgets/listview.cpp similarity index 100% rename from src/widgets/listview.cpp rename to commonlib/widgets/listview.cpp diff --git a/src/widgets/listview.h b/commonlib/widgets/listview.h similarity index 85% rename from src/widgets/listview.h rename to commonlib/widgets/listview.h index c66c465..a4ce6b6 100644 --- a/src/widgets/listview.h +++ b/commonlib/widgets/listview.h @@ -15,8 +15,10 @@ #include +#include "commonexport.h" + /**enhances QTreeView to react a bit friendlier on clicks*/ -class MListView:public QListView +class MAGICSMOKE_COMMON_EXPORT MListView:public QListView { public: MListView(QWidget*w=0):QListView(w){} diff --git a/src/widgets/treeview.cpp b/commonlib/widgets/treeview.cpp similarity index 100% rename from src/widgets/treeview.cpp rename to commonlib/widgets/treeview.cpp diff --git a/src/widgets/treeview.h b/commonlib/widgets/treeview.h similarity index 85% rename from src/widgets/treeview.h rename to commonlib/widgets/treeview.h index b79f952..06eb373 100644 --- a/src/widgets/treeview.h +++ b/commonlib/widgets/treeview.h @@ -15,8 +15,10 @@ #include +#include "commonexport.h" + /**enhances QTreeView to react a bit friendlier on clicks*/ -class MTreeView:public QTreeView +class MAGICSMOKE_COMMON_EXPORT MTreeView:public QTreeView { public: MTreeView(QWidget*w=0):QTreeView(w){} diff --git a/src/widgets/widgets.pri b/commonlib/widgets/widgets.pri similarity index 100% rename from src/widgets/widgets.pri rename to commonlib/widgets/widgets.pri diff --git a/mainapp/main.cpp b/mainapp/main.cpp index 6c02f95..404121e 100644 --- a/mainapp/main.cpp +++ b/mainapp/main.cpp @@ -2,5 +2,5 @@ int main(int ac,char**av) { - return MApplication::realmain(ac,av); -} \ No newline at end of file + return MagicSmokeMain::realmain(ac,av); +} diff --git a/sessman/login.cpp b/sessman/login.cpp index 1566497..1233c66 100644 --- a/sessman/login.cpp +++ b/sessman/login.cpp @@ -4,17 +4,15 @@ // Description: // // -// Author: Konrad Rosenbaum , (C) 2007-2011 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // // -// #include "main.h" #include "login.h" #include "msinterface.h" -// #include "overview.h" -// #include "configdialog.h" +#include "configdialog.h" #include #include @@ -157,10 +155,10 @@ void MLogin::startLogin() void MLogin::configwin() { -// MConfigDialog cd; -// cd.exec(); -// initProfiles(); -// loadProfile(); + MConfigDialog cd; + cd.exec(); + initProfiles(); + loadProfile(); } void MLogin::resizeEvent(QResizeEvent* ) diff --git a/sessman/login.h b/sessman/login.h index 1035fa2..2bb39c4 100644 --- a/sessman/login.h +++ b/sessman/login.h @@ -4,7 +4,7 @@ // Description: // // -// Author: Konrad Rosenbaum , (C) 2007-2011 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // diff --git a/sessman/sessman.pro b/sessman/sessman.pro index 6b628ce..7733749 100644 --- a/sessman/sessman.pro +++ b/sessman/sessman.pro @@ -9,6 +9,7 @@ TARGET = magicsmoke-sessman include(../basics.pri) include(../sesscli/scrand.pri) include(../iface/iface.pri) +include(../commonlib/commonlib.pri) #Localization TRANSLATIONS = \ diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index ff60fff..597979a 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -1,5 +1,4 @@ HEADERS += \ - dialogs/configdialog.h \ dialogs/eventedit.h \ dialogs/eventsummary.h \ dialogs/orderwin.h \ @@ -16,7 +15,6 @@ HEADERS += \ dialogs/payedit.h SOURCES += \ - dialogs/configdialog.cpp \ dialogs/eventedit.cpp \ dialogs/eventsummary.cpp \ dialogs/orderwin.cpp \ diff --git a/src/dialogs/orderauditdlg.cpp b/src/dialogs/orderauditdlg.cpp index ed864bf..ecedb1d 100644 --- a/src/dialogs/orderauditdlg.cpp +++ b/src/dialogs/orderauditdlg.cpp @@ -14,7 +14,7 @@ #include "orderwin.h" #include "formula.h" -#include "main.h" +#include "mapplication.h" #include "msinterface.h" #include "MTGetTicketAudit" diff --git a/src/libs.pri b/src/libs.pri index 09bd6b8..196e9d9 100644 --- a/src/libs.pri +++ b/src/libs.pri @@ -12,6 +12,9 @@ include($$PWD/../taurus/aurora.pri) # Session Client library include($$PWD/../sesscli/sesscli.pri) +# Common classes +include($$PWD/../commonlib/commonlib.pri) + #make sure the correct Qt DLLs are used QT += xml network script scripttools QT += widgets printsupport diff --git a/src/main.cpp b/src/main.cpp index eb272f8..db3d7bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,473 +4,23 @@ // Description: Main Program // // -// Author: Konrad Rosenbaum , (C) 2007-2014 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // // -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configdialog.h" -#include "debug.h" -#include "barcode-plugin.h" -#include "hmac.h" -#include "keygen.h" -#include "main.h" -// #include "login.h" -#include "msinterface.h" -#include -#include "misc.h" -#include -#include "boxwrapper.h" #include "overview.h" #include +#include +#include "msinterface.h" -QString choseLanguage(bool warn) -{ - QString lang=QSettings().value("lang","--").toString(); - if(lang=="--"){ - lang=QLocale::system().name(); - } - int cur=0; - QStringList langs; - langs<<"C - default"; - QStringList files=QDir(QApplication::applicationDirPath()).entryList(QStringList()<<"smoke_*.qm", QDir::Files, QDir::Name); - for(int i=0;isetMinimumDuration(0); - pd->show(); - } - ~MProgressWrapperGui() - { - if(pd)pd->deleteLater(); - pd=0; - } - virtual void setLabelText(QString l) - { - pd->setLabelText(l); - } - virtual void setCancelButtonText(QString t) - { - pd->setCancelButtonText(t); - } - virtual void cancel() - { - pd->cancel(); - } - virtual void setRange(int mi,int ma) - { - pd->setRange(mi,ma); - } - virtual void setValue(int v) - { - pd->setValue(v); - } -}; - -#ifndef HOMEPAGE_BASEURL -#define HOMEPAGE_BASEURL "http://smoke.silmor.de" -#endif - -void MApplication::aboutMS() -{ - QMessageBox mb; - mb.setIconPixmap(QPixmap(":/icon.png")); - mb.setWindowTitle(tr("About MagicSmoke")); - MSInterface*ifc=MSInterface::instance(); - mb.setText(tr( "

MagicSmoke v. %1

" - "© Konrad Rosenbaum, 2007-2013
" - "© Peter Keller, 2007-2008
" - "protected under the GNU GPL v.3 or at your option any newer

" - "See also the MagicSmoke Homepage.

" - "This version was compiled from repository '%3' revision '%4'.

" - "The current application data base path is '%5'.") - .arg(MSInterface::staticVersionInfo(WOb::VersionHR)) //%1 - .arg(HOMEPAGE_BASEURL) //%2 - .arg(MSInterface::staticVersionInfo(WOb::VersionRootURL)) //%3 - .arg(MSInterface::staticVersionInfo(WOb::VersionNumber)) //%4 - .arg(ifc?ifc->dataDir(): dataDir()) - ); - mb.setStandardButtons(QMessageBox::Ok); - mb.exec(); -} - -void MApplication::versionDlg() -{ - QMessageBox mb; - mb.setIconPixmap(QPixmap(":/icon.png")); - mb.setWindowTitle(tr("MagicSmoke Version Information")); - TimeZoneLib::TZFile tzf=TimeStamp::defaultZoneFile(); - auto unknown=[](const QString&s)->QString{if(s.isEmpty())return "(unknown)";else return "'"+s+"'";}; - mb.setText(tr( "

MagicSmoke Version %3

" - "" - "" - "" - "" - "" - "" - "
Repository:%1
Revision:%2
Modification State:%4
Commit Time:%5
Committer:%6

\n" - "

Libraries

\n" - "" - "" - "" - "" - "" - "" - "
WOC:%7
%8
PACK Library:%9
%10
Qt:%11
ELAM:%12
Time Zone Default:%13 in directory %14
version %15
Time Zone Built-In:%16 (library: %17)
" - ) - .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionRootURL))) // %1 - .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionNumber))) //%2 - .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionHR))) //%3 - .arg(MSInterface::staticVersionInfo(WOb::VersionLocallyModified)) //%4 - .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionTime))) //%5 - .arg(htmlize(MSInterface::staticVersionInfo(WOb::VersionAuthor))) //&6 - .arg(htmlize(MSInterface::staticWocVersionInfo(WOb::VersionRootURL))) //%7 - .arg(htmlize(MSInterface::staticWocVersionInfo(WOb::VersionNumber))) - .arg(htmlize(WInterface::staticLibraryVersionInfo(WOb::VersionRootURL))) //%9 - .arg(htmlize(WInterface::staticLibraryVersionInfo(WOb::VersionNumber))) - .arg(htmlize(QT_VERSION_STR)) //%11 - .arg(htmlize(ELAM::versionInfo())) //%12 - .arg(unknown(tzf.name())) //%13 - .arg(unknown(tzf.dirName())) - .arg(unknown(tzf.version())) - .arg(TimeZoneLib::TZFile::builtinVersion()) //%16 - .arg(TimeZoneLib::TZFile::libraryVersion()) //%17 - ); - mb.setStandardButtons(QMessageBox::Ok); - mb.exec(); -} - - -struct HelpUrl { - enum Type {None, Item, Separator} type=None; - QString label,url; - HelpUrl(Type t,QString l,QString u=QString()):type(t),label(l),url(u){} -}; -static QList helpUrl; - -static void loadHelpUrlFile(const QString&fname) -{ - QFile fd(fname); - QList urls; - //try to open - if(fd.open(QIODevice::ReadOnly)){ - //read config - QDomDocument doc; - doc.setContent(&fd); - QDomNodeList nl=doc.documentElement().childNodes(); - for(int i=0;i0 && urls.size()>0)helpUrl.append(HelpUrl(HelpUrl::Separator,"")); - helpUrl.append(urls); -} - -void MApplication::initHelpUrl() -{ - //check file exists, if not initialize it - loadHelpUrlFile(dataDir()+"/helpMenu.xml"); - loadHelpUrlFile(applicationDirPath()+"/helpMenu.xml"); - //fallback - if(helpUrl.size()<1) - helpUrl<addSeparator()->setText(helpUrl[i].label); - }else{ - QAction*a=m->addAction(helpUrl[i].label,map,SLOT(map())); - map->setMapping(a,i); - } - } - m->addSeparator(); - m->addAction("About &MagicSmoke",qApp,SLOT(aboutMS())); - m->addAction("About &Qt",qApp,SLOT(aboutQt())); - m->addAction("&Version Info",qApp,SLOT(versionDlg())); - return m; -} - -static inline QUrl convHelpUrl(QUrl s) -{ - if(s.scheme()=="default"){ - static const QString ad=QApplication::applicationDirPath()+"/doc/"; - if(QFile(ad+"index.html").exists()) - return QUrl::fromLocalFile(ad+s.path()); - else - //TODO: allow different versions? - return HOMEPAGE_BASEURL "/doc/" + s.path(); - } - else return s; -} - - - -void MApplication::help() -{ - qDebug()<<"Opening default help..."; - QDesktopServices::openUrl(convHelpUrl(QUrl("default:/index.html"))); -} - -void MApplication::help(int idx) -{ - if(idx<0 || idx>=helpUrl.size()){ - help(); - return; - } - QUrl u=convHelpUrl(helpUrl[idx].url); - qDebug()<<"Opening help:"<MProgressWrapper*{ - return new MProgressWrapperGui(label,button); - }); - - //check parameters -// qDebug()<<"arguments"<load(prog+"_"+lang,lpath[i]); - QString msg=QString("...loading %1_%2 from %3 ...%4") - .arg(prog).arg(lang) - .arg(lpath[i]) - .arg(ok?"ok":"failed"); - qDebug("%s",msg.toLatin1().data()); - if(ok)return; - } -} - -void MApplication::initLanguage() -{ - //try to find appropriate locale - QString lang=QSettings().value("lang","--").toString(); - if(lang=="--"){ - lang=choseLanguage(false); - } - qDebug("Loading language %s",lang.toLatin1().data()); - //load Qt translation - loadTranslation(qttrans=new QTranslator(this),lang,"qt"); - installTranslator(qttrans); - //load magicSmoke translation - loadTranslation(mstrans=new QTranslator(this),lang,"smoke"); - installTranslator(mstrans); - //load Pack translation - QTranslator*xtrans; - loadTranslation(xtrans=new QTranslator(this),lang,"qwbase"); - installTranslator(xtrans); - //detect and load remaining modules - QStringList files=QDir(applicationDirPath()).entryList(QStringList()<<"smoke-*.qm",QDir::Files|QDir::Readable,QDir::Name); - QStringList loaded, modules; - // --> stage 1: find modules - for(auto file:files){ - QString m=file.split('_').value(0); - if(!m.isEmpty() && !modules.contains(m)) - modules.append(m); - } - // --> stage 2: go through modules and load - for(auto mod:modules){ - loadTranslation(xtrans=new QTranslator(this),lang,mod); - installTranslator(xtrans); - } - //defaults - if(lang!="--"&&lang!=""){ - QLocale::setDefault(lang); -#ifndef Q_OS_WIN - setenv("LANG",lang.toLatin1().data(),1); - }else{ - setenv("LANG","C",1); -#endif - } -} - -void MApplication::initialize() -{ - //load the correct style - setMyStyle(); - //initialize log file - initDebug(); - //init localization and profiles - initLanguage(); - initProfile(); - //init help menu layout - initHelpUrl(); - //init updater - initUpdater(); - //init plugins - MBarcodeHub::instance()->initialize(); -} - -void MApplication::initUpdater() -{ - updater=new Aurora(applicationDirPath()+"/magicsmoke.xml",this); - connect(updater,SIGNAL(newVersionAvailable(QString)),this,SLOT(updateReadyDownload(QString))); - connect(updater,SIGNAL(readyForInstallation()),this,SLOT(updaterReadyInstall())); - connect(updater,SIGNAL(installationFinished()),this,SLOT(updaterCompleted())); - connect(updater,SIGNAL(downloadFailed()),this,SLOT(updaterFailed())); - connect(updater,SIGNAL(installationFailed()),this,SLOT(updaterFailed())); - //we ignore all errors that happen prior to successful verification, since they - //would create too much noise -} - -void MApplication::updateReadyDownload(const QString& v) -{ - qDebug()<<"Asking for Download permission"; - QMessageBox::StandardButton r=QMessageBox::question(0,tr("New Update"),tr("A new version of MagicSmoke is available. Do you want to download the new version %1?").arg(v),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); - if(r==QMessageBox::Yes) - updater->startDownload(); -} - -void MApplication::updaterReadyInstall() -{ - QMessageBox::Button r=QMessageBox::question(0,tr("New Update"),tr("A new version of MagicSmoke is ready for installation. Do you want to install?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); - if(r==QMessageBox::Yes) - updater->startInstallation(); -} - -void MApplication::updaterCompleted() -{ - QMessageBox::information(0,tr("Update Complete"),tr("A new version of MagicSmoke has been installed. It will be used the next time you start MagicSmoke.")); -} - -void MApplication::updaterFailed() -{ - QMessageBox::warning(0,tr("Update Failed"),tr("An update of MagicSmoke failed.")); -} - -QString MApplication::dataDir() -{ - return MSInterface::appDataDir(); -} - -void MApplication::initProfile() -{ - //check/generate profile - if(!QSettings().childGroups().contains("profiles")){ - QMessageBox::warning(0,translate("initprofile","Initial Profile Warning"), translate("initprofile","You need a profile to work with Magic Smoke. Please create one now.")); - MConfigDialog().exec(); - } -} - +#include "main.h" -int MApplication::realmain(int argc,char**argv) +int MagicSmokeMain::realmain(int argc,char**argv) { //create global app MApplication app(argc,argv); diff --git a/src/main.h b/src/main.h index 020a189..49d34de 100644 --- a/src/main.h +++ b/src/main.h @@ -4,7 +4,7 @@ // Description: // // -// Author: Konrad Rosenbaum , (C) 2007-2014 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // @@ -13,11 +13,7 @@ #ifndef MAGICSMOKE_MAIN_H #define MAGICSMOKE_MAIN_H -#include -#include - -/**show a dialog to change the language*/ -QString choseLanguage(bool warn=true); +#include #ifdef MAGICSMOKE_LIB_BUILD #define MAGICSMOKE_EXPORT Q_DECL_EXPORT @@ -25,75 +21,11 @@ QString choseLanguage(bool warn=true); #define MAGICSMOKE_EXPORT Q_DECL_IMPORT #endif -class QMenu; -class EFilter; -namespace AuroraUpdater{class Aurora;}; -///Main application object of MagicSmoke -class MAGICSMOKE_EXPORT MApplication:public QApplication +///shortcut: the main function +class MAGICSMOKE_EXPORT MagicSmokeMain { - Q_OBJECT - public: - ///create MagicSmoke application - MApplication(int&ac,char**av); - - ///return the standard help menu - static QMenu*helpMenu(); - - ///shortcut: the main function - static int realmain(int,char**); - /**contains the directory that is used for external data storage*/ - static QString dataDir(); - - ///override the data directory - ///- call it before any of the init functions - ///- never call this while a session is active! - static void setDataDir(QString); - ///override the configuration directory - ///- call this before initialize - ///- on Windows and MacOS, this also switches the settings mode to ini-files - static void setConfigDir(QString); - public slots: - ///complete initialization: style, language, data dir - void initialize(); - ///set the configured application style - void setMyStyle(); - ///initialize the localization - void initLanguage(); - ///initialize the profiles - void initProfile(); - - ///show about dialog - void aboutMS(); - ///show version info - void versionDlg(); - ///start a browser with the help page - void help(); - private slots: - ///jump to a specific help page - void help(int); - - ///initialize the help menu from config files - void initHelpUrl(); - - ///initialize the updater - void initUpdater(); - - ///updater is ready for download - void updateReadyDownload(const QString&); - ///updater is ready for install - void updaterReadyInstall(); - ///update complete - void updaterCompleted(); - ///something failed for the updater - void updaterFailed(); - - private: - EFilter *ef=nullptr; - QTranslator*qttrans=nullptr,*mstrans=nullptr; - AuroraUpdater::Aurora*updater=nullptr; +public: + static int realmain(int,char**); }; -///return the instance of the MApplication -#define mApp (qobject_cast(qApp)) - #endif diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 237b672..23c6632 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -4,14 +4,14 @@ // Description: // // -// Author: Konrad Rosenbaum , (C) 2007-2011 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // // #include "customerdlg.h" -#include "main.h" +#include "mapplication.h" #include "msinterface.h" #include "passwdchg.h" #include "shipping.h" @@ -590,7 +590,7 @@ void MOverview::displaySettings() void MOverview::changeLang() { - choseLanguage(); + MApplication::choseLanguage(); } diff --git a/src/mwin/overview.h b/src/mwin/overview.h index 512504b..8d4abd7 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -4,7 +4,7 @@ // Description: // // -// Author: Konrad Rosenbaum , (C) 2007-2011 +// Author: Konrad Rosenbaum , (C) 2007-2016 // // Copyright: See README/COPYING.GPL files that come with this distribution // diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp index bb22acb..267ba6d 100644 --- a/src/mwin/tabwin.cpp +++ b/src/mwin/tabwin.cpp @@ -11,7 +11,7 @@ // #include "customerdlg.h" -#include "main.h" +#include "mapplication.h" #include "msinterface.h" #include "passwdchg.h" #include "shipping.h" diff --git a/src/script/jsengine.cpp b/src/script/jsengine.cpp index e229e1a..b3a8372 100644 --- a/src/script/jsengine.cpp +++ b/src/script/jsengine.cpp @@ -13,7 +13,7 @@ #include "jsengine.h" #include "overview.h" #include "msinterface.h" -#include "main.h" +#include "mapplication.h" #include "templates.h" #include diff --git a/src/smoke.pri b/src/smoke.pri index 08bfa38..829c8b2 100644 --- a/src/smoke.pri +++ b/src/smoke.pri @@ -7,11 +7,8 @@ include (libs.pri) LIBS += -lmagicsmoke INCLUDEPATH += \ $$PWD \ - $$PWD/crypto \ $$PWD/dialogs \ - $$PWD/misc \ $$PWD/mwin \ $$PWD/script \ - $$PWD/templates \ - $$PWD/widgets + $$PWD/templates diff --git a/src/smoke.pro b/src/smoke.pro index 6e91bc0..17bd52d 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -29,10 +29,7 @@ DEFINES += HOMEPAGE_BASEURL=\\\"http://smoke.silmor.de\\\" RESOURCES += images/files.qrc #libraries, modules, stuff... -include(widgets/widgets.pri) include(templates/templates.pri) -include(misc/misc.pri) -include(crypto/crypto.pri) include(dialogs/dialogs.pri) include(mwin/mwin.pri) include(script/script.pri) diff --git a/src/templates/templates.pri b/src/templates/templates.pri index cb72c6f..b66ec54 100644 --- a/src/templates/templates.pri +++ b/src/templates/templates.pri @@ -1,19 +1,11 @@ HEADERS += \ - $$PWD/odtrender.h \ - $$PWD/ticketrender.h \ - $$PWD/office.h \ - $$PWD/labeldlg.h \ - $$PWD/templatedlg.h \ $$PWD/ticketedit.h \ - $$PWD/odfedit.h + $$PWD/odfedit.h \ + $$PWD/templatedlg.h SOURCES += \ - $$PWD/odtrender.cpp \ - $$PWD/ticketrender.cpp \ - $$PWD/office.cpp \ - $$PWD/labeldlg.cpp \ - $$PWD/templatedlg.cpp \ $$PWD/ticketedit.cpp \ - $$PWD/odfedit.cpp + $$PWD/odfedit.cpp \ + $$PWD/templatedlg.cpp -INCLUDEPATH += $$PWD \ No newline at end of file +INCLUDEPATH += $$PWD