diff --git a/CMakeLists.txt b/CMakeLists.txt index 321cacf7..b5059760 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,49 @@ cmake_minimum_required(VERSION 3.0) project(kube VERSION 0.7) set(QT_MIN_VERSION 5.9.0) cmake_policy(SET CMP0011 NEW) cmake_policy(SET CMP0028 NEW) cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0053 NEW) cmake_policy(SET CMP0063 NEW) option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) #Do not enable this unless you actually distribute a custom extension. option(ENABLE_EXTENSION "Enable custom kube extensions" OFF) +set(AVAILABLE_ACCOUNT_PLUGINS "kolabnow" "imap" "maildir" "gmail" CACHE STRING "List of enabled account plugins (provide as semicolon separated string)" ) include(CPack) include(FeatureSummary) find_package(PkgConfig REQUIRED) find_package(ECM 5.29.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECompilerSettings) #Avoid building appstreamtest set(KDE_SKIP_TEST_SETTINGS true) include(KDECMakeSettings NO_POLICY_SCOPE) include(ECMSetupVersion) ecm_setup_version(PROJECT SOVERSION kube_VERSION_MAJOR VERSION_HEADER kube_version.h ) enable_testing() include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) add_subdirectory(framework) add_subdirectory(components) add_subdirectory(icons) add_subdirectory(applications) add_subdirectory(views) add_subdirectory(accounts) add_subdirectory(tests) if (${ENABLE_EXTENSION}) add_subdirectory(extensions) endif() diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 9ae2824d..1f477a4d 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -1,13 +1,25 @@ project(kube-components) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Widgets) macro(install_qml_component name) install(DIRECTORY ${name}/qml/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) install(FILES ${name}/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) endmacro(install_qml_component) install_qml_component(kube) add_subdirectory(kube/tests) install_qml_component(accounts) + + +#Convert list to comma-separated and quoted list. +set(_AVAILABLE_ACCOUNT_PLUGINS ${AVAILABLE_ACCOUNT_PLUGINS}) +set(AVAILABLE_ACCOUNT_PLUGINS "") +foreach(PLUGIN ${_AVAILABLE_ACCOUNT_PLUGINS}) + set(AVAILABLE_ACCOUNT_PLUGINS "${AVAILABLE_ACCOUNT_PLUGINS}, \"${PLUGIN}\"") +endforeach() +string(SUBSTRING "${AVAILABLE_ACCOUNT_PLUGINS}" 2 -1 AVAILABLE_ACCOUNT_PLUGINS) + +configure_file(accounts/AccountConfiguration.qml.in accounts/AccountConfiguration.qml) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/accounts/AccountConfiguration.qml DESTINATION ${QML_INSTALL_DIR}/org/kube/components/accounts) install_qml_component(mailviewer) diff --git a/components/accounts/AccountConfiguration.qml.in b/components/accounts/AccountConfiguration.qml.in new file mode 100644 index 00000000..58c70b59 --- /dev/null +++ b/components/accounts/AccountConfiguration.qml.in @@ -0,0 +1,26 @@ +/* + Copyright (C) 2018 Christian Mollekopf, + + 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) any later version. + + 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, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +pragma Singleton + +import QtQuick 2.7 + +Item { + property var availableAccountPlugins: [@AVAILABLE_ACCOUNT_PLUGINS@] +} + diff --git a/components/accounts/qmldir b/components/accounts/qmldir index 24759d6a..26d2c9b6 100644 --- a/components/accounts/qmldir +++ b/components/accounts/qmldir @@ -1,4 +1,5 @@ module org.kube.components.accounts Accounts 1.0 Accounts.qml AccountWizard 1.0 AccountWizard.qml +singleton AccountConfiguration 1.0 AccountConfiguration.qml diff --git a/views/accounts/qml/View.qml b/views/accounts/qml/View.qml index 0bdab979..00fa845f 100644 --- a/views/accounts/qml/View.qml +++ b/views/accounts/qml/View.qml @@ -1,152 +1,152 @@ /* * Copyright (C) 2017 Michael Bohlender, * * 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) any later version. * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.4 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.3 as Controls1 import QtQuick.Controls 2.0 import org.kube.framework 1.0 as Kube import org.kube.components.accounts 1.0 as KubeAccounts FocusScope { id: root //Defines available account types. - property var availableAccountPlugins: ["kolabnow", "imap", "maildir", "gmail"] + property var availableAccountPlugins: KubeAccounts.AccountConfiguration.availableAccountPlugins //Defines whether more than one account is supported. property bool singleAccountMode: availableAccountPlugins.length == 1 Controls1.SplitView { height: parent.height width: parent.width Item { id: accountList width: Kube.Units.gridUnit * 12 Layout.fillHeight: true visible: !root.singleAccountMode Kube.PositiveButton { id: newAccountButton anchors { top: parent.top left: parent.left right: parent.right margins: Kube.Units.largeSpacing } text: qsTr("New Account") onClicked: { accountWizardComponent.createObject(root, {}).open() } } Kube.ListView { id: listView anchors { top: newAccountButton.bottom left: parent.left right: parent.right bottom: parent.bottom topMargin: Kube.Units.largeSpacing } clip: true model: Kube.AccountsModel {} onCountChanged: { if (count == 0) { edit.accountId = "" } } onCurrentItemChanged: { if (currentItem) { edit.accountId = currentItem.currentData.accountId } } delegate: Kube.ListDelegate { id: delegateRoot Kube.Label { anchors { verticalCenter: parent.verticalCenter left: parent.left leftMargin: Kube.Units.largeSpacing } width: parent.width - Kube.Units.largeSpacing * 2 text: model.name color: delegateRoot.textColor elide: Text.ElideRight } } } } Item { height: parent.height width: Kube.Units.gridUnit * 20 Layout.fillWidth: true Kube.EditAccount { id: edit anchors { fill: parent bottomMargin: Kube.Units.largeSpacing } canRemove: !root.singleAccountMode onAccountIdChanged: { if (accountId == "") { //Require the setup to be completed since it's the first account accountWizardComponent.createObject(root, {requireSetup: true}).open() } } Component.onCompleted: { //We don't have any accounts setup if accountId is empty, so we trigger the accountWizard //FIXME: this assumes we load accounts synchronously, which we do right now. if (accountId == "") { //Require the setup to be completed since it's the first account accountWizardComponent.createObject(root, {requireSetup: true}).open() } } } } } //BEGIN AccountWizard Component { id: accountWizardComponent KubeAccounts.AccountWizard { id: accountWizard parent: ApplicationWindow.overlay height: root.height width: app.width - app.sidebarWidth x: app.sidebarWidth y: 0 availableAccountPlugins: root.availableAccountPlugins } } //END AccountWizard }