aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore7
-rw-r--r--3rd-party/SingleApplication/singleapplication.pri18
-rw-r--r--BUGS.md24
-rw-r--r--CMakeLists.txt22
-rw-r--r--LICENSE.md5
-rw-r--r--lib/about/aboutdialog.cpp2
-rw-r--r--lib/configuration/configuration.cpp21
-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
11 files changed, 90 insertions, 88 deletions
diff --git a/.hgignore b/.hgignore
index ad67aff..39716ac 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,5 @@
+syntax: glob
+
# clion
cmake-build-*
.idea
@@ -7,9 +9,10 @@ build*
.kdev4
# qtcreator
-.user
+*.user
test/plugins.d
-.git
+3rd-party/*/.git
+3rd-party/*/examples
diff --git a/3rd-party/SingleApplication/singleapplication.pri b/3rd-party/SingleApplication/singleapplication.pri
new file mode 100644
index 0000000..a82ff28
--- /dev/null
+++ b/3rd-party/SingleApplication/singleapplication.pri
@@ -0,0 +1,18 @@
+QT += core network
+CONFIG += c++11
+
+HEADERS += $$PWD/singleapplication.h \
+ $$PWD/singleapplication_p.h
+SOURCES += $$PWD/singleapplication.cpp
+
+INCLUDEPATH += $$PWD
+
+win32 {
+ msvc:LIBS += Advapi32.lib
+ gcc:LIBS += -lAdvapi32
+}
+
+DISTFILES += \
+ $$PWD/README.md \
+ $$PWD/CHANGELOG.md \
+ $$PWD/Windows.md
diff --git a/BUGS.md b/BUGS.md
index 9ac353b..a3a5153 100644
--- a/BUGS.md
+++ b/BUGS.md
@@ -26,23 +26,29 @@ _Adapted from the guide in the texmate repository._
## Known bugs
-### Search terms in address bar
-QUrl always seems to return true when checking if valid url. Workaround is to
-prepend '#' to the search.
-
-### databases-incognito in home
+#### databases-incognito in home
https://bugreports.qt.io/browse/QTBUG-62957
-### loadFinished is not always emitted when loading is finished
+#### loadFinished is not always emitted when loading is finished
https://bugreports.qt.io/browse/QTBUG-65223
-### QWebEngineView setUrl()/load() methods in some case divide page in two parts
+#### QWebEngineView setUrl()/load() methods in some case divide page in two parts
https://bugreports.qt.io/browse/QTBUG-68224
Only affects Qt 5.11.0. Set __QTBUG_68224_WORKAROUND__.
-## Wayland bugs
+### Wayland bugs
-### mainwindow.maximized doesn't work
+#### mainwindow.maximized doesn't work
setWindowState(Qt::WindowMaximized) has no effect on KDE/Wayland:
https://community.kde.org/Plasma/Wayland_Showstoppers
+
+### Windows bugs
+
+#### stdout and stderr
+Starting the application with some command-line options (like --version,
+--help, etc) causes the application to 'stall' on exit.
+
+Starting the application from the command prompt returns after launch, but
+continues outputting stdout and stderr to it.
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a76f89e..7e09b83 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,14 +46,21 @@ endif (UseLibCpp)
# detect version and commit from mercurial
if (MercurialRepo AND EXISTS "${PROJECT_SOURCE_DIR}/.hg")
- execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND hg log -r '.' --template={bookmarks} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBookmark OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg log -r '.' --template={latesttag}.{latesttagdistance} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerInfo OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg log -r '.' --template={bookmarks} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerBookmark OUTPUT_STRIP_TRAILING_WHITESPACE)
+ # remove bookmark if it's not set
if(VcsBookmark STREQUAL "")
unset(VcsBookmark)
endif()
- execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND hg identify --num WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND hg identify --branch WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --num WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --branch WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
+ set(VerInfo "0.0.0.0")
+ set(VerBookmark "unknown")
+ set(VerCommit "00000000")
+ set(VerRevision "0")
+ set(VerBranch "default")
endif()
# configure a header file to pass version information
@@ -82,8 +89,7 @@ if (Tests)
add_subdirectory(test)
endif()
-if(NOT VcsVersion STREQUAL "")
- message("VCS latesttag='${VcsVersion}' bookmark='${VcsBookmark}' commit='${VcsCommit}'")
-endif()
+message("Version='${VerInfo}' bookmark='${VerBookmark}' commit='${VerCommit}'")
+
feature_summary(WHAT ALL)
diff --git a/LICENSE.md b/LICENSE.md
index d7dc51b..09f2704 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -24,3 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
- url: http://www.boost.org/
- license: BSL-1.0
- source code: http://www.boost.org/users/download/
+
+## SingleApplication
+- url: https://github.com/itay-grudev/SingleApplication
+- license: MIT
+
diff --git a/lib/about/aboutdialog.cpp b/lib/about/aboutdialog.cpp
index 9136d4a..1b427fb 100644
--- a/lib/about/aboutdialog.cpp
+++ b/lib/about/aboutdialog.cpp
@@ -51,7 +51,7 @@ AboutDialog::AboutDialog(QWidget *parent)
"<p>This program is distributed in the hope that it will be useful, but without any warranty.</p>"));
ui->detailsLabel->setText(tr("<p>Version " SMOLBOTE_DESCRIBE "</p>"
- "<p>Build " SMOLBOTE_BRANCH ":" SMOLBOTE_COMMIT "</p>"
+ "<p>Build " SMOLBOTE_BUILD "</p>"
"<p>Compiled with " compiler "</p>"));
}
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index 648eec8..c7209e3 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -27,17 +27,6 @@ inline std::string defaultUserConfigLocation()
return path.toStdString();
}
-constexpr const char *defaultSocketPath()
-{
-#if defined(Q_OS_UNIX)
- // could be a path such as "/tmp/foo"
- return "/tmp/smolbote.socket";
-#elif defined(Q_OS_WIN32)
- // could be a pipe path such as "\\.\pipe\foo"
- return "\\\\.\\pipe\\smolbote_socket";
-#endif
-}
-
Configuration::Configuration(QObject *parent)
: QObject(parent)
{
@@ -49,18 +38,18 @@ Configuration::Configuration(QObject *parent)
("build", "Display build branch and commit.")
("config,c", po::value<std::string>()->default_value(defaultUserConfigLocation()), "Set the configuration file.")
- ("socket,s", po::value<std::string>()->default_value(defaultSocketPath()), "Local server socket")
+ ("no-remote", "Do not accept or send remote commands.")
- ("args", po::value<std::vector<std::string>>(), "arguments")
+ ("args", po::value<std::vector<std::string>>(), "Command(s) and/or URL(s).")
;
arguments_desc.add("args", -1);
configuration_desc.add_options()
("browser.stylesheet", po::value<std::string>())
- ("browser.session", po::value<std::string>(), "Load session data from the specified path.")
- ("browser.locale", po::value<std::string>())
- ("browser.translation", po::value<std::string>())
+ ("browser.session", po::value<std::string>(), "Load session data from specified arg.")
+ ("browser.locale", po::value<std::string>(), "Set Qt localization.")
+ ("browser.translation", po::value<std::string>(), "Set application localization.")
// main window ui
("mainwindow.height", po::value<int>()->default_value(720))
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
+