diff --git a/CMakeLists.txt b/CMakeLists.txt index b73a910..39a8d4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,89 +1,91 @@ # vim:set softtabstop=3 shiftwidth=3 tabstop=3 expandtab: cmake_minimum_required (VERSION 2.8.12) project (PlasmaVault) set(PROJECT_VERSION "5.11.90") set(PROJECT_VERSION_MAJOR 5) set (PLASMAVAULT_VERSION "0.1") set (REQUIRED_QT_VERSION 5.7.0) # We don't build in-source if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message ( FATAL_ERROR "plasmavault requires an out of source build. Please create a separate build directory and run 'cmake path_to_plasma [options]' there." ) endif () # Extra CMake stuff include (FeatureSummary) find_package (ECM 5.17.0 NO_MODULE) set_package_properties (ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary (WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include (KDEInstallDirs) include (KDECMakeSettings) include (KDECompilerSettings) include (GenerateExportHeader) include (ECMGenerateHeaders) # Qt set (CMAKE_AUTOMOC ON) find_package ( Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED COMPONENTS Core DBus Quick Widgets ) # KDE Frameworks set (KF5_DEP_VERSION "5.17.0") # handled by release scripts find_package ( KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Activities Config ConfigWidgets CoreAddons DBusAddons I18n KIO Plasma WidgetsAddons ) find_package (KF5SysGuard REQUIRED) include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common ) # Basic includes include (CPack) include (ECMPackageConfigHelpers) include (ECMSetupVersion) +add_definitions (-DQT_NO_URL_CAST_FROM_STRING) +add_definitions (-DQT_NO_CAST_TO_ASCII) add_definitions (-DTRANSLATION_DOMAIN=\"plasmavault-kde\") add_definitions (-fexceptions) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install (po) endif () # libPlasmaVault add_subdirectory (kded) add_subdirectory (plasma) add_subdirectory (icons) # Write out the features feature_summary (WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kded/ui/directorychooserwidget.cpp b/kded/ui/directorychooserwidget.cpp index fd8e6e4..e965639 100644 --- a/kded/ui/directorychooserwidget.cpp +++ b/kded/ui/directorychooserwidget.cpp @@ -1,102 +1,102 @@ /* * Copyright 2017 by Ivan Cukic * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "directorychooserwidget.h" #include "ui_directorychooserwidget.h" #include "vault.h" class DirectoryChooserWidget::Private { public: Ui::DirectoryChooserWidget ui; DirectoryChooserWidget::Flags flags; bool mountPointValid = false; DirectoryChooserWidget *const q; Private(DirectoryChooserWidget *parent) : q(parent) { } void setMountPointValid(bool valid) { if (mountPointValid == valid) return; mountPointValid = valid; q->setIsValid(valid); } bool isDirectoryValid(const QUrl &url) const { if (url.isEmpty()) return false; QDir directory(url.toString()); // TODO: Support alternative flags once they are needed if (!directory.exists() || directory.entryList().isEmpty()) return true; return false; } }; DirectoryChooserWidget::DirectoryChooserWidget( DirectoryChooserWidget::Flags flags) : DialogDsl::DialogModule(false), d(new Private(this)) { d->ui.setupUi(this); d->flags = flags; connect(d->ui.editMountPoint, &KUrlRequester::textEdited, - this, [&] (const QString &url) { - d->setMountPointValid(d->isDirectoryValid(url)); + this, [&] () { + d->setMountPointValid(d->isDirectoryValid(d->ui.editMountPoint->url())); }); } DirectoryChooserWidget::~DirectoryChooserWidget() { } PlasmaVault::Vault::Payload DirectoryChooserWidget::fields() const { return { { KEY_MOUNT_POINT, d->ui.editMountPoint->url().toLocalFile() } }; } void DirectoryChooserWidget::init( const PlasmaVault::Vault::Payload &payload) { const auto mountPoint = payload[KEY_MOUNT_POINT].toString(); d->ui.editMountPoint->setText(mountPoint); } diff --git a/kded/ui/directorypairchooserwidget.cpp b/kded/ui/directorypairchooserwidget.cpp index d28a379..a22e80f 100644 --- a/kded/ui/directorypairchooserwidget.cpp +++ b/kded/ui/directorypairchooserwidget.cpp @@ -1,135 +1,135 @@ /* * Copyright 2017 by Ivan Cukic * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "directorypairchooserwidget.h" #include "ui_directorypairchooserwidget.h" #include "vault.h" #include class DirectoryPairChooserWidget::Private { public: Ui::DirectoryPairChooserWidget ui; const DirectoryPairChooserWidget::Flags flags; bool mountPointValid = false; bool encryptedLocationValid = false; DirectoryPairChooserWidget *const q; Private(DirectoryPairChooserWidget *parent, DirectoryPairChooserWidget::Flags flags) : flags(flags), q(parent) { if (flags & DirectoryPairChooserWidget::SkipDevicePicker) encryptedLocationValid = true; } void setEncryptedLocationValid(bool valid) { if (encryptedLocationValid == valid) return; encryptedLocationValid = valid; // We only change the global valid state if // the mount point was already valid if (mountPointValid) { q->setIsValid(valid); } } void setMountPointValid(bool valid) { if (mountPointValid == valid) return; mountPointValid = valid; // We only change the global valid state if // the enc location was already valid if (encryptedLocationValid) { q->setIsValid(valid); } } bool isDirectoryValid(const QUrl &url) const { if (url.isEmpty()) return false; // TODO check the vaults database to see if another vault already uses this dir QDir directory(url.toString()); // TODO: Support alternative flags once they are needed if (!directory.exists() || directory.entryList().isEmpty()) return true; return false; } }; DirectoryPairChooserWidget::DirectoryPairChooserWidget( DirectoryPairChooserWidget::Flags flags) : DialogDsl::DialogModule(false), d(new Private(this, flags)) { d->ui.setupUi(this); if (flags & DirectoryPairChooserWidget::SkipDevicePicker) { d->ui.editDevice->setVisible(false); d->ui.labelDevice->setVisible(false); } else { connect(d->ui.editDevice, &KUrlRequester::textEdited, - this, [&] (const QString &url) { - d->setEncryptedLocationValid(d->isDirectoryValid(url)); + this, [&] () { + d->setEncryptedLocationValid(d->isDirectoryValid(d->ui.editDevice->url())); }); } connect(d->ui.editMountPoint, &KUrlRequester::textEdited, - this, [&] (const QString &url) { - d->setMountPointValid(d->isDirectoryValid(url)); + this, [&] () { + d->setMountPointValid(d->isDirectoryValid(d->ui.editMountPoint->url())); }); } DirectoryPairChooserWidget::~DirectoryPairChooserWidget() { } PlasmaVault::Vault::Payload DirectoryPairChooserWidget::fields() const { return { { KEY_DEVICE, d->ui.editDevice->url().toLocalFile() }, { KEY_MOUNT_POINT, d->ui.editMountPoint->url().toLocalFile() } }; } void DirectoryPairChooserWidget::init( const PlasmaVault::Vault::Payload &payload) { const QString basePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/plasma-vault"); const auto name = payload[KEY_NAME].toString(); Q_ASSERT(!name.isEmpty()); QString path = QString("%1/%2.enc").arg(basePath).arg(name); int index = 1; while (QDir(path).exists()) { path = QString("%1/%2_%3.enc").arg(basePath).arg(name).arg(index++); } d->ui.editDevice->setText(path); d->ui.editMountPoint->setText(QDir::homePath() + QStringLiteral("/Vaults/") + name); }