diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ea0fc8..40f9ab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,38 +1,38 @@ project(Koko) cmake_minimum_required(VERSION 2.8.12) find_package(ECM 5.53.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH}) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Widgets Test Sql Positioning) if(ANDROID) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS AndroidExtras) endif() -find_package(KF5 5.5 REQUIRED COMPONENTS I18n Declarative Config KIO GuiAddons CoreAddons Notifications IconThemes) +find_package(KF5 5.5 REQUIRED COMPONENTS I18n Declarative Config KIO GuiAddons CoreAddons Notifications) find_package(LibExiv2 0.21 REQUIRED) include(FeatureSummary) include(ECMAddTests) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings) include(GenerateExportHeader) include(ECMInstallIcons) include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src ) kde_enable_exceptions() add_subdirectory(src) add_subdirectory(autotests) add_subdirectory(icons) install(FILES org.kde.koko.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c4ffad..bac43ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,144 +1,148 @@ # # Common Library # set(LIB_SRCS imagestorage.cpp filesystemimagefetcher.cpp ${LIB_SRCS} ) add_library(kokocommon SHARED ${LIB_SRCS}) target_link_libraries(kokocommon Qt5::Core Qt5::Positioning Qt5::Sql KF5::CoreAddons ) generate_export_header(kokocommon BASE_NAME KOKO EXPORT_FILE_NAME koko_export.h) set_target_properties(kokocommon PROPERTIES VERSION 0.0.1 SOVERSION 0.0.1 ) install(TARGETS kokocommon EXPORT KokoLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) # # Application # -add_executable(koko + +set(koko_SRCS main.cpp reversegeocoder.cpp filesystemtracker.cpp processor.cpp committimer.cpp imageprocessorrunnable.cpp exiv2extractor.cpp - kokoconfig.cpp kdtree.c resources.qrc ) +kconfig_add_kcfg_files(koko_SRCS kokoconfig.kcfgc GENERATE_MOC) + +add_executable(koko ${koko_SRCS}) + target_link_libraries(koko Qt5::Quick Qt5::Widgets Qt5::Qml Qt5::Positioning KF5::ConfigCore KF5::I18n KF5::CoreAddons KF5::KIOCore - KF5::IconThemes + KF5::ConfigGui kokocommon LibExiv2::LibExiv2 ) if(ANDROID) target_link_libraries(koko Qt5::AndroidExtras) endif() install(TARGETS koko ${INSTALL_TARGETS_DEFAULT_ARGS}) # # QML Plugin # set (qml_plugin_SRCS qmlplugins.cpp tagmodel.cpp imagelocationmodel.cpp imagetimemodel.cpp imagefoldermodel.cpp sortmodel.cpp allimagesmodel.cpp imagelistmodel.cpp notificationmanager.cpp types.cpp roles.cpp imagedocument.cpp ) add_library (kokoqmlplugin SHARED ${qml_plugin_SRCS}) target_link_libraries (kokoqmlplugin Qt5::Qml KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::GuiAddons KF5::I18n KF5::Notifications kokocommon ) install (TARGETS kokoqmlplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/koko) install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/koko) install (FILES org.kde.koko.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) # # Reverse GeoLookup Data # # Packagers can download the file and put it in the tarball if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cities1000.zip) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/cities1000.zip DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif() if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cities1000.zip) file (DOWNLOAD "http://download.geonames.org/export/dump/cities1000.zip" ${CMAKE_CURRENT_BINARY_DIR}/cities1000.zip SHOW_PROGRESS ) endif() execute_process( COMMAND ${CMAKE_COMMAND} -E tar -xzf ${CMAKE_CURRENT_BINARY_DIR}/cities1000.zip WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/admin1CodesASCII.txt) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/admin1CodesASCII.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif() if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/admin1CodesASCII.txt) file (DOWNLOAD "http://download.geonames.org/export/dump/admin1CodesASCII.txt" ${CMAKE_CURRENT_BINARY_DIR}/admin1CodesASCII.txt SHOW_PROGRESS ) endif() file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/admin1CodesASCII.txt ${CMAKE_CURRENT_BINARY_DIR}/admin1Codes.txt) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/admin2Codes.txt) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/admin2Codes.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif() if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/admin2Codes.txt) file (DOWNLOAD "http://download.geonames.org/export/dump/admin2Codes.txt" ${CMAKE_CURRENT_BINARY_DIR}/admin2Codes.txt SHOW_PROGRESS ) endif() install (FILES ${CMAKE_CURRENT_BINARY_DIR}/cities1000.txt DESTINATION ${DATA_INSTALL_DIR}/koko) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/admin1Codes.txt DESTINATION ${DATA_INSTALL_DIR}/koko) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/admin2Codes.txt DESTINATION ${DATA_INSTALL_DIR}/koko) install (FILES countries.csv DESTINATION ${DATA_INSTALL_DIR}/koko) install (FILES koko.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR}) diff --git a/src/kokoconfig.cpp b/src/kokoconfig.cpp deleted file mode 100644 index ebeb182..0000000 --- a/src/kokoconfig.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2014 Vishesh Handa - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "kokoconfig.h" - -#include -#include - -#include - -KokoConfig::KokoConfig(QObject* parent) - : QObject(parent) - , m_config("kokorc") -{ -} - -KokoConfig::~KokoConfig() -{ -} - -bool KokoConfig::initialRun() const -{ - return m_config.group("general").readEntry("InitialRun", true); -} - -void KokoConfig::setInitialRun(bool value) -{ - m_config.group("general").writeEntry("InitialRun", value); - m_config.sync(); -} - -int KokoConfig::iconSize() const -{ - return m_config.group("general").readEntry("IconSize", (int)KIconLoader::SizeHuge); -} - -void KokoConfig::setIconSize(int size) -{ - m_config.group("general").writeEntry("IconSize", size); - m_config.sync(); - emit iconSizeChanged(); -} - -void KokoConfig::reset() -{ - QString path = QStandardPaths::locate(QStandardPaths::ConfigLocation, m_config.name()); - if (QFile::exists(path)) { - QFile::remove(path); - } - - m_config.reparseConfiguration(); -} diff --git a/src/kokoconfig.h b/src/kokoconfig.h deleted file mode 100644 index 1fac4ee..0000000 --- a/src/kokoconfig.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2014 Vishesh Handa - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef JUNGLE_JUNGLECONFIG_H -#define JUNGLE_JUNGLECONFIG_H - -#include -#include -#include - -class KokoConfig : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool initialRun READ initialRun WRITE setInitialRun) - Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) -public: - KokoConfig(QObject* parent = 0); - virtual ~KokoConfig(); - - bool initialRun() const; - void setInitialRun(bool value); - - int iconSize() const; - void setIconSize(int size); - - void reset(); -Q_SIGNALS: - void iconSizeChanged(); - -private: - KConfig m_config; -}; - -#endif // JUNGLE_JUNGLECONFIG_H diff --git a/src/kokoconfig.kcfg b/src/kokoconfig.kcfg new file mode 100644 index 0000000..352bbfa --- /dev/null +++ b/src/kokoconfig.kcfg @@ -0,0 +1,20 @@ + + + + + + + true + + + + + + 64 + + + + diff --git a/src/kokoconfig.kcfgc b/src/kokoconfig.kcfgc new file mode 100644 index 0000000..1d27603 --- /dev/null +++ b/src/kokoconfig.kcfgc @@ -0,0 +1,6 @@ +File=kokoconfig.kcfg +ClassName=KokoConfig +Mutators=true +DefaultValueGetters=true +GenerateProperties=true +ParentInConstructor=true diff --git a/src/main.cpp b/src/main.cpp index 8a68781..3f0b5f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,118 +1,116 @@ /* * Copyright (C) 2017 Atul Sharma * Copyright (C) 2014 Vishesh Handa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "filesystemtracker.h" #include "processor.h" #include "kokoconfig.h" #include "imagestorage.h" #ifdef Q_OS_ANDROID #include #endif int main(int argc, char** argv) { QApplication app(argc, argv); app.setApplicationDisplayName("Koko"); app.setOrganizationDomain("kde.org"); QCommandLineParser parser; parser.addOption(QCommandLineOption("reset", i18n("Reset the database"))); parser.addPositionalArgument( "image", i18n("path of image you want to open")); parser.addHelpOption(); parser.process(app); if (parser.positionalArguments().size() > 1) { parser.showHelp(1); } if (parser.isSet("reset")) { - KokoConfig config; - config.reset(); - ImageStorage::reset(); } QThread trackerThread; QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); Q_ASSERT(locations.size() >= 1); qDebug() << locations; #ifdef Q_OS_ANDROID QtAndroid::requestPermissionsSync({"android.permission.WRITE_EXTERNAL_STORAGE"}); #endif FileSystemTracker tracker; tracker.setFolder(locations.first()); tracker.moveToThread(&trackerThread); Koko::Processor processor; QObject::connect(&tracker, &FileSystemTracker::imageAdded, &processor, &Koko::Processor::addFile); QObject::connect(&tracker, &FileSystemTracker::imageRemoved, &processor, &Koko::Processor::removeFile); QObject::connect(&tracker, &FileSystemTracker::initialScanComplete, &processor, &Koko::Processor::initialScanCompleted); QObject::connect(&trackerThread, &QThread::started, &tracker, &FileSystemTracker::setupDb); trackerThread.start(); tracker.setSubFolder(tracker.folder()); KokoConfig config; + QObject::connect(&config, &KokoConfig::IconSizeChanged, &config, &KokoConfig::save); QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.rootContext()->setContextProperty("kokoProcessor", &processor); engine.rootContext()->setContextProperty("kokoConfig", &config); QString path; //we want different main files on desktop or mobile //very small difference as they as they are subclasses of the same thing if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE") && (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("1") || QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("true"))) { engine.load(QUrl(QStringLiteral("qrc:/qml/mobileMain.qml"))); } else { engine.load(QUrl(QStringLiteral("qrc:/qml/desktopMain.qml"))); } int rt = app.exec(); trackerThread.quit(); return rt; }