diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 99 |
1 files changed, 43 insertions, 56 deletions
diff --git a/src/main.cpp b/src/main.cpp index a483078b..20c30c68 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,71 +9,58 @@ * Description: Application Entry Point * ============================================================ */ -// version include -#include <config-version.h> - -// Local Includes #include "application.h" -#include "sessionmanager.h" -#include "rekonqwindow.h" -#include "urlresolver.h" - -// KDE Includes -#include <KDE/KCmdLineArgs> -#include <KDE/KUniqueApplication> - -// Qt Includes -#include <QDir> -#include <QUrl> +//#include "sessionmanager.h" +//#include "rekonqwindow.h" +//#include "urlresolver.h" +#include <QCommandLineParser> +static const char *description = "A lightweight Web Browser based on Qt WebEngine"; -static const char description[] = - I18N_NOOP("A lightweight Web Browser for KDE based on WebKit"); - - -extern "C" KDE_EXPORT int kdemain(int argc, char **argv) +int main(int argc, char **argv) { + Application app(argc, argv); + // Set application data + QCoreApplication::setApplicationName(QL1S("rekonq")); + QCoreApplication::setApplicationVersion(REKONQ_VERSION); + // Initialize command line args - KCmdLineArgs::init(argc, argv, &about); + QCommandLineParser parser; + parser.setApplicationDescription(description); + parser.addHelpOption(); + parser.addVersionOption(); - // Define the command line options using KCmdLineOptions - KCmdLineOptions options; + // Define the command line options + QCommandLineOption options_incognito("incognito", QCoreApplication::translate("main", "Open in incognito mode")); + QCommandLineOption options_webapp("webapp", + QCoreApplication::translate("main", "Open URL as web app (in a simple window)")); + parser.addOptions({options_incognito, options_webapp}); - // adding options - options.add("incognito", ki18n("Open in incognito mode")); - options.add("webapp", ki18n("Open URL as web app (in a simple window)")); - options.add("+[URL]", ki18n("Location to open")); + // Define the positional arguments + parser.addPositionalArgument("URL", QCoreApplication::translate("main", "Location to open")); - // Register the supported options - KCmdLineArgs::addCmdLineOptions(options); + parser.process(app); - if (!Application::start()) { + const auto positionalArguments = parser.positionalArguments(); + if (parser.isSet(options_webapp)) + positionalArguments.isEmpty() ? app.newWebApp() : app.newWebApp(QUrl::fromUserInput(positionalArguments.first())); + + /*if (!Application::start()) { kWarning() << "rekonq is already running!"; return 0; - } - -#if defined(Q_WS_X11) - // On X11, the raster engine gives better performance than native. - QApplication::setGraphicsSystem(QLatin1String("raster")); -#endif - - KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); - - Application app; - - // set application data - QCoreApplication::setApplicationName(QLatin1String("rekonq")); - QCoreApplication::setApplicationVersion(REKONQ_VERSION); - - if (app.isSessionRestored()) - { - for (int i = 1; RekonqWindow::canBeRestored(i); i++) - { - RekonqWindow * newRekonqWindow = app.newWindow(false); - if (newRekonqWindow->restore(i)) - SessionManager::self()->restoreWindow(newRekonqWindow); - } - } - - return app.exec(); + }*/ + + /* + + if (app.isSessionRestored()) + { + for (int i = 1; RekonqWindow::canBeRestored(i); i++) + { + RekonqWindow * newRekonqWindow = app.newWindow(false); + if (newRekonqWindow->restore(i)) + SessionManager::self()->restoreWindow(newRekonqWindow); + } + } + */ + return Application::exec(); } |