aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LuminaSingleApplication.h
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2016-04-25 13:08:12 -0400
committerKen Moore <moorekou@gmail.com>2016-04-25 13:08:12 -0400
commited5ecf7ea7a482b4649e66ecb35fbc60af680684 (patch)
treeacc0fa17d228259e847f55c678db9fb0a9b50f0c /src-qt5/core/libLumina/LuminaSingleApplication.h
parentMerge branch 'master' of github.com:pcbsd/lumina (diff)
downloadlumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.tar.gz
lumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.tar.bz2
lumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.zip
Rearrange the Lumina source tree quite a bit:
Now the utilites are arranged by category (core, core-utils, desktop-utils), so all the -utils may be excluded by a package system (or turned into separate packages) as needed.
Diffstat (limited to 'src-qt5/core/libLumina/LuminaSingleApplication.h')
-rw-r--r--src-qt5/core/libLumina/LuminaSingleApplication.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.h b/src-qt5/core/libLumina/LuminaSingleApplication.h
new file mode 100644
index 00000000..725d8e40
--- /dev/null
+++ b/src-qt5/core/libLumina/LuminaSingleApplication.h
@@ -0,0 +1,59 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the general class for a single-instance application
+//===========================================
+//EXAMPLE USAGE in main.cpp:
+//
+// LSingleApplication app(argc, argv);
+// if( !app.isPrimaryProcess() ){
+// return 0;
+// }
+// QMainWindow w; //or whatever the main window class is
+// connect(app, SIGNAL(InputsAvailable(QStringList)), w, SLOT(<some slot>)); //for interactive apps - optional
+// app.exec();
+//===========================================
+#ifndef _LUMINA_LIBRARY_SINGLE_APPLICATION_H
+#define _LUMINA_LIBRARY_SINGLE_APPLICATION_H
+
+#include <QString>
+#include <QStringList>
+#include <QLocalServer>
+#include <QLockFile>
+#include <QApplication>
+
+#include <LuminaUtils.h>
+
+//NOTE: This application type will automatically load the proper translation file(s)
+// if the application name is set properly
+class LSingleApplication : public QApplication{
+ Q_OBJECT
+public:
+ LSingleApplication(int &argc, char **argv, QString appname);
+ ~LSingleApplication();
+
+ bool isPrimaryProcess();
+
+ QStringList inputlist; //in case the app wants access to modified inputs (relative path fixes and such)
+
+private:
+ bool isActive, isBypass;
+ QLockFile *lockfile;
+ QLocalServer *lserver;
+ QString cfile;
+ QTranslator *cTrans; //current translation
+
+ void PerformLockChecks();
+
+private slots:
+ void newInputsAvailable(); //internally used to detect a message from an alternate instance
+
+signals:
+ void InputsAvailable(QStringList);
+
+};
+
+#endif
bgstack15