diff --git a/src/akonadi/akonadidatasourcerepository.cpp b/src/akonadi/akonadidatasourcerepository.cpp index 3e45a143..902e8221 100644 --- a/src/akonadi/akonadidatasourcerepository.cpp +++ b/src/akonadi/akonadidatasourcerepository.cpp @@ -1,51 +1,58 @@ /* This file is part of Zanshin Copyright 2014 Kevin Ottens 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "akonadidatasourcerepository.h" #include +#include + #include "akonadiconfigdialog.h" using namespace Akonadi; DataSourceRepository::DataSourceRepository(const StorageInterface::Ptr &storage, const SerializerInterface::Ptr &serializer) : m_storage(storage), m_serializer(serializer) { } KJob *DataSourceRepository::update(Domain::DataSource::Ptr source) { auto collection = m_serializer->createCollectionFromDataSource(source); Q_ASSERT(collection.isValid()); return m_storage->updateCollection(collection); } void DataSourceRepository::showConfigDialog() { ConfigDialog dialog(qApp->activeWindow()); dialog.exec(); } + +void DataSourceRepository::windowNeedsDataBackend(QWidget *window) +{ + Akonadi::ControlGui::widgetNeedsAkonadi(window); +} diff --git a/src/akonadi/akonadidatasourcerepository.h b/src/akonadi/akonadidatasourcerepository.h index 35a1981a..2a7affaa 100644 --- a/src/akonadi/akonadidatasourcerepository.h +++ b/src/akonadi/akonadidatasourcerepository.h @@ -1,56 +1,58 @@ /* This file is part of Zanshin Copyright 2014 Kevin Ottens 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AKONADI_DATASOURCEREPOSITORY_H #define AKONADI_DATASOURCEREPOSITORY_H #include "domain/datasourcerepository.h" #include "akonadi/akonadiserializerinterface.h" #include "akonadi/akonadistorageinterface.h" namespace Akonadi { class SerializerInterface; class StorageInterface; class DataSourceRepository : public QObject, public Domain::DataSourceRepository { Q_OBJECT public: typedef QSharedPointer Ptr; DataSourceRepository(const StorageInterface::Ptr &storage, const SerializerInterface::Ptr &serializer); KJob *update(Domain::DataSource::Ptr source) Q_DECL_OVERRIDE; + void showConfigDialog() Q_DECL_OVERRIDE; + void windowNeedsDataBackend(QWidget *window) Q_DECL_OVERRIDE; private: StorageInterface::Ptr m_storage; SerializerInterface::Ptr m_serializer; }; } #endif // AKONADI_DATASOURCEREPOSITORY_H diff --git a/src/domain/datasourcerepository.h b/src/domain/datasourcerepository.h index 79a8859e..3bf56665 100644 --- a/src/domain/datasourcerepository.h +++ b/src/domain/datasourcerepository.h @@ -1,47 +1,49 @@ /* This file is part of Zanshin Copyright 2014 Kevin Ottens 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DOMAIN_DATASOURCEREPOSITORY_H #define DOMAIN_DATASOURCEREPOSITORY_H #include "datasource.h" class KJob; namespace Domain { class DataSourceRepository { public: typedef QSharedPointer Ptr; DataSourceRepository(); virtual ~DataSourceRepository(); virtual KJob *update(DataSource::Ptr source) = 0; + virtual void showConfigDialog() = 0; + virtual void windowNeedsDataBackend(QWidget *window) = 0; }; } #endif // DOMAIN_DATASOURCEREPOSITORY_H diff --git a/src/renku/app/main.cpp b/src/renku/app/main.cpp index 37ffbf36..f2e03f55 100644 --- a/src/renku/app/main.cpp +++ b/src/renku/app/main.cpp @@ -1,113 +1,121 @@ /* This file is part of Renku Notes Copyright 2015 Kevin Ottens 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, 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 "widgets/applicationcomponents.h" #include "widgets/availablepagesview.h" #include "widgets/availablesourcesview.h" #include "widgets/editorview.h" #include "widgets/pageview.h" #include "presentation/applicationmodel.h" +#include "utils/dependencymanager.h" + #include "aboutdata.h" #include "dependencies.h" int main(int argc, char **argv) { KLocalizedString::setApplicationDomain("zanshin"); QApplication app(argc, argv); App::initializeDependencies(); auto aboutData = App::getAboutData(); QCommandLineParser parser; KAboutData::setApplicationData(aboutData); parser.addVersionOption(); parser.addHelpOption(); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); auto widget = new QWidget; auto components = new Widgets::ApplicationComponents(widget); components->setModel(Presentation::ApplicationModel::Ptr::create()); auto layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(components->pageView()); widget->setLayout(layout); auto sourcesDock = new QDockWidget(i18n("Sources")); sourcesDock->setObjectName(QStringLiteral("sourcesDock")); sourcesDock->setWidget(components->availableSourcesView()); auto pagesDock = new QDockWidget(i18n("Pages")); pagesDock->setObjectName(QStringLiteral("pagesDock")); pagesDock->setWidget(components->availablePagesView()); auto editorDock = new QDockWidget(i18n("Editor")); editorDock->setObjectName(QStringLiteral("editorDock")); editorDock->setWidget(components->editorView()); auto window = new KXmlGuiWindow; window->setCentralWidget(widget); window->addDockWidget(Qt::RightDockWidgetArea, editorDock); window->addDockWidget(Qt::LeftDockWidgetArea, pagesDock); window->addDockWidget(Qt::LeftDockWidgetArea, sourcesDock); auto actions = components->globalActions(); actions.insert(QStringLiteral("dock_sources"), sourcesDock->toggleViewAction()); actions.insert(QStringLiteral("dock_pages"), pagesDock->toggleViewAction()); actions.insert(QStringLiteral("dock_editor"), editorDock->toggleViewAction()); auto ac = window->actionCollection(); ac->addAction(KStandardAction::Quit, window, SLOT(close())); for (auto it = actions.constBegin(); it != actions.constEnd(); ++it) { auto shortcut = it.value()->shortcut(); if (!shortcut.isEmpty()) { ac->setDefaultShortcut(it.value(), shortcut); } ac->addAction(it.key(), it.value()); } window->setupGUI(QSize(1024, 600), KXmlGuiWindow::ToolBar | KXmlGuiWindow::Keys | KXmlGuiWindow::Save | KXmlGuiWindow::Create); window->show(); + { + auto &deps = Utils::DependencyManager::globalInstance(); + auto repo = deps.create(); + repo->windowNeedsDataBackend(window); + } + return app.exec(); } diff --git a/src/zanshin/app/main.cpp b/src/zanshin/app/main.cpp index 19213ed7..089599ef 100644 --- a/src/zanshin/app/main.cpp +++ b/src/zanshin/app/main.cpp @@ -1,116 +1,124 @@ /* This file is part of Zanshin Copyright 2014 Kevin Ottens 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include "widgets/taskapplicationcomponents.h" #include "widgets/availablepagesview.h" #include "widgets/availablesourcesview.h" #include "widgets/editorview.h" #include "widgets/pageview.h" #include "presentation/taskapplicationmodel.h" +#include "utils/dependencymanager.h" + #include "aboutdata.h" #include "dependencies.h" #include #include #include #include int main(int argc, char **argv) { KLocalizedString::setApplicationDomain("zanshin"); QApplication app(argc, argv); App::initializeDependencies(); auto aboutData = App::getAboutData(); QCommandLineParser parser; KAboutData::setApplicationData(aboutData); parser.addVersionOption(); parser.addHelpOption(); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); auto widget = new QWidget; auto components = new Widgets::TaskApplicationComponents(widget); components->setModel(Presentation::TaskApplicationModel::Ptr::create()); auto layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(components->pageView()); widget->setLayout(layout); auto sourcesDock = new QDockWidget(i18n("Sources")); sourcesDock->setObjectName(QStringLiteral("sourcesDock")); sourcesDock->setWidget(components->availableSourcesView()); auto pagesDock = new QDockWidget(i18n("Pages")); pagesDock->setObjectName(QStringLiteral("pagesDock")); pagesDock->setWidget(components->availablePagesView()); auto editorDock = new QDockWidget(i18n("Editor")); editorDock->setObjectName(QStringLiteral("editorDock")); editorDock->setWidget(components->editorView()); auto window = new KXmlGuiWindow; window->setCentralWidget(widget); window->addDockWidget(Qt::RightDockWidgetArea, editorDock); window->addDockWidget(Qt::LeftDockWidgetArea, pagesDock); window->addDockWidget(Qt::LeftDockWidgetArea, sourcesDock); auto actions = components->globalActions(); actions.insert(QStringLiteral("dock_sources"), sourcesDock->toggleViewAction()); actions.insert(QStringLiteral("dock_pages"), pagesDock->toggleViewAction()); actions.insert(QStringLiteral("dock_editor"), editorDock->toggleViewAction()); auto ac = window->actionCollection(); ac->addAction(KStandardAction::Quit, window, SLOT(close())); for (auto it = actions.constBegin(); it != actions.constEnd(); ++it) { auto shortcut = it.value()->shortcut(); if (!shortcut.isEmpty()) { ac->setDefaultShortcut(it.value(), shortcut); } ac->addAction(it.key(), it.value()); } window->setupGUI(QSize(1024, 600), KXmlGuiWindow::ToolBar | KXmlGuiWindow::Keys | KXmlGuiWindow::Save | KXmlGuiWindow::Create); window->show(); + { + auto &deps = Utils::DependencyManager::globalInstance(); + auto repo = deps.create(); + repo->windowNeedsDataBackend(window); + } + return app.exec(); }