diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-03 16:39:32 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-03 16:39:32 +0100 |
commit | 85d9f14aa8bac16ab341662c770b64a15c21628b (patch) | |
tree | 422db18e798646cd4bc98abf342f25c09c0bdf1d | |
parent | Download items' width should no longer exceed the list width (diff) | |
download | smolbote-85d9f14aa8bac16ab341662c770b64a15c21628b.tar.xz |
Changed from qbs to cmake
-rw-r--r-- | CMakeLists.txt | 96 | ||||
-rw-r--r-- | docs/manual/Building.md | 23 | ||||
-rw-r--r-- | lib/bookmarks/CMakeLists.txt | 10 | ||||
-rw-r--r-- | lib/bookmarks/bookmarksform.ui (renamed from src/lib/bookmarks/bookmarksform.ui) | 0 | ||||
-rw-r--r-- | lib/bookmarks/bookmarkswidget.cpp (renamed from src/lib/bookmarks/bookmarkswidget.cpp) | 0 | ||||
-rw-r--r-- | lib/bookmarks/bookmarkswidget.h (renamed from src/lib/bookmarks/bookmarkswidget.h) | 0 | ||||
-rw-r--r-- | lib/bookmarks/xbel.cpp (renamed from src/lib/bookmarks/xbel.cpp) | 0 | ||||
-rw-r--r-- | lib/bookmarks/xbel.h (renamed from src/lib/bookmarks/xbel.h) | 0 | ||||
-rw-r--r-- | lib/downloads/CMakeLists.txt | 13 | ||||
-rw-r--r-- | lib/downloads/downloadsform.ui (renamed from src/lib/downloads/downloadsform.ui) | 0 | ||||
-rw-r--r-- | lib/downloads/downloadswidget.cpp (renamed from src/lib/downloads/downloadswidget.cpp) | 0 | ||||
-rw-r--r-- | lib/downloads/downloadswidget.h (renamed from src/lib/downloads/downloadswidget.h) | 0 | ||||
-rw-r--r-- | lib/downloads/widgets/downloaditemform.ui (renamed from src/lib/downloads/widgets/downloaditemform.ui) | 0 | ||||
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.cpp (renamed from src/lib/downloads/widgets/downloaditemwidget.cpp) | 0 | ||||
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.h (renamed from src/lib/downloads/widgets/downloaditemwidget.h) | 0 | ||||
-rw-r--r-- | lib/downloads/widgets/elidedlabel.cpp (renamed from src/lib/downloads/widgets/elidedlabel.cpp) | 0 | ||||
-rw-r--r-- | lib/downloads/widgets/elidedlabel.h (renamed from src/lib/downloads/widgets/elidedlabel.h) | 0 | ||||
-rw-r--r-- | lib/navigation/CMakeLists.txt | 11 | ||||
-rw-r--r-- | lib/navigation/navigationbutton.cpp (renamed from src/lib/navigation/navigationbutton.cpp) | 0 | ||||
-rw-r--r-- | lib/navigation/navigationbutton.h (renamed from src/lib/navigation/navigationbutton.h) | 2 | ||||
-rw-r--r-- | lib/navigation/urlcompleter.cpp (renamed from src/lib/navigation/urlcompleter.cpp) | 0 | ||||
-rw-r--r-- | lib/navigation/urlcompleter.h (renamed from src/lib/navigation/urlcompleter.h) | 0 | ||||
-rw-r--r-- | lib/navigation/urllineedit.cpp (renamed from src/lib/navigation/urllineedit.cpp) | 2 | ||||
-rw-r--r-- | lib/navigation/urllineedit.h (renamed from src/lib/navigation/urllineedit.h) | 0 | ||||
-rw-r--r-- | lib/settings/CMakeLists.txt | 10 | ||||
-rw-r--r-- | lib/settings/configuration.cpp | 4 | ||||
-rw-r--r-- | lib/settings/settings.qbs | 38 | ||||
-rw-r--r-- | linux/makepkg/PKGBUILD | 53 | ||||
-rwxr-xr-x | mach | 65 | ||||
-rw-r--r-- | smolbote.qbs | 153 | ||||
-rw-r--r-- | src/forms/aboutdialog.cpp | 37 | ||||
-rw-r--r-- | src/forms/aboutdialog.h | 2 | ||||
-rw-r--r-- | src/interfaces.h | 41 | ||||
-rw-r--r-- | src/lib/bookmarks/bookmarks.qbs | 25 | ||||
-rw-r--r-- | src/lib/downloads/downloads.qbs | 28 | ||||
-rw-r--r-- | src/lib/navigation/navigation.qbs | 26 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/settings.cpp | 182 | ||||
-rw-r--r-- | src/settings.h | 47 | ||||
-rw-r--r-- | src/version.h.in | 7 | ||||
-rw-r--r-- | src/webengine/webview.h | 2 | ||||
-rwxr-xr-x | tools/hooks/pre-commit.rb | 2 |
42 files changed, 205 insertions, 675 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8700909 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,96 @@ +cmake_minimum_required(VERSION 3.1.0) +project(smolbote) + +# Options +option(UseLibCpp "Use libc++ over stdlibc++" OFF) + +# Libraries +find_package(Qt5Core REQUIRED) +find_package(Qt5Widgets REQUIRED) +find_package(Qt5WebEngineWidgets REQUIRED) +find_package(libconfig++ REQUIRED) + +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +# Global C++ settings +set(CMAKE_CXX_STANDARD 17) +add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050900) + +# link to libc++ +if (UseLibCpp) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") +endif (UseLibCpp) + +add_subdirectory(lib/settings) +add_subdirectory(lib/bookmarks) +add_subdirectory(lib/downloads) +add_subdirectory(lib/navigation) + +# configure a header file to pass version information +execute_process(COMMAND "git" "describe" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GitDescribe OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND "git" "describe" "--abbrev=0" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GitVersion OUTPUT_STRIP_TRAILING_WHITESPACE) +configure_file(src/version.h.in "${PROJECT_BINARY_DIR}/version.h") + +set(SourceCode + # main + "src/main.cpp" + "src/singleapplication.cpp" + "src/singleapplication.h" + "src/browser.cpp" + "src/browser.h" + + # main window + # todo: move all to src/mainwindow + "src/mainwindow.cpp" + "src/mainwindow.h" + "src/mainwindow.ui" + "src/widgets/loadingbar.cpp" + "src/widgets/loadingbar.h" + "src/widgets/mainwindowmenubar.cpp" + "src/widgets/mainwindowmenubar.h" + "src/widgets/mainwindowtabbar.cpp" + "src/widgets/mainwindowtabbar.h" + # todo: move to src/mainwindow + "src/forms/searchform.cpp" + "src/forms/searchform.h" + "src/forms/searchform.ui" + "data/resources.qrc" + + # webengine + "src/webengine/urlinterceptor.cpp" + "src/webengine/urlinterceptor.h" + "src/webengine/webengineprofile.cpp" # todo: rename to profile + "src/webengine/webengineprofile.h" + "src/webengine/webpage.cpp" + "src/webengine/webpage.h" + "src/webengine/webview.cpp" + "src/webengine/webview.h" + + # forms + "src/forms/aboutdialog.cpp" + "src/forms/aboutdialog.h" + "src/forms/aboutdialog.ui" + "src/forms/profileview.cpp" + "src/forms/profileview.h" + "src/forms/profileview.ui" + # todo: move to src/webengine + "src/forms/cookiesform.cpp" + "src/forms/cookiesform.h" + "src/forms/cookiesform.ui" + ) + +add_executable(poi ${SourceCode}) + +target_include_directories(poi PRIVATE src lib) + +target_link_libraries(poi Qt5::Core Qt5::Widgets Qt5::WebEngineWidgets) +target_link_libraries(poi config++ configuration) +target_link_libraries(poi bookmarks downloads navigation) + +install(TARGETS poi DESTINATION bin CONFIGURATIONS Release) diff --git a/docs/manual/Building.md b/docs/manual/Building.md index 56a6646..a0c6d94 100644 --- a/docs/manual/Building.md +++ b/docs/manual/Building.md @@ -13,24 +13,19 @@ * A working compiler - gcc or clang on Linux - msvc on Windows due to QtWebEngine -* qbs - - minimal version 1.8.0 +* cmake + - minimal version 3.1.0, but please use something up-to-date ## Compiling - -### Create qbs configuration -Before you can build anything with qbs, you need to set up the compiler -toolchain. - ``` -qbs setup-toolchains --detect -qbs setup-qt /usr/bin/qmake-qt5 qt5 +cmake -DCMAKE_BUILD_TYPE=Release ../smolbote.git +make -j 4 ``` -### Compiling -``` -mkdir ../build -qbs build -d ../build profile:qt5 release +### Using libc++ +```text +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DUseLibCpp=On ../smolbote.git +make -j 4 ``` ## Packaging @@ -46,7 +41,7 @@ sha512sum --binary head.tar.lz > head.tar.lz.sha512 ``` ### makepkg -A PKGBUILD is provided in linux/makepkg/PKGBUILD. +A PKGBUILD is provided in linux/makepkg/PKGBUILD. Please read before using. ## Troubleshooting diff --git a/lib/bookmarks/CMakeLists.txt b/lib/bookmarks/CMakeLists.txt new file mode 100644 index 0000000..8fb7f45 --- /dev/null +++ b/lib/bookmarks/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.0) + +add_library(bookmarks + bookmarksform.ui + bookmarkswidget.cpp + bookmarkswidget.h + xbel.cpp + xbel.h) + +target_link_libraries(bookmarks Qt5::Widgets)
\ No newline at end of file diff --git a/src/lib/bookmarks/bookmarksform.ui b/lib/bookmarks/bookmarksform.ui index 2df0c4b..2df0c4b 100644 --- a/src/lib/bookmarks/bookmarksform.ui +++ b/lib/bookmarks/bookmarksform.ui diff --git a/src/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp index cb191c7..cb191c7 100644 --- a/src/lib/bookmarks/bookmarkswidget.cpp +++ b/lib/bookmarks/bookmarkswidget.cpp diff --git a/src/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h index aa188b2..aa188b2 100644 --- a/src/lib/bookmarks/bookmarkswidget.h +++ b/lib/bookmarks/bookmarkswidget.h diff --git a/src/lib/bookmarks/xbel.cpp b/lib/bookmarks/xbel.cpp index 523ed99..523ed99 100644 --- a/src/lib/bookmarks/xbel.cpp +++ b/lib/bookmarks/xbel.cpp diff --git a/src/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h index ed0a256..ed0a256 100644 --- a/src/lib/bookmarks/xbel.h +++ b/lib/bookmarks/xbel.h diff --git a/lib/downloads/CMakeLists.txt b/lib/downloads/CMakeLists.txt new file mode 100644 index 0000000..ca67f0a --- /dev/null +++ b/lib/downloads/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1.0) + +add_library(downloads + downloadsform.ui + downloadswidget.cpp + downloadswidget.h + widgets/downloaditemform.ui + widgets/downloaditemwidget.cpp + widgets/downloaditemwidget.h + widgets/elidedlabel.cpp + widgets/elidedlabel.h) + +target_link_libraries(downloads Qt5::Widgets Qt5::WebEngineWidgets)
\ No newline at end of file diff --git a/src/lib/downloads/downloadsform.ui b/lib/downloads/downloadsform.ui index 43a0d49..43a0d49 100644 --- a/src/lib/downloads/downloadsform.ui +++ b/lib/downloads/downloadsform.ui diff --git a/src/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp index f9a8f34..f9a8f34 100644 --- a/src/lib/downloads/downloadswidget.cpp +++ b/lib/downloads/downloadswidget.cpp diff --git a/src/lib/downloads/downloadswidget.h b/lib/downloads/downloadswidget.h index 8c9ea21..8c9ea21 100644 --- a/src/lib/downloads/downloadswidget.h +++ b/lib/downloads/downloadswidget.h diff --git a/src/lib/downloads/widgets/downloaditemform.ui b/lib/downloads/widgets/downloaditemform.ui index 17f1d6a..17f1d6a 100644 --- a/src/lib/downloads/widgets/downloaditemform.ui +++ b/lib/downloads/widgets/downloaditemform.ui diff --git a/src/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index fff3cfc..fff3cfc 100644 --- a/src/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp diff --git a/src/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h index c6246da..c6246da 100644 --- a/src/lib/downloads/widgets/downloaditemwidget.h +++ b/lib/downloads/widgets/downloaditemwidget.h diff --git a/src/lib/downloads/widgets/elidedlabel.cpp b/lib/downloads/widgets/elidedlabel.cpp index dc17d32..dc17d32 100644 --- a/src/lib/downloads/widgets/elidedlabel.cpp +++ b/lib/downloads/widgets/elidedlabel.cpp diff --git a/src/lib/downloads/widgets/elidedlabel.h b/lib/downloads/widgets/elidedlabel.h index d0f6221..d0f6221 100644 --- a/src/lib/downloads/widgets/elidedlabel.h +++ b/lib/downloads/widgets/elidedlabel.h diff --git a/lib/navigation/CMakeLists.txt b/lib/navigation/CMakeLists.txt new file mode 100644 index 0000000..4a4cf94 --- /dev/null +++ b/lib/navigation/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1.0) + +add_library(navigation + navigationbutton.cpp + navigationbutton.h + urlcompleter.cpp + urlcompleter.h + urllineedit.cpp + urllineedit.h) + +target_link_libraries(navigation Qt5::Widgets Qt5::WebEngineWidgets)
\ No newline at end of file diff --git a/src/lib/navigation/navigationbutton.cpp b/lib/navigation/navigationbutton.cpp index 13daebc..13daebc 100644 --- a/src/lib/navigation/navigationbutton.cpp +++ b/lib/navigation/navigationbutton.cpp diff --git a/src/lib/navigation/navigationbutton.h b/lib/navigation/navigationbutton.h index ec39efa..7c76b9c 100644 --- a/src/lib/navigation/navigationbutton.h +++ b/lib/navigation/navigationbutton.h @@ -10,7 +10,7 @@ #define NAVIGATIONBUTTON_H #include <QToolButton> -#include <webengine/webview.h> +#include "../../src/webengine/webview.h" class QMenu; diff --git a/src/lib/navigation/urlcompleter.cpp b/lib/navigation/urlcompleter.cpp index bbde297..bbde297 100644 --- a/src/lib/navigation/urlcompleter.cpp +++ b/lib/navigation/urlcompleter.cpp diff --git a/src/lib/navigation/urlcompleter.h b/lib/navigation/urlcompleter.h index f2c52ff..f2c52ff 100644 --- a/src/lib/navigation/urlcompleter.h +++ b/lib/navigation/urlcompleter.h diff --git a/src/lib/navigation/urllineedit.cpp b/lib/navigation/urllineedit.cpp index 4dc6b39..24924bb 100644 --- a/src/lib/navigation/urllineedit.cpp +++ b/lib/navigation/urllineedit.cpp @@ -18,7 +18,7 @@ // ssl menu #include <QLabel> -#include "lib/bookmarks/bookmarkswidget.h" +#include "../bookmarks/bookmarkswidget.h" #include <QCompleter> diff --git a/src/lib/navigation/urllineedit.h b/lib/navigation/urllineedit.h index 46366a7..46366a7 100644 --- a/src/lib/navigation/urllineedit.h +++ b/lib/navigation/urllineedit.h diff --git a/lib/settings/CMakeLists.txt b/lib/settings/CMakeLists.txt new file mode 100644 index 0000000..704c40f --- /dev/null +++ b/lib/settings/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.0) + +add_library(configuration + configuration.cpp + configuration.h + settingsdialog.cpp + settingsdialog.h + settingsdialog.ui) + +target_link_libraries(configuration Qt5::Widgets)
\ No newline at end of file diff --git a/lib/settings/configuration.cpp b/lib/settings/configuration.cpp index 34d50db..4603779 100644 --- a/lib/settings/configuration.cpp +++ b/lib/settings/configuration.cpp @@ -214,6 +214,8 @@ void Configuration::setValue(std::string path, const T &val) // compiler complained about operator= not taking unsinged ints, longs and long longs if constexpr(std::is_unsigned_v<T> && !std::is_same_v<T, bool>) { setting = static_cast<typename std::make_signed_t<T>>(val); + } else if constexpr(std::is_same_v<T, std::string>) { + setting = static_cast<std::string>(val).c_str(); } else { setting = val; } @@ -240,6 +242,8 @@ void Configuration::setValue(std::string path, const T &val) if constexpr(std::is_unsigned_v<T> && !std::is_same_v<T, bool>) { *userSetting = static_cast<typename std::make_signed_t<T>>(val); + } else if constexpr(std::is_same_v<T, std::string>) { + *userSetting = static_cast<std::string>(val).c_str(); } else { *userSetting = val; } diff --git a/lib/settings/settings.qbs b/lib/settings/settings.qbs deleted file mode 100644 index 0559daa..0000000 --- a/lib/settings/settings.qbs +++ /dev/null @@ -1,38 +0,0 @@ -import qbs - -Project { - name: "Settings" - - StaticLibrary { - name: "settings" - - Depends { name: "cpp" } - - cpp.defines: "C_LIKE_CONFIG" - cpp.cxxLanguageVersion: "c++17" - - files: [ - "configuration.cpp", - "configuration.h" - ] - } - - StaticLibrary { - name: "settingsDialog" - - Depends { name: "cpp" } - - Depends { - name: "Qt" - submodules: ["core", "widgets"] - } - - cpp.cxxLanguageVersion: "c++17" - - files: [ - "settingsdialog.cpp", - "settingsdialog.h", - "settingsdialog.ui", - ] - } -} diff --git a/linux/makepkg/PKGBUILD b/linux/makepkg/PKGBUILD index 31b2e9b..69cea4b 100644 --- a/linux/makepkg/PKGBUILD +++ b/linux/makepkg/PKGBUILD @@ -10,57 +10,36 @@ arch=('x86_64') license=('GPL3') depends=('qt5-base' 'qt5-webengine') -makedepends=('git' 'qt5-tools' 'qbs' 'libconfig' 'pkg-config') +makedepends=('git' 'qt5-tools' 'cmake' 'libconfig' 'pkg-config') source=("git+git://neueland.iserlohn-fortress.net/smolbote.git") sha512sums=('SKIP') -# qmake location for your Qt version -# Useful if you have another Qt version installed in a specific location -_qmake='/usr/bin/qmake-qt5' - -# compiler profile for the qt profile -_compiler='clang' - -# Target architecture: x86 x86_64 arm -_architecture='x86_64' -# Optimization level: none, fast, small -_optimization='fast' - -# install root, ex: '/usr' or '/usr/local' -# Should this install in /usr/bin, or in /usr/local/bin, or perhaps in /somewhere/else/bin? -_installroot='/usr/local' +prepare() { + # any patches go here +} pkgver() { cd smolbote echo "$(git describe --long --tags | tr - .)" } -prepare() { - # Prepare qbs toolchain - # qbs config location - rm -rf config - mkdir config - - qbs-setup-toolchains --settings-dir config --detect - qbs-setup-qt --settings-dir config ${_qmake} qt +build() { + cd "$pkgname-$pkgver" - # set a custom compiler profile - #qbs-config --settings-dir config profiles.${_compiler}.qbs.architecture ${_architecture} - qbs-config --settings-dir config profiles.${_compiler}.qbs.optimization ${_optimization} - qbs-config --settings-dir config profiles.qt.baseProfile ${_compiler} + # Generate a makefile + # Adjust the install prefix as necessary, default is /usr/local/bin + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "$srcdir" - # Clear out the build folder - rm -rf build - mkdir build -} + # Use this if you want to link with libc++ instead + # This requires clang, since gcc doesn't understand the concept of not using GPL software + #cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DUseLibCpp=On "$srcdir" -build() { - cd smolbote - qbs build --settings-dir ../config -d ../build -p poi profile:qt release + # build, with 4 threads + make -j 4 } package() { - cd smolbote - qbs install --settings-dir ../config -d ../build -p poi --install-root "${pkgdir}${_installroot}" profile:qt release + cd "$pkgname-$pkgver" + make install } @@ -1,65 +0,0 @@ -#!/usr/bin/env ruby -# DISCLAIMER: this is not Mozilla's mach - -require 'optparse' - -options = { - :settingsDir => "../build/config", - :profile => 'qt5', - :build => 'release', - :buildDir => '../build', -} - -OptionParser.new do |opts| - opts.banner = "Usage: ./mach [options]" - - opts.on("-h", "--help", "Prints this help") do - puts opts - puts "Options: #{options}" - puts 'Commands: setup, run, clean, build' - exit - end - - opts.on("--profile", "Set profile") do |profile| - options[:profile] = profile - end - - opts.on("-d", "--build DIRECTORY", "Build location") do |dir| - options[:buildDir] = dir - end - - opts.on("-i", "--install DIRECTORY", "Install location") do |dir| - options[:installDir] = dir - end - - opts.on("--debug", "Debug build") do - options[:build] = 'debug' - end - - opts.on("--release", "Release build") do - options[:build] = 'release' - end - -end.parse! - -if not ARGV.empty? then - ARGV.each do|arg| - case arg - when 'setup' - system "qbs-setup-toolchains --settings-dir #{options[:settingsDir]} --detect" - system "qbs-setup-qt --settings-dir #{options[:settingsDir]} /usr/bin/qmake-qt5 #{options[:profile]}" - when 'run' - system "qbs run --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} -p poi profile:#{options[:profile]} #{options[:build]}" - when 'clean' - system "qbs clean --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} profile:#{options[:profile]} #{options[:build]}" - when 'build' - system "qbs build --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} --force-probe-execution profile:#{options[:profile]} #{options[:build]}" - else - puts "Unknown argument #{arg}; use ./mach -h for more details" - end - end - -else - puts 'No arguments; use ./mach -h for more details' -end - diff --git a/smolbote.qbs b/smolbote.qbs deleted file mode 100644 index 406874d..0000000 --- a/smolbote.qbs +++ /dev/null @@ -1,153 +0,0 @@ -import qbs -import "tools/qbs/GitRepo.js" as GitRepo -import qbs.Probes - -Project { - id: project - minimumQbsVersion: "1.8.0" - - property bool gitVersion: true - - // The following define makes your compiler emit warnings if you use any - // feature of Qt which as been marked as deprecated (the exact warnings - // depend on your compiler). - property bool deprecatedWarnings: true - - // The code also fails to compile if you use APIs deprecated before Qt 5.9. - property string deprecatedBefore: "0x050900" - - references: [ - "src/lib/bookmarks/bookmarks.qbs", - "src/lib/downloads/downloads.qbs", - "src/lib/navigation/navigation.qbs", - "lib/settings/settings.qbs", - ] - - Probes.PkgConfigProbe { - id: libconfig - name: "libconfig++" - } - - Probe { - id: git - property string version: "" - property string describe: "" - configure: { - if(project.gitVersion) { - var meta = GitRepo.read(project.sourceDirectory); - version = meta.version; - found = true; - } - } - } - - CppApplication { - id: poi - name: "poi" - - Depends { - name: "Qt" - versionAtLeast: "5.7.1" - submodules: ["core", "widgets", "webenginecore", "webenginewidgets", "printsupport"] - } - - Depends { name: "navigation" } - Depends { name: "bookmarks" } - Depends { name: "downloads" } - Depends { name: "settings" } - Depends { name: "settingsDialog" } - - // global includes - cpp.includePaths: ['src', 'src/lib', 'lib'] - // global defines - cpp.defines: { - var defs = []; - if(project.deprecatedWarnings) { - defs.push("QT_DEPRECATED_WARNINGS", "QT_DISABLE_DEPRECATED_BEFORE="+project.deprecatedBefore); - } - - return defs; - } - - cpp.cxxLanguageVersion: "c++17" - - cpp.linkerFlags: libconfig.libs - - Group { - name: "main" - files: [ - "src/main.cpp", - ] - cpp.defines: outer.concat(["GIT_VERSION=\""+git.version+"\""]) - } - - Group { - name: "Browser" - files: [ - "src/browser.cpp", - "src/browser.h", - "src/singleapplication.cpp", - "src/singleapplication.h", - ] - } - - Group { - name: "Main Window" - files: [ - "src/mainwindow.cpp", - "src/mainwindow.h", - "src/mainwindow.ui", - "src/forms/aboutdialog.cpp", - "src/forms/aboutdialog.h", - "src/forms/aboutdialog.ui", - "src/forms/searchform.cpp", - "src/forms/searchform.h", - "src/forms/searchform.ui", - "src/webengine/webpage.cpp", - "src/webengine/webpage.h", - "src/webengine/webview.cpp", - "src/webengine/webview.h", - "src/widgets/loadingbar.cpp", - "src/widgets/loadingbar.h", - "src/widgets/mainwindowmenubar.cpp", - "src/widgets/mainwindowmenubar.h", - "src/widgets/mainwindowtabbar.cpp", - "src/widgets/mainwindowtabbar.h", - ] - } - - Group { - name: "Request Filter" - files: [ - "src/webengine/urlinterceptor.cpp", - "src/webengine/urlinterceptor.h", - ] - } - - Group { - name: "Profile" - files: [ - "src/forms/cookiesform.cpp", - "src/forms/cookiesform.h", - "src/forms/cookiesform.ui", - "src/forms/profileview.cpp", - "src/forms/profileview.h", - "src/forms/profileview.ui", - "src/webengine/webengineprofile.cpp", - "src/webengine/webengineprofile.h", - ] - } - - files: [ - "data/resources.qrc", - ] - - Group { - name: "Executable" - fileTagsFilter: product.type - qbs.install: true - qbs.installDir: "bin" - } - } // CppApplication poi - -} diff --git a/src/forms/aboutdialog.cpp b/src/forms/aboutdialog.cpp index 25c5384..3f89118 100644 --- a/src/forms/aboutdialog.cpp +++ b/src/forms/aboutdialog.cpp @@ -8,6 +8,28 @@ #include "aboutdialog.h" #include "ui_aboutdialog.h" +#include "version.h" + +constexpr const char *getCompiler() +{ + // clang also defines __GNUC__, so we need to check for clang first +#if defined(__clang__) + return "Clang " __clang_version__; +#elif defined(__GNUC__) + return "GCC " __VERSION__; +#else + return "unknown compiler"; +#endif +} + +inline const QString getLongVersion() +{ +#ifdef GIT_DESCRIBE + return QString(GIT_DESCRIBE); +#else + return qApp->applicationVersion(); +#endif +} AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), @@ -22,7 +44,7 @@ AboutDialog::AboutDialog(QWidget *parent) : aboutLabel->setWordWrap(true); aboutLabel->setText(tr("<h2>smolbote %1</h2>" "<p><i>yet another Qute browser</i></p>") - .arg(qApp->applicationVersion().left(qApp->applicationVersion().indexOf('-')))); + .arg(qApp->applicationVersion())); ui->toolBox->addItem(aboutLabel, tr("About")); QLabel *licenseLabel = new QLabel(this); @@ -50,7 +72,7 @@ AboutDialog::AboutDialog(QWidget *parent) : "<li>Qt %3</li>" "<li>libconfig</li>" "</ul></p>") - .arg(qApp->applicationVersion(), getCompiler(), qVersion())); + .arg(getLongVersion(), getCompiler(), qVersion())); ui->toolBox->addItem(libsLabel, tr("Details")); } @@ -58,14 +80,3 @@ AboutDialog::~AboutDialog() { delete ui; } - -constexpr const char *getCompiler() -{ -#if defined(__clang__) - return "Clang " __clang_version__; -#elif defined(__GNUC__) - return "GCC " __VERSION__; -#else - return "unknown compiler"; -#endif -} diff --git a/src/forms/aboutdialog.h b/src/forms/aboutdialog.h index ba848e7..9f2189e 100644 --- a/src/forms/aboutdialog.h +++ b/src/forms/aboutdialog.h @@ -27,6 +27,4 @@ private: Ui::AboutDialog *ui; }; -constexpr const char* getCompiler(); - #endif // ABOUTDIALOG_H diff --git a/src/interfaces.h b/src/interfaces.h deleted file mode 100644 index f42b513..0000000 --- a/src/interfaces.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef INTERFACES_H -#define INTERFACES_H - -#include <QtPlugin> - -class QString; -class QWidget; -class QAction; - -class PluginInterface -{ -public: - virtual QString name() const = 0; -}; - -class GuiInterface -{ -public: - // The widget that should be displayed for this plugin - virtual QWidget *widget() = 0; - // The action that should trigger displaying the widget - virtual QAction *action() = 0; -}; - -#define PluginInterface_iid "net.iserlohn-fortress.poi.PluginInterface" - -Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid) - -#define GuiInterface_iid "net.iserlohn-fortress.poi.GuiInterface" - -Q_DECLARE_INTERFACE(GuiInterface, GuiInterface_iid) - -#endif // INTERFACES_H diff --git a/src/lib/bookmarks/bookmarks.qbs b/src/lib/bookmarks/bookmarks.qbs deleted file mode 100644 index 211b017..0000000 --- a/src/lib/bookmarks/bookmarks.qbs +++ /dev/null @@ -1,25 +0,0 @@ -import qbs 1.0 - -Project { - name: "bookmarks" - - StaticLibrary { - id: bookmarks - name: "bookmarks" - - cpp.includePaths: ['../..'] - - Depends { - name: "Qt" - submodules: ["core", "widgets"] - } - - files: [ - "bookmarksform.ui", - "bookmarkswidget.cpp", - "bookmarkswidget.h", - "xbel.cpp", - "xbel.h", - ] - } -} diff --git a/src/lib/downloads/downloads.qbs b/src/lib/downloads/downloads.qbs deleted file mode 100644 index bdb18ad..0000000 --- a/src/lib/downloads/downloads.qbs +++ /dev/null @@ -1,28 +0,0 @@ -import qbs 1.0 - -Project { - name: "downloads" - - StaticLibrary { - id: downloads - name: "downloads" - - cpp.includePaths: ['.', '../..'] - - Depends { - name: "Qt" - submodules: ["core", "widgets", "webenginewidgets"] - } - - files: [ - "downloadsform.ui", - "downloadswidget.cpp", - "downloadswidget.h", - "widgets/downloaditemform.ui", - "widgets/downloaditemwidget.cpp", - "widgets/downloaditemwidget.h", - "widgets/elidedlabel.cpp", - "widgets/elidedlabel.h", - ] - } -} diff --git a/src/lib/navigation/navigation.qbs b/src/lib/navigation/navigation.qbs deleted file mode 100644 index 7719fbc..0000000 --- a/src/lib/navigation/navigation.qbs +++ /dev/null @@ -1,26 +0,0 @@ -import qbs 1.0 - -Project { - name: "navigation" - - StaticLibrary { - id: navigation - name: "navigation" - - cpp.includePaths: ['../..'] - - Depends { - name: "Qt" - submodules: ["core", "widgets", "webengine", "webenginewidgets"] - } - - files: [ - "navigationbutton.cpp", - "navigationbutton.h", - "urlcompleter.cpp", - "urlcompleter.h", - "urllineedit.cpp", - "urllineedit.h", - ] - } -} diff --git a/src/main.cpp b/src/main.cpp index 23dfa68..ffb7a4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ */ #include <iostream> +#include "version.h" #include "browser.h" #include <QCommandLineParser> #include <QFile> diff --git a/src/settings.cpp b/src/settings.cpp deleted file mode 100644 index 7f867f7..0000000 --- a/src/settings.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "settings.h" -#include <QStandardPaths> -#include <fstream> -#include <cstdio> -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QFileSystemWatcher> - -Settings::Settings(const QString &configFile, const QString &defaultsFile) -{ - m_configurationPath = configFile; - m_defaultsPath = defaultsFile; - - // homeLocation is the user's home folder - homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); - - // settingsLocation is the location of the configFile - if(QFile::exists(configFile)) { - settingsLocation = QFileInfo(configFile).dir().absolutePath(); - } else { - // if file doesn't exist, use the generic location - settingsLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); - } - - // cacheLocation - cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - - userValues = parse(m_configurationPath); - defaultValues = parse(m_defaultsPath); - - m_watcher = new QFileSystemWatcher(); - m_watcher->addPath(configFile); - QObject::connect(m_watcher, &QFileSystemWatcher::fileChanged, [this](const QString &path) { - if(path == m_configurationPath) { -#ifdef QT_DEBUG - qDebug("Reloading user configuration"); -#endif - userValues = parse(m_configurationPath); - } - }); - -#ifdef QT_DEBUG - qDebug(">> Configuration"); - qDebug("- userconf: [%s]", qUtf8Printable(m_configurationPath)); - qDebug("- defaults: [%s]", qUtf8Printable(m_defaultsPath)); - qDebug("- $home [%s]", qUtf8Printable(homeLocation)); - qDebug("- $settings [%s]", qUtf8Printable(settingsLocation)); - qDebug("- $cache [%s]", qUtf8Printable(cacheLocation)); -#endif -} - -Settings::~Settings() -{ - m_watcher->deleteLater(); -} - -QString Settings::configurationPath() const -{ - return m_configurationPath; -} - -QString Settings::defaultsPath() const -{ - return m_defaultsPath; -} - -bool Settings::isEmpty() const -{ - return userValues.empty(); -} - -QVariant Settings::value(const QString &key) const -{ - const toml::Value *cValue = userValues.find(key.toStdString()); - const toml::Value *dValue = defaultValues.find(key.toStdString()); - - QVariant r; - - if(userValues.has(key.toStdString())) { - r = valueToVariant(cValue); - } else { - if(defaultValues.has(key.toStdString())) { - r = valueToVariant(dValue); - } - } - - // check if key is a path, in which case replace '~' with the home location - if(key.endsWith(QLatin1String("path"), Qt::CaseInsensitive)) { - QString value = r.toString(); - while(value.contains('$')) { - value.replace("$settings", settingsLocation); - value.replace("$cache", cacheLocation); - value.replace("$home", homeLocation); - } - r = QVariant(value); - } - - return r; -} - -toml::Value Settings::parse(const QString &filename) -{ - toml::Value r; - - if(filename.isEmpty()) { - qWarning("Empty configuration path."); - - } else { - QFile file(filename); - if(file.open(QIODevice::ReadOnly)) { - std::stringstream d(file.readAll().toStdString()); - file.close(); - - toml::ParseResult result = toml::parse(d); - if(!result.valid()) { - qWarning("Invalid configuration: %s", result.errorReason.c_str()); - } - r = result.value; - - } else { - qWarning("Cannot open configuration: %s", qUtf8Printable(filename)); - } - } - - return r; -} - -QVariant Settings::fromList(const toml::Value *list) const -{ - QStringList l; - - for(const toml::Value &v : list->as<toml::Array>()) { - // TODO check value type - l.append(QString::fromStdString(v.as<std::string>())); - } - - return QVariant(l); -} - -QVariant Settings::valueToVariant(const toml::Value *value) const -{ - QVariant r; - switch (value->type()) { - case toml::Value::NULL_TYPE: - break; - - case toml::Value::BOOL_TYPE: - r = QVariant(value->as<bool>()); - break; - - case toml::Value::INT_TYPE: - r = QVariant(value->as<int>()); - break; - - case toml::Value::DOUBLE_TYPE: - r = QVariant(value->as<double>()); - break; - - case toml::Value::STRING_TYPE: - r = QVariant(QString::fromStdString(value->as<std::string>())); - break; - - case toml::Value::ARRAY_TYPE: - r = fromList(value); - break; - - default: - qWarning("Unhandled type in configuration"); - break; - } - - return r; -} diff --git a/src/settings.h b/src/settings.h deleted file mode 100644 index ec25eb4..0000000 --- a/src/settings.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef SETTINGS_H -#define SETTINGS_H - -#include <toml/toml.h> -#include <QVariant> - -class QFileSystemWatcher; -class Settings -{ -public: - explicit Settings(const QString &configFile, const QString &defaultsFile = QString()); - ~Settings(); - - QString configurationPath() const; - QString defaultsPath() const; - - bool isEmpty() const; - QVariant value(const QString &key) const; - -private: - toml::Value parse(const QString &filename); - - QVariant fromList(const toml::Value *list) const; - QVariant valueToVariant(const toml::Value *value) const; - - toml::Value userValues; - toml::Value defaultValues; - - QString m_configurationPath; - QString m_defaultsPath; - - QString homeLocation; - QString settingsLocation; - QString cacheLocation; - - QFileSystemWatcher *m_watcher; -}; - -#endif // SETTINGS_H diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..1ec633a --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,7 @@ +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION "@GitVersion@" +#define GIT_DESCRIBE "@GitDescribe@" + +#endif //VERSION_H
\ No newline at end of file diff --git a/src/webengine/webview.h b/src/webengine/webview.h index bf5b1a6..9951630 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -11,7 +11,7 @@ #include <QWebEngineView> #include <QMenu> -#include "webengine/webpage.h" +#include "webpage.h" class MainWindow; class WebView : public QWebEngineView diff --git a/tools/hooks/pre-commit.rb b/tools/hooks/pre-commit.rb index f93281c..c224a49 100755 --- a/tools/hooks/pre-commit.rb +++ b/tools/hooks/pre-commit.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby result = 0 -files = Dir.glob("**/*.h") + Dir.glob("**/*.cpp") +files = Dir.glob("src/**/*.h") + Dir.glob("src/**/*.cpp") + Dir.glob("lib/**/*.h") + Dir.glob("lib/**/*.cpp") puts "pre-commit: #{`pwd`}" |