52#include <QWebEngineSettings>
53#include <QDesktopServices>
54#include <QFontDatabase>
55#include <QSqlDatabase>
56#include <QLibraryInfo>
64#include <QStandardPaths>
65#include <QWebEngineProfile>
66#include <QWebEngineScriptCollection>
67#include <QRegularExpression>
68#include <QtWebEngineWidgetsVersion>
69#include <QtWebEngineCoreVersion>
71#include <QWebEngineNotification>
72#include <QWebEngineUrlScheme>
76#include <QWinJumpList>
77#include <QWinJumpListCategory>
82#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
86static bool s_testMode =
false;
93 , m_isStartingAfterCrash(false)
95 , m_bookmarks(nullptr)
97 , m_cookieJar(nullptr)
99 , m_browsingLibrary(nullptr)
100 , m_networkManager(nullptr)
101 , m_restoreManager(nullptr)
102 , m_sessionManager(nullptr)
103 , m_downloadManager(nullptr)
104 , m_userAgentManager(nullptr)
105 , m_searchEnginesManager(nullptr)
106 , m_closedWindowsManager(nullptr)
107 , m_protocolHandlerManager(nullptr)
108 , m_html5PermissionsManager(nullptr)
109 , m_siteSettingsManager(nullptr)
110 , m_desktopNotifications(nullptr)
111 , m_webProfile(nullptr)
112 , m_autoSaver(nullptr)
113#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
114 , m_registerQAppAssociation(0)
117 setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
119 setApplicationName(QStringLiteral(
"falkon"));
120 setOrganizationDomain(QStringLiteral(
"org.kde"));
121 setWindowIcon(QIcon::fromTheme(
QSL(
"falkon"), QIcon(
QSL(
":icons/falkon.svg"))));
122 setDesktopFileName(
QSL(
"org.kde.falkon"));
125 setApplicationVersion(
QSL(
"%1 (%2)").arg(QString::fromLatin1(
Qz::VERSION), GIT_REVISION));
127 setApplicationVersion(QString::fromLatin1(
Qz::VERSION));
131 if (QIcon::fromTheme(
QSL(
"view-refresh")).isNull()) {
132 QIcon::setThemeName(
QSL(
"breeze-fallback"));
136 if (!QSqlDatabase::isDriverAvailable(
QSL(
"QSQLITE"))) {
137 QMessageBox::critical(
nullptr,
QSL(
"Error"),
QSL(
"Qt SQLite database plugin is not available. Please install it and restart the application."));
144 int fontId = QFontDatabase::addApplicationFont(
QSL(
"font.ttf"));
146 const QStringList families = QFontDatabase::applicationFontFamilies(fontId);
147 if (!families.empty())
148 setFont(QFont(families.at(0)));
152 QByteArray chromium_flags = qgetenv(
"QTWEBENGINE_CHROMIUM_FLAGS");
153 chromium_flags.append(
" --enable-features=WebRTCPipeWireCapturer");
154 qputenv(
"QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags);
157 QString startProfile;
158 QStringList messages;
160 bool noAddons =
false;
161 bool newInstance =
false;
167 switch (pair.action) {
172 startProfile = pair.text;
178 messages.append(QStringLiteral(
"ACTION:NewTab"));
179 m_postLaunchActions.append(OpenNewTab);
182 messages.append(QStringLiteral(
"ACTION:NewWindow"));
185 messages.append(QStringLiteral(
"ACTION:ToggleFullScreen"));
186 m_postLaunchActions.append(ToggleFullScreen);
189 messages.append(QStringLiteral(
"ACTION:ShowDownloadManager"));
190 m_postLaunchActions.append(OpenDownloadManager);
199 startUrl = QUrl::fromUserInput(pair.text);
200 messages.append(
QSL(
"ACTION:OpenUrlInCurrentTab") + pair.text);
203 startUrl = QUrl::fromUserInput(pair.text);
204 messages.append(
QSL(
"ACTION:OpenUrlInNewWindow") + pair.text);
207 startUrl = QUrl::fromUserInput(pair.text);
208 messages.append(
QSL(
"URL:") + pair.text);
214 m_wmClass = pair.text.toUtf8();
223 QSettings falkonConf(
QSL(
"%1/falkon.conf").arg(applicationDirPath()), QSettings::IniFormat);
224 m_isPortable = falkonConf.value(
QSL(
"Config/Portable")).toBool();
228 std::cout <<
"Falkon: Running in Portable Mode." << std::endl;
234 QString appId = QStringLiteral(
"org.kde.Falkon");
237 appId.append(QLatin1String(
".Portable"));
241 appId.append(
QSL(
".TestMode"));
245 if (startProfile.isEmpty() || startProfile == QLatin1String(
"default")) {
246 std::cout <<
"New instance cannot be started with default profile!" << std::endl;
252 appId.append(QLatin1Char(
'.') + startProfile + QString::number(QDateTime::currentMSecsSinceEpoch()));
260 if (messages.isEmpty()) {
261 messages.append(QStringLiteral(
" "));
266 for (
const QString &message : std::as_const(messages)) {
273 setQuitOnLastWindowClosed(
false);
278 setQuitOnLastWindowClosed(
true);
281 QSettings::setDefaultFormat(QSettings::IniFormat);
282 QDesktopServices::setUrlHandler(
QSL(
"http"),
this,
"addNewTab");
283 QDesktopServices::setUrlHandler(
QSL(
"https"),
this,
"addNewTab");
284 QDesktopServices::setUrlHandler(
QSL(
"ftp"),
this,
"addNewTab");
292 chromium_flags.append(
" --enable-oop-rasterization --enable-gpu-rasterization --enable-native-gpu-memory-buffers --use-gl=desktop");
293 qputenv(
"QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags);
297 registerAllowedSchemes();
300 m_webProfile =
new QWebEngineProfile();
303 m_webProfile =
new QWebEngineProfile(startProfile.isEmpty() ?
QSL(
"Default") : startProfile);
305 connect(m_webProfile, &QWebEngineProfile::downloadRequested,
this, &MainApplication::downloadRequested);
307 m_webProfile->setNotificationPresenter([&] (std::unique_ptr<QWebEngineNotification> notification) {
309 notifications->showNotification(
310 QPixmap::fromImage(notification->icon()), notification->title(), notification->message()
325 const bool wasRunning = settings.
value(
QSL(
"isRunning"),
false).toBool();
326 const bool wasRestoring = settings.
value(
QSL(
"isRestoring"),
false).toBool();
332 m_isStartingAfterCrash = wasRunning && wasRestoring;
335 QTimer::singleShot(60 * 1000,
this, [
this]() {
349 mApp->protocolHandlerManager();
357 connect(
this, &QApplication::focusChanged,
this, &MainApplication::onFocusChanged);
360#ifndef DISABLE_CHECK_UPDATES
362 bool checkUpdates = settings.
value(
"Web-Browser-Settings/CheckUpdates",
true).toBool();
373 if (!m_restoreManager->
isValid()) {
378 if (!m_isStartingAfterCrash && m_restoreManager) {
385 connect(
this, SIGNAL(messageReceived(QString)),
this, SLOT(messageReceived(QString)));
386 connect(
this, &QCoreApplication::aboutToQuit,
this, &MainApplication::saveSettings);
388 QTimer::singleShot(0,
this, &MainApplication::postLaunch);
395 QDesktopServices::unsetUrlHandler(
QSL(
"http"));
396 QDesktopServices::unsetUrlHandler(
QSL(
"https"));
397 QDesktopServices::unsetUrlHandler(
QSL(
"ftp"));
402 QThreadPool::globalInstance()->waitForDone();
406 m_bookmarks =
nullptr;
408 m_cookieJar =
nullptr;
412 m_webProfile =
nullptr;
438 return m_isStartingAfterCrash;
443 return m_windows.count();
453 if (m_lastActiveWindow) {
454 return m_lastActiveWindow.data();
457 return m_windows.isEmpty() ? nullptr : m_windows.at(0);
467 connect(window, &QObject::destroyed,
this, &MainApplication::windowDestroyed);
469 m_windows.prepend(window);
480 setOverrideCursor(Qt::BusyCursor);
493 const auto restoreWindows = restoreData.
windows;
506 if (m_isPrivate || !restoreData.
isValid()) {
520 if (m_restoreManager && m_restoreManager->
isValid()) {
524 delete m_restoreManager;
525 m_restoreManager =
nullptr;
536 return m_proxyStyle ? m_proxyStyle->
name() : QString();
541 m_proxyStyle = style;
586 if (!m_browsingLibrary) {
589 return m_browsingLibrary;
594 return m_networkManager;
599 return m_restoreManager;
604 return m_sessionManager;
609 if (!m_downloadManager) {
612 return m_downloadManager;
617 if (!m_userAgentManager) {
620 return m_userAgentManager;
625 if (!m_searchEnginesManager) {
628 return m_searchEnginesManager;
633 if (!m_closedWindowsManager) {
636 return m_closedWindowsManager;
641 if (!m_protocolHandlerManager) {
644 return m_protocolHandlerManager;
649 if (!m_html5PermissionsManager) {
652 return m_html5PermissionsManager;
657 if (!m_siteSettingsManager) {
660 return m_siteSettingsManager;
665 if (!m_desktopNotifications) {
668 return m_desktopNotifications;
678 return m_webProfile->settings();
696 s_testMode = enabled;
711 if (
auto* act = qobject_cast<QAction*>(sender())) {
712 url = act->data().toUrl();
716 args.append(
QSL(
"--private-browsing"));
719 if (!url.isEmpty()) {
720 args << QString::fromUtf8(url.toEncoded());
723 if (!QProcess::startDetached(applicationFilePath(), args)) {
724 qWarning() <<
"MainApplication: Cannot start new browser process for private browsing!" << applicationFilePath() << args;
730 const QString userCssFile =
Settings().
value(
QSL(
"Web-Browser-Settings/userStyleSheet"), QString()).toString();
731 setUserStyleSheet(userCssFile);
736 QApplication::restoreOverrideCursor();
747 if (m_downloadManager && !m_downloadManager->
canClose()) {
748 m_downloadManager->
show();
753 Q_EMIT window->aboutToClose();
756 if (m_sessionManager && m_windows.count() > 0) {
778void MainApplication::postLaunch()
780 if (m_postLaunchActions.contains(OpenDownloadManager)) {
784 if (m_postLaunchActions.contains(OpenNewTab)) {
788 if (m_postLaunchActions.contains(ToggleFullScreen)) {
795 QTimer::singleShot(5000,
this, &MainApplication::runDeferredPostLaunchActions);
801 restoreData.
windows.reserve(m_windows.count());
806 if (m_restoreManager && m_restoreManager->
isValid()) {
807 QDataStream stream(&restoreData.
crashedSession, QIODevice::WriteOnly);
814 QDataStream stream(&data, QIODevice::WriteOnly);
817 stream << restoreData;
822void MainApplication::saveSettings()
837 bool deleteCache = settings.
value(
QSL(
"deleteCacheOnClose"),
false).toBool();
838 bool deleteHistory = settings.
value(
QSL(
"deleteHistoryOnClose"),
false).toBool();
839 bool deleteHtml5Storage = settings.
value(
QSL(
"deleteHTML5StorageOnClose"),
false).toBool();
843 bool deleteCookies = settings.
value(
QSL(
"deleteCookiesOnClose"),
false).toBool();
849 if (deleteHtml5Storage) {
869void MainApplication::messageReceived(
const QString &message)
874 if (message.startsWith(QLatin1String(
"URL:"))) {
875 const QUrl url = QUrl::fromUserInput(message.mid(4));
879 else if (message.startsWith(QLatin1String(
"ACTION:"))) {
880 const QString text = message.mid(7);
881 if (text == QLatin1String(
"NewTab")) {
884 else if (text == QLatin1String(
"NewWindow")) {
887 else if (text == QLatin1String(
"ShowDownloadManager")) {
891 else if (text == QLatin1String(
"ToggleFullScreen") && actWin) {
895 else if (text.startsWith(QLatin1String(
"OpenUrlInCurrentTab"))) {
896 actUrl = QUrl::fromUserInput(text.mid(19));
898 else if (text.startsWith(QLatin1String(
"OpenUrlInNewWindow"))) {
916 actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
918 actWin->activateWindow();
921 auto* win = qobject_cast<BrowserWindow*>(actWin);
923 if (win && !actUrl.isEmpty()) {
924 win->loadAddress(actUrl);
928void MainApplication::windowDestroyed(QObject* window)
932 Q_ASSERT(m_windows.contains(
static_cast<BrowserWindow*
>(window)));
937void MainApplication::onFocusChanged()
939 auto* activeBrowserWindow = qobject_cast<BrowserWindow*>(activeWindow());
941 if (activeBrowserWindow) {
942 m_lastActiveWindow = activeBrowserWindow;
948void MainApplication::runDeferredPostLaunchActions()
950 checkDefaultWebBrowser();
951 checkOptimizeDatabase();
954void MainApplication::downloadRequested(QWebEngineDownloadRequest *download)
959void MainApplication::loadSettings()
966 loadTheme(activeTheme);
968 QWebEngineSettings*
webSettings = m_webProfile->settings();
973 webSettings->setAttribute(QWebEngineSettings::LocalStorageEnabled, settings.
value(
QSL(
"HTML5StorageEnabled"),
true).toBool());
974 webSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.
value(
QSL(
"allowPlugins"),
true).toBool());
975 webSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.
value(
QSL(
"allowJavaScript"),
true).toBool());
976 webSettings->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, settings.
value(
QSL(
"allowJavaScriptOpenWindow"),
false).toBool());
977 webSettings->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, settings.
value(
QSL(
"allowJavaScriptAccessClipboard"),
true).toBool());
978 webSettings->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, settings.
value(
QSL(
"IncludeLinkInFocusChain"),
false).toBool());
979 webSettings->setAttribute(QWebEngineSettings::XSSAuditingEnabled, settings.
value(
QSL(
"XSSAuditing"),
false).toBool());
980 webSettings->setAttribute(QWebEngineSettings::PrintElementBackgrounds, settings.
value(
QSL(
"PrintElementBackground"),
true).toBool());
981 webSettings->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, settings.
value(
QSL(
"SpatialNavigation"),
false).toBool());
982 webSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.
value(
QSL(
"AnimateScrolling"),
true).toBool());
983 webSettings->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled,
false);
984 webSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled,
true);
985 webSettings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls,
true);
986 webSettings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled,
false);
988 webSettings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, settings.
value(
QSL(
"allowJavaScriptActivateWindow"),
false).toBool());
990 webSettings->setAttribute(QWebEngineSettings::JavascriptCanPaste, settings.
value(
QSL(
"allowJavaScriptPaste"),
true).toBool());
991 webSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, settings.
value(
QSL(
"DisableVideoAutoPlay"),
false).toBool());
992 webSettings->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, settings.
value(
QSL(
"WebRTCPublicIpOnly"),
true).toBool());
993 webSettings->setUnknownUrlSchemePolicy(QWebEngineSettings::AllowAllUnknownUrlSchemes);
994 webSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, settings.
value(
QSL(
"DNSPrefetch"),
true).toBool());
995 webSettings->setAttribute(QWebEngineSettings::PdfViewerEnabled, settings.
value(
QSL(
"intPDFViewer"),
false).toBool());
996 webSettings->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, settings.
value(
QSL(
"screenCaptureEnabled"),
false).toBool());
998#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(6, 6, 0)
999 webSettings->setAttribute(QWebEngineSettings::ReadingFromCanvasEnabled, settings.
value(
QSL(
"readingFromCanvasEnabled"),
true).toBool());
1001#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(6, 7, 0)
1002 webSettings->setAttribute(QWebEngineSettings::ForceDarkMode, settings.
value(
QSL(
"forceDarkMode"),
false).toBool());
1007 setWheelScrollLines(settings.
value(
QSL(
"wheelScrollLines"), wheelScrollLines()).toInt());
1009 const QString userCss = settings.
value(
QSL(
"userStyleSheet"), QString()).toString();
1012 setUserStyleSheet(userCss);
1015 webSettings->setFontFamily(QWebEngineSettings::StandardFont, settings.
value(
QSL(
"StandardFont"),
webSettings->fontFamily(QWebEngineSettings::StandardFont)).toString());
1016 webSettings->setFontFamily(QWebEngineSettings::CursiveFont, settings.
value(
QSL(
"CursiveFont"),
webSettings->fontFamily(QWebEngineSettings::CursiveFont)).toString());
1017 webSettings->setFontFamily(QWebEngineSettings::FantasyFont, settings.
value(
QSL(
"FantasyFont"),
webSettings->fontFamily(QWebEngineSettings::FantasyFont)).toString());
1018 webSettings->setFontFamily(QWebEngineSettings::FixedFont, settings.
value(
QSL(
"FixedFont"),
webSettings->fontFamily(QWebEngineSettings::FixedFont)).toString());
1019 webSettings->setFontFamily(QWebEngineSettings::SansSerifFont, settings.
value(
QSL(
"SansSerifFont"),
webSettings->fontFamily(QWebEngineSettings::SansSerifFont)).toString());
1020 webSettings->setFontFamily(QWebEngineSettings::SerifFont, settings.
value(
QSL(
"SerifFont"),
webSettings->fontFamily(QWebEngineSettings::SerifFont)).toString());
1021 webSettings->setFontSize(QWebEngineSettings::DefaultFontSize, settings.
value(
QSL(
"DefaultFontSize"), 15).toInt());
1022 webSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, settings.
value(
QSL(
"FixedFontSize"), 14).toInt());
1023 webSettings->setFontSize(QWebEngineSettings::MinimumFontSize, settings.
value(
QSL(
"MinimumFontSize"), 3).toInt());
1024 webSettings->setFontSize(QWebEngineSettings::MinimumLogicalFontSize, settings.
value(
QSL(
"MinimumLogicalFontSize"), 5).toInt());
1027 QWebEngineProfile* profile = m_webProfile;
1028 profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
1034 const QString &cachePath = settings.
value(
QSL(
"Web-Browser-Settings/CachePath"), defaultPath).toString();
1035 profile->setCachePath(cachePath);
1037 const bool allowCache = settings.
value(
QSL(
"Web-Browser-Settings/AllowLocalCache"),
true).toBool();
1038 profile->setHttpCacheType(allowCache ? QWebEngineProfile::DiskHttpCache : QWebEngineProfile::MemoryHttpCache);
1040 const int cacheSize = settings.
value(
QSL(
"Web-Browser-Settings/LocalCacheSize"), 50).toInt() * 1000 * 1000;
1041 profile->setHttpCacheMaximumSize(cacheSize);
1044 profile->setSpellCheckEnabled(settings.
value(
QSL(
"Enabled"),
false).toBool());
1045 profile->setSpellCheckLanguages(settings.
value(
QSL(
"Languages")).toStringList());
1053 if (m_downloadManager) {
1062void MainApplication::loadTheme(
const QString &name)
1066 if (activeThemePath.isEmpty()) {
1067 qWarning() <<
"Cannot load theme " << name;
1073#if defined(Q_OS_MACOS)
1075#elif defined(Q_OS_UNIX)
1077#elif defined(Q_OS_WIN) || defined(Q_OS_OS2)
1081 if (isRightToLeft()) {
1091 QString relativePath = QDir::current().relativeFilePath(activeThemePath);
1092 qss.replace(QRegularExpression(
QSL(
"url\\s*\\(\\s*([^\\*:\\);]+)\\s*\\)")),
QSL(
"url(%1/\\1)").arg(relativePath));
1096void MainApplication::checkDefaultWebBrowser()
1102#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
1110 bool checkAgain =
true;
1112 if (!associationManager()->isDefaultForAllCapabilities()) {
1114 dialog.setDefaultButton(QMessageBox::Yes);
1115 dialog.setText(tr(
"Falkon is not currently your default browser. Would you like to make it your default browser?"));
1116 dialog.setCheckBoxText(tr(
"Always perform this check when starting Falkon."));
1117 dialog.setDefaultCheckState(Qt::Checked);
1118 dialog.setWindowTitle(tr(
"Default Browser"));
1119 dialog.setIcon(QMessageBox::Warning);
1121 if (dialog.exec() == QMessageBox::Yes) {
1122 if (!
mApp->associationManager()->showNativeDefaultAppSettingsUi())
1123 mApp->associationManager()->registerAllAssociation();
1126 checkAgain = dialog.isChecked();
1129 settings.
setValue(
QSL(
"Web-Browser-Settings/CheckDefaultBrowser"), checkAgain);
1133void MainApplication::checkOptimizeDatabase()
1137 const int numberOfRuns = settings.
value(
QSL(
"RunsWithoutOptimizeDb"), 0).toInt();
1138 settings.
setValue(
QSL(
"RunsWithoutOptimizeDb"), numberOfRuns + 1);
1140 if (numberOfRuns > 20) {
1141 std::cout <<
"Optimizing database..." << std::endl;
1143 settings.
setValue(
QSL(
"RunsWithoutOptimizeDb"), 0);
1149void MainApplication::registerAllowedSchemes()
1151 for (
const QString &schemeName : std::as_const(
qzSettings->allowedSchemes)) {
1152 if (
qzSettings->blockedSchemes.contains(schemeName)) {
1155 QWebEngineUrlScheme scheme(schemeName.toUtf8());
1156 scheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
1157 scheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
1158 QWebEngineUrlScheme::registerScheme(scheme);
1162void MainApplication::setupUserScripts()
1165 QWebEngineScript script;
1166 script.setName(
QSL(
"_falkon_webchannel"));
1167 script.setInjectionPoint(QWebEngineScript::DocumentCreation);
1169 script.setRunsOnSubFrames(
true);
1171 m_webProfile->scripts()->insert(script);
1174 QWebEngineScript falkonRestore;
1177 m_webProfile->scripts()->insert(falkonRestore);
1180 QWebEngineScript falkonSpeedDial;
1183 m_webProfile->scripts()->insert(falkonSpeedDial);
1186 QWebEngineScript documentWindowAddons;
1187 documentWindowAddons.setName(
QSL(
"_falkon_window_object"));
1188 documentWindowAddons.setInjectionPoint(QWebEngineScript::DocumentCreation);
1190 documentWindowAddons.setRunsOnSubFrames(
true);
1192 m_webProfile->scripts()->insert(documentWindowAddons);
1195void MainApplication::setUserStyleSheet(
const QString &filePath)
1199#if !defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
1201 QString highlightColor;
1202 QString highlightedTextColor;
1204 highlightColor = QLatin1String(
"#b6d6fc");
1205 highlightedTextColor = QLatin1String(
"#000");
1207 QPalette pal = style()->standardPalette();
1208 highlightColor = pal.color(QPalette::Highlight).name();
1209 highlightedTextColor = pal.color(QPalette::HighlightedText).name();
1211 userCss += QString(
"::selection {background: %1; color: %2;} ").arg(highlightColor, highlightedTextColor);
1216 const QString name = QStringLiteral(
"_falkon_userstylesheet");
1217 for (
const QWebEngineScript &oldScript : m_webProfile->scripts()->find(name)) {
1218 m_webProfile->scripts()->remove(oldScript);
1221 if (userCss.isEmpty())
1224 QWebEngineScript script;
1225 script.setName(name);
1226 script.setInjectionPoint(QWebEngineScript::DocumentReady);
1228 script.setRunsOnSubFrames(
true);
1230 m_webProfile->scripts()->insert(script);
1233void MainApplication::createJumpList()
1236 QWinJumpList *jumpList =
new QWinJumpList(
this);
1240 QWinJumpListCategory *frequent = jumpList->frequent();
1241 frequent->setVisible(
true);
1242 const QVector<HistoryEntry> mostList = m_history->
mostVisited(7);
1244 frequent->addLink(
IconProvider::iconForUrl(entry.url), entry.title, applicationFilePath(), QStringList{(QString::fromUtf8entry.url.toEncoded())});
1248 QWinJumpListCategory *tasks = jumpList->tasks();
1249 tasks->setVisible(
true);
1256void MainApplication::initPulseSupport()
1258 qputenv(
"PULSE_PROP_OVERRIDE_application.name",
"Falkon");
1259 qputenv(
"PULSE_PROP_OVERRIDE_application.icon_name",
"falkon");
1260 qputenv(
"PULSE_PROP_OVERRIDE_media.icon_name",
"falkon");
1263#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
1266 if (!m_registerQAppAssociation) {
1267 QString desc = tr(
"Falkon is a new and very fast Qt web browser. Falkon is licensed under GPL version 3 or (at your option) any later version. It is based on QtWebEngine and Qt Framework.");
1268 QString fileIconPath = QApplication::applicationFilePath() +
QSL(
",1");
1269 QString appIconPath = QApplication::applicationFilePath() +
QSL(
",0");
1270 m_registerQAppAssociation =
new RegisterQAppAssociation(
QSL(
"Falkon"), QApplication::applicationFilePath(), appIconPath, desc,
this);
1277 return m_registerQAppAssociation;
1282#include <QFileOpenEvent>
1284bool MainApplication::event(QEvent* e)
1286 switch (e->type()) {
1287 case QEvent::FileOpen: {
1288 QFileOpenEvent *ev =
static_cast<QFileOpenEvent*
>(e);
1289 if (!ev->url().isEmpty()) {
1291 }
else if (!ev->file().isEmpty()) {
1292 addNewTab(QUrl::fromLocalFile(ev->file()));
1299 case QEvent::ApplicationActivate:
1300 if (!activeWindow() && m_windows.isEmpty())
1308 return QtSingleApplication::event(e);
TabWidget * tabWidget() const
void restoreWindow(const SavedWindow &window)
static void clearLocalStorage()
QByteArray saveState() const
void restoreState(const QByteArray &state)
ActionPairList getActions()
void deleteAllCookies(bool deleteAll=true)
static void setPortableVersion()
static QString path(Path type)
static QString currentProfilePath()
static QString locate(Path type, const QString &file)
void download(QWebEngineDownloadRequest *downloadItem)
void setSaving(bool state)
QVector< HistoryEntry > mostVisited(int count)
static QIcon iconForUrl(const QUrl &url, bool allowNull=false)
static QIcon privateBrowsingIcon()
static IconProvider * instance()
static QIcon newWindowIcon()
void clearOldIconsInDatabase()
static QIcon newTabIcon()
void saveIconsToDatabase()
QString styleName() const
void restoreOverrideCursor()
void startPrivateBrowsing(const QUrl &startUrl=QUrl())
AfterLaunch afterLaunch() const
static bool isTestModeEnabled()
ProtocolHandlerManager * protocolHandlerManager()
void activeWindowChanged(BrowserWindow *window)
void setProxyStyle(ProxyStyle *style)
RestoreManager * restoreManager()
void openSession(BrowserWindow *window, RestoreData &restoreData)
SessionManager * sessionManager()
MainApplication(int &argc, char **argv)
QByteArray wmClass() const
QWebEngineSettings * webSettings() const
ClosedWindowsManager * closedWindowsManager()
DownloadManager * downloadManager()
HTML5PermissionsManager * html5PermissionsManager()
bool restoreSession(BrowserWindow *window, RestoreData restoreData)
UserAgentManager * userAgentManager()
DesktopNotificationsFactory * desktopNotifications()
QList< BrowserWindow * > windows() const
QByteArray saveState() const
SearchEnginesManager * searchEnginesManager()
NetworkManager * networkManager()
BrowserWindow * createWindow(Qz::BrowserWindowType type, const QUrl &startUrl=QUrl())
static MainApplication * instance()
SiteSettingsManager * siteSettingsManager()
void addNewTab(const QUrl &url=QUrl())
bool isStartingAfterCrash() const
void destroyRestoreManager()
static void setTestModeEnabled(bool enabled)
BrowserWindow * getWindow() const
BrowsingLibrary * browsingLibrary()
QWebEngineProfile * webProfile() const
void reloadUserStyleSheet()
static void registerSchemes()
void initCurrentProfile(const QString &profileName)
static QString currentProfile()
The QtSingleApplication class provides an API to detect and communicate with running instances of an ...
bool sendMessage(const QString &message, int timeout=5000)
void setAppId(const QString &id)
RestoreData restoreData() const
static QString setCss(const QString &css)
static QString setupWindowObject()
static QString setupWebChannel()
static QString setupSpeedDial()
void backupSavedSessions()
QString askSessionFromUser()
void autoSaveLastSession()
void beginGroup(const QString &prefix)
static QSettings * globalSettings()
QVariant value(const QString &key, const QVariant &defaultValue=QVariant())
void setValue(const QString &key, const QVariant &defaultValue=QVariant())
static void createSettings(const QString &fileName)
static void syncSettings()
void disableWindowTabbing()
int value(const QColor &c)
@ CL_StartPrivateBrowsing
FALKON_EXPORT const char * VERSION
#define DEFAULT_THEME_NAME
#define DEFAULT_CHECK_DEFAULTBROWSER
QVector< BrowserWindow::SavedWindow > windows
QByteArray crashedSession