X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fmain%2Fmain.cpp;fp=src%2Fmain%2Fmain.cpp;h=c8185b03b4cca3ba5aed941290a9f53f6c80d505;hb=4ce53949ab7d52a49ae79b8817bd3aa50fada0d1;hp=0000000000000000000000000000000000000000;hpb=48d41896ba35eafc64b4cb00e446d6123b3502cb;p=quassel.git diff --git a/src/main/main.cpp b/src/main/main.cpp new file mode 100644 index 00000000..c8185b03 --- /dev/null +++ b/src/main/main.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** + * Copyright (C) 2005-2018 by the Quassel Project * + * devel@quassel-irc.org * + * * + * 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. * + * * + * 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 + +#ifdef HAVE_UMASK +# include +# include +#endif /* HAVE_UMASK */ + +#include +#include + +#ifdef BUILD_CORE +# include "coreapplication.h" +#elif defined BUILD_QTUI +# include "aboutdata.h" +# include "qtuiapplication.h" +#elif defined BUILD_MONO +# include "aboutdata.h" +# include "monoapplication.h" + +#else +#error "Something is wrong - you need to #define a build mode!" +#endif + +// We don't want quasselcore to depend on KDE +#if defined HAVE_KF5 && defined BUILD_CORE +# undef HAVE_KF5 +#endif + +#if defined HAVE_KF5 +# include +# include +#endif + +#include "quassel.h" +#include "types.h" + +int main(int argc, char **argv) +{ + // We need to explicitly initialize the required resources when linking statically +#ifndef BUILD_QTUI + Q_INIT_RESOURCE(sql); +#endif +#ifndef BUILD_CORE + Q_INIT_RESOURCE(pics); + Q_INIT_RESOURCE(hicolor_icons); +#endif + +#ifdef EMBED_DATA + Q_INIT_RESOURCE(i18n); +# ifndef BUILD_CORE + Q_INIT_RESOURCE(data); + Q_INIT_RESOURCE(breeze_icons); + Q_INIT_RESOURCE(breeze_dark_icons); +# ifdef WITH_OXYGEN_ICONS + Q_INIT_RESOURCE(oxygen_icons); +# endif +# ifdef WITH_BUNDLED_ICONS + Q_INIT_RESOURCE(breeze_icon_theme); + Q_INIT_RESOURCE(breeze_dark_icon_theme); +# ifdef WITH_OXYGEN_ICONS + Q_INIT_RESOURCE(oxygen_icon_theme); +# endif +# endif +# endif +#endif + + // Set umask so files are created with restricted permissions +#ifdef HAVE_UMASK + umask(S_IRWXG | S_IRWXO); +#endif + + // Instantiate early, so log messages are handled + Quassel quassel; + + Quassel::setupBuildInfo(); + QCoreApplication::setApplicationName(Quassel::buildInfo().applicationName); + QCoreApplication::setApplicationVersion(Quassel::buildInfo().plainVersionString); + QCoreApplication::setOrganizationName(Quassel::buildInfo().organizationName); + QCoreApplication::setOrganizationDomain(Quassel::buildInfo().organizationDomain); + + // Migrate settings from KDE4 to KF5 if appropriate +#ifdef HAVE_KF5 + Kdelibs4ConfigMigrator migrator(QCoreApplication::applicationName()); + migrator.setConfigFiles(QStringList() << "quasselrc" << "quassel.notifyrc"); + migrator.migrate(); +#endif + + //Setup the High-DPI settings +# if QT_VERSION >= 0x050600 && defined(Q_OS_WIN) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //Added in Qt 5.6 +#endif + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + + // Instantiate application +#if defined BUILD_CORE + CoreApplication app(argc, argv); + const auto runMode = Quassel::RunMode::CoreOnly; +#elif defined BUILD_QTUI + QtUiApplication app(argc, argv); + const auto runMode = Quassel::RunMode::ClientOnly; +#elif defined BUILD_MONO + MonolithicApplication app(argc, argv); + const auto runMode = Quassel::RunMode::Monolithic; +#endif + + try { + Quassel::instance()->init(runMode); + +#ifdef HAVE_KF5 + AboutData aboutData; + AboutData::setQuasselPersons(&aboutData); + KAboutData::setApplicationData(aboutData.kAboutData()); +#endif + + // Initialize the application + app.init(); + } + catch (ExitException e) { + if (!e.errorString.isEmpty()) { + qCritical() << e.errorString; + } + return e.exitCode; + } + + return app.exec(); +}