aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2024-04-27 19:18:12 +0300
committeraqua <aqua@iserlohn-fortress.net>2024-04-27 19:31:41 +0300
commit289966819b657de3c1b1704555963ee77d9b60da (patch)
tree03dc994d72523e2c16fb2d4ef42e9b90ff410e1d
parentUpdated pkgbuild (diff)
downloadsmolbote-289966819b657de3c1b1704555963ee77d9b60da.tar.xz
Readded command line options
-rw-r--r--linux/makepkg/PKGBUILD27
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/main.cpp76
3 files changed, 72 insertions, 38 deletions
diff --git a/linux/makepkg/PKGBUILD b/linux/makepkg/PKGBUILD
index 9f3fae9..9981f46 100644
--- a/linux/makepkg/PKGBUILD
+++ b/linux/makepkg/PKGBUILD
@@ -1,8 +1,6 @@
# Maintainer: Aqua-sama <aqua at iserlohn-fortress dot net>
## not-use flags
-# Enable plugin signing:
-_signPlugins=0
# install prefix
_prefix='/usr'
@@ -11,7 +9,7 @@ pkgdesc='Yet another no-frills browser'
pkgver=0
pkgrel=1
-url="https://neueland.iserlohn-fortress.net/gitea/smolbote"
+url="https://neueland.iserlohn-fortress.net/cgit/smolbote"
install="smolbote.install"
arch=('x86_64' 'aarch64')
@@ -21,19 +19,14 @@ depends=('qt6-svg' 'qt6-webengine' 'spdlog' 'fmt')
makedepends=('git' 'cmake' 'python-kconfiglib' 'openssl' 'qt6-tools' 'scdoc')
optdepends=('firejail: launch a sandboxed instance')
-# this isn't a hard requirement, simply a workaround as the build script
-# sets some additional hardening flags that the default makepkg.conf
-# will turn down
-options=(!buildflags)
-
# use git+file:///path/to/your/repo to build from a local repo
source=("git+https://neueland.iserlohn-fortress.net/cgit/smolbote"
- "https://github.com/itay-grudev/SingleApplication/archive/refs/tags/v3.4.1.tar.gz")
+ "SingleApplication-v3.4.1.tar.gz::https://github.com/itay-grudev/SingleApplication/archive/refs/tags/v3.4.1.tar.gz")
-sha256sums=('SKIP'
- '7dfa5cafc30ae6d8b108fff7e99d35e52e728e9c2876202bcd612dbb75cc44ea')
+b2sums=('SKIP'
+ 'fe320ccb0390b13b1c7b0c017cff34b02f5138bd6643457843a7200374c8a994a37a1b00a65c70e83ba5bdc61f157ccfaa8cdfc0eee7b2149df4acda06173669')
-validgpgkeys=(BB1C090188E3E32B375C13FD095DE26BC16D2E98) # Aqua-sama <aqua@iserlohn-fortress.net>
+validpgpkeys=(BB1C090188E3E32B375C13FD095DE26BC16D2E98) # Aqua-sama <aqua@iserlohn-fortress.net>
prepare() {
mkdir "$srcdir/smolbote/third_party"
@@ -43,6 +36,7 @@ prepare() {
KCONFIG_CONFIG=linux/.config alldefconfig
cmake -S $srcdir/smolbote -B $srcdir/build \
+ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr
}
@@ -53,13 +47,12 @@ pkgver() {
}
build() {
- echo "make flags: ${MAKEFLAGS}"
- cmake --build $srcdir/build -j16
+ cmake --build $srcdir/build -- ${MAKEFLAGS}
}
-#check() {
-# ninja -C $srcdir/build test
-#}
+check() {
+ ctest --test-dir $srcdir/build
+}
package() {
DESTDIR="$pkgdir" cmake --install $srcdir/build --strip
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b1ec891..bd6082a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,12 @@
# settings.h
-add_custom_target(settings.h
- ${PROJECT_SOURCE_DIR}/scripts/gen-default-cfg.py
+add_custom_command(
+ OUTPUT settings.h
+ COMMAND ${PROJECT_SOURCE_DIR}/scripts/gen-default-cfg.py
--kconfig ${PROJECT_SOURCE_DIR}/Kconfig
--dotconfig ${PROJECT_SOURCE_DIR}/linux/.config
--input ${CMAKE_CURRENT_LIST_DIR}/settings.h.in
--output settings.h
- BYPRODUCTS settings.h
+ DEPENDS ${PROJECT_SOURCE_DIR}/linux/.config
)
# version.h
diff --git a/src/main.cpp b/src/main.cpp
index 60c3031..42acf5c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,21 +25,61 @@ int main(int argc, char **argv)
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
#endif
- init_conf("");
-
- // argc, argv, allowSecondary
- Browser app(argc, argv);
- // set this, otherwise the webview becomes black when using a stylesheet
- app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
-
QCommandLineParser parser;
parser.addHelpOption();
+ parser.addVersionOption();
parser.addPositionalArgument("url", "URLs to open");
+
+ // generic options
+ QCommandLineOption cmd_config({ "c", "config" }, "Set the configuration file.", "path");
+ parser.addOption(cmd_config);
+
+ QCommandLineOption cmd_session({ "s", "session" }, "Open the specified session.", "path");
+ parser.addOption(cmd_session);
+
+ QCommandLineOption cmd_pick_session("pick-session", "Show all available sessions and select which one to open.");
+ parser.addOption(cmd_pick_session);
+
+ // Qt options
+ QCommandLineOption cmd_renderer("renderer", "Select the OpenGL renderer used by the application. Available options are: desktop, gles, software", "value");
+ parser.addOption(cmd_renderer);
+
+ // SingleApplication options
+ QCommandLineOption cmd_no_remote("no-remote", "Start a new instance that won't accept or send remote commands.");
+ parser.addOption(cmd_no_remote);
+
+ { // handle command line options that need to be set before the QApplication object is created
+ QStringList args;
+ for(int i = 0; i < argc; ++i)
+ args.append(argv[i]);
+ parser.parse(args);
+
+ // the OpenGL implementation needs to be manually set to software if it's not properly configured
+ if(parser.isSet(cmd_renderer)) {
+ const auto value = parser.value(cmd_renderer);
+ if(value == QLatin1String("desktop")) {
+ QApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true);
+ } else if(value == QLatin1String("gles")) {
+ QApplication::setAttribute(Qt::AA_UseOpenGLES, true);
+ } else if(value == QLatin1String("software")) {
+ QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
+ } else {
+ spdlog::error("Unknown cmd_renderer flag: {}", qUtf8Printable(value));
+ }
+ }
+ }
+
+ // set this, otherwise the webview becomes black when using a stylesheet
+ QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
+
+ init_conf(parser.value(cmd_config).toStdString());
+
+ Browser app(argc, argv);
parser.process(app);
const auto profile = []() {
- Configuration c;
- return c.value<QString>("profile.default").value();
+ Configuration conf;
+ return conf.value<QString>("profile.default").value();
}();
QStringList urls = parser.positionalArguments();
@@ -48,8 +88,8 @@ int main(int argc, char **argv)
}
// if app is primary, create new sessions from received messages
- if(app.isPrimary() /*&& !cmd_noRemote*/) {
- QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) {
+ if(app.isPrimary() && !parser.isSet(cmd_no_remote)) {
+ QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, const QByteArray &message) {
Q_UNUSED(instanceId);
JsonSession session(message);
app.open(session.get());
@@ -58,28 +98,28 @@ int main(int argc, char **argv)
{
const auto session = [&]() {
- /*if(cmd_session) {
- QFile sessionJson(QString::fromStdString(args::get(cmd_session)));
+ if(parser.isSet(cmd_session)) {
+ QFile sessionJson(parser.value(cmd_session));
if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) {
return JsonSession(sessionJson.readAll());
}
}
- if(cmd_pickSession) {
+ if(parser.isSet(cmd_pick_session)) {
SessionDialog dlg;
if(const auto pick = dlg.pickSession()) {
return JsonSession(pick.value());
}
- }*/
+ }
return JsonSession(profile, urls);
}();
- if(app.isPrimary() /*|| cmd_noRemote */) {
+ if(app.isPrimary() || parser.isSet(cmd_no_remote)) {
app.open(session.get());
} else {
// app is secondary and not standalone
- return app.sendMessage(session.serialize());
+ return app.sendMessage(session.serialize()) ? EXIT_SUCCESS : EXIT_FAILURE;
}
}
- return app.exec();
+ return QApplication::exec();
}