File indexing completed on 2022-11-29 20:24:04

0001 /*
0002     SPDX-FileCopyrightText: 1998-2001 Michael Kropfberger <michael.kropfberger@gmx.net>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "kdf.h"
0007 
0008 #include "kdf_version.h"
0009 #include <KAboutData>
0010 #include <KXMLGUIFactory>
0011 #include <KStandardShortcut>
0012 #include <KStandardAction>
0013 #include <KActionCollection>
0014 #include <KLocalizedString>
0015 
0016 #include <QApplication>
0017 #include <QCommandLineParser>
0018 
0019 /***************************************************************/
0020 KDFTopLevel::KDFTopLevel(QWidget *)
0021         : KXmlGuiWindow(nullptr)
0022 {
0023     kdf = new KDFWidget(this,false);
0024     Q_CHECK_PTR(kdf);
0025     QAction *action = actionCollection()->addAction( QStringLiteral("updatedf"));
0026     action->setText( i18nc( "Update action", "&Update" ) );
0027     actionCollection()->setDefaultShortcuts(action, KStandardShortcut::reload());
0028     connect(action, &QAction::triggered, kdf, &KDFWidget::updateDF);
0029 
0030     KStandardAction::quit(this, &KDFTopLevel::close, actionCollection());
0031     KStandardAction::preferences(kdf, &KDFWidget::settingsBtnClicked, actionCollection());
0032     KStandardAction::keyBindings(guiFactory(), &KXMLGUIFactory::showConfigureShortcutsDialog, actionCollection());
0033     setCentralWidget(kdf);
0034     //  kdf->setMinimumSize(kdf->sizeHint());
0035     kdf->resize(kdf->sizeHint());
0036     setupGUI(KXmlGuiWindow::Keys | StatusBar | Save | Create);
0037 }
0038 
0039 
0040 void KDFTopLevel::closeEvent(QCloseEvent *event)
0041 {
0042     kdf->applySettings();
0043     KXmlGuiWindow::closeEvent(event);
0044 }
0045 
0046 
0047 /***************************************************************/
0048 int main(int argc, char **argv)
0049 {
0050     //Fixes blurry icons with fractional scaling
0051 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0052     QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0053 #endif
0054     QApplication app(argc, argv);
0055 
0056     KLocalizedString::setApplicationDomain("kdf");
0057 
0058     KAboutData aboutData(QStringLiteral("kdf"),
0059                          i18n("KDiskFree"),
0060                          QStringLiteral(KDF_VERSION_STRING),
0061                          i18n("KDE free disk space utility"),
0062                          KAboutLicense::GPL,
0063                          i18n("(c) 1998-2001, Michael Kropfberger"),
0064                          QString(),
0065                          QStringLiteral("http://utils.kde.org/projects/kdf"),
0066                          QString()
0067                         );
0068 
0069     aboutData.addAuthor(i18n("Michael Kropfberger"),
0070                         QString(),
0071                         QStringLiteral("michael.kropfberger@gmx.net"));
0072 
0073     QCommandLineParser parser;
0074     parser.setApplicationDescription(aboutData.shortDescription());
0075 
0076     aboutData.setupCommandLine(&parser);
0077 
0078     KAboutData::setApplicationData(aboutData);
0079 
0080     // do the command line parsing
0081     parser.process(app);
0082 
0083     // handle standard options
0084     aboutData.processCommandLine(&parser);
0085 
0086     if( app.isSessionRestored() ) //SessionManagement
0087     {
0088         for( int n=1; KDFTopLevel::canBeRestored(n); n++ )
0089         {
0090             KDFTopLevel *ktl = new KDFTopLevel();
0091             Q_CHECK_PTR(ktl);
0092             ktl->restore(n);
0093         }
0094     }
0095     else
0096     {
0097         KDFTopLevel *ktl = new KDFTopLevel();
0098         Q_CHECK_PTR(ktl);
0099         ktl->show();
0100     }
0101 
0102     return app.exec();
0103 }
0104 
0105