Merge remote-tracking branch 'origin/Applications/16.08'
[kdepim.git] / akregator / src / main.cpp
blob93ec1caa1685958fd9c4bb470e0d5b9219d13d35
1 /*
2 This file is part of Akregator.
4 Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
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.
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.
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
25 #include "aboutdata.h"
26 #include "mainwindow.h"
27 #include "akregator_options.h"
28 #include "utils.h"
29 #include "akregator_debug.h"
30 #include "akregratormigrateapplication.h"
31 #include <KCrash>
32 #include <KLocalizedString>
33 #include <kontactinterface/pimuniqueapplication.h>
34 #include <QtDBus/QtDBus>
36 namespace Akregator
39 class Application : public KontactInterface::PimUniqueApplication
41 public:
42 Application(int &argc, char **argv[])
43 : KontactInterface::PimUniqueApplication(argc, argv)
44 , mMainWindow(0)
47 ~Application() {}
49 int activate(const QStringList &args, const QString &workingDir) Q_DECL_OVERRIDE;
51 private:
52 Akregator::MainWindow *mMainWindow;
55 int Application::activate(const QStringList &args, const QString &workingDir)
57 if (!isSessionRestored()) {
58 QDBusInterface akr(QStringLiteral("org.kde.akregator"), QStringLiteral("/Akregator"), QStringLiteral("org.kde.akregator.part"));
60 QCommandLineParser *parser = cmdArgs();
61 parser->process(args);
63 if (!mMainWindow) {
64 mMainWindow = new Akregator::MainWindow();
65 mMainWindow->loadPart();
66 mMainWindow->setupProgressWidgets();
67 if (!parser->isSet(QStringLiteral("hide-mainwindow"))) {
68 mMainWindow->show();
70 akr.call(QStringLiteral("openStandardFeedList"));
73 akr.call(QStringLiteral("handleCommandLine"), args);
75 return PimUniqueApplication::activate(args, workingDir);
78 } // namespace Akregator
80 int main(int argc, char **argv)
82 Akregator::Application app(argc, &argv);
83 KLocalizedString::setApplicationDomain("akregator");
85 KCrash::initialize();
87 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
88 app.setAttribute(Qt::AA_EnableHighDpiScaling);
89 Akregator::AboutData about;
90 app.setAboutData(about);
92 QCommandLineParser *cmdArgs = app.cmdArgs();
93 Akregator::akregator_options(cmdArgs);
95 const QStringList args = QCoreApplication::arguments();
96 cmdArgs->process(args);
97 about.processCommandLine(cmdArgs);
99 if (!Akregator::Application::start(args)) {
100 qCWarning(AKREGATOR_LOG) << "akregator is already running, exiting.";
101 exit(0);
103 AkregratorMigrateApplication migrate;
104 migrate.migrate();
106 // start knotifyclient if not already started. makes it work for people who doesn't use full kde, according to kmail devels
107 //KNotifyClient::startDaemon();
109 // see if we are starting with session management
110 if (app.isSessionRestored()) {
111 #undef RESTORE
112 #define RESTORE(type) { int n = 1;\
113 while (KMainWindow::canBeRestored(n)){\
114 (new type)->restore(n, false);\
115 n++;}}
117 RESTORE(Akregator::MainWindow);
120 return app.exec();