File indexing completed on 2024-03-24 15:49:02
0001 // SPDX-FileCopyrightText: 2003 Lukáš Tinkl <lukas@kde.org> 0002 // SPDX-FileCopyrightText: 2003 Simon Hausmann <hausmann@kde.org> 0003 // SPDX-FileCopyrightText: 2003 Stephan Binner <binner@kde.org> 0004 // SPDX-FileCopyrightText: 2003-2014 Jesper K. Pedersen <blackie@kde.org> 0005 // SPDX-FileCopyrightText: 2005-2007 Dirk Mueller <mueller@kde.org> 0006 // SPDX-FileCopyrightText: 2006-2008 Tuomas Suutari <tuomas@nepnep.net> 0007 // SPDX-FileCopyrightText: 2007 Chusslove Illich <caslav.ilic@gmx.net> 0008 // SPDX-FileCopyrightText: 2007-2011 Jan Kundrát <jkt@flaska.net> 0009 // SPDX-FileCopyrightText: 2009 Andrew Coles <andrew.i.coles@googlemail.com> 0010 // SPDX-FileCopyrightText: 2009 Christoph Feck <cfeck@kde.org> 0011 // SPDX-FileCopyrightText: 2010-2012 Miika Turkia <miika.turkia@gmail.com> 0012 // SPDX-FileCopyrightText: 2012-2024 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0013 // SPDX-FileCopyrightText: 2018 Antoni Bella Pérez <antonibella5@yahoo.com> 0014 // SPDX-FileCopyrightText: 2018-2020 Tobias Leupold <tl at stonemx dot de> 0015 // SPDX-FileCopyrightText: 2018-2022 Tobias Leupold <tl@stonemx.de> 0016 // SPDX-FileCopyrightText: 2019 Alexander Potashev <aspotashev@gmail.com> 0017 // 0018 // SPDX-License-Identifier: GPL-2.0-or-later 0019 0020 #include <MainWindow/Options.h> 0021 #include <MainWindow/SplashScreen.h> 0022 #include <MainWindow/Window.h> 0023 #ifdef KPA_ENABLE_REMOTECONTROL 0024 #include <RemoteControl/RemoteInterface.h> 0025 #endif 0026 #include <kpabase/SettingsData.h> 0027 #include <kpabase/version.h> 0028 0029 #include <KAboutData> 0030 #include <KColorScheme> 0031 #include <KConfigGroup> 0032 #include <KLocalizedString> 0033 #include <KSharedConfig> 0034 #include <Kdelibs4ConfigMigrator> 0035 #include <QApplication> 0036 #include <QCommandLineOption> 0037 #include <QCommandLineParser> 0038 #include <QDebug> 0039 #include <QLocale> 0040 #include <QLoggingCategory> 0041 #include <QTemporaryFile> 0042 0043 Q_DECLARE_LOGGING_CATEGORY(MainLog) 0044 Q_LOGGING_CATEGORY(MainLog, "kphotoalbum", QtWarningMsg) 0045 0046 namespace 0047 { 0048 0049 const auto STYLE = QStringLiteral( 0050 "Viewer--TaggedArea { border: none; background-color: none; }" 0051 "Viewer--TaggedArea:hover, Viewer--TaggedArea[selected=\"true\"] {" 0052 " border: 1px solid rgb(0,255,0,99); background-color: rgb(255,255,255,30);" 0053 " }" 0054 "Viewer--TaggedArea[highlighted=\"true\"]{ border: 1px solid rgb(255,128,0,99); background-color: rgb(255,255,255,30); }" 0055 "AnnotationDialog--ResizableFrame { color: rgb(255,0,0); }" 0056 "AnnotationDialog--ResizableFrame:hover { background-color: rgb(255,255,255,30); }" 0057 "AnnotationDialog--ResizableFrame[associated=true] { color: rgb(0,255,0); }"); 0058 } 0059 void migrateKDE4Config() 0060 { 0061 Kdelibs4ConfigMigrator migrator(QStringLiteral("kphotoalbum")); // the same name defined in the aboutData 0062 migrator.setConfigFiles(QStringList() << QStringLiteral("kphotoalbumrc")); 0063 migrator.setUiFiles(QStringList() << QStringLiteral("kphotoalbumui.rc")); 0064 if (migrator.migrate()) { 0065 KConfigGroup unnamedConfig = KSharedConfig::openConfig()->group(QString()); 0066 if (unnamedConfig.hasKey(QStringLiteral("configfile"))) { 0067 // rename config file entry on update 0068 KConfigGroup generalConfig = KSharedConfig::openConfig()->group(QStringLiteral("General")); 0069 generalConfig.writeEntry(QStringLiteral("imageDBFile"), 0070 unnamedConfig.readEntry(QStringLiteral("configfile"))); 0071 unnamedConfig.deleteEntry(QStringLiteral("configfile")); 0072 qCWarning(MainLog) << "Renamed config entry configfile to General.imageDBFile."; 0073 } 0074 } 0075 } 0076 0077 int main(int argc, char **argv) 0078 { 0079 KLocalizedString::setApplicationDomain("kphotoalbum"); 0080 QApplication app(argc, argv); 0081 migrateKDE4Config(); 0082 0083 KAboutData aboutData( 0084 QStringLiteral("kphotoalbum"), // component name 0085 i18n("KPhotoAlbum"), // display name 0086 QStringLiteral(KPA_VERSION), 0087 i18n("KDE Photo Album"), // short description 0088 KAboutLicense::GPL_V3, 0089 i18n("Copyright (C) 2003-2024 The KPhotoAlbum Development Team"), // copyright statement 0090 QString(), // other text 0091 QStringLiteral("https://www.kphotoalbum.org") // homepage 0092 ); 0093 aboutData.setOrganizationDomain("kde.org"); 0094 // maintainer is expected to be the first entry 0095 // Note: I like to sort by name, grouped by active/inactive; 0096 // Jesper gets ranked with the active authors for obvious reasons 0097 aboutData.addAuthor(i18n("Johannes Zarl-Zierl"), i18n("Development, Maintainer"), QStringLiteral("johannes@zarl-zierl.at")); 0098 aboutData.addAuthor(i18n("Robert Krawitz"), i18n("Development, Optimization"), QStringLiteral("rlk@alum.mit.edu")); 0099 aboutData.addAuthor(i18n("Tobias Leupold"), i18n("Development, Releases, Website"), QStringLiteral("tl@stonemx.de")); 0100 aboutData.addAuthor(i18n("Jesper K. Pedersen"), i18n("Former Maintainer, Project Creator"), QStringLiteral("blackie@kde.org")); 0101 // not currently active: 0102 aboutData.addAuthor(i18n("Hassan Ibraheem"), QString(), QStringLiteral("hasan.ibraheem@gmail.com")); 0103 aboutData.addAuthor(i18n("Jan Kundrát"), QString(), QStringLiteral("jkt@gentoo.org")); 0104 aboutData.addAuthor(i18n("Andreas Neustifter"), QString(), QStringLiteral("andreas.neustifter@gmail.com")); 0105 aboutData.addAuthor(i18n("Tuomas Suutari"), QString(), QStringLiteral("thsuut@utu.fi")); 0106 aboutData.addAuthor(i18n("Miika Turkia"), QString(), QStringLiteral("miika.turkia@gmail.com")); 0107 aboutData.addAuthor(i18n("Henner Zeller"), QString(), QStringLiteral("h.zeller@acm.org")); 0108 0109 // sort alphabetically: 0110 aboutData.addCredit(i18n("Marco Caldarelli"), i18n("Patch for making it possible to reread Exif info using a nice dialog."), QStringLiteral("caldarel@yahoo.it")); 0111 aboutData.addCredit(i18n("Jean-Michel FAYARD"), i18n("(.) Patch with folder info made available through the browser. (.) Patch for adding a check box for \"and/or\" searches in the search page."), QStringLiteral("jmfayard@gmail.com")); 0112 aboutData.addCredit(i18n("Matthias Füssel"), i18n("Geo Position page in browser and various bug fixes"), QStringLiteral("matthias.fuessel@gmx.net")); 0113 aboutData.addCredit(i18n("Wes Hardaker"), i18n("Some very useful features to improve workflow"), QStringLiteral("kpa@capturedonearth.com")); 0114 aboutData.addCredit(i18n("Reimar Imhof"), i18n("Patch to sort items in option listboxes"), QStringLiteral("Reimar.Imhof@netCologne.de")); 0115 aboutData.addCredit(i18n("Christoph Moseler"), i18n("Numerous patches for lots of bugs plus patches for a few new features"), QStringLiteral("forums@moseler.net")); 0116 aboutData.addCredit(i18n("Teemu Rytilahti"), 0117 i18n("Theme support for HTML generation"), QStringLiteral("teemu.rytilahti@kde-fi.org")); 0118 aboutData.addCredit(i18n("Thomas Schwarzgruber"), i18n("Patch to sort images in the thumbnail view, plus reading time info out of Exif images for existing images"), QStringLiteral("possebaer@gmx.at")); 0119 aboutData.addCredit(i18n("Clytie Siddall"), i18n("Tremendous help with the English text in the application."), QStringLiteral("clytie@riverland.net.au")); 0120 aboutData.addCredit(i18n("Will Stephenson"), i18n("Developing an Icon for KPhotoAlbum"), QStringLiteral("will@stevello.free-online.co.uk")); 0121 aboutData.addCredit(i18n("Marcel Wiesweg"), i18n("Patch which speed up loading of thumbnails plus preview in image property dialog."), QStringLiteral("marcel.wiesweg@gmx.de")); 0122 0123 // initialize the commandline parser 0124 QCommandLineParser *parser = MainWindow::Options::the()->parser(); 0125 0126 KAboutData::setApplicationData(aboutData); 0127 aboutData.setupCommandLine(parser); 0128 0129 parser->process(app); 0130 aboutData.processCommandLine(parser); 0131 0132 const QString schemePath = KSharedConfig::openConfig()->group("General").readEntry(QStringLiteral("colorScheme"), QString()); 0133 qCDebug(MainLog) << "Loading color scheme from " << (schemePath.isEmpty() ? QStringLiteral("system default") : schemePath); 0134 app.setPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(schemePath))); 0135 if (app.styleSheet().isEmpty()) 0136 app.setStyleSheet(STYLE); 0137 app.setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); 0138 0139 new MainWindow::SplashScreen(); 0140 0141 // a KXmlGuiWindow per-default is created with the Qt::WA_DeleteOnClose attribute set 0142 // -> don't delete the view directly! 0143 MainWindow::Window *view = nullptr; 0144 try { 0145 view = new MainWindow::Window(nullptr); 0146 } catch (int retVal) { 0147 // MainWindow ctor throws if no config is loaded 0148 return retVal; 0149 } 0150 0151 const auto mainWindowGeometry = Settings::SettingsData::instance()->windowGeometry(Settings::MainWindow); 0152 if (mainWindowGeometry.isValid()) 0153 view->setGeometry(mainWindowGeometry); 0154 else 0155 view->showMaximized(); 0156 0157 #ifdef KPA_ENABLE_REMOTECONTROL 0158 (void)RemoteControl::RemoteInterface::instance(); 0159 #endif 0160 0161 int code = QApplication::exec(); 0162 return code; 0163 } 0164 // vi:expandtab:tabstop=4 shiftwidth=4: