Use qtpaths directly
[kdepim.git] / kaddressbook / main.cpp
blob9986c24d5d3e3f910c1e3a615d402a7a0a7676bf
1 /*
2 This file is part of KAddressBook.
4 Copyright (c) 2007 Tobias Koenig <tokoe@kde.org>
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 along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "aboutdata.h"
22 #include "mainwindow.h"
23 #include "mainwidget.h"
24 #include "kaddressbook_options.h"
25 #include "kaddressbookmigrateapplication.h"
27 #include <QCommandLineParser>
29 #include "kaddressbook_debug.h"
30 #include <kontactinterface/pimuniqueapplication.h>
32 //-----------------------------------------------------------------------------
34 class KAddressBookApplication : public KontactInterface::PimUniqueApplication
36 public:
37 KAddressBookApplication(int &argc, char **argv[])
38 : KontactInterface::PimUniqueApplication(argc, argv),
39 mMainWindow(Q_NULLPTR)
42 int activate(const QStringList &arguments, const QString &) Q_DECL_OVERRIDE;
44 private:
45 MainWindow *mMainWindow;
48 int KAddressBookApplication::activate(const QStringList &arguments, const QString &)
50 if (!mMainWindow) {
51 mMainWindow = new MainWindow;
52 mMainWindow->show();
54 mMainWindow->mainWidget()->handleCommandLine(arguments);
55 return 0;
58 int main(int argc, char **argv)
60 KAddressBookApplication app(argc, &argv);
61 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
62 KLocalizedString::setApplicationDomain("kaddressbook");
64 AboutData about;
65 app.setAboutData(about);
66 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kaddressbook")));
67 QCommandLineParser *cmdArgs = app.cmdArgs();
68 kaddressbook_options(cmdArgs);
70 const QStringList args = QCoreApplication::arguments();
71 cmdArgs->process(args);
72 about.processCommandLine(cmdArgs);
74 if (!KAddressBookApplication::start(args)) {
75 qCWarning(KADDRESSBOOK_LOG) << "kaddressbook is already running, exiting.";
76 return 0;
78 KAddressBookMigrateApplication migrate;
79 migrate.migrate();
81 return app.exec();