Add AA_EnableHighDpiScaling
[kdepim.git] / kaddressbook / main.cpp
blob537eeea91fb415b7bca365b1737addb79e3db98d
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 #if QT_VERSION >= 0x050600
63 app.setAttribute(Qt::AA_EnableHighDpiScaling);
64 #endif
65 KLocalizedString::setApplicationDomain("kaddressbook");
67 AboutData about;
68 app.setAboutData(about);
69 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kaddressbook")));
70 QCommandLineParser *cmdArgs = app.cmdArgs();
71 kaddressbook_options(cmdArgs);
73 const QStringList args = QCoreApplication::arguments();
74 cmdArgs->process(args);
75 about.processCommandLine(cmdArgs);
77 if (!KAddressBookApplication::start(args)) {
78 qCWarning(KADDRESSBOOK_LOG) << "kaddressbook is already running, exiting.";
79 return 0;
81 KAddressBookMigrateApplication migrate;
82 migrate.migrate();
84 return app.exec();