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)
--- /dev/null
+
+#include <QtCore/QtGlobal>
+
+#ifndef MAGICSMOKE_COMMON_LIB_BUILD
+#define MAGICSMOKE_COMMON_EXPORT Q_DECL_EXPORT
+#else
+#define MAGICSMOKE_COMMON_EXPORT Q_DECL_IMPORT
+#endif
--- /dev/null
+#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)
--- /dev/null
+#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
//
-// C++ Implementation: mainwindow
+// C++ Implementation: config dialog
//
// Description:
//
//
#include "keygen.h"
-#include "main.h"
+#include "mapplication.h"
#include "configdialog.h"
#include "office.h"
#include "listview.h"
void MConfigDialog::changeLang()
{
- choseLanguage();
+ MApplication::choseLanguage();
}
void MConfigDialog::exportKey()
QNetworkAccessManager man;
connect(&man,SIGNAL(finished(QNetworkReply*)),&loop,SLOT(quit()));
QTimer::singleShot(30000,&loop,SLOT(quit()));
- connect(&man,SIGNAL(sslErrors(QNetworkReply*,const QList<QSslError>&)), this,SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
+ connect(&man,SIGNAL(sslErrors(QNetworkReply*,const QList<QSslError>&)), this,SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
if(useproxy->isChecked())
man.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,proxyname->text(),proxyport->value(),proxyuser->text(),proxypass->text()));
//query server
class MSslExceptions;
+#include "commonexport.h"
+
/**login and profile configuration window*/
-class MConfigDialog:public QDialog
+class MAGICSMOKE_COMMON_EXPORT MConfigDialog:public QDialog
{
Q_OBJECT
public:
class QComboBox;
class QLineEdit;
-class MAppStyleDialog:public QDialog
+class MAGICSMOKE_COMMON_EXPORT MAppStyleDialog:public QDialog
{
Q_OBJECT
public:
#include <QCryptographicHash>
+#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*/
class QLabel;
class QPushButton;
-class MKeyGen:public QDialog
+#include "commonexport.h"
+
+class MAGICSMOKE_COMMON_EXPORT MKeyGen:public QDialog
{
Q_OBJECT
public:
void updateProps();
};
-class EFilter:public QObject
+class MAGICSMOKE_COMMON_EXPORT EFilter:public QObject
{
Q_OBJECT
public:
};
//shortcut:
-QByteArray getRandom(int);
-int getEntropy();
+MAGICSMOKE_COMMON_EXPORT QByteArray getRandom(int);
+MAGICSMOKE_COMMON_EXPORT int getEntropy();
#endif
--- /dev/null
+//
+// C++ Implementation: main
+//
+// Description: Main Program
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include <QDesktopServices>
+#include <QDebug>
+#include <QDir>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QHostInfo>
+#include <QIcon>
+#include <QInputDialog>
+#include <QLibraryInfo>
+#include <QLocale>
+#include <QMenu>
+#include <QMessageBox>
+#include <QProgressDialog>
+#include <QSettings>
+#include <QSignalMapper>
+#include <QStringList>
+#include <QTranslator>
+#include <QUrl>
+
+#include <TimeStamp>
+#include <TZFile>
+
+#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 <ELAM/Engine>
+#include "misc.h"
+#include <Aurora>
+#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;i<files.size();i++){
+ QString l=files[i].mid(6);
+ l.chop(3);
+ langs<<l;
+ if(l==lang)cur=langs.size()-1;
+ }
+ bool ok;
+ QString lc;
+ lc=QInputDialog::getItem(0,QApplication::translate("lang","Chose Language"),QApplication::translate("lang","Language:"),langs,cur,false,&ok);
+ if(ok){
+ lang=lc.split(' ').at(0);
+ QSettings().setValue("lang",lang);
+ if(warn)
+ QMessageBox::information(0,QApplication::translate("lang","Information"), QApplication::translate("lang","The changed language setting will only be active after restarting the application."));
+ }
+ return lang;
+}
+
+class MProgressWrapperGui:public MProgressWrapper
+{
+ QProgressDialog*pd;
+ public:
+ MProgressWrapperGui(QString label,QString button)
+ {
+ pd=new QProgressDialog(label,button,0,0);
+ pd->setMinimumDuration(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( "<h3>MagicSmoke v. %1</h3>"
+ "© Konrad Rosenbaum, 2007-2013<br>"
+ "© Peter Keller, 2007-2008<br>"
+ "protected under the GNU GPL v.3 or at your option any newer<p>"
+ "See also the <a href=\"%2\">MagicSmoke Homepage</a>.<p>"
+ "This version was compiled from repository '%3' revision '%4'.<p>"
+ "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( "<h3>MagicSmoke Version %3</h3>"
+ "<table border='1' style='border-style: solid; border-color: #888;'>"
+ "<tr><td>Repository:<td>%1</tr>"
+ "<tr><td>Revision:<td>%2</tr>"
+ "<tr><td>Modification State:<td>%4</tr>"
+ "<tr><td>Commit Time:<td>%5</tr>"
+ "<tr><td>Committer:<td>%6</tr>"
+ "</table><p>\n"
+ "<h3>Libraries</h3>\n<table border='1' style='border-style: solid; border-color: #888;'>"
+ "<tr><td>WOC:<td>%7<br/>%8</tr>"
+ "<tr><td>PACK Library:<td>%9<br/>%10</tr>"
+ "<tr><td>Qt:<td>%11</tr>"
+ "<tr><td>ELAM:<td>%12</tr>"
+ "<tr><td>Time Zone Default:<td>%13 in directory %14<br/>version %15</tr>"
+ "<tr><td>Time Zone Built-In:<td>%16 (library: %17)</tr>"
+ "</table>"
+ )
+ .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> helpUrl;
+
+static void loadHelpUrlFile(const QString&fname)
+{
+ QFile fd(fname);
+ QList<HelpUrl > 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;i<nl.size();i++){
+ QDomElement el=nl.at(i).toElement();
+ if(!el.isElement())continue;
+ if(el.tagName()=="Item")
+ urls.append(HelpUrl(HelpUrl::Item, el.attribute("label").trimmed(), el.text().trimmed()));
+ else if(el.tagName()=="Separator")
+ urls.append(HelpUrl(HelpUrl::Separator, el.attribute("label").trimmed()));
+ }
+ }
+ //append to url list
+ if(helpUrl.size()>0 && 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<<HelpUrl(HelpUrl::Item,tr("&Help"),tr("default:/index.html","default help URL, if you translate the index.html file, then change this as well"));
+}
+
+QMenu* MApplication::helpMenu()
+{
+ QMenu*m=new QMenu(tr("&Help"));
+ QSignalMapper *map=new QSignalMapper(m);
+ connect(map,SIGNAL(mapped(int)),qApp,SLOT(help(int)));
+ for(int i=0;i<helpUrl.size();i++){
+ if(helpUrl[i].type==HelpUrl::Separator){
+ m->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:"<<u;
+ QDesktopServices::openUrl(u);
+}
+
+MApplication::MApplication(int&ac,char**av)
+:QApplication(ac,av)
+{
+ //locate settings
+ setOrganizationName("MagicSmoke");
+ setApplicationName("MagicSmoke2");
+
+ //set icon
+ setWindowIcon(QIcon(":/icon.png"));
+
+ //install event filter for random generator
+ installEventFilter(ef=new EFilter);
+
+ //init GUI wrappers
+ MBoxWrapper::setWarning([](QString title,QString text){QMessageBox::warning(nullptr,title,text);});
+ MProgressWrapper::setFactory([](QString label,QString button)->MProgressWrapper*{
+ return new MProgressWrapperGui(label,button);
+ });
+
+ //check parameters
+// qDebug()<<"arguments"<<arguments();
+ for(const QString& param:arguments()){
+ if(param.startsWith("-confdir=")){
+ setConfigDir(param.mid(9));
+ }else if(param.startsWith("-datadir=")){
+ setDataDir(param.mid(9));
+ }
+ }
+
+ //data directory
+ if(dataDir().isEmpty())
+ setDataDir("$BASE/.magicSmoke2");
+}
+
+void MApplication::setConfigDir(QString d)
+{
+ QSettings::setDefaultFormat(QSettings::IniFormat);
+ const QString cdir=MSInterface::resolveDir(d);
+ QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,cdir);
+ qDebug()<<"Setting the config directory to"<<cdir<<"from"<<d;
+}
+
+void MApplication::setDataDir(QString d)
+{
+ MSInterface::setAppDataDir(d);
+}
+
+
+void MApplication::setMyStyle()
+{
+ QSettings set;
+ if(set.contains("appstyle"))
+ setStyle(set.value("appstyle").toString());
+ if(set.contains("appstylesheet")){
+ QFile fd(set.value("appstylesheet").toString());
+ if(fd.open(QIODevice::ReadOnly)){
+ setStyleSheet(QString::fromLocal8Bit(fd.readAll()));
+ fd.close();
+ }
+ }
+}
+
+static inline void loadTranslation(QTranslator*trans,const QString&lang,const QString&prog)
+{
+ QStringList lpath;
+ lpath <<QApplication::applicationDirPath() <<QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ for(int i=0;i<lpath.size();i++){
+ bool ok=trans->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();
+ }
+}
--- /dev/null
+//
+// C++ Interface: main
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2014
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_MAPP_H
+#define MAGICSMOKE_MAPP_H
+
+#include <QString>
+#include <QApplication>
+
+#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<MApplication*>(qApp))
+
+#endif
#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 <QtPlugin>
#include <QStringList>
class QTabWidget;
///Scanner Configuration Dialog
-class MAGICSMOKE_EXPORT MBarcodeConfiguration:public QDialog
+class MAGICSMOKE_COMMON_EXPORT MBarcodeConfiguration:public QDialog
{
Q_OBJECT
public:
};
///base class of actual scanner implementations
-class MAGICSMOKE_EXPORT MBarcodeScanner:public QObject
+class MAGICSMOKE_COMMON_EXPORT MBarcodeScanner:public QObject
{
Q_OBJECT
public:
};
///base class of barcode scanner plugins
-class MAGICSMOKE_EXPORT MBarcodePlugin
+class MAGICSMOKE_COMMON_EXPORT MBarcodePlugin
{
public:
virtual ~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:
#include <QImage>
#include <QString>
+#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);
//
#include "debug.h"
-#include "main.h"
+// #include "main.h"
#include <QCoreApplication>
#include <QDateTime>
#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
#ifndef MAGICSMOKE_DEBUG_H
#define MAGICSMOKE_DEBUG_H
-void initDebug();
+#include "commonexport.h"
+
+MAGICSMOKE_COMMON_EXPORT void initDebug(const QString&dataDir);
#endif
#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;
#include <functional>
+#include "commonexport.h"
+
class QDomNode;
class QDomDocument;
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);
#include <QLabel>
+#include "commonexport.h"
class QMenu;
class QAction;
-class MServerClock:public QLabel
+class MAGICSMOKE_COMMON_EXPORT MServerClock:public QLabel
{
Q_OBJECT
public:
#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)*/
#ifndef MAGICSMOKE_LABELDLG_H
#define MAGICSMOKE_LABELDLG_H
+#include "commonexport.h"
+
#include <QDialog>
#include <QPointF>
#include <QList>
class QLabel;
///access to the label specific configuration
-class MLabelConfig
+class MAGICSMOKE_COMMON_EXPORT MLabelConfig
{
public:
///shows the configuration dialog
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:
///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:
#include <QString>
#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*/
};
/**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:
#include <QDialog>
+#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:
--- /dev/null
+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
class QPaintDevice;
class QPainter;
+#include "commonexport.h"
+
/**base class that describes labels*/
-class MLabel
+class MAGICSMOKE_COMMON_EXPORT MLabel
{
public:
/**constructs the label*/
};
/**base class for all label rendering classes*/
-class MLabelRenderer
+class MAGICSMOKE_COMMON_EXPORT MLabelRenderer
{
public:
/**instantiates a renderer loaded from template file*/
};
/**convenience class: renders vouchers directly*/
-class MVoucherRenderer:public MLabelRenderer
+class MAGICSMOKE_COMMON_EXPORT MVoucherRenderer:public MLabelRenderer
{
public:
MVoucherRenderer(MTemplate f);
};
/**convenience class: renders vouchers directly*/
-class MTicketRenderer:public MLabelRenderer
+class MAGICSMOKE_COMMON_EXPORT MTicketRenderer:public MLabelRenderer
{
public:
MTicketRenderer(MTemplate f);
#include <QLineEdit>
-class MBarcodeLine:public QLineEdit
+#include "commonexport.h"
+
+class MAGICSMOKE_COMMON_EXPORT MBarcodeLine:public QLineEdit
{
Q_OBJECT
public:
#include <QDialog>
#include <QRegExpValidator>
-class MCentSpinBox:public QAbstractSpinBox
+#include "commonexport.h"
+
+class MAGICSMOKE_COMMON_EXPORT MCentSpinBox:public QAbstractSpinBox
{
Q_OBJECT
public:
QRegExpValidator mvalid;
};
-class MCentDialog:public QDialog
+class MAGICSMOKE_COMMON_EXPORT MCentDialog:public QDialog
{
Q_OBJECT
public:
#include <MOEvent>
+#include "commonexport.h"
+
///Event Viewer
-class MEventView:public QTextBrowser
+class MAGICSMOKE_COMMON_EXPORT MEventView:public QTextBrowser
{
Q_OBJECT
public:
#include <QListView>
+#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){}
#include <QTreeView>
+#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){}
int main(int ac,char**av)
{
- return MApplication::realmain(ac,av);
-}
\ No newline at end of file
+ return MagicSmokeMain::realmain(ac,av);
+}
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (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 <QApplication>
#include <QByteArray>
void MLogin::configwin()
{
-// MConfigDialog cd;
-// cd.exec();
-// initProfiles();
-// loadProfile();
+ MConfigDialog cd;
+ cd.exec();
+ initProfiles();
+ loadProfile();
}
void MLogin::resizeEvent(QResizeEvent* )
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2016
//
// Copyright: See README/COPYING.GPL files that come with this distribution
//
include(../basics.pri)
include(../sesscli/scrand.pri)
include(../iface/iface.pri)
+include(../commonlib/commonlib.pri)
#Localization
TRANSLATIONS = \
HEADERS += \
- dialogs/configdialog.h \
dialogs/eventedit.h \
dialogs/eventsummary.h \
dialogs/orderwin.h \
dialogs/payedit.h
SOURCES += \
- dialogs/configdialog.cpp \
dialogs/eventedit.cpp \
dialogs/eventsummary.cpp \
dialogs/orderwin.cpp \
#include "orderwin.h"
#include "formula.h"
-#include "main.h"
+#include "mapplication.h"
#include "msinterface.h"
#include "MTGetTicketAudit"
# 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
// Description: Main Program
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2014
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2016
//
// Copyright: See README/COPYING.GPL files that come with this distribution
//
//
-#include <QDesktopServices>
-#include <QDebug>
-#include <QDir>
-#include <QDomDocument>
-#include <QDomElement>
-#include <QHostInfo>
-#include <QIcon>
-#include <QInputDialog>
-#include <QLibraryInfo>
-#include <QLocale>
-#include <QMenu>
-#include <QMessageBox>
-#include <QProgressDialog>
-#include <QSettings>
-#include <QSignalMapper>
-#include <QStringList>
-#include <QTranslator>
-#include <QUrl>
-#include <TimeStamp>
-#include <TZFile>
-
-#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 <ELAM/Engine>
-#include "misc.h"
-#include <Aurora>
-#include "boxwrapper.h"
#include "overview.h"
#include <scli.h>
+#include <mapplication.h>
+#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;i<files.size();i++){
- QString l=files[i].mid(6);
- l.chop(3);
- langs<<l;
- if(l==lang)cur=langs.size()-1;
- }
- bool ok;
- QString lc;
- lc=QInputDialog::getItem(0,QApplication::translate("lang","Chose Language"),QApplication::translate("lang","Language:"),langs,cur,false,&ok);
- if(ok){
- lang=lc.split(' ').at(0);
- QSettings().setValue("lang",lang);
- if(warn)
- QMessageBox::information(0,QApplication::translate("lang","Information"), QApplication::translate("lang","The changed language setting will only be active after restarting the application."));
- }
- return lang;
-}
-
-class MProgressWrapperGui:public MProgressWrapper
-{
- QProgressDialog*pd;
- public:
- MProgressWrapperGui(QString label,QString button)
- {
- pd=new QProgressDialog(label,button,0,0);
- pd->setMinimumDuration(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( "<h3>MagicSmoke v. %1</h3>"
- "© Konrad Rosenbaum, 2007-2013<br>"
- "© Peter Keller, 2007-2008<br>"
- "protected under the GNU GPL v.3 or at your option any newer<p>"
- "See also the <a href=\"%2\">MagicSmoke Homepage</a>.<p>"
- "This version was compiled from repository '%3' revision '%4'.<p>"
- "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( "<h3>MagicSmoke Version %3</h3>"
- "<table border='1' style='border-style: solid; border-color: #888;'>"
- "<tr><td>Repository:<td>%1</tr>"
- "<tr><td>Revision:<td>%2</tr>"
- "<tr><td>Modification State:<td>%4</tr>"
- "<tr><td>Commit Time:<td>%5</tr>"
- "<tr><td>Committer:<td>%6</tr>"
- "</table><p>\n"
- "<h3>Libraries</h3>\n<table border='1' style='border-style: solid; border-color: #888;'>"
- "<tr><td>WOC:<td>%7<br/>%8</tr>"
- "<tr><td>PACK Library:<td>%9<br/>%10</tr>"
- "<tr><td>Qt:<td>%11</tr>"
- "<tr><td>ELAM:<td>%12</tr>"
- "<tr><td>Time Zone Default:<td>%13 in directory %14<br/>version %15</tr>"
- "<tr><td>Time Zone Built-In:<td>%16 (library: %17)</tr>"
- "</table>"
- )
- .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> helpUrl;
-
-static void loadHelpUrlFile(const QString&fname)
-{
- QFile fd(fname);
- QList<HelpUrl > 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;i<nl.size();i++){
- QDomElement el=nl.at(i).toElement();
- if(!el.isElement())continue;
- if(el.tagName()=="Item")
- urls.append(HelpUrl(HelpUrl::Item, el.attribute("label").trimmed(), el.text().trimmed()));
- else if(el.tagName()=="Separator")
- urls.append(HelpUrl(HelpUrl::Separator, el.attribute("label").trimmed()));
- }
- }
- //append to url list
- if(helpUrl.size()>0 && 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<<HelpUrl(HelpUrl::Item,tr("&Help"),tr("default:/index.html","default help URL, if you translate the index.html file, then change this as well"));
-}
-
-QMenu* MApplication::helpMenu()
-{
- QMenu*m=new QMenu(tr("&Help"));
- QSignalMapper *map=new QSignalMapper(m);
- connect(map,SIGNAL(mapped(int)),qApp,SLOT(help(int)));
- for(int i=0;i<helpUrl.size();i++){
- if(helpUrl[i].type==HelpUrl::Separator){
- m->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:"<<u;
- QDesktopServices::openUrl(u);
-}
-
-MApplication::MApplication(int&ac,char**av)
-:QApplication(ac,av)
-{
- //locate settings
- setOrganizationName("MagicSmoke");
- setApplicationName("MagicSmoke2");
-
- //set icon
- setWindowIcon(QIcon(":/icon.png"));
-
- //install event filter for random generator
- installEventFilter(ef=new EFilter);
-
- //init GUI wrappers
- MBoxWrapper::setWarning([](QString title,QString text){QMessageBox::warning(nullptr,title,text);});
- MProgressWrapper::setFactory([](QString label,QString button)->MProgressWrapper*{
- return new MProgressWrapperGui(label,button);
- });
-
- //check parameters
-// qDebug()<<"arguments"<<arguments();
- for(const QString& param:arguments()){
- if(param.startsWith("-confdir=")){
- setConfigDir(param.mid(9));
- }else if(param.startsWith("-datadir=")){
- setDataDir(param.mid(9));
- }
- }
-
- //data directory
- if(dataDir().isEmpty())
- setDataDir("$BASE/.magicSmoke2");
-}
-
-void MApplication::setConfigDir(QString d)
-{
- QSettings::setDefaultFormat(QSettings::IniFormat);
- const QString cdir=MSInterface::resolveDir(d);
- QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,cdir);
- qDebug()<<"Setting the config directory to"<<cdir<<"from"<<d;
-}
-
-void MApplication::setDataDir(QString d)
-{
- MSInterface::setAppDataDir(d);
-}
-
-
-void MApplication::setMyStyle()
-{
- QSettings set;
- if(set.contains("appstyle"))
- setStyle(set.value("appstyle").toString());
- if(set.contains("appstylesheet")){
- QFile fd(set.value("appstylesheet").toString());
- if(fd.open(QIODevice::ReadOnly)){
- setStyleSheet(QString::fromLocal8Bit(fd.readAll()));
- fd.close();
- }
- }
-}
-
-static inline void loadTranslation(QTranslator*trans,const QString&lang,const QString&prog)
-{
- QStringList lpath;
- lpath <<QApplication::applicationDirPath() <<QLibraryInfo::location(QLibraryInfo::TranslationsPath);
- for(int i=0;i<lpath.size();i++){
- bool ok=trans->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);
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2014
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2016
//
// Copyright: See README/COPYING.GPL files that come with this distribution
//
#ifndef MAGICSMOKE_MAIN_H
#define MAGICSMOKE_MAIN_H
-#include <QString>
-#include <QApplication>
-
-/**show a dialog to change the language*/
-QString choseLanguage(bool warn=true);
+#include <QtCore/QtGlobal>
#ifdef MAGICSMOKE_LIB_BUILD
#define MAGICSMOKE_EXPORT Q_DECL_EXPORT
#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<MApplication*>(qApp))
-
#endif
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (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"
void MOverview::changeLang()
{
- choseLanguage();
+ MApplication::choseLanguage();
}
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (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"
#include "jsengine.h"
#include "overview.h"
#include "msinterface.h"
-#include "main.h"
+#include "mapplication.h"
#include "templates.h"
#include <QAction>
LIBS += -lmagicsmoke
INCLUDEPATH += \
$$PWD \
- $$PWD/crypto \
$$PWD/dialogs \
- $$PWD/misc \
$$PWD/mwin \
$$PWD/script \
- $$PWD/templates \
- $$PWD/widgets
+ $$PWD/templates
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)
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