diff --git a/LoFloccus/LoFloccus.pro b/LoFloccus/LoFloccus.pro index 6502133..0fb5f57 100644 --- a/LoFloccus/LoFloccus.pro +++ b/LoFloccus/LoFloccus.pro @@ -26,7 +26,7 @@ FORMS += \ lofloccus.ui # Generic for all builds -VERSION = 1.2.0 +VERSION = 1.2.1 DEFINES += APP_VERSION=\\\"$$VERSION\\\" INCLUDEPATH += $${PWD}/libs @@ -44,6 +44,11 @@ mac { ICON = assets/icon.icns QMAKE_TARGET_BUNDLE_PREFIX = "com.tcb13" LIBS += -L$${PWD}/libs -lLoFloccusDavDarwin + + SOURCES += platformdarwin.mm + HEADERS += platformdarwin.h + LIBS += -framework Foundation + LIBS += -framework AppKit } @@ -59,12 +64,13 @@ RESOURCES += \ # Static Builds QTPREFIX=$$[QT_INSTALL_PREFIX] -equals(QTPREFIX, "C:/Qt-Static/Qt-5.14.2"){ +equals(QTPREFIX, "C:/Qt-Static/Qt-5.14.2") || equals(QTPREFIX, "/Users/tcb13/Qt-Static/Qt-5.12.12") { message("--STATIC BUILD--") CONFIG += qt static - QMAKE_LFLAGS += -static-libgcc -static-libstdc++ + win32 { + QMAKE_LFLAGS += -static-libgcc -static-libstdc++ + } + } else { message("--NON-STATIC BUILD--") } - - diff --git a/LoFloccus/LoFloccus.pro.user b/LoFloccus/LoFloccus.pro.user index 05cbb38..7a622a0 100644 --- a/LoFloccus/LoFloccus.pro.user +++ b/LoFloccus/LoFloccus.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -58,8 +58,7 @@ -fno-delayed-template-parsing - false - {192c391d-0473-4629-8a1a-9afd4593b70b} + true @@ -68,7 +67,7 @@ Desktop Qt 5.14.2 MinGW 64-bit Desktop Qt 5.14.2 MinGW 64-bit qt.qt5.5142.win64_mingw73_kit - 0 + 1 0 0 @@ -228,249 +227,6 @@ 1 - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Tadeu Bento/Projetos/LoFloccus/LoFloccus/LoFloccus.pro - C:/Users/Tadeu Bento/Projetos/LoFloccus/LoFloccus/LoFloccus.pro - - false - - false - true - true - false - false - true - - C:/Users/Tadeu Bento/Projetos/LoFloccus/build-LoFloccus-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit - 0 - 0 - 0 - - C:/Users/Tadeu Bento/Projetos/LoFloccus/build-LoFloccus-Desktop_Qt_5_14_2_MinGW_32_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - C:/Users/Tadeu Bento/Projetos/LoFloccus/build-LoFloccus-Desktop_Qt_5_14_2_MinGW_32_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - C:/Users/Tadeu Bento/Projetos/LoFloccus/build-LoFloccus-Desktop_Qt_5_14_2_MinGW_32_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - dwarf @@ -549,12 +305,12 @@ - ProjectExplorer.Project.Target.2 + ProjectExplorer.Project.Target.1 Desktop Static Desktop Static {6ade0079-14a6-434a-872a-bd67ebf6cbea} - 1 + 0 0 0 @@ -774,26 +530,26 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Tadeu Bento/Projetos/LoFloccus/LoFloccus/LoFloccus.pro - C:/Users/Tadeu Bento/Projetos/LoFloccus/LoFloccus/LoFloccus.pro + + ProjectExplorer.CustomExecutableRunConfiguration + false false true - true false false true - C:/Users/Tadeu Bento/Projetos/LoFloccus/build-LoFloccus-Desktop_Static-Release + 1 ProjectExplorer.Project.TargetCount - 3 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/LoFloccus/libs/libLoFloccusDav.go b/LoFloccus/libs/libLoFloccusDav.go index a877458..5216721 100644 --- a/LoFloccus/libs/libLoFloccusDav.go +++ b/LoFloccus/libs/libLoFloccusDav.go @@ -8,8 +8,9 @@ Complied with: How to install/compile this as a static library: 1. go get "golang.org/x/net/webdav" 2. Build ir for your architecture: -2.1. Windows: go build -buildmode c-archive -o libLoFloccusDavWin64.a libLoFloccusDav.go -2.2. macOS: go build -buildmode c-shared -o libLoFloccusDavDarwin.a libLoFloccusDav.go +2.1. Windows (dev/release): go build -buildmode c-archive -o libLoFloccusDavWin64.a libLoFloccusDav.go +2.2. macOS (dev): go build -buildmode c-shared -o libLoFloccusDavDarwin.a libLoFloccusDav.go +2.3. macOS (release): go build -buildmode c-archive -o libLoFloccusDavDarwin.a libLoFloccusDav.go */ package main diff --git a/LoFloccus/lofloccus.cpp b/LoFloccus/lofloccus.cpp index be16404..e3af8b5 100644 --- a/LoFloccus/lofloccus.cpp +++ b/LoFloccus/lofloccus.cpp @@ -28,12 +28,16 @@ LoFloccus::LoFloccus(QWidget *parent) appIcon = QIcon(":/assets/icon.ico"); running = false; + #ifdef Q_OS_DARWIN + darwinBridge = new PlatformDarwin(); + #endif + // Make sure nobody can resize the app under any platform this->setFixedSize(this->width(), this->height()); this->setWindowTitle(this->windowTitle() + " - v" + APP_VERSION); // Fetch settings from storage and/or write defaults - this->initSettings(); + this->initSettings(false, false); // Populate UI with the loaded settings this->reloadUiState(); @@ -49,17 +53,16 @@ LoFloccus::LoFloccus(QWidget *parent) showMinimized(); } if (settings->value("startminimized").toBool() && settings->value("hidetosystray").toBool()) { + #ifdef Q_OS_DARWIN + darwinBridge->makeAppAccessory(); + #endif sysTray->showMessage("LoFloccus", "LoFloccus is running in the background. Click the menu for more options.", appIcon); } - // Start the server with the app if required - if (settings->value("startopen").toBool()) { - this->startServer(); - } - + // Start the server with the app + this->startServer(); } -#ifdef Q_OS_WIN void LoFloccus::closeEvent(QCloseEvent *event) { if (minimizeAndCloseToTray) { @@ -75,10 +78,12 @@ void LoFloccus::hideEvent(QHideEvent *event) event->accept(); if (minimizeAndCloseToTray) { hide(); + #ifdef Q_OS_DARWIN + darwinBridge->makeAppAccessory(); + #endif sysTray->showMessage("LoFloccus", "LoFloccus is running in the background. Click the menu for more options.", appIcon); } } -#endif LoFloccus::~LoFloccus() { @@ -90,10 +95,29 @@ LoFloccus::~LoFloccus() delete ui; } -void LoFloccus::initSettings() -{ - // Initialized a shared settings object with the appropriate path - settings = new QSettings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/settings.ini", QSettings::IniFormat); +void LoFloccus::initSettings(bool makeExistingSettingsPortable = false, bool makeExistingSettingsLocal = false) +{ + QString localSettingsFile = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/settings.ini"; + QString portableSettingsFile = "lofloccus-settings.ini"; + + // Deal with settings location move + if (makeExistingSettingsPortable) { + if (QFile::exists(portableSettingsFile)) { + QFile::remove(portableSettingsFile); + } + QFile::copy(localSettingsFile, portableSettingsFile); + QFile::remove(localSettingsFile); + } + if (makeExistingSettingsLocal) { + if (QFile::exists(localSettingsFile)) { + QFile::remove(localSettingsFile); + } + QFile::copy(portableSettingsFile, localSettingsFile); + QFile::remove(portableSettingsFile); + } + + // Initialize a shared settings object with the appropriate path + settings = new QSettings(QFile::exists(portableSettingsFile) ? portableSettingsFile : localSettingsFile, QSettings::IniFormat); // Generate random defaults for port and password QString defaultPort = QString::number(QRandomGenerator::global()->bounded(40000, 65535)); @@ -107,15 +131,14 @@ void LoFloccus::initSettings() settings->setValue("serveruser", settings->value("serveruser", "floccus")); settings->setValue("serverpasswd", settings->value("serverpasswd", defaultPasswd)); - settings->setValue("startopen", settings->value("startopen", false)); settings->setValue("startminimized", settings->value("startminimized", false)); settings->setValue("hidetosystray", settings->value("hidetosystray", false)); settings->setValue("sharednetwork", settings->value("sharednetwork", false)); + settings->setValue("portablemode", settings->value("portablemode", false)); } void LoFloccus::reloadUiState() { - ui->btn_server_control->setText(running ? "Stop LoFloccus Server": "Start LoFloccus Server"); ui->xbel_path->setText(settings->value("serverpath").toString()); // Take care of the server addresses, might be just local or all IPs of the machine @@ -130,10 +153,10 @@ void LoFloccus::reloadUiState() ui->srv_user->setText(settings->value("serveruser").toString()); ui->srv_passwd->setText(settings->value("serverpasswd").toString()); - ui->startopen->setChecked(settings->value("startopen").toBool()); ui->startminimized->setChecked(settings->value("startminimized").toBool()); ui->hidetosystray->setChecked(settings->value("hidetosystray").toBool()); ui->sharednetwork->setChecked(settings->value("sharednetwork").toBool()); + ui->portablemode->setChecked(settings->value("portablemode").toBool()); } void LoFloccus::initSystray() @@ -147,6 +170,9 @@ void LoFloccus::initSystray() QAction *openAction = new QAction("Open LoFloccus", this); connect(openAction, &QAction::triggered, [this]() { + #ifdef Q_OS_DARWIN + darwinBridge->makeAppRegular(); + #endif showNormal(); activateWindow(); }); @@ -184,25 +210,19 @@ void LoFloccus::restartServer() void LoFloccus::startServer() { - ui->btn_server_control->setDisabled(true); - ui->btn_server_control->setChecked(false); serverStart(settings->value("serveraddr").toString().toUtf8().data(), settings->value("serverport").toString().toUtf8().data(), settings->value("serverpath").toString().toUtf8().data(), settings->value("serveruser").toString().toUtf8().data(), settings->value("serverpasswd").toString().toUtf8().data() ); - ui->btn_server_control->setDisabled(false); running = true; this->reloadUiState(); } void LoFloccus::stopServer() { - ui->btn_server_control->setDisabled(true); - ui->btn_server_control->setChecked(false); serverStop(); - ui->btn_server_control->setDisabled(false); running = false; this->reloadUiState(); } @@ -225,16 +245,6 @@ QList LoFloccus::getSystemIPAddresses(bool locals = true, bool v4 = tru return returnList; } - -void LoFloccus::on_btn_server_control_clicked() -{ - if (running) { - this->stopServer(); - } else { - this->startServer(); - } -} - void LoFloccus::on_btn_xbel_localtion_clicked() { QString dir = QFileDialog::getExistingDirectory(this, @@ -245,17 +255,19 @@ void LoFloccus::on_btn_xbel_localtion_clicked() return; } settings->setValue("serverpath", dir); - if (!running) { - this->reloadUiState(); - } this->restartServer(); } -void LoFloccus::on_startopen_clicked() +void LoFloccus::on_portablemode_clicked() { - settings->setValue("startopen", ui->startopen->isChecked()); + if (ui->portablemode->isChecked()) { + this->initSettings(true, false); + } else { + this->initSettings(false, true); + } + settings->setValue("portablemode", ui->portablemode->isChecked()); } void LoFloccus::on_startminimized_clicked() @@ -275,3 +287,4 @@ void LoFloccus::on_sharednetwork_clicked() settings->setValue("serveraddr", ui->sharednetwork->isChecked() ? "0.0.0.0" : "127.0.0.1"); this->restartServer(); } + diff --git a/LoFloccus/lofloccus.h b/LoFloccus/lofloccus.h index 74ca31e..9fd26a8 100644 --- a/LoFloccus/lofloccus.h +++ b/LoFloccus/lofloccus.h @@ -6,6 +6,10 @@ #include #include +#ifdef Q_OS_DARWIN +#include "platformdarwin.h" +#endif + QT_BEGIN_NAMESPACE namespace Ui { class LoFloccus; } QT_END_NAMESPACE @@ -19,25 +23,16 @@ class LoFloccus : public QMainWindow ~LoFloccus(); QIcon appIcon; - - private slots: - void on_btn_server_control_clicked(); void on_btn_xbel_localtion_clicked(); - - void on_startopen_clicked(); - void on_startminimized_clicked(); - void on_hidetosystray_clicked(); - void on_sharednetwork_clicked(); + void on_portablemode_clicked(); protected: - #ifdef Q_OS_WIN void closeEvent(QCloseEvent *event) override; void hideEvent(QHideEvent *event) override; - #endif private: bool minimizeAndCloseToTray; @@ -46,10 +41,14 @@ private slots: QSettings *settings; QSystemTrayIcon *sysTray; + #ifdef Q_OS_DARWIN + PlatformDarwin *darwinBridge; + #endif + Ui::LoFloccus *ui; - void initSettings(); - void reloadUiState(); + void initSettings(bool makeExistingSettingsPortable, bool makeExistingSettingsLocal); + void reloadUiState(); void startServer(); void stopServer(); void restartServer(); diff --git a/LoFloccus/lofloccus.ui b/LoFloccus/lofloccus.ui index 45287f1..e3b3326 100644 --- a/LoFloccus/lofloccus.ui +++ b/LoFloccus/lofloccus.ui @@ -7,7 +7,7 @@ 0 0 462 - 451 + 413 @@ -55,7 +55,7 @@ 20 - 300 + 260 431 16 @@ -116,40 +116,11 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 130 - 90 - 201 - 31 - - - - Start Server - - - - :/assets/icon.ico:/assets/icon.ico - - - true - - - false - - - false - - - false - - 10 - 130 + 90 441 16 @@ -162,7 +133,7 @@ 20 - 180 + 140 421 91 @@ -171,13 +142,6 @@ 4 - - - - Start the server on launch - - - @@ -199,13 +163,20 @@ + + + + Run in portable mode (settings are saved on the app directory) + + + 30 - 330 + 290 411 36 @@ -234,7 +205,7 @@ 40 - 380 + 340 401 51 @@ -336,7 +307,7 @@ 20 - 150 + 110 421 27 @@ -433,7 +404,7 @@ 10 - 280 + 240 441 16 diff --git a/LoFloccus/platformdarwin.h b/LoFloccus/platformdarwin.h new file mode 100644 index 0000000..5172870 --- /dev/null +++ b/LoFloccus/platformdarwin.h @@ -0,0 +1,11 @@ +#ifndef __PlatformDarwin_h_ +#define __PlatformDarwin_h_ + +class PlatformDarwin +{ +public: + static void makeAppAccessory(); + static void makeAppRegular(); +}; + +#endif diff --git a/LoFloccus/platformdarwin.mm b/LoFloccus/platformdarwin.mm new file mode 100644 index 0000000..ec006aa --- /dev/null +++ b/LoFloccus/platformdarwin.mm @@ -0,0 +1,13 @@ +#include "platformdarwin.h" +#import +#import + +void PlatformDarwin::makeAppAccessory() +{ + NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; +} + +void PlatformDarwin::makeAppRegular() +{ + NSApp.activationPolicy = NSApplicationActivationPolicyRegular; +} diff --git a/README.md b/README.md index fc0fb50..2ea2473 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,15 @@ Sync Floccus to a Local Folder! **LoFloccus** is a small companion app for Floccus that empowers you to sync your bookmarks with whatever service or tool you would like to! +![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white) +![Mac OS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white) + ![LoFloccus](https://cdn.iklive.eu/tcb13/2021/lofloccus-1-2-0.png.png) ## Download LoFloccus -- **Windows**: https://github.com/TCB13/LoFloccus/releases/download/1.2.0/LoFloccus-Win.zip -- **macOS**: https://github.com/TCB13/LoFloccus/releases/download/1.1.2/LoFloccus-macOS.zip +- **Windows**: https://github.com/TCB13/LoFloccus/releases/download/1.2.1/LoFloccus-Win.zip +- **macOS**: https://github.com/TCB13/LoFloccus/releases/download/1.2.1/LoFloccus-macOS.zip ## Why and How