Changeset View
Changeset View
Standalone View
Standalone View
krusader/main.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
46 | #include <KWindowSystem/KStartupInfo> | 46 | #include <KWindowSystem/KStartupInfo> | ||
47 | 47 | | |||
48 | #include "../Archive/krarchandler.h" | 48 | #include "../Archive/krarchandler.h" | ||
49 | 49 | | |||
50 | #include "defaults.h" | 50 | #include "defaults.h" | ||
51 | #include "krservices.h" | 51 | #include "krservices.h" | ||
52 | #include "krslots.h" | 52 | #include "krslots.h" | ||
53 | #include "krusader.h" | 53 | #include "krusader.h" | ||
54 | #include "icon.h" | ||||
54 | #include "krusaderversion.h" | 55 | #include "krusaderversion.h" | ||
55 | #include "krusaderview.h" | 56 | #include "krusaderview.h" | ||
56 | #include "panelmanager.h" | 57 | #include "panelmanager.h" | ||
57 | 58 | | |||
58 | static const char *description = I18N_NOOP("Krusader\nTwin-Panel File Manager by KDE"); | 59 | static const char *description = I18N_NOOP("Krusader\nTwin-Panel File Manager by KDE"); | ||
59 | 60 | | |||
60 | static void sigterm_handler(int i) | 61 | static void sigterm_handler(int i) | ||
61 | { | 62 | { | ||
Show All 24 Lines | 86 | if (!reply.isValid()) | |||
86 | fprintf(stderr, "DBus Error: %s, %s\n", reply.error().name().toLocal8Bit().constData(), reply.error().message().toLocal8Bit().constData()); | 87 | fprintf(stderr, "DBus Error: %s, %s\n", reply.error().name().toLocal8Bit().constData(), reply.error().message().toLocal8Bit().constData()); | ||
87 | } | 88 | } | ||
88 | 89 | | |||
89 | //! An object that manages archives in several parts of the source code. | 90 | //! An object that manages archives in several parts of the source code. | ||
90 | KRarcHandler arcHandler; | 91 | KRarcHandler arcHandler; | ||
91 | 92 | | |||
92 | int main(int argc, char *argv[]) | 93 | int main(int argc, char *argv[]) | ||
93 | { | 94 | { | ||
94 | // ============ begin icon-stuff =========== | | |||
95 | // If the user has no icon specified over the commandline we set up our own. | | |||
96 | // this is according to the users privileges. The icons are in Krusader::privIcon() | | |||
97 | | ||||
98 | /* bool hasIcon = false; | | |||
99 | int i = 0; | | |||
100 | char * myArgv[argc+2];*/ | | |||
101 | | ||||
102 | // if no --miniicon is given, --icon is used. So we don't need to check for --miniicon separately | | |||
103 | /* for (i = 0; i < argc; ++i) { | | |||
104 | if (strstr(argv[ i ], "-icon") != 0) // important: just one dash because both can appear! | | |||
105 | hasIcon = true; | | |||
106 | } | | |||
107 | | ||||
108 | static const char* const icon_text = "--icon"; | | |||
109 | const char* icon_name = Krusader::privIcon(); | | |||
110 | char addedParams[strlen(icon_text)+strlen(icon_name)+2]; | | |||
111 | | ||||
112 | if (! hasIcon) { | | |||
113 | for (i = 0; i < argc; ++i) | | |||
114 | myArgv[ i ] = argv[ i ]; | | |||
115 | | ||||
116 | strcpy(addedParams, icon_text); | | |||
117 | strcpy(addedParams + strlen(icon_text) + 1, icon_name); | | |||
118 | | ||||
119 | myArgv[ argc ] = addedParams; | | |||
120 | myArgv[ ++argc ] = addedParams + strlen(icon_text) + 1; | | |||
121 | myArgv[ ++argc ] = 0; | | |||
122 | | ||||
123 | argv = myArgv; | | |||
124 | }*/ | | |||
125 | // ============ end icon-stuff =========== | | |||
126 | | ||||
127 | // set global log message format | 95 | // set global log message format | ||
128 | qSetMessagePattern(KrServices::GLOBAL_MESSAGE_PATTERN); | 96 | qSetMessagePattern(KrServices::GLOBAL_MESSAGE_PATTERN); | ||
129 | 97 | | |||
130 | // prevent qt5-webengine crashing | 98 | // prevent qt5-webengine crashing | ||
131 | QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); | 99 | QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); | ||
132 | 100 | | |||
133 | // create the application and set application domain so that calls to i18n get strings from right place. | 101 | // create the application and set application domain so that calls to i18n get strings from right place. | ||
134 | QApplication app(argc, argv); | 102 | QApplication app(argc, argv); | ||
135 | KLocalizedString::setApplicationDomain("krusader"); | 103 | KLocalizedString::setApplicationDomain("krusader"); | ||
136 | 104 | | |||
105 | // init icon theme | ||||
106 | qDebug() << "System icon theme:" << QIcon::themeName(); | ||||
107 | // [WORKAROUND] setThemeName sets user theme in QIconLoader and allows to avoid Qt issues with invalid icon caching later | ||||
108 | // IMPORTANT: this must be done before the first QIcon::fromTheme / QIcon::hasThemeIcon call | ||||
109 | QIcon::setThemeName(QIcon::themeName()); | ||||
110 | | ||||
137 | // ABOUT data information | 111 | // ABOUT data information | ||
138 | #ifdef RELEASE_NAME | 112 | #ifdef RELEASE_NAME | ||
139 | QString versionName = QString("%1 \"%2\"").arg(VERSION).arg(RELEASE_NAME); | 113 | QString versionName = QString("%1 \"%2\"").arg(VERSION).arg(RELEASE_NAME); | ||
140 | #else | 114 | #else | ||
141 | QString versionName = VERSION; | 115 | QString versionName = VERSION; | ||
142 | #endif | 116 | #endif | ||
143 | 117 | | |||
144 | KAboutData aboutData(QStringLiteral("krusader"), | 118 | KAboutData aboutData(QStringLiteral("krusader"), | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
225 | aboutData.addCredit(i18n("Peter Landgren"), i18n("Swedish translation"), QStringLiteral("peter.talken@telia.com"), 0); | 199 | aboutData.addCredit(i18n("Peter Landgren"), i18n("Swedish translation"), QStringLiteral("peter.talken@telia.com"), 0); | ||
226 | aboutData.addCredit(i18n("Bekir Sonat"), i18n("Turkish translation"), QStringLiteral("bekirsonat@kde.org.tr"), 0); | 200 | aboutData.addCredit(i18n("Bekir Sonat"), i18n("Turkish translation"), QStringLiteral("bekirsonat@kde.org.tr"), 0); | ||
227 | aboutData.addCredit(i18n("Ivan Petrouchtchak"), i18n("Ukrainian translation"), QStringLiteral("connyosis@gmx.net"), 0); | 201 | aboutData.addCredit(i18n("Ivan Petrouchtchak"), i18n("Ukrainian translation"), QStringLiteral("connyosis@gmx.net"), 0); | ||
228 | aboutData.addCredit(i18n("Seongnam Jee"), i18n("Korean translation"), QStringLiteral("snjee@intellicam.com"), 0); | 202 | aboutData.addCredit(i18n("Seongnam Jee"), i18n("Korean translation"), QStringLiteral("snjee@intellicam.com"), 0); | ||
229 | 203 | | |||
230 | // This will call QCoreApplication::setApplicationName, etc for us by using info in the KAboutData instance. | 204 | // This will call QCoreApplication::setApplicationName, etc for us by using info in the KAboutData instance. | ||
231 | // The only thing not called for us is setWindowIcon(), which is why we do it ourselves here. | 205 | // The only thing not called for us is setWindowIcon(), which is why we do it ourselves here. | ||
232 | KAboutData::setApplicationData(aboutData); | 206 | KAboutData::setApplicationData(aboutData); | ||
233 | app.setWindowIcon(QIcon::fromTheme(Krusader::privIcon())); | 207 | app.setWindowIcon(Icon(Krusader::appIconName())); | ||
234 | 208 | | |||
235 | // Command line arguments ... | 209 | // Command line arguments ... | ||
236 | QCommandLineParser parser; | 210 | QCommandLineParser parser; | ||
237 | aboutData.setupCommandLine(&parser); | 211 | aboutData.setupCommandLine(&parser); | ||
238 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("left"), i18n("Start left panel at <path>"), QLatin1String("path"))); | 212 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("left"), i18n("Start left panel at <path>"), QLatin1String("path"))); | ||
239 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("right"), i18n("Start right panel at <path>"), QLatin1String("path"))); | 213 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("right"), i18n("Start right panel at <path>"), QLatin1String("path"))); | ||
240 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("profile"), i18n("Load this profile on startup"), QLatin1String("panel-profile"))); | 214 | parser.addOption(QCommandLineOption(QStringList() << QLatin1String("profile"), i18n("Load this profile on startup"), QLatin1String("panel-profile"))); | ||
241 | parser.addOption(QCommandLineOption(QStringList() << "d" << QLatin1String("debug"), i18n("Enable debug output"))); | 215 | parser.addOption(QCommandLineOption(QStringList() << "d" << QLatin1String("debug"), i18n("Enable debug output"))); | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
321 | } | 295 | } | ||
322 | if (!dbus.registerObject("/Instances/" + appName + "/left_manager", LEFT_MNG, QDBusConnection::ExportScriptableSlots)) { | 296 | if (!dbus.registerObject("/Instances/" + appName + "/left_manager", LEFT_MNG, QDBusConnection::ExportScriptableSlots)) { | ||
323 | fprintf(stderr, "DBus Error: %s, %s\n", dbus.lastError().name().toLocal8Bit().constData(), dbus.lastError().message().toLocal8Bit().constData()); | 297 | fprintf(stderr, "DBus Error: %s, %s\n", dbus.lastError().name().toLocal8Bit().constData(), dbus.lastError().message().toLocal8Bit().constData()); | ||
324 | } | 298 | } | ||
325 | if (!dbus.registerObject("/Instances/" + appName + "/right_manager", RIGHT_MNG, QDBusConnection::ExportScriptableSlots)) { | 299 | if (!dbus.registerObject("/Instances/" + appName + "/right_manager", RIGHT_MNG, QDBusConnection::ExportScriptableSlots)) { | ||
326 | fprintf(stderr, "DBus Error: %s, %s\n", dbus.lastError().name().toLocal8Bit().constData(), dbus.lastError().message().toLocal8Bit().constData()); | 300 | fprintf(stderr, "DBus Error: %s, %s\n", dbus.lastError().name().toLocal8Bit().constData(), dbus.lastError().message().toLocal8Bit().constData()); | ||
327 | } | 301 | } | ||
328 | 302 | | |||
329 | qDebug() << "Qt icon theme: " << QIcon::themeName(); | | |||
330 | | ||||
331 | // catching SIGTERM, SIGHUP, SIGQUIT | 303 | // catching SIGTERM, SIGHUP, SIGQUIT | ||
332 | signal(SIGTERM, sigterm_handler); | 304 | signal(SIGTERM, sigterm_handler); | ||
333 | signal(SIGPIPE, sigterm_handler); | 305 | signal(SIGPIPE, sigterm_handler); | ||
334 | signal(SIGHUP, sigterm_handler); | 306 | signal(SIGHUP, sigterm_handler); | ||
335 | 307 | | |||
336 | QObject::connect(&app, &QGuiApplication::applicationStateChanged, SLOTS, &KRslots::applicationStateChanged); | 308 | QObject::connect(&app, &QGuiApplication::applicationStateChanged, SLOTS, &KRslots::applicationStateChanged); | ||
337 | 309 | | |||
338 | // hide splashscreen | 310 | // hide splashscreen | ||
339 | if (splash) { | 311 | if (splash) { | ||
340 | splash->finish(krusader); | 312 | splash->finish(krusader); | ||
341 | delete splash; | 313 | delete splash; | ||
342 | } | 314 | } | ||
343 | // let's go. | 315 | // let's go. | ||
344 | return app.exec(); | 316 | return app.exec(); | ||
345 | } | 317 | } |