From 5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 22 Feb 2017 15:56:21 +0100 Subject: Removed Create/Edit*.qml and controllers, added gmail plugin The current settings plugin could potentially be replaced by a proper controller, but what we have works so that's low priority. --- accounts/CMakeLists.txt | 1 + accounts/gmail/CMakeLists.txt | 43 +++++++ accounts/gmail/gmailaccountplugin.cpp | 29 +++++ accounts/gmail/gmailaccountplugin.h | 31 +++++ accounts/gmail/gmailsettings.cpp | 58 +++++++++ accounts/gmail/gmailsettings.h | 33 +++++ .../gmail/package/contents/ui/GmailSettings.qml | 136 ++++++++++++++++++++ accounts/gmail/package/metadata.desktop | 8 ++ accounts/gmail/qmldir | 3 + .../package/contents/ui/ImapAccountSettings.qml | 137 ++++++--------------- .../package/contents/ui/MaildirAccountSettings.qml | 124 ++++--------------- 11 files changed, 405 insertions(+), 198 deletions(-) create mode 100644 accounts/gmail/CMakeLists.txt create mode 100644 accounts/gmail/gmailaccountplugin.cpp create mode 100644 accounts/gmail/gmailaccountplugin.h create mode 100644 accounts/gmail/gmailsettings.cpp create mode 100644 accounts/gmail/gmailsettings.h create mode 100644 accounts/gmail/package/contents/ui/GmailSettings.qml create mode 100644 accounts/gmail/package/metadata.desktop create mode 100644 accounts/gmail/qmldir (limited to 'accounts') diff --git a/accounts/CMakeLists.txt b/accounts/CMakeLists.txt index e941e07d..613f9792 100644 --- a/accounts/CMakeLists.txt +++ b/accounts/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(maildir) add_subdirectory(imap) add_subdirectory(kolabnow) +add_subdirectory(gmail) diff --git a/accounts/gmail/CMakeLists.txt b/accounts/gmail/CMakeLists.txt new file mode 100644 index 00000000..f75cf388 --- /dev/null +++ b/accounts/gmail/CMakeLists.txt @@ -0,0 +1,43 @@ +project(kube-accounts-gmail) + +cmake_minimum_required(VERSION 2.8.12) + +include(CPack) +include(FeatureSummary) +find_package(PkgConfig) + +################# set KDE specific information ################# + +find_package(ECM 0.0.8 REQUIRED NO_MODULE) + +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings) + +find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) + +set (QT_MIN_VERSION "5.4.0") +find_package(Sink CONFIG REQUIRED) +find_package(KF5Async CONFIG REQUIRED) +find_package(KF5 REQUIRED COMPONENTS Package Mime) + +include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/) +#FIXME +include_directories(../../framework/) + +set(SRCS + gmailsettings.cpp + gmailaccountplugin.cpp +) + +add_library(gmailaccountplugin SHARED ${SRCS}) +qt5_use_modules(gmailaccountplugin Core Quick Qml) +target_link_libraries(gmailaccountplugin sink settingsplugin mailplugin) + +kpackage_install_package(package org.kube.accounts.gmail "genericqml") + +install(TARGETS gmailaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail) +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail) diff --git a/accounts/gmail/gmailaccountplugin.cpp b/accounts/gmail/gmailaccountplugin.cpp new file mode 100644 index 00000000..53218939 --- /dev/null +++ b/accounts/gmail/gmailaccountplugin.cpp @@ -0,0 +1,29 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#include "gmailaccountplugin.h" + +#include "gmailsettings.h" + +#include + +void GmailAccountPlugin::registerTypes (const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kube.accounts.gmail")); + qmlRegisterType(uri, 1, 0, "GmailSettings"); +} diff --git a/accounts/gmail/gmailaccountplugin.h b/accounts/gmail/gmailaccountplugin.h new file mode 100644 index 00000000..5876e393 --- /dev/null +++ b/accounts/gmail/gmailaccountplugin.h @@ -0,0 +1,31 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#pragma once + +#include +#include + +class GmailAccountPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + virtual void registerTypes(const char *uri); +}; diff --git a/accounts/gmail/gmailsettings.cpp b/accounts/gmail/gmailsettings.cpp new file mode 100644 index 00000000..428b164a --- /dev/null +++ b/accounts/gmail/gmailsettings.cpp @@ -0,0 +1,58 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#include "gmailsettings.h" + +GmailSettings::GmailSettings(QObject *parent) + : AccountSettings(parent) +{ +} + +void GmailSettings::load() +{ + loadAccount(); + loadImapResource(); + loadMailtransportResource(); + loadIdentity(); +} + +void GmailSettings::save() +{ + mUsername = mEmailAddress; + mImapServer = "imaps://imap.gmail.com:993"; + mImapUsername = mEmailAddress; + // mImapPassword = mPassword; + + mSmtpServer = "smtps://smtp.gmail.com:465"; + mSmtpUsername = mEmailAddress; + mSmtpPassword = mImapPassword; + + saveAccount(); + saveImapResource(); + saveMailtransportResource(); + saveIdentity(); +} + +void GmailSettings::remove() +{ + removeResource(mMailtransportIdentifier); + removeResource(mImapIdentifier); + removeIdentity(); + removeAccount(); +} + diff --git a/accounts/gmail/gmailsettings.h b/accounts/gmail/gmailsettings.h new file mode 100644 index 00000000..708cb94b --- /dev/null +++ b/accounts/gmail/gmailsettings.h @@ -0,0 +1,33 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#pragma once + +#include + +class GmailSettings : public AccountSettings +{ + Q_OBJECT + +public: + GmailSettings(QObject *parent = 0); + + Q_INVOKABLE virtual void load() Q_DECL_OVERRIDE; + Q_INVOKABLE virtual void save() Q_DECL_OVERRIDE; + Q_INVOKABLE virtual void remove() Q_DECL_OVERRIDE; +}; diff --git a/accounts/gmail/package/contents/ui/GmailSettings.qml b/accounts/gmail/package/contents/ui/GmailSettings.qml new file mode 100644 index 00000000..33dafe8d --- /dev/null +++ b/accounts/gmail/package/contents/ui/GmailSettings.qml @@ -0,0 +1,136 @@ +/* + Copyright (C) 2016 Michael Bohlender, + Copyright (C) 2017 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. +*/ + +import QtQuick 2.4 +import QtQuick.Controls 1.4 as Controls +import QtQuick.Layouts 1.1 + +import org.kde.kirigami 1.0 as Kirigami + +import org.kube.framework.settings 1.0 as KubeSettings +import org.kube.accounts.gmail 1.0 as GmailAccount + +Item { + + property string accountId + property string heading: "Connect your GMail account" + property string subheadline: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube." + + GmailAccount.GmailSettings { + id: gmailSettings + accountIdentifier: accountId + accountType: "gmail" + } + + function save(){ + gmailSettings.save() + } + + function remove(){ + gmailSettings.remove() + } + + Item { + anchors { + fill: parent + } + + GridLayout { + anchors { + fill: parent + } + columns: 2 + columnSpacing: Kirigami.Units.largeSpacing + rowSpacing: Kirigami.Units.largeSpacing + + Controls.Label { + text: "Title of Account" + Layout.alignment: Qt.AlignRight + } + Controls.TextField { + Layout.fillWidth: true + placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name" + text: gmailSettings.accountName + onTextChanged: { + gmailSettings.accountName = text + } + } + + Controls.Label { + text: "Name" + Layout.alignment: Qt.AlignRight + } + Controls.TextField { + Layout.fillWidth: true + placeholderText: "Your name" + text: gmailSettings.userName + onTextChanged: { + gmailSettings.userName = text + } + } + + Controls.Label { + text: "Email address" + Layout.alignment: Qt.AlignRight + } + Controls.TextField { + Layout.fillWidth: true + + text: gmailSettings.emailAddress + onTextChanged: { + gmailSettings.emailAddress = text + } + placeholderText: "Your email address" + } + + Controls.Label { + text: "Password" + Layout.alignment: Qt.AlignRight + } + RowLayout { + Layout.fillWidth: true + + Controls.TextField { + id: pwField + Layout.fillWidth: true + + placeholderText: "Password of your email account" + text: gmailSettings.imapPassword + onTextChanged: { + gmailSettings.imapPassword = text + gmailSettings.smtpPassword = text + } + + echoMode: TextInput.Password + } + + Controls.CheckBox { + text: "Show Password" + onClicked: { + if(pwField.echoMode == TextInput.Password) { + pwField.echoMode = TextInput.Normal; + } else { + pwField.echoMode = TextInput.Password; + } + } + } + } + } + } +} diff --git a/accounts/gmail/package/metadata.desktop b/accounts/gmail/package/metadata.desktop new file mode 100644 index 00000000..e2b71ec9 --- /dev/null +++ b/accounts/gmail/package/metadata.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Kube GMail Accounts Plugin +X-KDE-PluginInfo-Name=org.kube.accounts.gmail +Exec=kpackagelauncherqml -a org.kube.accounts.gmail +X-Plasma-MainScript=ui/GmailSettings.qml +X-KDE-ServiceTypes=KPackage/GenericQML +Icon=folder +Type=Service diff --git a/accounts/gmail/qmldir b/accounts/gmail/qmldir new file mode 100644 index 00000000..78a9e5b7 --- /dev/null +++ b/accounts/gmail/qmldir @@ -0,0 +1,3 @@ +module org.kube.accounts.gmail + +plugin gmailaccountplugin diff --git a/accounts/imap/package/contents/ui/ImapAccountSettings.qml b/accounts/imap/package/contents/ui/ImapAccountSettings.qml index a9ac9317..e7834368 100644 --- a/accounts/imap/package/contents/ui/ImapAccountSettings.qml +++ b/accounts/imap/package/contents/ui/ImapAccountSettings.qml @@ -1,5 +1,6 @@ /* Copyright (C) 2016 Michael Bohlender, + Copyright (C) 2017 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 @@ -17,7 +18,7 @@ */ import QtQuick 2.4 -import QtQuick.Controls 1.4 +import QtQuick.Controls 1.4 as Controls import QtQuick.Layouts 1.1 import org.kde.kirigami 1.0 as Kirigami @@ -25,132 +26,101 @@ import org.kde.kirigami 1.0 as Kirigami import org.kube.framework.settings 1.0 as KubeSettings import org.kube.accounts.imap 1.0 as ImapAccount - Item { property string accountId + property string heading: "Connect your IMAP account" + property string subheadline: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube. For information about which SMTP, IMAP address, which authentification and port to be used, please contact your email provider." ImapAccount.ImapSettings { id: imapSettings accountIdentifier: accountId + accountType: "imap" + } + + function save(){ + imapSettings.save() } - anchors.fill: parent + function remove(){ + imapSettings.remove() + } Item { anchors { fill: parent - margins: Kirigami.Units.largeSpacing * 2 - } - - Kirigami.Heading { - id: heading - text: "Connect your IMAP account" - - color: Kirigami.Theme.highlightColor } - Label { - id: subHeadline - - anchors { - left: heading.left - top: heading.bottom - } - - width: parent.width - - text: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube. For information about which SMTP, IMAP address, which authentification and port to be used, please contact your email provider" - - color: Kirigami.Theme.disabledTextColor - - wrapMode: Text.Wrap - } - - GridLayout { anchors { - top:subHeadline.bottom - bottom: parent.bottom - left: parent.left - right: parent.right - topMargin: Kirigami.Units.largeSpacing - bottomMargin: Kirigami.Units.largeSpacing * 2 + fill: parent } - columns: 2 columnSpacing: Kirigami.Units.largeSpacing rowSpacing: Kirigami.Units.largeSpacing - Kirigami.Label { - text: "Title of Acocunt" + Controls.Label { + text: "Title of Account" Layout.alignment: Qt.AlignRight } - TextField { + Controls.TextField { Layout.fillWidth: true - placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name" - text: imapSettings.accountName onTextChanged: { imapSettings.accountName = text } } - Kirigami.Label { - text: "Email address" + Controls.Label { + text: "Name" Layout.alignment: Qt.AlignRight } - - TextField { + Controls.TextField { Layout.fillWidth: true - - placeholderText: "Your email address" - - text: imapSettings.emailAddress + placeholderText: "Your name" + text: imapSettings.userName onTextChanged: { - imapSettings.emailAddress = text + imapSettings.userName = text } } - Kirigami.Label { - text: "Username" + Controls.Label { + text: "Email address" Layout.alignment: Qt.AlignRight } - TextField { + Controls.TextField { Layout.fillWidth: true - placeholderText: "The name used to log into your email account" - - text: imapSettings.imapUsername + text: imapSettings.emailAddress onTextChanged: { - imapSettings.imapUsername = text - imapSettings.smtpUsername = text + imapSettings.emailAddress = text } + placeholderText: "Your email address" } - Kirigami.Label { + Controls.Label { text: "Password" Layout.alignment: Qt.AlignRight } - RowLayout { Layout.fillWidth: true - TextField { + Controls.TextField { id: pwField Layout.fillWidth: true - text: imapSettings.imapPassword placeholderText: "Password of your email account" - echoMode: TextInput.Password + text: imapSettings.imapPassword onTextChanged: { imapSettings.imapPassword = text imapSettings.smtpPassword = text } + + echoMode: TextInput.Password } - CheckBox { + Controls.CheckBox { text: "Show Password" onClicked: { if(pwField.echoMode == TextInput.Password) { @@ -160,14 +130,13 @@ Item { } } } - } - Kirigami.Label { - text: "IMAP address" + Controls.Label { + text: "IMAP server address" Layout.alignment: Qt.AlignRight } - TextField { + Controls.TextField { id: imapServer Layout.fillWidth: true @@ -187,11 +156,11 @@ Item { } } - Kirigami.Label { + Controls.Label { text: "Smtp address" Layout.alignment: Qt.AlignRight } - TextField { + Controls.TextField { id: smtpServer Layout.fillWidth: true @@ -209,34 +178,6 @@ Item { visible: smtpServer.acceptableInput } } - - Label { - text: "" - } - Item { - Layout.fillWidth: true - - Button { - text: "Delete" - - onClicked: { - imapSettings.remove() - root.closeDialog() - } - } - - Button { - anchors.right: parent.right - - text: "Save" - - onClicked: { - focus: true - imapSettings.save() - root.closeDialog() - } - } - } } } } diff --git a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml index a5d35d5c..b768979a 100644 --- a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml +++ b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml @@ -1,5 +1,6 @@ /* Copyright (C) 2016 Michael Bohlender, + Copyright (C) 2017 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 @@ -17,108 +18,76 @@ */ import QtQuick 2.4 -import QtQuick.Controls 1.4 +import QtQuick.Controls 1.4 as Controls +import QtQuick.Controls 2.0 as Controls2 import QtQuick.Layouts 1.1 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs 1.0 as Dialogs import org.kde.kirigami 1.0 as Kirigami import org.kube.framework.settings 1.0 as KubeSettings import org.kube.accounts.maildir 1.0 as MaildirAccount - Item { property string accountId + property string heading: "Add your Maildir archive" + property string subheadline: "To let Kube access your maildir archive, add the path to your archive and give the account a title that will be displayed inside Kube." MaildirAccount.MaildirSettings { id: maildirSettings accountIdentifier: accountId + accountType: "maildir" + } + + function save(){ + maildirSettings.save() } - anchors.fill: parent + function remove(){ + maildirSettings.remove() + } Item { anchors { fill: parent - margins: Kirigami.Units.largeSpacing * 2 - } - - Kirigami.Heading { - id: heading - text: "Add your Maildir archive" - - color: Kirigami.Theme.highlightColor - } - - Label { - id: subHeadline - - anchors { - left: heading.left - top: heading.bottom - } - - width: parent.width - - text: "To let Kube access your maildir archive, add the path to your archive and give the account a title that will be displayed inside Kube" - //TODO wait for kirgami theme disabled text color - opacity: 0.5 - wrapMode: Text.Wrap } GridLayout { anchors { - top:subHeadline.bottom - bottom: parent.bottom - left: parent.left - right: parent.right - topMargin: Kirigami.Units.largeSpacing * 2 - bottomMargin: Kirigami.Units.largeSpacing * 2 + fill: parent } - columns: 2 columnSpacing: Kirigami.Units.largeSpacing rowSpacing: Kirigami.Units.largeSpacing - Kirigami.Label { - text: "Title of account" + Controls.Label { + text: "Title of Account" Layout.alignment: Qt.AlignRight } - TextField { + Controls.TextField { Layout.fillWidth: true - + placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name" text: maildirSettings.accountName onTextChanged: { maildirSettings.accountName = text } } - Kirigami.Label { + Controls2.Label { text: "Path" Layout.alignment: Qt.AlignRight } RowLayout { Layout.fillWidth: true - TextField { + Controls.TextField { id: path Layout.fillWidth: true - + enabled: false text: maildirSettings.path - onTextChanged: { - maildirSettings.path = text - } - validator: maildirSettings.pathValidator - - Rectangle { - anchors.fill: parent - opacity: 0.2 - color: "yellow" - visible: path.acceptableInput == false - } } - Button { + Controls.Button { iconName: "folder" onClicked: { @@ -127,7 +96,7 @@ Item { Component { id: fileDialogComponent - FileDialog { + Dialogs.FileDialog { id: fileDialog visible: true @@ -142,51 +111,6 @@ Item { } } } - - Label { - text: "" - } - CheckBox { - text: "Read only" - } - - Label { - text: "" - Layout.fillHeight: true - } - Label { - text: "" - } - - Label { - text: "" - } - Item { - Layout.fillWidth: true - - Button { - text: "Delete" - - onClicked: { - maildirSettings.remove() - root.closeDialog() - } - } - - Button { - id: saveButton - - anchors.right: parent.right - - text: "Save" - - onClicked: { - focus: true - maildirSettings.save() - root.closeDialog() - } - } - } } } } -- cgit v1.2.3