Changeset View
Changeset View
Standalone View
Standalone View
src/lib/app/mainapplication.cpp
Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Line(s) | 443 | { | |||
---|---|---|---|---|---|
447 | 447 | | |||
448 | BrowserWindow* window = new BrowserWindow(type, startUrl); | 448 | BrowserWindow* window = new BrowserWindow(type, startUrl); | ||
449 | connect(window, &QObject::destroyed, this, &MainApplication::windowDestroyed); | 449 | connect(window, &QObject::destroyed, this, &MainApplication::windowDestroyed); | ||
450 | 450 | | |||
451 | m_windows.prepend(window); | 451 | m_windows.prepend(window); | ||
452 | return window; | 452 | return window; | ||
453 | } | 453 | } | ||
454 | 454 | | |||
455 | void MainApplication::openNonPrivateWindow(Qz::BrowserWindowType type, const QUrl& startUrl) | ||||
drosca: Rename to `openNonPrivateWindow` because it doesn'r return BrowserWindow. | |||||
456 | { | ||||
457 | if (!isPrivate()) { | ||||
Coding style + early return (same in start private browsing). if (!isPrivate()) { createWindow(...); return; } drosca: Coding style + early return (same in start private browsing).
```
if (!isPrivate()) {… | |||||
458 | createWindow(type, startUrl); | ||||
QtSingleApplication::isRunning only tests if the same instance of Falkon is already running, and it makes sense to test it only during startup. In this case it will always return false. drosca: `QtSingleApplication::isRunning` only tests if the same instance of Falkon is already running… | |||||
459 | return; | ||||
460 | } | ||||
461 | | ||||
462 | QUrl url = startUrl; | ||||
463 | if (QAction* act = qobject_cast<QAction*>(sender())) { | ||||
464 | url = act->data().toUrl(); | ||||
465 | } | ||||
466 | | ||||
467 | QStringList args({QSL("--new-window"), QSL("--profile=") + ProfileManager::currentProfile()}); | ||||
468 | | ||||
469 | if (!url.isEmpty()) { | ||||
470 | args << url.toEncoded(); | ||||
471 | } | ||||
472 | | ||||
473 | if (!QProcess::startDetached(applicationFilePath(), args)) { | ||||
474 | qWarning() << "MainApplication: Cannot start new browser process!" << applicationFilePath() << args; | ||||
475 | } | ||||
476 | } | ||||
477 | | ||||
478 | | ||||
455 | MainApplication::AfterLaunch MainApplication::afterLaunch() const | 479 | MainApplication::AfterLaunch MainApplication::afterLaunch() const | ||
456 | { | 480 | { | ||
457 | return static_cast<AfterLaunch>(Settings().value(QSL("Web-URL-Settings/afterLaunch"), RestoreSession).toInt()); | 481 | return static_cast<AfterLaunch>(Settings().value(QSL("Web-URL-Settings/afterLaunch"), RestoreSession).toInt()); | ||
458 | } | 482 | } | ||
459 | 483 | | |||
460 | void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreData) | 484 | void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreData) | ||
461 | { | 485 | { | ||
462 | setOverrideCursor(Qt::BusyCursor); | 486 | setOverrideCursor(Qt::BusyCursor); | ||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Line(s) | 698 | { | |||
676 | 700 | | |||
677 | if (window) { | 701 | if (window) { | ||
678 | window->tabWidget()->addView(url, url.isEmpty() ? Qz::NT_SelectedNewEmptyTab : Qz::NT_SelectedTabAtTheEnd); | 702 | window->tabWidget()->addView(url, url.isEmpty() ? Qz::NT_SelectedNewEmptyTab : Qz::NT_SelectedTabAtTheEnd); | ||
679 | } | 703 | } | ||
680 | } | 704 | } | ||
681 | 705 | | |||
682 | void MainApplication::startPrivateBrowsing(const QUrl &startUrl) | 706 | void MainApplication::startPrivateBrowsing(const QUrl &startUrl) | ||
683 | { | 707 | { | ||
708 | if (isPrivate()) { | ||||
709 | createWindow(Qz::BW_NewWindow, startUrl); | ||||
710 | return; | ||||
711 | } | ||||
712 | | ||||
684 | QUrl url = startUrl; | 713 | QUrl url = startUrl; | ||
685 | if (QAction* act = qobject_cast<QAction*>(sender())) { | 714 | if (QAction* act = qobject_cast<QAction*>(sender())) { | ||
686 | url = act->data().toUrl(); | 715 | url = act->data().toUrl(); | ||
687 | } | 716 | } | ||
688 | 717 | | |||
689 | QStringList args; | 718 | QStringList args; | ||
690 | args.append(QSL("--private-browsing")); | 719 | args.append(QSL("--private-browsing")); | ||
691 | args.append(QSL("--profile=") + ProfileManager::currentProfile()); | 720 | args.append(QSL("--profile=") + ProfileManager::currentProfile()); | ||
▲ Show 20 Lines • Show All 584 Lines • Show Last 20 Lines |
Rename to openNonPrivateWindow because it doesn'r return BrowserWindow.