File indexing completed on 2024-12-01 04:37:14
0001 /* 0002 Main file of the Smb4K program. 0003 0004 SPDX-FileCopyrightText: 2003-2024 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 // application specific includes 0009 #include "core/smb4kclient.h" 0010 #include "core/smb4kmounter.h" 0011 #include "core/smb4ksettings.h" 0012 #include "smb4kmainwindow.h" 0013 0014 // Qt includes 0015 #include <QApplication> 0016 #include <QString> 0017 0018 // KDE includes 0019 #include <KAboutData> 0020 #include <KCrash> 0021 #include <KDBusService> 0022 #include <KLocalizedString> 0023 #include <KWindowSystem> 0024 #include <kwindowsystem_version.h> 0025 0026 #include <smb4k_version.h> 0027 0028 using namespace Smb4KGlobal; 0029 0030 int main(int argc, char **argv) 0031 { 0032 #if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0) 0033 // Set attributes 0034 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); 0035 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0036 #endif 0037 0038 // Create the application 0039 QApplication app(argc, argv); 0040 0041 // Connect the application with the translation catalog 0042 KLocalizedString::setApplicationDomain("smb4k"); 0043 0044 // Create the about data for Smb4K 0045 KAboutData aboutData(QStringLiteral("smb4k"), 0046 i18n("Smb4K"), 0047 QStringLiteral(SMB4K_VERSION_STRING), 0048 i18n("Advanced network neighborhood browser and Samba share mounting utility"), 0049 KAboutLicense::GPL_V2, 0050 i18n("\u00A9 2003-2024 Alexander Reinholdt"), 0051 QString(), 0052 QStringLiteral("https://smb4k.sourceforge.io")); 0053 0054 // DBus prefix 0055 aboutData.setOrganizationDomain("kde.org"); 0056 aboutData.setDesktopFileName(QStringLiteral("org.kde.") + aboutData.componentName()); 0057 0058 // Authors 0059 aboutData.addAuthor(i18n("Alexander Reinholdt"), i18n("Developer"), QStringLiteral("alexander.reinholdt@kdemail.net")); 0060 0061 // Credits: 0062 // People who supported the Smb4K development by donating 0063 // money 0064 aboutData.addCredit(i18n("Wolfgang Geisendörfer"), i18n("Donator"), QStringLiteral("wdm-lin@gmx.net")); 0065 0066 // Register about data 0067 KAboutData::setApplicationData(aboutData); 0068 0069 // Now add the data to the application 0070 app.setApplicationName(aboutData.componentName()); 0071 app.setApplicationDisplayName(aboutData.displayName()); 0072 app.setOrganizationDomain(aboutData.organizationDomain()); 0073 app.setApplicationVersion(aboutData.version()); 0074 0075 // We need to set this property because otherwise the application 0076 // will quit when it is embedded into the system tray, the main window 0077 // is hidden and the last window that was opened through the system 0078 // tray is closed. 0079 app.setQuitOnLastWindowClosed(false); 0080 0081 // Program icon 0082 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("smb4k"))); 0083 0084 // Launch the main window 0085 Smb4KMainWindow *mainWindow = new Smb4KMainWindow(); 0086 mainWindow->setVisible(!Smb4KSettings::startMainWindowDocked()); 0087 0088 // FIXME: Move this to the main window? 0089 // Start scanning the network neighborhood and remounting shares. 0090 Smb4KClient::self()->start(); 0091 Smb4KMounter::self()->start(); 0092 0093 // Unique application 0094 const KDBusService service(KDBusService::Unique); 0095 0096 QObject::connect(&service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList & /*args*/, const QString & /*workingDir*/) { 0097 if (mainWindow->isVisible()) { 0098 KWindowSystem::updateStartupId(mainWindow->windowHandle()); 0099 KWindowSystem::activateWindow(mainWindow->windowHandle()); 0100 } else { 0101 mainWindow->setVisible(true); 0102 } 0103 }); 0104 0105 // Use a crash handler 0106 KCrash::setDrKonqiEnabled(true); 0107 0108 // Start the application 0109 return app.exec(); 0110 }