aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp6
-rw-r--r--src/browser.h2
-rw-r--r--src/main.cpp28
-rw-r--r--src/version.h.in43
4 files changed, 27 insertions, 52 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 38c7d85..f056525 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -26,14 +26,12 @@
#include "profilemanager.h"
#include <QJsonDocument>
-Browser::Browser(int &argc, char *argv[])
- : SingleApplication(argc, argv, true, SingleApplication::User | SingleApplication::SecondaryNotification | SingleApplication::ExcludeAppVersion)
+Browser::Browser(int &argc, char *argv[], bool allowSecondary)
+ : SingleApplication(argc, argv, allowSecondary, SingleApplication::User | SingleApplication::SecondaryNotification | SingleApplication::ExcludeAppVersion)
{
setApplicationName("smolbote");
setWindowIcon(QIcon(":/icon.svg"));
setApplicationVersion(SMOLBOTE_VERSION);
-
- //qDebug(QAPPLICATION_CLASS);
}
Browser::~Browser()
diff --git a/src/browser.h b/src/browser.h
index b03243f..99da8a7 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -29,7 +29,7 @@ class Browser : public SingleApplication
Q_OBJECT
public:
- explicit Browser(int &argc, char *argv[]);
+ explicit Browser(int &argc, char *argv[], bool allowSecondary = true);
~Browser() final;
public slots:
diff --git a/src/main.cpp b/src/main.cpp
index e81c846..d7bcee0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
// --build
if(config->exists("build")) {
- std::cout << SMOLBOTE_BRANCH << ":" << SMOLBOTE_COMMIT;
+ std::cout << SMOLBOTE_BUILD;
return 0;
}
@@ -92,17 +92,11 @@ int main(int argc, char **argv)
return 0;
}
+ // argc, argv, allowSecondary
Browser app(argc, argv);
// set this, otherwise the webview becomes black when using a stylesheet
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
- if(app.isPrimary())
- qDebug("app is primary");
- else if(app.isSecondary())
- qDebug("app is secondary");
- else
- qDebug("app is something?");
-
// translator
if(config->exists("browser.locale")) {
auto *translator = new QTranslator(&app);
@@ -121,9 +115,8 @@ int main(int argc, char **argv)
}
// command line arguments
+ bool ignoreSecondary = config->exists("no-remote");
auto arguments = config->value<std::vector<std::string>>("args");
-
- auto socket = config->value<QString>("socket");
auto session = config->value<QString>("browser.session");
auto profile = config->value<QString>("profile.default");
@@ -145,14 +138,19 @@ int main(int argc, char **argv)
}
}
- // set up socket
- QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) {
- auto doc = QJsonDocument::fromJson(message);
- app.createSession(doc.object());
- });
+ //
+ if(!ignoreSecondary) {
+ QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) {
+ auto doc = QJsonDocument::fromJson(message);
+ app.createSession(doc.object());
+ });
+ }
if(app.isPrimary()) {
app.createSession(Session::toJsonObject(profile.value(), urls));
+ } else if(ignoreSecondary) {
+ // app is not primary (= secondary), and --ignore-secondary is set
+ return -1;
} else if(session) {
QFile sessionJson(session.value());
if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) {
diff --git a/src/version.h.in b/src/version.h.in
index 03d00d1..055c84b 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -1,44 +1,23 @@
#ifndef SMOLBOTE_VERSION_H
#define SMOLBOTE_VERSION_H
-// VcsVersion gets defined by the CMakeLists if project-src/.hg exists
-#cmakedefine VcsVersion
-#cmakedefine VcsBookmark
+#cmakedefine VerBookmark
-#ifdef VcsVersion
+#ifdef VerBookmark
+// Version: tag.tagdistance-activebookmark
+#define SMOLBOTE_VERSION "@VerInfo@-@VerBookmark@"
-#ifdef VcsBookmark
-// Version: 1.2.3 (stable)
-#define SMOLBOTE_VERSION "@VcsVersion@ (@VcsBookmark@)"
#else
-// Version: 1.2.3
-#define SMOLBOTE_VERSION "@VcsVersion@"
-#endif
+// Version: tag.tagdistance
+#define SMOLBOTE_VERSION "@VerInfo@"
-// Describe: 1.2.3-r123-0123456789ab
-#define SMOLBOTE_DESCRIBE "@VcsVersion@-r@VcsRevision@-@VcsCommit@"
-
-// Commit
-#define SMOLBOTE_COMMIT "@VcsCommit@"
-
-// Branch: default
-#define SMOLBOTE_BRANCH "@VcsBranch@"
-
-#else
-
-// If VcsVersion has not been defined, these values will be used
-// Version: 1.2.3
-#define SMOLBOTE_VERSION "0.3.0"
+#endif // Bookmark
// Describe: 1.2.3-r123-0123456789ab
-#define SMOLBOTE_DESCRIBE "0.3.0-release"
-
-// Commit
-#define SMOLBOTE_COMMIT "package"
+#define SMOLBOTE_DESCRIBE "@VerInfo@-r@VerRevision@-@VerCommit@"
-// Branch: default
-#define SMOLBOTE_BRANCH "release"
-
-#endif
+// Build
+#define SMOLBOTE_BUILD "@VerBranch@:@VerCommit@"
#endif // SMOLBOTE_VERSION_H
+