Changeset View
Changeset View
Standalone View
Standalone View
plugins/nextcloud-ui/nextcloud.cpp
- This file was added.
1 | /************************************************************************************* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 by Rituka Patwal <ritukapatwal21@gmail.com> * | ||||
3 | * Copyright (C) 2015 by Martin Klapetek <mklapetek@kde.org> * | ||||
4 | * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> * | ||||
5 | * * | ||||
6 | * This program is free software; you can redistribute it and/or * | ||||
7 | * modify it under the terms of the GNU General Public License * | ||||
8 | * as published by the Free Software Foundation; either version 2 * | ||||
9 | * of the License, or (at your option) any later version. * | ||||
10 | * * | ||||
11 | * This program is distributed in the hope that it will be useful, * | ||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
14 | * GNU General Public License for more details. * | ||||
15 | * * | ||||
16 | * You should have received a copy of the GNU General Public License * | ||||
17 | * along with this program; if not, write to the Free Software * | ||||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||||
19 | *************************************************************************************/ | ||||
20 | | ||||
21 | #include "nextcloud.h" | ||||
22 | #include "qmlhelper.h" | ||||
23 | | ||||
24 | #include <KLocalizedString> | ||||
25 | #include <KDeclarative/QmlObject> | ||||
26 | | ||||
27 | #include <QQmlEngine> | ||||
28 | #include <QQmlContext> | ||||
29 | | ||||
30 | NextcloudWizard::NextcloudWizard(QObject *parent) | ||||
31 | : KAccountsUiPlugin(parent) | ||||
32 | { | ||||
33 | } | ||||
34 | | ||||
35 | NextcloudWizard::~NextcloudWizard() | ||||
36 | { | ||||
37 | } | ||||
38 | | ||||
39 | void NextcloudWizard::init(KAccountsUiPlugin::UiType type) | ||||
40 | { | ||||
41 | if (type == KAccountsUiPlugin::NewAccountDialog) { | ||||
42 | | ||||
43 | const QString packagePath("org.kde.kaccounts.nextcloud"); | ||||
44 | | ||||
45 | m_object = new KDeclarative::QmlObject(); | ||||
46 | m_object->setTranslationDomain(packagePath); | ||||
47 | m_object->setInitializationDelayed(true); | ||||
48 | m_object->loadPackage(packagePath); | ||||
49 | | ||||
50 | QmlHelper *helper = new QmlHelper(m_object); | ||||
51 | connect(helper, &QmlHelper::wizardFinished, this, &NextcloudWizard::success); | ||||
52 | connect(helper, &QmlHelper::wizardFinished, [=] { | ||||
53 | QWindow *window = qobject_cast<QWindow *>(m_object->rootObject()); | ||||
54 | if (window) { | ||||
55 | window->close(); | ||||
56 | } | ||||
57 | m_object->deleteLater(); | ||||
58 | }); | ||||
59 | m_object->engine()->rootContext()->setContextProperty("helper", helper); | ||||
60 | | ||||
61 | m_object->completeInitialization(); | ||||
62 | | ||||
63 | if (!m_object->package().metadata().isValid()) { | ||||
64 | return; | ||||
65 | } | ||||
66 | | ||||
67 | Q_EMIT uiReady(); | ||||
68 | } | ||||
69 | | ||||
70 | } | ||||
71 | | ||||
72 | void NextcloudWizard::setProviderName(const QString &providerName) | ||||
73 | { | ||||
74 | //TODO: unused? | ||||
75 | m_providerName = providerName; | ||||
76 | } | ||||
77 | | ||||
78 | void NextcloudWizard::showNewAccountDialog() | ||||
79 | { | ||||
80 | QWindow *window = qobject_cast<QWindow *>(m_object->rootObject()); | ||||
81 | if (window) { | ||||
82 | window->setTransientParent(transientParent()); | ||||
83 | window->show(); | ||||
84 | window->requestActivate(); | ||||
85 | window->setTitle(m_object->package().metadata().name()); | ||||
86 | window->setIcon(QIcon::fromTheme(m_object->package().metadata().iconName())); | ||||
87 | } | ||||
88 | } | ||||
89 | | ||||
90 | void NextcloudWizard::showConfigureAccountDialog(const quint32 accountId) | ||||
91 | { | ||||
92 | | ||||
93 | } | ||||
94 | | ||||
95 | QStringList NextcloudWizard::supportedServicesForConfig() const | ||||
96 | { | ||||
97 | return QStringList(); | ||||
98 | } |