From 6470038fc7fa8d68a6c5c28c7d804c8c616c31c0 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 30 Sep 2016 23:55:25 +0200 Subject: [PATCH] Refactor to allow sharing backend with other apps Intended for creating command line tool and plasmoid --- CMakeLists.txt | 161 +------ README.md | 39 +- connector/CMakeLists.txt | 42 ++ connector/global.h | 17 + {data => connector}/syncthingconfig.cpp | 0 {data => connector}/syncthingconfig.h | 4 +- {data => connector}/syncthingconnection.cpp | 7 +- {data => connector}/syncthingconnection.h | 16 +- .../syncthingconnectionsettings.cpp | 0 .../syncthingconnectionsettings.h | 4 +- {data => connector}/syncthingprocess.cpp | 0 {data => connector}/syncthingprocess.h | 4 +- {data => connector}/utils.cpp | 0 {data => connector}/utils.h | 4 +- model/CMakeLists.txt | 38 ++ model/global.h | 17 + {data => model}/syncthingdevicemodel.cpp | 5 +- {data => model}/syncthingdevicemodel.h | 4 +- {data => model}/syncthingdirectorymodel.cpp | 5 +- {data => model}/syncthingdirectorymodel.h | 4 +- {data => model}/syncthingdownloadmodel.cpp | 5 +- {data => model}/syncthingdownloadmodel.h | 4 +- tray/CMakeLists.txt | 133 ++++++ {application => tray/application}/main.cpp | 2 +- .../application}/settings.cpp | 0 {application => tray/application}/settings.h | 2 +- .../application}/singleinstance.cpp | 0 .../application}/singleinstance.h | 0 {gui => tray/gui}/appearanceoptionpage.ui | 0 {gui => tray/gui}/autostartoptionpage.ui | 0 {gui => tray/gui}/connectionoptionpage.ui | 0 {gui => tray/gui}/devbuttonsitemdelegate.cpp | 4 +- {gui => tray/gui}/devbuttonsitemdelegate.h | 0 {gui => tray/gui}/devview.cpp | 2 +- {gui => tray/gui}/devview.h | 0 {gui => tray/gui}/dirbuttonsitemdelegate.cpp | 0 {gui => tray/gui}/dirbuttonsitemdelegate.h | 0 {gui => tray/gui}/dirview.cpp | 2 +- {gui => tray/gui}/dirview.h | 0 {gui => tray/gui}/downloaditemdelegate.cpp | 2 +- {gui => tray/gui}/downloaditemdelegate.h | 0 {gui => tray/gui}/downloadview.cpp | 2 +- {gui => tray/gui}/downloadview.h | 0 {gui => tray/gui}/launcheroptionpage.ui | 0 {gui => tray/gui}/notificationsoptionpage.ui | 0 {gui => tray/gui}/settingsdialog.cpp | 6 +- {gui => tray/gui}/settingsdialog.h | 0 {gui => tray/gui}/textviewdialog.cpp | 0 {gui => tray/gui}/textviewdialog.h | 0 {gui => tray/gui}/trayicon.cpp | 3 +- {gui => tray/gui}/trayicon.h | 6 +- {gui => tray/gui}/traymenu.cpp | 0 {gui => tray/gui}/traymenu.h | 0 {gui => tray/gui}/traywidget.cpp | 7 +- {gui => tray/gui}/traywidget.h | 12 +- {gui => tray/gui}/traywidget.ui | 0 {gui => tray/gui}/webpage.cpp | 3 +- {gui => tray/gui}/webpage.h | 0 {gui => tray/gui}/webviewdialog.cpp | 0 {gui => tray/gui}/webviewdialog.h | 0 {gui => tray/gui}/webviewoptionpage.ui | 0 {gui => tray/gui}/webviewprovider.h | 0 {resources => tray/resources}/icons.qrc | 0 .../scalable/actions/application-menu.svg | 0 .../hicolor/scalable/actions/edit-copy.svg | 0 .../hicolor/scalable/actions/folder-sync.svg | 0 .../hicolor/scalable/actions/help-about.svg | 0 .../scalable/actions/media-playback-pause.svg | 0 .../scalable/actions/media-playback-start.svg | 0 .../scalable/actions/network-connect.svg | 0 .../hicolor/scalable/actions/view-barcode.svg | 0 .../hicolor/scalable/actions/view-refresh.svg | 0 .../hicolor/scalable/actions/window-close.svg | 0 .../hicolor/scalable/app/syncthingtray.png | Bin .../hicolor/scalable/app/syncthingtray.svg | 0 .../hicolor/scalable/apps/help-about.svg | 0 .../scalable/apps/internet-web-browser.svg | 0 .../scalable/apps/preferences-other.svg | 0 .../hicolor/scalable/apps/system-run.svg | 0 .../hicolor/scalable/devices/network-card.svg | 0 .../scalable/mimetypes/text-x-generic.svg | 0 .../hicolor/scalable/places/folder-open.svg | 0 .../icons/hicolor/scalable/places/folder.svg | 0 .../scalable/places/network-workgroup.svg | 0 .../scalable/status/syncthing-default.svg | 0 .../status/syncthing-disconnected.svg | 0 .../scalable/status/syncthing-error.svg | 0 .../scalable/status/syncthing-notify.svg | 0 .../hicolor/scalable/status/syncthing-ok.svg | 0 .../scalable/status/syncthing-pause.svg | 0 .../scalable/status/syncthing-sync.svg | 0 .../resources}/screenshots/plasma.png | Bin .../resources}/screenshots/settings.png | Bin .../resources}/screenshots/tint2.png | Bin .../resources}/screenshots/webview.png | Bin .../translations}/syncthingtray_de_DE.ts | 440 ++---------------- .../translations}/syncthingtray_en_US.ts | 440 ++---------------- 97 files changed, 413 insertions(+), 1033 deletions(-) create mode 100644 connector/CMakeLists.txt create mode 100644 connector/global.h rename {data => connector}/syncthingconfig.cpp (100%) rename {data => connector}/syncthingconfig.h (86%) rename {data => connector}/syncthingconnection.cpp (99%) rename {data => connector}/syncthingconnection.h (97%) rename {data => connector}/syncthingconnectionsettings.cpp (100%) rename {data => connector}/syncthingconnectionsettings.h (84%) rename {data => connector}/syncthingprocess.cpp (100%) rename {data => connector}/syncthingprocess.h (84%) rename {data => connector}/utils.cpp (100%) rename {data => connector}/utils.h (63%) create mode 100644 model/CMakeLists.txt create mode 100644 model/global.h rename {data => model}/syncthingdevicemodel.cpp (99%) rename {data => model}/syncthingdevicemodel.h (93%) rename {data => model}/syncthingdirectorymodel.cpp (99%) rename {data => model}/syncthingdirectorymodel.h (92%) rename {data => model}/syncthingdownloadmodel.cpp (99%) rename {data => model}/syncthingdownloadmodel.h (95%) create mode 100644 tray/CMakeLists.txt rename {application => tray/application}/main.cpp (99%) rename {application => tray/application}/settings.cpp (100%) rename {application => tray/application}/settings.h (95%) rename {application => tray/application}/singleinstance.cpp (100%) rename {application => tray/application}/singleinstance.h (100%) rename {gui => tray/gui}/appearanceoptionpage.ui (100%) rename {gui => tray/gui}/autostartoptionpage.ui (100%) rename {gui => tray/gui}/connectionoptionpage.ui (100%) rename {gui => tray/gui}/devbuttonsitemdelegate.cpp (95%) rename {gui => tray/gui}/devbuttonsitemdelegate.h (100%) rename {gui => tray/gui}/devview.cpp (98%) rename {gui => tray/gui}/devview.h (100%) rename {gui => tray/gui}/dirbuttonsitemdelegate.cpp (100%) rename {gui => tray/gui}/dirbuttonsitemdelegate.h (100%) rename {gui => tray/gui}/dirview.cpp (98%) rename {gui => tray/gui}/dirview.h (100%) rename {gui => tray/gui}/downloaditemdelegate.cpp (98%) rename {gui => tray/gui}/downloaditemdelegate.h (100%) rename {gui => tray/gui}/downloadview.cpp (98%) rename {gui => tray/gui}/downloadview.h (100%) rename {gui => tray/gui}/launcheroptionpage.ui (100%) rename {gui => tray/gui}/notificationsoptionpage.ui (100%) rename {gui => tray/gui}/settingsdialog.cpp (99%) rename {gui => tray/gui}/settingsdialog.h (100%) rename {gui => tray/gui}/textviewdialog.cpp (100%) rename {gui => tray/gui}/textviewdialog.h (100%) rename {gui => tray/gui}/trayicon.cpp (99%) rename {gui => tray/gui}/trayicon.h (92%) rename {gui => tray/gui}/traymenu.cpp (100%) rename {gui => tray/gui}/traymenu.h (100%) rename {gui => tray/gui}/traywidget.cpp (99%) rename {gui => tray/gui}/traywidget.h (91%) rename {gui => tray/gui}/traywidget.ui (100%) rename {gui => tray/gui}/webpage.cpp (98%) rename {gui => tray/gui}/webpage.h (100%) rename {gui => tray/gui}/webviewdialog.cpp (100%) rename {gui => tray/gui}/webviewdialog.h (100%) rename {gui => tray/gui}/webviewoptionpage.ui (100%) rename {gui => tray/gui}/webviewprovider.h (100%) rename {resources => tray/resources}/icons.qrc (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/application-menu.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/edit-copy.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/folder-sync.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/help-about.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/media-playback-pause.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/media-playback-start.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/network-connect.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/view-barcode.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/view-refresh.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/actions/window-close.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/app/syncthingtray.png (100%) rename {resources => tray/resources}/icons/hicolor/scalable/app/syncthingtray.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/apps/help-about.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/apps/internet-web-browser.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/apps/preferences-other.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/apps/system-run.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/devices/network-card.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/mimetypes/text-x-generic.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/places/folder-open.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/places/folder.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/places/network-workgroup.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-default.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-disconnected.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-error.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-notify.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-ok.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-pause.svg (100%) rename {resources => tray/resources}/icons/hicolor/scalable/status/syncthing-sync.svg (100%) rename {resources => tray/resources}/screenshots/plasma.png (100%) rename {resources => tray/resources}/screenshots/settings.png (100%) rename {resources => tray/resources}/screenshots/tint2.png (100%) rename {resources => tray/resources}/screenshots/webview.png (100%) rename {translations => tray/translations}/syncthingtray_de_DE.ts (61%) rename {translations => tray/translations}/syncthingtray_en_US.ts (61%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b46236..e076468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,158 +8,23 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Tray application for Syncthing") set(META_APP_CATEGORIES "Utility;Network;") -set(META_GUI_OPTIONAL false) set(META_VERSION_MAJOR 0) set(META_VERSION_MINOR 0) set(META_VERSION_PATCH 2) -set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}) -# add project files -set(HEADER_FILES - data/syncthingconnection.h - data/syncthingconnectionsettings.h - data/syncthingdirectorymodel.h - data/syncthingdevicemodel.h - data/syncthingdownloadmodel.h - data/syncthingconfig.h - data/syncthingprocess.h - data/utils.h -) -set(SRC_FILES - data/syncthingconnection.cpp - data/syncthingconnectionsettings.cpp - data/syncthingdirectorymodel.cpp - data/syncthingdevicemodel.cpp - data/syncthingdownloadmodel.cpp - data/syncthingconfig.cpp - data/syncthingprocess.cpp - data/utils.cpp -) +project(${META_PROJECT_NAME}) -set(WIDGETS_HEADER_FILES - application/settings.h - application/singleinstance.h - gui/trayicon.h - gui/traywidget.h - gui/traymenu.h - gui/settingsdialog.h - gui/webpage.h - gui/webviewdialog.h - gui/webviewprovider.h - gui/dirbuttonsitemdelegate.h - gui/devbuttonsitemdelegate.h - gui/downloaditemdelegate.h - gui/dirview.h - gui/devview.h - gui/downloadview.h - gui/textviewdialog.h -) -set(WIDGETS_SRC_FILES - application/main.cpp - application/settings.cpp - application/singleinstance.cpp - gui/trayicon.cpp - gui/traywidget.cpp - gui/traymenu.cpp - gui/settingsdialog.cpp - gui/webpage.cpp - gui/webviewdialog.cpp - gui/dirbuttonsitemdelegate.cpp - gui/devbuttonsitemdelegate.cpp - gui/downloaditemdelegate.cpp - gui/dirview.cpp - gui/devview.cpp - gui/downloadview.cpp - gui/textviewdialog.cpp - resources/icons.qrc -) -set(WIDGETS_UI_FILES - gui/traywidget.ui - gui/connectionoptionpage.ui - gui/notificationsoptionpage.ui - gui/appearanceoptionpage.ui - gui/autostartoptionpage.ui - gui/launcheroptionpage.ui - gui/webviewoptionpage.ui -) +# options for partial build +option(NO_TRAY "specifies whether building the tray should be skipped" OFF) +option(NO_MODEL "specifies whether building models should be skipped, implies NO_TRAY" OFF) -#set(QUICK_HEADER_FILES -#) -#set(QUICK_SRC_FILES -#) - -set(TS_FILES - translations/${META_PROJECT_NAME}_de_DE.ts - translations/${META_PROJECT_NAME}_en_US.ts -) - -set(ICON_FILES - resources/icons/hicolor/scalable/app/${META_PROJECT_NAME}.svg -) -set(PNG_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/hicolor/scalable/app/${META_PROJECT_NAME}.png") -set(PNG_ICON_NO_CROP ON) - -set(DOC_FILES - README.md -) - -set(REQUIRED_ICONS - dialog-cancel - dialog-ok - dialog-ok-apply - edit-copy - edit-paste - folder - folder-download - folder-open - folder-sync - help-about - internet-web-browser - list-add - list-remove - media-playback-pause - media-playback-start - network-card - network-connect - network-server - preferences-desktop - preferences-desktop-icons - preferences-desktop-locale - preferences-desktop-notification - preferences-other - qtcreator - system-run - system-search - system-file-manager - text-plain - view-barcode - view-refresh - window-close -) - -# find c++utilities -find_package(c++utilities 4.0.0 REQUIRED) -use_cpp_utilities() -include(BasicConfig) - -# find qtutilities -if(WIDGETS_GUI OR QUICK_GUI) - find_package(qtutilities 5.0.0 REQUIRED) - use_qt_utilities() +# add subdirectories +add_subdirectory(connector) +link_directories(${LIB_SYNCTHING_CONNECTOR_BINARY_DIR}) +if(NOT NO_MODEL) + add_subdirectory(model) + link_directories(${LIB_SYNCTHING_MODEL_BINARY_DIR}) + if(NOT NO_TRAY) + add_subdirectory(tray) + endif() endif() - -list(APPEND ADDITIONAL_QT_MODULES Network Svg) - -# include modules to apply configuration -include(BasicConfig) -include(QtGuiConfig) -include(QtConfig) -include(WindowsResources) -include(WebViewProviderConfig) -include(AppTarget) -include(ShellCompletion) -include(Doxygen) -include(ConfigHeader) - -# create desktop file using previously defined meta data -add_desktop_file() diff --git a/README.md b/README.md index 10569ff..31241ed 100644 --- a/README.md +++ b/README.md @@ -36,23 +36,22 @@ support The tray is still under development; the following features are planned: * Show recently processed items * Improve notification handling +* Create simple command line application * Create Plasmoid for Plasma 5 desktop - * Outsource backend to extra library so it can be shared by regular tray menu - and Plasmoid ## Screenshots ### Under Openbox/Tint2 -![Openbox/Tint2](/resources/screenshots/tint2.png?raw=true) +![Openbox/Tint2](/tray/resources/screenshots/tint2.png?raw=true) ### Under Plasma 5 (dark color theme) -![Plasma 5](/resources/screenshots/plasma.png?raw=true) +![Plasma 5](/tray/resources/screenshots/plasma.png?raw=true) ### Settings dialog (dark color theme) -![Settings dialog](/resources/screenshots/settings.png?raw=true) +![Settings dialog](/tray/resources/screenshots/settings.png?raw=true) ### Web view (dark color theme) -![Web view](/resources/screenshots/webview.png?raw=true) +![Web view](/tray/resources/screenshots/webview.png?raw=true) ## Hotkey for Web UI To create a hotkey for the web UI, you can use the same approach as for any other @@ -66,10 +65,30 @@ separate [repository](https://github.com/Martchus/PKGBUILDs). For binaries check [website](http://martchus.no-ip.biz/website/page.php?name=programming). ## Build instructions -The application depends on [c++utilities](https://github.com/Martchus/cpp-utilities) and [qtutilities](https://github.com/Martchus/qtutilities) and is built the same way as these libaries. For basic instructions checkout the README file of [c++utilities](https://github.com/Martchus/cpp-utilities). +The application depends on [c++utilities](https://github.com/Martchus/cpp-utilities) and [qtutilities](https://github.com/Martchus/qtutilities) and is built the same way as these libaries. For basic instructions checkout the README file of [c++utilities](https://github.com/Martchus/cpp-utilities). For building this straight, see the next section. The following Qt 5 modules are requried: core network gui widgets svg webenginewidgets/webkitwidgets +#### Building this straight +0. Install (preferably the latest version of) g++ or clang, the required Qt 5 modules and CMake. +1. Get the sources. For the lastest version from Git clone the following repositories: + ``` + cd $SOURCES + git clone https://github.com/Martchus/cpp-utilities.git + git clone https://github.com/Martchus/qtutilities.git + git glone https://github.com/Martchus/syncthingtray.git + git clone https://github.com/Martchus/subdirs.git + ``` +2. Build and install everything in one step: + ``` + cd $BUILD_DIR + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="/install/prefix" \ + $SOURCES/subdirs/syncthingtray + make install -j$(nproc) + ``` + #### Select Qt module for WebView * If Qt WebKitWidgets is installed on the system, the tray will link against it. Otherwise it will link against Qt WebEngineWidgets. * To force usage of Qt WebKit/Qt WebEngine or to disable both add `-DWEBVIEW_PROVIDER=webkit/webengine/none` to the CMake arguments. @@ -77,7 +96,9 @@ The following Qt 5 modules are requried: core network gui widgets svg webenginew #### BTW: I still prefer the deprecated Qt WebKit because * Currently there is no way to allow a particular self-signed certificate in Qt WebEngine. Currently any self-signed certificate is accepted! See: - https://bugreports.qt.io/browse/QTBUG-51176) + https://bugreports.qt.io/browse/QTBUG-51176 * Qt WebEngine can not be built with mingw-w64. * Qt WebEngine is more buggy in my experience. -* Security issues are not a concern because no other website than the Syncthing web UI is shown. +* Security issues are not a concern because no other website than the + Syncthing web UI is shown. Any external links will be opened in the + regular web browser anyways. diff --git a/connector/CMakeLists.txt b/connector/CMakeLists.txt new file mode 100644 index 0000000..40c8490 --- /dev/null +++ b/connector/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) + +# metadata +set(META_PROJECT_NAME syncthingconnector) +set(META_PROJECT_TYPE library) +set(META_APP_DESCRIPTION "Connection backend of Syncthing Tray") +set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING_CONNECTOR) + +# add project files +set(HEADER_FILES + syncthingconnection.h + syncthingconnectionsettings.h + syncthingconfig.h + syncthingprocess.h + utils.h +) +set(SRC_FILES + syncthingconnection.cpp + syncthingconnectionsettings.cpp + syncthingconfig.cpp + syncthingprocess.cpp + utils.cpp +) + +# find c++utilities +find_package(c++utilities 4.0.0 REQUIRED) +use_cpp_utilities() + +# find qtutilities (only header used) +find_package(qtutilities 5.0.0 REQUIRED) +include_directories(BEFORE SYSTEM ${QT_UTILITIES_INCLUDE_DIRS}) + +# link also explicitely against the following Qt 5 modules +list(APPEND ADDITIONAL_QT_MODULES Network) + +# include modules to apply configuration +include(BasicConfig) +include(QtConfig) +include(WindowsResources) +include(LibraryTarget) +include(Doxygen) +include(ConfigHeader) diff --git a/connector/global.h b/connector/global.h new file mode 100644 index 0000000..63e1a66 --- /dev/null +++ b/connector/global.h @@ -0,0 +1,17 @@ +// Created via CMake from template global.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef LIB_SYNCTHING_CONNECTOR_GLOBAL +#define LIB_SYNCTHING_CONNECTOR_GLOBAL + +#include + +#ifdef LIB_SYNCTHING_CONNECTOR_STATIC +# define LIB_SYNCTHING_CONNECTOR_EXPORT +# define LIB_SYNCTHING_CONNECTOR_IMPORT +#else +# define LIB_SYNCTHING_CONNECTOR_EXPORT LIB_EXPORT +# define LIB_SYNCTHING_CONNECTOR_IMPORT LIB_IMPORT +#endif + +#endif // LIB_SYNCTHING_CONNECTOR_GLOBAL diff --git a/data/syncthingconfig.cpp b/connector/syncthingconfig.cpp similarity index 100% rename from data/syncthingconfig.cpp rename to connector/syncthingconfig.cpp diff --git a/data/syncthingconfig.h b/connector/syncthingconfig.h similarity index 86% rename from data/syncthingconfig.h rename to connector/syncthingconfig.h index e764e34..54f2549 100644 --- a/data/syncthingconfig.h +++ b/connector/syncthingconfig.h @@ -1,11 +1,13 @@ #ifndef DATA_SYNCTHINGCONFIG_H #define DATA_SYNCTHINGCONFIG_H +#include "./global.h" + #include namespace Data { -struct SyncthingConfig +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConfig { QString version; bool guiEnabled = false; diff --git a/data/syncthingconnection.cpp b/connector/syncthingconnection.cpp similarity index 99% rename from data/syncthingconnection.cpp rename to connector/syncthingconnection.cpp index 9150cdb..8ad34c4 100644 --- a/data/syncthingconnection.cpp +++ b/connector/syncthingconnection.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -555,18 +554,16 @@ void SyncthingConnection::requestEvents() * * The specified \a callback is called on success; otherwise error() is emitted. */ -QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, std::function callback) +QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, std::function callback) { QUrlQuery query; query.addQueryItem(QStringLiteral("text"), text); QNetworkReply *reply = requestData(QStringLiteral("/qr/"), query, false); return QObject::connect(reply, &QNetworkReply::finished, [this, reply, callback] { reply->deleteLater(); - QPixmap pixmap; switch(reply->error()) { case QNetworkReply::NoError: - pixmap.loadFromData(reply->readAll()); - callback(pixmap); + callback(reply->readAll()); break; default: emit error(tr("Unable to request QR-Code: ") + reply->errorString()); diff --git a/data/syncthingconnection.h b/connector/syncthingconnection.h similarity index 97% rename from data/syncthingconnection.h rename to connector/syncthingconnection.h index 6cc9f07..14fd1da 100644 --- a/data/syncthingconnection.h +++ b/connector/syncthingconnection.h @@ -1,6 +1,8 @@ #ifndef SYNCTHINGCONNECTION_H #define SYNCTHINGCONNECTION_H +#include "./global.h" + #include #include @@ -45,7 +47,7 @@ enum class DirStatus OutOfSync }; -struct DirErrors +struct LIB_SYNCTHING_CONNECTOR_EXPORT DirErrors { DirErrors(const QString &message, const QString &path) : message(message), @@ -55,7 +57,7 @@ struct DirErrors QString path; }; -struct SyncthingItemDownloadProgress +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingItemDownloadProgress { SyncthingItemDownloadProgress(const QString &containingDirPath, const QString &relativeItemPath, const QJsonObject &values); QString relativePath; @@ -74,7 +76,7 @@ struct SyncthingItemDownloadProgress static constexpr unsigned int syncthingBlockSize = 128 * 1024; }; -struct SyncthingDir +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir { QString id; QString label; @@ -118,7 +120,7 @@ enum class DevStatus Rejected }; -struct SyncthingDev +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev { QString id; QString name; @@ -138,7 +140,7 @@ struct SyncthingDev ChronoUtilities::DateTime lastSeen; }; -struct SyncthingLogEntry +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry { SyncthingLogEntry(const QString &when, const QString &message) : when(when), @@ -148,7 +150,7 @@ struct SyncthingLogEntry QString message; }; -class SyncthingConnection : public QObject +class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject { Q_OBJECT Q_PROPERTY(QString syncthingUrl READ syncthingUrl WRITE setSyncthingUrl) @@ -189,7 +191,7 @@ public: double totalOutgoingRate() const; const std::vector &dirInfo() const; const std::vector &devInfo() const; - QMetaObject::Connection requestQrCode(const QString &text, std::function callback); + QMetaObject::Connection requestQrCode(const QString &text, std::function callback); QMetaObject::Connection requestLog(std::function &)> callback); const QList &expectedSslErrors(); diff --git a/data/syncthingconnectionsettings.cpp b/connector/syncthingconnectionsettings.cpp similarity index 100% rename from data/syncthingconnectionsettings.cpp rename to connector/syncthingconnectionsettings.cpp diff --git a/data/syncthingconnectionsettings.h b/connector/syncthingconnectionsettings.h similarity index 84% rename from data/syncthingconnectionsettings.h rename to connector/syncthingconnectionsettings.h index e98581e..2c1dbff7 100644 --- a/data/syncthingconnectionsettings.h +++ b/connector/syncthingconnectionsettings.h @@ -1,13 +1,15 @@ #ifndef SYNCTHINGCONNECTIONSETTINGS_H #define SYNCTHINGCONNECTIONSETTINGS_H +#include "./global.h" + #include #include #include namespace Data { -struct SyncthingConnectionSettings { +struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnectionSettings { QString label; QString syncthingUrl; bool authEnabled = false; diff --git a/data/syncthingprocess.cpp b/connector/syncthingprocess.cpp similarity index 100% rename from data/syncthingprocess.cpp rename to connector/syncthingprocess.cpp diff --git a/data/syncthingprocess.h b/connector/syncthingprocess.h similarity index 84% rename from data/syncthingprocess.h rename to connector/syncthingprocess.h index a9ab013..88a3b76 100644 --- a/data/syncthingprocess.h +++ b/connector/syncthingprocess.h @@ -1,11 +1,13 @@ #ifndef DATA_SYNCTHINGPROCESS_H #define DATA_SYNCTHINGPROCESS_H +#include "./global.h" + #include namespace Data { -class SyncthingProcess : public QProcess +class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingProcess : public QProcess { Q_OBJECT public: diff --git a/data/utils.cpp b/connector/utils.cpp similarity index 100% rename from data/utils.cpp rename to connector/utils.cpp diff --git a/data/utils.h b/connector/utils.h similarity index 63% rename from data/utils.h rename to connector/utils.h index badfdef..72044e4 100644 --- a/data/utils.h +++ b/connector/utils.h @@ -1,6 +1,8 @@ #ifndef DATA_UTILS_H #define DATA_UTILS_H +#include "./global.h" + #include QT_FORWARD_DECLARE_CLASS(QString) @@ -11,7 +13,7 @@ class DateTime; namespace Data { -QString agoString(ChronoUtilities::DateTime dateTime); +QString LIB_SYNCTHING_CONNECTOR_EXPORT agoString(ChronoUtilities::DateTime dateTime); } diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt new file mode 100644 index 0000000..9d80bd3 --- /dev/null +++ b/model/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) + +# metadata +set(META_PROJECT_NAME syncthingmodel) +set(META_PROJECT_TYPE library) +set(META_APP_DESCRIPTION "Data models of Syncthing Tray") +set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING_MODEL) + +# add project files +set(HEADER_FILES + syncthingdirectorymodel.h + syncthingdevicemodel.h + syncthingdownloadmodel.h +) +set(SRC_FILES + syncthingdirectorymodel.cpp + syncthingdevicemodel.cpp + syncthingdownloadmodel.cpp +) + +# find c++utilities +find_package(c++utilities 4.0.0 REQUIRED) +use_cpp_utilities() + +# find backend libraries +find_package(syncthingconnector ${META_APP_VERSION} REQUIRED) +use_syncthingconnector() + +# link also explicitely against the following Qt 5 modules +list(APPEND ADDITIONAL_QT_MODULES Network Gui Widgets) + +# include modules to apply configuration +include(BasicConfig) +include(QtConfig) +include(WindowsResources) +include(LibraryTarget) +include(Doxygen) +include(ConfigHeader) diff --git a/model/global.h b/model/global.h new file mode 100644 index 0000000..7fef159 --- /dev/null +++ b/model/global.h @@ -0,0 +1,17 @@ +// Created via CMake from template global.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef LIB_SYNCTHING_MODEL_GLOBAL +#define LIB_SYNCTHING_MODEL_GLOBAL + +#include + +#ifdef LIB_SYNCTHING_MODEL_STATIC +# define LIB_SYNCTHING_MODEL_EXPORT +# define LIB_SYNCTHING_MODEL_IMPORT +#else +# define LIB_SYNCTHING_MODEL_EXPORT LIB_EXPORT +# define LIB_SYNCTHING_MODEL_IMPORT LIB_IMPORT +#endif + +#endif // LIB_SYNCTHING_MODEL_GLOBAL diff --git a/data/syncthingdevicemodel.cpp b/model/syncthingdevicemodel.cpp similarity index 99% rename from data/syncthingdevicemodel.cpp rename to model/syncthingdevicemodel.cpp index 8ccffd8..f97cbff 100644 --- a/data/syncthingdevicemodel.cpp +++ b/model/syncthingdevicemodel.cpp @@ -1,6 +1,7 @@ #include "./syncthingdevicemodel.h" -#include "./syncthingconnection.h" -#include "./utils.h" + +#include "../connector/syncthingconnection.h" +#include "../connector/utils.h" using namespace ChronoUtilities; diff --git a/data/syncthingdevicemodel.h b/model/syncthingdevicemodel.h similarity index 93% rename from data/syncthingdevicemodel.h rename to model/syncthingdevicemodel.h index 55a89f7..5a674f4 100644 --- a/data/syncthingdevicemodel.h +++ b/model/syncthingdevicemodel.h @@ -1,6 +1,8 @@ #ifndef DATA_SYNCTHINGDEVICEMODEL_H #define DATA_SYNCTHINGDEVICEMODEL_H +#include "./global.h" + #include #include @@ -11,7 +13,7 @@ namespace Data { class SyncthingConnection; struct SyncthingDev; -class SyncthingDeviceModel : public QAbstractItemModel +class LIB_SYNCTHING_MODEL_EXPORT SyncthingDeviceModel : public QAbstractItemModel { Q_OBJECT public: diff --git a/data/syncthingdirectorymodel.cpp b/model/syncthingdirectorymodel.cpp similarity index 99% rename from data/syncthingdirectorymodel.cpp rename to model/syncthingdirectorymodel.cpp index 7e93dfa..18615b0 100644 --- a/data/syncthingdirectorymodel.cpp +++ b/model/syncthingdirectorymodel.cpp @@ -1,6 +1,7 @@ #include "./syncthingdirectorymodel.h" -#include "./syncthingconnection.h" -#include "./utils.h" + +#include "../connector/syncthingconnection.h" +#include "../connector/utils.h" using namespace ChronoUtilities; diff --git a/data/syncthingdirectorymodel.h b/model/syncthingdirectorymodel.h similarity index 92% rename from data/syncthingdirectorymodel.h rename to model/syncthingdirectorymodel.h index 7c167eb..b487ad9 100644 --- a/data/syncthingdirectorymodel.h +++ b/model/syncthingdirectorymodel.h @@ -1,6 +1,8 @@ #ifndef DATA_SYNCTHINGDIRECTORYMODEL_H #define DATA_SYNCTHINGDIRECTORYMODEL_H +#include "./global.h" + #include #include @@ -11,7 +13,7 @@ namespace Data { class SyncthingConnection; struct SyncthingDir; -class SyncthingDirectoryModel : public QAbstractItemModel +class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public QAbstractItemModel { Q_OBJECT public: diff --git a/data/syncthingdownloadmodel.cpp b/model/syncthingdownloadmodel.cpp similarity index 99% rename from data/syncthingdownloadmodel.cpp rename to model/syncthingdownloadmodel.cpp index 83e1432..2d7b521 100644 --- a/data/syncthingdownloadmodel.cpp +++ b/model/syncthingdownloadmodel.cpp @@ -1,6 +1,7 @@ #include "./syncthingdownloadmodel.h" -#include "./syncthingconnection.h" -#include "./utils.h" + +#include "../connector/syncthingconnection.h" +#include "../connector/utils.h" #include diff --git a/data/syncthingdownloadmodel.h b/model/syncthingdownloadmodel.h similarity index 95% rename from data/syncthingdownloadmodel.h rename to model/syncthingdownloadmodel.h index d186203..dbf1c12 100644 --- a/data/syncthingdownloadmodel.h +++ b/model/syncthingdownloadmodel.h @@ -1,6 +1,8 @@ #ifndef DATA_SYNCTHINGDOWNLOADMODEL_H #define DATA_SYNCTHINGDOWNLOADMODEL_H +#include "./global.h" + #include #include #include @@ -13,7 +15,7 @@ class SyncthingConnection; struct SyncthingDir; struct SyncthingItemDownloadProgress; -class SyncthingDownloadModel : public QAbstractItemModel +class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public QAbstractItemModel { Q_OBJECT Q_PROPERTY(unsigned int pendingDownloads READ pendingDownloads NOTIFY pendingDownloadsChanged) diff --git a/tray/CMakeLists.txt b/tray/CMakeLists.txt new file mode 100644 index 0000000..fb8732e --- /dev/null +++ b/tray/CMakeLists.txt @@ -0,0 +1,133 @@ +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) + +# metadata +set(META_PROJECT_TYPE application) +set(META_GUI_OPTIONAL false) + +# add project files +set(WIDGETS_HEADER_FILES + application/settings.h + application/singleinstance.h + gui/trayicon.h + gui/traywidget.h + gui/traymenu.h + gui/settingsdialog.h + gui/webpage.h + gui/webviewdialog.h + gui/webviewprovider.h + gui/dirbuttonsitemdelegate.h + gui/devbuttonsitemdelegate.h + gui/downloaditemdelegate.h + gui/dirview.h + gui/devview.h + gui/downloadview.h + gui/textviewdialog.h +) +set(WIDGETS_SRC_FILES + application/main.cpp + application/settings.cpp + application/singleinstance.cpp + gui/trayicon.cpp + gui/traywidget.cpp + gui/traymenu.cpp + gui/settingsdialog.cpp + gui/webpage.cpp + gui/webviewdialog.cpp + gui/dirbuttonsitemdelegate.cpp + gui/devbuttonsitemdelegate.cpp + gui/downloaditemdelegate.cpp + gui/dirview.cpp + gui/devview.cpp + gui/downloadview.cpp + gui/textviewdialog.cpp + resources/icons.qrc +) +set(WIDGETS_UI_FILES + gui/traywidget.ui + gui/connectionoptionpage.ui + gui/notificationsoptionpage.ui + gui/appearanceoptionpage.ui + gui/autostartoptionpage.ui + gui/launcheroptionpage.ui + gui/webviewoptionpage.ui +) + +set(TS_FILES + translations/${META_PROJECT_NAME}_de_DE.ts + translations/${META_PROJECT_NAME}_en_US.ts +) + +set(ICON_FILES + resources/icons/hicolor/scalable/app/${META_PROJECT_NAME}.svg +) +set(PNG_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/hicolor/scalable/app/${META_PROJECT_NAME}.png") +set(PNG_ICON_NO_CROP ON) + +set(DOC_FILES + README.md +) + +set(REQUIRED_ICONS + dialog-cancel + dialog-ok + dialog-ok-apply + edit-copy + edit-paste + folder + folder-download + folder-open + folder-sync + help-about + internet-web-browser + list-add + list-remove + media-playback-pause + media-playback-start + network-card + network-connect + network-server + preferences-desktop + preferences-desktop-icons + preferences-desktop-locale + preferences-desktop-notification + preferences-other + qtcreator + system-run + system-search + system-file-manager + text-plain + view-barcode + view-refresh + window-close +) + +# find c++utilities +find_package(c++utilities 4.0.0 REQUIRED) +use_cpp_utilities() + +# find qtutilities +find_package(qtutilities 5.0.0 REQUIRED) +use_qt_utilities() + +# find backend libraries +find_package(syncthingconnector ${META_APP_VERSION} REQUIRED) +use_syncthingconnector() +find_package(syncthingmodel ${META_APP_VERSION} REQUIRED) +use_syncthingmodel() + +# link also explicitely against the following Qt 5 modules +list(APPEND ADDITIONAL_QT_MODULES Network Svg) + +# include modules to apply configuration +include(BasicConfig) +include(QtGuiConfig) +include(QtConfig) +include(WindowsResources) +include(WebViewProviderConfig) +include(AppTarget) +include(ShellCompletion) +include(Doxygen) +include(ConfigHeader) + +# create desktop file using previously defined meta data +add_desktop_file() diff --git a/application/main.cpp b/tray/application/main.cpp similarity index 99% rename from application/main.cpp rename to tray/application/main.cpp index f8ea253..a2339ef 100644 --- a/application/main.cpp +++ b/tray/application/main.cpp @@ -4,7 +4,7 @@ #include "../gui/trayicon.h" #include "../gui/traywidget.h" -#include "../data/syncthingprocess.h" +#include "../../connector/syncthingprocess.h" #include "resources/config.h" diff --git a/application/settings.cpp b/tray/application/settings.cpp similarity index 100% rename from application/settings.cpp rename to tray/application/settings.cpp diff --git a/application/settings.h b/tray/application/settings.h similarity index 95% rename from application/settings.h rename to tray/application/settings.h index 44dfc59..cff8b04 100644 --- a/application/settings.h +++ b/tray/application/settings.h @@ -1,7 +1,7 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include "../data/syncthingconnectionsettings.h" +#include "../../connector/syncthingconnectionsettings.h" #include diff --git a/application/singleinstance.cpp b/tray/application/singleinstance.cpp similarity index 100% rename from application/singleinstance.cpp rename to tray/application/singleinstance.cpp diff --git a/application/singleinstance.h b/tray/application/singleinstance.h similarity index 100% rename from application/singleinstance.h rename to tray/application/singleinstance.h diff --git a/gui/appearanceoptionpage.ui b/tray/gui/appearanceoptionpage.ui similarity index 100% rename from gui/appearanceoptionpage.ui rename to tray/gui/appearanceoptionpage.ui diff --git a/gui/autostartoptionpage.ui b/tray/gui/autostartoptionpage.ui similarity index 100% rename from gui/autostartoptionpage.ui rename to tray/gui/autostartoptionpage.ui diff --git a/gui/connectionoptionpage.ui b/tray/gui/connectionoptionpage.ui similarity index 100% rename from gui/connectionoptionpage.ui rename to tray/gui/connectionoptionpage.ui diff --git a/gui/devbuttonsitemdelegate.cpp b/tray/gui/devbuttonsitemdelegate.cpp similarity index 95% rename from gui/devbuttonsitemdelegate.cpp rename to tray/gui/devbuttonsitemdelegate.cpp index 1eddcb4..da1a087 100644 --- a/gui/devbuttonsitemdelegate.cpp +++ b/tray/gui/devbuttonsitemdelegate.cpp @@ -1,7 +1,7 @@ #include "./devbuttonsitemdelegate.h" -#include "../data/syncthingdevicemodel.h" -#include "../data/syncthingconnection.h" +#include "../../connector/syncthingconnection.h" +#include "../../model/syncthingdevicemodel.h" #include #include diff --git a/gui/devbuttonsitemdelegate.h b/tray/gui/devbuttonsitemdelegate.h similarity index 100% rename from gui/devbuttonsitemdelegate.h rename to tray/gui/devbuttonsitemdelegate.h diff --git a/gui/devview.cpp b/tray/gui/devview.cpp similarity index 98% rename from gui/devview.cpp rename to tray/gui/devview.cpp index a36bbf8..08defe1 100644 --- a/gui/devview.cpp +++ b/tray/gui/devview.cpp @@ -1,7 +1,7 @@ #include "./devview.h" #include "./devbuttonsitemdelegate.h" -#include "../data/syncthingdevicemodel.h" +#include "../../model/syncthingdevicemodel.h" #include #include diff --git a/gui/devview.h b/tray/gui/devview.h similarity index 100% rename from gui/devview.h rename to tray/gui/devview.h diff --git a/gui/dirbuttonsitemdelegate.cpp b/tray/gui/dirbuttonsitemdelegate.cpp similarity index 100% rename from gui/dirbuttonsitemdelegate.cpp rename to tray/gui/dirbuttonsitemdelegate.cpp diff --git a/gui/dirbuttonsitemdelegate.h b/tray/gui/dirbuttonsitemdelegate.h similarity index 100% rename from gui/dirbuttonsitemdelegate.h rename to tray/gui/dirbuttonsitemdelegate.h diff --git a/gui/dirview.cpp b/tray/gui/dirview.cpp similarity index 98% rename from gui/dirview.cpp rename to tray/gui/dirview.cpp index e37d851..5cd6c19 100644 --- a/gui/dirview.cpp +++ b/tray/gui/dirview.cpp @@ -1,7 +1,7 @@ #include "./dirview.h" #include "./dirbuttonsitemdelegate.h" -#include "../data/syncthingdirectorymodel.h" +#include "../../model/syncthingdirectorymodel.h" #include #include diff --git a/gui/dirview.h b/tray/gui/dirview.h similarity index 100% rename from gui/dirview.h rename to tray/gui/dirview.h diff --git a/gui/downloaditemdelegate.cpp b/tray/gui/downloaditemdelegate.cpp similarity index 98% rename from gui/downloaditemdelegate.cpp rename to tray/gui/downloaditemdelegate.cpp index 2345330..3c5c8d2 100644 --- a/gui/downloaditemdelegate.cpp +++ b/tray/gui/downloaditemdelegate.cpp @@ -1,6 +1,6 @@ #include "./downloaditemdelegate.h" -#include "../data/syncthingdownloadmodel.h" +#include "../../model/syncthingdownloadmodel.h" #include #include diff --git a/gui/downloaditemdelegate.h b/tray/gui/downloaditemdelegate.h similarity index 100% rename from gui/downloaditemdelegate.h rename to tray/gui/downloaditemdelegate.h diff --git a/gui/downloadview.cpp b/tray/gui/downloadview.cpp similarity index 98% rename from gui/downloadview.cpp rename to tray/gui/downloadview.cpp index ae8c812..fc2f016 100644 --- a/gui/downloadview.cpp +++ b/tray/gui/downloadview.cpp @@ -1,7 +1,7 @@ #include "./downloadview.h" #include "./downloaditemdelegate.h" -#include "../data/syncthingdownloadmodel.h" +#include "../../model/syncthingdownloadmodel.h" #include #include diff --git a/gui/downloadview.h b/tray/gui/downloadview.h similarity index 100% rename from gui/downloadview.h rename to tray/gui/downloadview.h diff --git a/gui/launcheroptionpage.ui b/tray/gui/launcheroptionpage.ui similarity index 100% rename from gui/launcheroptionpage.ui rename to tray/gui/launcheroptionpage.ui diff --git a/gui/notificationsoptionpage.ui b/tray/gui/notificationsoptionpage.ui similarity index 100% rename from gui/notificationsoptionpage.ui rename to tray/gui/notificationsoptionpage.ui diff --git a/gui/settingsdialog.cpp b/tray/gui/settingsdialog.cpp similarity index 99% rename from gui/settingsdialog.cpp rename to tray/gui/settingsdialog.cpp index 22849e7..da42acd 100644 --- a/gui/settingsdialog.cpp +++ b/tray/gui/settingsdialog.cpp @@ -1,8 +1,8 @@ #include "./settingsdialog.h" -#include "../data/syncthingconnection.h" -#include "../data/syncthingconfig.h" -#include "../data/syncthingprocess.h" +#include "../../connector/syncthingconnection.h" +#include "../../connector/syncthingconfig.h" +#include "../../connector/syncthingprocess.h" #include "ui_connectionoptionpage.h" #include "ui_notificationsoptionpage.h" diff --git a/gui/settingsdialog.h b/tray/gui/settingsdialog.h similarity index 100% rename from gui/settingsdialog.h rename to tray/gui/settingsdialog.h diff --git a/gui/textviewdialog.cpp b/tray/gui/textviewdialog.cpp similarity index 100% rename from gui/textviewdialog.cpp rename to tray/gui/textviewdialog.cpp diff --git a/gui/textviewdialog.h b/tray/gui/textviewdialog.h similarity index 100% rename from gui/textviewdialog.h rename to tray/gui/textviewdialog.h diff --git a/gui/trayicon.cpp b/tray/gui/trayicon.cpp similarity index 99% rename from gui/trayicon.cpp rename to tray/gui/trayicon.cpp index 2033906..897584e 100644 --- a/gui/trayicon.cpp +++ b/tray/gui/trayicon.cpp @@ -2,7 +2,8 @@ #include "./traywidget.h" #include "../application/settings.h" -#include "../data/syncthingconnection.h" + +#include "../../connector/syncthingconnection.h" #include diff --git a/gui/trayicon.h b/tray/gui/trayicon.h similarity index 92% rename from gui/trayicon.h rename to tray/gui/trayicon.h index 2bca693..7fa5736 100644 --- a/gui/trayicon.h +++ b/tray/gui/trayicon.h @@ -3,17 +3,13 @@ #include "./traymenu.h" -#include +#include #include #include QT_FORWARD_DECLARE_CLASS(QPixmap) -namespace ChronoUtilities { -class DateTime; -} - namespace Data { enum class SyncthingStatus; } diff --git a/gui/traymenu.cpp b/tray/gui/traymenu.cpp similarity index 100% rename from gui/traymenu.cpp rename to tray/gui/traymenu.cpp diff --git a/gui/traymenu.h b/tray/gui/traymenu.h similarity index 100% rename from gui/traymenu.h rename to tray/gui/traymenu.h diff --git a/gui/traywidget.cpp b/tray/gui/traywidget.cpp similarity index 99% rename from gui/traywidget.cpp rename to tray/gui/traywidget.cpp index 9148da5..a625c96 100644 --- a/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -209,8 +209,11 @@ void TrayWidget::showOwnDeviceId() layout->addWidget(copyPushButton); connect(dlg, &QWidget::destroyed, bind(static_cast(&QObject::disconnect), - m_connection.requestQrCode(m_connection.myId(), bind(&QLabel::setPixmap, pixmapLabel, placeholders::_1)) - )); + m_connection.requestQrCode(m_connection.myId(), [pixmapLabel](const QByteArray &data) { + QPixmap pixmap; + pixmap.loadFromData(data); + pixmapLabel->setPixmap(pixmap); + }))); dlg->setLayout(layout); centerWidget(dlg); showDialog(dlg); diff --git a/gui/traywidget.h b/tray/gui/traywidget.h similarity index 91% rename from gui/traywidget.h rename to tray/gui/traywidget.h index 33d34f5..c6f590f 100644 --- a/gui/traywidget.h +++ b/tray/gui/traywidget.h @@ -3,13 +3,15 @@ #include "./webviewprovider.h" -#include "../data/syncthingconnection.h" -#include "../data/syncthingdirectorymodel.h" -#include "../data/syncthingdevicemodel.h" -#include "../data/syncthingdownloadmodel.h" -#include "../data/syncthingprocess.h" #include "../application/settings.h" +#include "../../connector/syncthingconnection.h" +#include "../../connector/syncthingprocess.h" + +#include "../../model/syncthingdirectorymodel.h" +#include "../../model/syncthingdevicemodel.h" +#include "../../model/syncthingdownloadmodel.h" + #include #include diff --git a/gui/traywidget.ui b/tray/gui/traywidget.ui similarity index 100% rename from gui/traywidget.ui rename to tray/gui/traywidget.ui diff --git a/gui/webpage.cpp b/tray/gui/webpage.cpp similarity index 98% rename from gui/webpage.cpp rename to tray/gui/webpage.cpp index d52987f..26228bd 100644 --- a/gui/webpage.cpp +++ b/tray/gui/webpage.cpp @@ -3,7 +3,8 @@ #include "./webviewdialog.h" #include "../application/settings.h" -#include "../data/syncthingconnection.h" + +#include "../../connector/syncthingconnection.h" #include "resources/config.h" diff --git a/gui/webpage.h b/tray/gui/webpage.h similarity index 100% rename from gui/webpage.h rename to tray/gui/webpage.h diff --git a/gui/webviewdialog.cpp b/tray/gui/webviewdialog.cpp similarity index 100% rename from gui/webviewdialog.cpp rename to tray/gui/webviewdialog.cpp diff --git a/gui/webviewdialog.h b/tray/gui/webviewdialog.h similarity index 100% rename from gui/webviewdialog.h rename to tray/gui/webviewdialog.h diff --git a/gui/webviewoptionpage.ui b/tray/gui/webviewoptionpage.ui similarity index 100% rename from gui/webviewoptionpage.ui rename to tray/gui/webviewoptionpage.ui diff --git a/gui/webviewprovider.h b/tray/gui/webviewprovider.h similarity index 100% rename from gui/webviewprovider.h rename to tray/gui/webviewprovider.h diff --git a/resources/icons.qrc b/tray/resources/icons.qrc similarity index 100% rename from resources/icons.qrc rename to tray/resources/icons.qrc diff --git a/resources/icons/hicolor/scalable/actions/application-menu.svg b/tray/resources/icons/hicolor/scalable/actions/application-menu.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/application-menu.svg rename to tray/resources/icons/hicolor/scalable/actions/application-menu.svg diff --git a/resources/icons/hicolor/scalable/actions/edit-copy.svg b/tray/resources/icons/hicolor/scalable/actions/edit-copy.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/edit-copy.svg rename to tray/resources/icons/hicolor/scalable/actions/edit-copy.svg diff --git a/resources/icons/hicolor/scalable/actions/folder-sync.svg b/tray/resources/icons/hicolor/scalable/actions/folder-sync.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/folder-sync.svg rename to tray/resources/icons/hicolor/scalable/actions/folder-sync.svg diff --git a/resources/icons/hicolor/scalable/actions/help-about.svg b/tray/resources/icons/hicolor/scalable/actions/help-about.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/help-about.svg rename to tray/resources/icons/hicolor/scalable/actions/help-about.svg diff --git a/resources/icons/hicolor/scalable/actions/media-playback-pause.svg b/tray/resources/icons/hicolor/scalable/actions/media-playback-pause.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/media-playback-pause.svg rename to tray/resources/icons/hicolor/scalable/actions/media-playback-pause.svg diff --git a/resources/icons/hicolor/scalable/actions/media-playback-start.svg b/tray/resources/icons/hicolor/scalable/actions/media-playback-start.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/media-playback-start.svg rename to tray/resources/icons/hicolor/scalable/actions/media-playback-start.svg diff --git a/resources/icons/hicolor/scalable/actions/network-connect.svg b/tray/resources/icons/hicolor/scalable/actions/network-connect.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/network-connect.svg rename to tray/resources/icons/hicolor/scalable/actions/network-connect.svg diff --git a/resources/icons/hicolor/scalable/actions/view-barcode.svg b/tray/resources/icons/hicolor/scalable/actions/view-barcode.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/view-barcode.svg rename to tray/resources/icons/hicolor/scalable/actions/view-barcode.svg diff --git a/resources/icons/hicolor/scalable/actions/view-refresh.svg b/tray/resources/icons/hicolor/scalable/actions/view-refresh.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/view-refresh.svg rename to tray/resources/icons/hicolor/scalable/actions/view-refresh.svg diff --git a/resources/icons/hicolor/scalable/actions/window-close.svg b/tray/resources/icons/hicolor/scalable/actions/window-close.svg similarity index 100% rename from resources/icons/hicolor/scalable/actions/window-close.svg rename to tray/resources/icons/hicolor/scalable/actions/window-close.svg diff --git a/resources/icons/hicolor/scalable/app/syncthingtray.png b/tray/resources/icons/hicolor/scalable/app/syncthingtray.png similarity index 100% rename from resources/icons/hicolor/scalable/app/syncthingtray.png rename to tray/resources/icons/hicolor/scalable/app/syncthingtray.png diff --git a/resources/icons/hicolor/scalable/app/syncthingtray.svg b/tray/resources/icons/hicolor/scalable/app/syncthingtray.svg similarity index 100% rename from resources/icons/hicolor/scalable/app/syncthingtray.svg rename to tray/resources/icons/hicolor/scalable/app/syncthingtray.svg diff --git a/resources/icons/hicolor/scalable/apps/help-about.svg b/tray/resources/icons/hicolor/scalable/apps/help-about.svg similarity index 100% rename from resources/icons/hicolor/scalable/apps/help-about.svg rename to tray/resources/icons/hicolor/scalable/apps/help-about.svg diff --git a/resources/icons/hicolor/scalable/apps/internet-web-browser.svg b/tray/resources/icons/hicolor/scalable/apps/internet-web-browser.svg similarity index 100% rename from resources/icons/hicolor/scalable/apps/internet-web-browser.svg rename to tray/resources/icons/hicolor/scalable/apps/internet-web-browser.svg diff --git a/resources/icons/hicolor/scalable/apps/preferences-other.svg b/tray/resources/icons/hicolor/scalable/apps/preferences-other.svg similarity index 100% rename from resources/icons/hicolor/scalable/apps/preferences-other.svg rename to tray/resources/icons/hicolor/scalable/apps/preferences-other.svg diff --git a/resources/icons/hicolor/scalable/apps/system-run.svg b/tray/resources/icons/hicolor/scalable/apps/system-run.svg similarity index 100% rename from resources/icons/hicolor/scalable/apps/system-run.svg rename to tray/resources/icons/hicolor/scalable/apps/system-run.svg diff --git a/resources/icons/hicolor/scalable/devices/network-card.svg b/tray/resources/icons/hicolor/scalable/devices/network-card.svg similarity index 100% rename from resources/icons/hicolor/scalable/devices/network-card.svg rename to tray/resources/icons/hicolor/scalable/devices/network-card.svg diff --git a/resources/icons/hicolor/scalable/mimetypes/text-x-generic.svg b/tray/resources/icons/hicolor/scalable/mimetypes/text-x-generic.svg similarity index 100% rename from resources/icons/hicolor/scalable/mimetypes/text-x-generic.svg rename to tray/resources/icons/hicolor/scalable/mimetypes/text-x-generic.svg diff --git a/resources/icons/hicolor/scalable/places/folder-open.svg b/tray/resources/icons/hicolor/scalable/places/folder-open.svg similarity index 100% rename from resources/icons/hicolor/scalable/places/folder-open.svg rename to tray/resources/icons/hicolor/scalable/places/folder-open.svg diff --git a/resources/icons/hicolor/scalable/places/folder.svg b/tray/resources/icons/hicolor/scalable/places/folder.svg similarity index 100% rename from resources/icons/hicolor/scalable/places/folder.svg rename to tray/resources/icons/hicolor/scalable/places/folder.svg diff --git a/resources/icons/hicolor/scalable/places/network-workgroup.svg b/tray/resources/icons/hicolor/scalable/places/network-workgroup.svg similarity index 100% rename from resources/icons/hicolor/scalable/places/network-workgroup.svg rename to tray/resources/icons/hicolor/scalable/places/network-workgroup.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-default.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-default.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-default.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-default.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-disconnected.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-disconnected.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-disconnected.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-disconnected.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-error.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-error.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-error.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-error.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-notify.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-notify.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-notify.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-notify.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-ok.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-ok.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-ok.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-ok.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-pause.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-pause.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-pause.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-pause.svg diff --git a/resources/icons/hicolor/scalable/status/syncthing-sync.svg b/tray/resources/icons/hicolor/scalable/status/syncthing-sync.svg similarity index 100% rename from resources/icons/hicolor/scalable/status/syncthing-sync.svg rename to tray/resources/icons/hicolor/scalable/status/syncthing-sync.svg diff --git a/resources/screenshots/plasma.png b/tray/resources/screenshots/plasma.png similarity index 100% rename from resources/screenshots/plasma.png rename to tray/resources/screenshots/plasma.png diff --git a/resources/screenshots/settings.png b/tray/resources/screenshots/settings.png similarity index 100% rename from resources/screenshots/settings.png rename to tray/resources/screenshots/settings.png diff --git a/resources/screenshots/tint2.png b/tray/resources/screenshots/tint2.png similarity index 100% rename from resources/screenshots/tint2.png rename to tray/resources/screenshots/tint2.png diff --git a/resources/screenshots/webview.png b/tray/resources/screenshots/webview.png similarity index 100% rename from resources/screenshots/webview.png rename to tray/resources/screenshots/webview.png diff --git a/translations/syncthingtray_de_DE.ts b/tray/translations/syncthingtray_de_DE.ts similarity index 61% rename from translations/syncthingtray_de_DE.ts rename to tray/translations/syncthingtray_de_DE.ts index 1eecc7c..91053aa 100644 --- a/translations/syncthingtray_de_DE.ts +++ b/tray/translations/syncthingtray_de_DE.ts @@ -1,392 +1,6 @@ - - Data::SyncthingConnection - - - disconnected - - - - - reconnecting - - - - - connected - - - - - connected, notifications available - - - - - connected, paused - - - - - connected, synchronizing - - - - - unknown - - - - - - Connection configuration is insufficient. - - - - - Unable to parse Syncthing log: - - - - - Unable to request system log: - - - - - Unable to locate certificate used by Syncthing GUI. - - - - - Unable to load certificate used by Syncthing GUI. - - - - - - Unable to parse Syncthing config: - - - - - - Unable to request Syncthing config: - - - - - Unable to parse connections: - - - - - Unable to request connections: - - - - - Unable to parse directory statistics: - - - - - Unable to request directory statistics: - - - - - Unable to parse device statistics: - - - - - Unable to request device statistics: - - - - - Unable to parse errors: - - - - - Unable to request errors: - - - - - Unable to parse Syncthing events: - - - - - Unable to request Syncthing events: - - - - - Unable to request rescan: - - - - - Unable to request pause/resume: - - - - - Unable to request restart: - - - - - Unable to request QR-Code: - - - - - Data::SyncthingDeviceModel - - - - ID - - - - - Status - - - - - Addresses - - - - - Last seen - - - - - Compression - - - - - Certificate - - - - - Introducer - - - - - none - - - - - yes - - - - - no - - - - - Unknown status - - - - - Idle - - - - - Disconnected - - - - - Synchronizing (%1 %) - - - - - Synchronizing - - - - - Own device - - - - - unknown or own device - - - - - Paused - - - - - Out of sync - - - - - Rejected - - - - - Data::SyncthingDirectoryModel - - - - ID - - - - - Status - - - - - Path - - - - - Devices - - - - - Rescan interval - - - - - Last scan - - - - - Last file - - - - - yes - - - - - no - - - - - - unknown - - - - - Deleted at %1 - - - - - Updated at %1 - - - - - Idle - - - - - Scanning (%1 %) - - - - - Synchronizing (%1 %) - - - - - Out of sync - - - - - Scanning - - - - - Read-only - - - - - Unknown status - - - - - Synchronizing - - - - - Paused - - - - - Data::SyncthingDownloadModel - - - Dir/item - - - - - Progress - - - - - Data::Utils - - - %1 ago - - - - - right now - - - QtGui::AppearanceOptionPage @@ -790,82 +404,82 @@ QtGui::TrayIcon - + Web UI - + Settings - + Rescan all - + About - + Close - + Error - + Syncthing notification - click to dismiss - + Not connected to Syncthing - + Disconnected from Syncthing - + Reconnecting ... - + Syncthing is idling - + Syncthing is scanning - + Notifications available - + At least one device is paused - + Synchronization is ongoing - + Synchronization complete @@ -879,7 +493,7 @@ - + Connect @@ -917,7 +531,7 @@ For <i>all</i> notifications, checkout the log - + unknown @@ -994,42 +608,42 @@ For <i>all</i> notifications, checkout the log - + New notifications - + Not connected to Syncthing, click to connect - + Pause - + Syncthing is running, click to pause all devices - + At least one device is paused, click to resume - + The directory <i>%1</i> does not exist on the local machine. - + The file <i>%1</i> does not exist on the local machine. - + Continue @@ -1039,7 +653,7 @@ For <i>all</i> notifications, checkout the log - + Log diff --git a/translations/syncthingtray_en_US.ts b/tray/translations/syncthingtray_en_US.ts similarity index 61% rename from translations/syncthingtray_en_US.ts rename to tray/translations/syncthingtray_en_US.ts index fb74e1e..6042fb2 100644 --- a/translations/syncthingtray_en_US.ts +++ b/tray/translations/syncthingtray_en_US.ts @@ -1,392 +1,6 @@ - - Data::SyncthingConnection - - - disconnected - - - - - reconnecting - - - - - connected - - - - - connected, notifications available - - - - - connected, paused - - - - - connected, synchronizing - - - - - unknown - - - - - - Connection configuration is insufficient. - - - - - Unable to parse Syncthing log: - - - - - Unable to request system log: - - - - - Unable to locate certificate used by Syncthing GUI. - - - - - Unable to load certificate used by Syncthing GUI. - - - - - - Unable to parse Syncthing config: - - - - - - Unable to request Syncthing config: - - - - - Unable to parse connections: - - - - - Unable to request connections: - - - - - Unable to parse directory statistics: - - - - - Unable to request directory statistics: - - - - - Unable to parse device statistics: - - - - - Unable to request device statistics: - - - - - Unable to parse errors: - - - - - Unable to request errors: - - - - - Unable to parse Syncthing events: - - - - - Unable to request Syncthing events: - - - - - Unable to request rescan: - - - - - Unable to request pause/resume: - - - - - Unable to request restart: - - - - - Unable to request QR-Code: - - - - - Data::SyncthingDeviceModel - - - - ID - - - - - Status - - - - - Addresses - - - - - Last seen - - - - - Compression - - - - - Certificate - - - - - Introducer - - - - - none - - - - - yes - - - - - no - - - - - Unknown status - - - - - Idle - - - - - Disconnected - - - - - Synchronizing (%1 %) - - - - - Synchronizing - - - - - Own device - - - - - unknown or own device - - - - - Paused - - - - - Out of sync - - - - - Rejected - - - - - Data::SyncthingDirectoryModel - - - - ID - - - - - Status - - - - - Path - - - - - Devices - - - - - Rescan interval - - - - - Last scan - - - - - Last file - - - - - yes - - - - - no - - - - - - unknown - - - - - Deleted at %1 - - - - - Updated at %1 - - - - - Idle - - - - - Scanning (%1 %) - - - - - Synchronizing (%1 %) - - - - - Out of sync - - - - - Scanning - - - - - Read-only - - - - - Unknown status - - - - - Synchronizing - - - - - Paused - - - - - Data::SyncthingDownloadModel - - - Dir/item - - - - - Progress - - - - - Data::Utils - - - %1 ago - - - - - right now - - - QtGui::AppearanceOptionPage @@ -790,82 +404,82 @@ QtGui::TrayIcon - + Web UI - + Settings - + Rescan all - + About - + Close - + Error - + Syncthing notification - click to dismiss - + Not connected to Syncthing - + Disconnected from Syncthing - + Reconnecting ... - + Syncthing is idling - + Syncthing is scanning - + Notifications available - + At least one device is paused - + Synchronization is ongoing - + Synchronization complete @@ -879,7 +493,7 @@ - + Connect @@ -917,7 +531,7 @@ For <i>all</i> notifications, checkout the log - + unknown @@ -994,42 +608,42 @@ For <i>all</i> notifications, checkout the log - + New notifications - + Not connected to Syncthing, click to connect - + Pause - + Syncthing is running, click to pause all devices - + At least one device is paused, click to resume - + The directory <i>%1</i> does not exist on the local machine. - + The file <i>%1</i> does not exist on the local machine. - + Continue @@ -1039,7 +653,7 @@ For <i>all</i> notifications, checkout the log - + Log