File indexing completed on 2022-11-29 20:25:16

0001 /***************************************************************************
0002                           main.cpp  -  description
0003                              -------------------
0004     begin                : Die Mai 15 15:34:19 CEST 2001
0005     copyright            : (C) 2001 by Dominik Seichter
0006     email                : domseichter@web.de
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your2192 option) any later version.                               *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 // Qt includes
0019 #include <QRect>
0020 #include <QtGlobal>
0021 #include <QWidget>
0022 
0023 // KDE includes
0024 
0025 #include <kaboutdata.h>
0026 
0027 #include <kconfig.h>
0028 #include <kmessagebox.h>
0029 
0030 #include <klocalizedstring.h>
0031 
0032 // Own includes
0033 #include "krenameimpl.h"
0034 
0035 // OS includes
0036 #ifndef Q_OS_WIN
0037 #include <unistd.h>
0038 #endif
0039 #include <sys/types.h>
0040 #include <QApplication>
0041 #include <KAboutData>
0042 #include <KCrash>
0043 #include <KLocalizedString>
0044 #include <QCommandLineParser>
0045 #include <QCommandLineOption>
0046 
0047 #include "../config-krename.h"
0048 
0049 int main(int argc, char *argv[])
0050 {
0051     QApplication app(argc, argv);
0052     app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0053     KLocalizedString::setApplicationDomain("krename");
0054 
0055     KCrash::initialize();
0056 
0057     KAboutData aboutData("krename", i18n("KRename"), VERSION);
0058     aboutData.setShortDescription(i18n(
0059                                       "KRename is a batch file renamer which can rename a "
0060                                       "list of files based on a set of expressions."));
0061     aboutData.setOtherText(i18n(
0062                                "If you like KRename you may want to support it. "
0063                                "Testing, bug fixes and feature requests are as welcome "
0064                                "as financial support (everybody needs money ;). See help files for details."));
0065     aboutData.setLicense(KAboutLicense::GPL_V3);
0066     aboutData.setCopyrightStatement(i18n("(c) 2001-2012, Dominik Seichter\n"));
0067     aboutData.setHomepage("https://userbase.kde.org/KRename");
0068 
0069     aboutData.addAuthor(i18n("Heiko Becker"), i18n("Current maintainer"),
0070                         "heirecka@exherbo.org");
0071     aboutData.addAuthor(i18n("Dominik Seichter"), i18n("Developer and former maintainer"), "domseichter@web.de",
0072                         "https://www.krename.net/");
0073     aboutData.addAuthor(i18n("Stefan \"Stonki\" Onken"),
0074                         i18n("Website, testing, very good ideas and keeping me coding!"),
0075                         "support@stonki.de", "https://www.stonki.com/");
0076 
0077     aboutData.addCredit(i18n("Arpad Biro"), i18n("Helped to fix style guide issues and made improvements to user messages."), "biro.arpad@gmail.com");
0078     aboutData.addCredit(i18n("Trevor Semeniuk"),  i18n("Thanks to him for creating RedHat 7.x packages and some other help."),
0079                         "semeniuk@ee.ualberta.ca", "http://www.semeniuk.net");
0080     aboutData.addCredit(i18n("Groult Richard"),   i18n("Fixed a bug with startIndex and added the BatchRenamer class\n"
0081                         "to his excellent image viewer showimg."),
0082                         "rgroult@jalix.org");
0083     aboutData.addCredit(i18n("Michael Elvers"),  i18n("Fixed a bug that caused krename not closing open files."),
0084                         "m_elvers@yahoo.com");
0085     aboutData.addCredit(i18n("Andreas Pour"),  i18n("Thanks for his great job at apps.kde.com and help with contributing krename to apps.kde.com."),
0086                         "pour@mieterra.com");
0087     aboutData.addCredit(i18n("Charles Samuels"), i18n("Thanks for noatun and the ID3/Ogg Tag code is based on his noatun modules."),
0088                         "charles@kde.org");
0089     aboutData.addCredit(i18n("Franz Schmid"), i18n("Gave me a good start into writing plugins with his application scribus."),
0090                         "Franz.Schmid@altmuehlnet.de", "http://web2.altmuehlnet.de/fschmid/index.html");
0091     aboutData.addCredit(i18n("Rolf Magnus"), i18n("Parts of the PNG support are copied from his KFile plugin for png support."),
0092                         "ramagnus@kde.org");
0093     aboutData.addCredit(i18n("Michael v.Ostheim"), i18n("Created the Gentoo Ebuild scripts for Krename."),
0094                         "MvOstheim@web.de", "http://www.vonostheim.de");
0095     aboutData.addCredit(i18n("Brandon Low"), i18n("Some GCC 3.1 fixes for Gentoo."),
0096                         "lostlogic@gentoo.org");
0097     aboutData.addCredit(i18n("Per Oyvind Karlsen"), i18n("Thanks for creating the Mandrake RPM"),
0098                         "peroyvind@delonic.no");
0099     aboutData.addCredit(i18n("Vincenzo Reale"), i18n("Italian translation"), "smart2128@baslug.org");
0100     aboutData.addCredit(i18n("Daniele Medri"), i18n("Italian translation work"), "madrid@linuxmeeting.net");
0101     aboutData.addCredit(i18n("Stephan Johach"), i18n("Provided a gcc3.x namespace patch"), "lucardus@onlinehome.de");
0102     aboutData.addCredit(i18n("Michael Zugaro"), i18n("Provided the new preview and move features") , "michael.zugaro@college-de-france.fr");
0103     aboutData.addCredit(i18n("Rene Gass"), i18n("Fixed problems with the spec file and contributed rpms for every SuSE version you can imagine and is also the new Gentoo maintainer for KRename"), "kde-package@gmx.de");
0104     aboutData.addCredit(i18n("Mark Ziegler"), i18n("Provided SuSE RPMs and very good suggestions"), "mark.ziegler@rakekniven.de");
0105     aboutData.addCredit(i18n("Jose Rodriguez"), i18n("Contributed a Spanish translation"), "chmpmi@eresmas.net");
0106     aboutData.addCredit(i18n("Steven P. Ulrick"), i18n("Provided a RedHat RPM and was big help in improving KRename"), "steve@afolkey2.net");
0107     aboutData.addCredit(i18n("UTUMI Hirosi"), i18n("Translated KRename to Japanese"), "utuhiro@mx12.freecom.ne.jp");
0108     aboutData.addCredit(i18n("Nicolas Benoit"), i18n("Translated KRename into French"), "nbenoit@tuxfamily.org");
0109     aboutData.addCredit(i18n("Krzysztof Pawlak"), i18n("Translated KRename into Polish"), "jmnemonic@gazeta.pl");
0110     aboutData.addCredit(i18n("Ilya Ivkov"), i18n("Translated KRename into Russian"), "ilya-ivkov@yandex.ru");
0111     aboutData.addCredit(i18n("Asim Husanovic"), i18n("Translated KRename into Bosnian"), "asim.h@megatel.ba");
0112     aboutData.addCredit(i18n("Michal Smoczyk"), i18n("Polish Translation"), "msmoczyk@wp.pl");
0113     aboutData.addCredit(i18n("Pavel Fric"), i18n("Czech Translation"), "pavelfric@seznam.cz");
0114     aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
0115                             i18nc("EMAIL OF TRANSLATORS", "Your emails"));
0116 
0117     aboutData.setDesktopFileName(QStringLiteral("org.kde.krename"));
0118 
0119     KAboutData::setApplicationData(aboutData);
0120     QApplication::setWindowIcon(QIcon::fromTheme("krename", QApplication::windowIcon()));
0121 
0122     QCommandLineParser parser;
0123     parser.addPositionalArgument(QLatin1String("files"), i18n("Files to be added to the list to be renamed"), i18n("[files...]"));
0124     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("r"), i18n("add folder recursively"), i18n("folder")));
0125     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("template"), i18n("set a template")));
0126     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("extension"), i18n("set a template for the file extension")));
0127     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("use-plugin"), i18n("enable a plugin for use")));
0128     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("copy"), i18n("copy files to folder or url"), i18n("path or url")));
0129     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("move"), i18n("move files to folder or url"), i18n("path or url")));
0130     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("link"), i18n("link files to folder or url"), i18n("path or url")));
0131     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("start"), i18n("start renaming immediately")));
0132     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("test"), i18n("start KRename's selftest (developers only)")));
0133     // This option was never implemented in the KDE4 version:
0134     //parser.addOption(QCommandLineOption(QStringList() << QLatin1String("previewitems"), i18n("only show <num> preview items"), QLatin1String("num")));
0135 
0136     aboutData.setupCommandLine(&parser);
0137     parser.process(app);
0138     aboutData.processCommandLine(&parser);
0139 
0140     app.setQuitOnLastWindowClosed(true);
0141 
0142     QWidget *krename = KRenameImpl::launch(QRect(0, 0, 0, 0), KRenameFile::List(), &parser);
0143 
0144 #ifndef Q_OS_WIN
0145     /* Check if KRename
0146      * was started from root!
0147      */
0148     unsigned int uid = geteuid();
0149     if (uid == 0)
0150         KMessageBox::information(krename, i18n(
0151                                      "<b>Krename was started from root!</b><br>"
0152                                      "When started from root, Krename may damage your "
0153                                      "system if you do not know exactly what you are "
0154                                      "doing!"
0155                                  ), i18n("Error"), "KrenameRootWarning");
0156 #endif // Q_OS_WIN
0157 
0158     /*
0159      * Activate this warning message for unstable development releases.
0160      */
0161     /*    KMessageBox::sorry( krename, i18n(
0162         "<b>Warning !</b> This is a development release which may cause damage to your files!"
0163         "<br>Make backups before using KRename." ));
0164     */
0165     return app.exec();
0166 }
0167