mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
Add "Preffer color scheme" option
BUG: 439891 CCBUG: 497331 Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
b084416f40
commit
4f94d09258
@ -67,6 +67,8 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QtWebEngineWidgetsVersion>
|
#include <QtWebEngineWidgetsVersion>
|
||||||
#include <QtWebEngineCoreVersion>
|
#include <QtWebEngineCoreVersion>
|
||||||
|
#include <QtGuiVersion>
|
||||||
|
#include <QStyleHints>
|
||||||
|
|
||||||
#include <QWebEngineNotification>
|
#include <QWebEngineNotification>
|
||||||
#include <QWebEngineUrlScheme>
|
#include <QWebEngineUrlScheme>
|
||||||
@ -149,10 +151,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QByteArray chromium_flags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
|
|
||||||
chromium_flags.append(" --enable-features=WebRTCPipeWireCapturer");
|
|
||||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags);
|
|
||||||
|
|
||||||
QUrl startUrl;
|
QUrl startUrl;
|
||||||
QString startProfile;
|
QString startProfile;
|
||||||
QStringList messages;
|
QStringList messages;
|
||||||
@ -287,11 +285,8 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||||||
profileManager.initCurrentProfile(startProfile);
|
profileManager.initCurrentProfile(startProfile);
|
||||||
|
|
||||||
Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"));
|
Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"));
|
||||||
if (Settings::globalSettings()->value("Web-Browser-Settings/hardwareAccel", false).toBool()) {
|
|
||||||
chromium_flags.append(" --enable-oop-rasterization --enable-gpu-rasterization --enable-native-gpu-memory-buffers --use-gl=desktop");
|
|
||||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
setChromiumFlags();
|
||||||
NetworkManager::registerSchemes();
|
NetworkManager::registerSchemes();
|
||||||
registerAllowedSchemes();
|
registerAllowedSchemes();
|
||||||
|
|
||||||
@ -412,6 +407,33 @@ MainApplication::~MainApplication()
|
|||||||
Settings::syncSettings();
|
Settings::syncSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainApplication::setChromiumFlags()
|
||||||
|
{
|
||||||
|
QByteArray chromium_flags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
|
||||||
|
chromium_flags.append(" --enable-features=WebRTCPipeWireCapturer");
|
||||||
|
|
||||||
|
if (Settings::globalSettings()->value("Web-Browser-Settings/hardwareAccel", false).toBool()) {
|
||||||
|
chromium_flags.append(" --enable-oop-rasterization --enable-gpu-rasterization --enable-native-gpu-memory-buffers --use-gl=desktop");
|
||||||
|
}
|
||||||
|
|
||||||
|
int prefferColorScheme = Settings::globalSettings()->value("Web-Browser-Settings/prefferColorScheme", Qz::ColorScheme_Auto).toInt();
|
||||||
|
if ( (prefferColorScheme == Qz::ColorScheme_Dark)
|
||||||
|
#if QTGUI_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
|| ((prefferColorScheme == Qz::ColorScheme_Auto) && (styleHints()->colorScheme() == Qt::ColorScheme::Dark))
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
chromium_flags.append(" --blink-settings=preferredColorScheme=0");
|
||||||
|
}
|
||||||
|
else if ((prefferColorScheme == Qz::ColorScheme_Light)
|
||||||
|
#if QTGUI_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
|| ((prefferColorScheme == Qz::ColorScheme_Auto) && (styleHints()->colorScheme() == Qt::ColorScheme::Light))
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
chromium_flags.append(" --blink-settings=preferredColorScheme=1");
|
||||||
|
}
|
||||||
|
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags);
|
||||||
|
}
|
||||||
|
|
||||||
bool MainApplication::isClosing() const
|
bool MainApplication::isClosing() const
|
||||||
{
|
{
|
||||||
return m_isClosing;
|
return m_isClosing;
|
||||||
|
@ -71,6 +71,8 @@ public:
|
|||||||
explicit MainApplication(int &argc, char** argv);
|
explicit MainApplication(int &argc, char** argv);
|
||||||
~MainApplication();
|
~MainApplication();
|
||||||
|
|
||||||
|
void setChromiumFlags();
|
||||||
|
|
||||||
bool isClosing() const;
|
bool isClosing() const;
|
||||||
bool isPrivate() const;
|
bool isPrivate() const;
|
||||||
bool isPortable() const;
|
bool isPortable() const;
|
||||||
|
@ -111,6 +111,12 @@ enum NewTabPositionFlag {
|
|||||||
Q_DECLARE_FLAGS(NewTabPositionFlags, NewTabPositionFlag)
|
Q_DECLARE_FLAGS(NewTabPositionFlags, NewTabPositionFlag)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
|
||||||
|
|
||||||
|
enum ColorScheme {
|
||||||
|
ColorScheme_Auto = 0,
|
||||||
|
ColorScheme_Light,
|
||||||
|
ColorScheme_Dark
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
#include <QWebEngineSettings>
|
#include <QWebEngineSettings>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QtWebEngineWidgetsVersion>
|
#include <QtWebEngineWidgetsVersion>
|
||||||
|
#include <QtGuiVersion>
|
||||||
|
|
||||||
static QString createLanguageItem(const QString &lang)
|
static QString createLanguageItem(const QString &lang)
|
||||||
{
|
{
|
||||||
@ -308,6 +309,19 @@ Preferences::Preferences(BrowserWindow* window)
|
|||||||
ui->forceDarkMode->hide();
|
ui->forceDarkMode->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int prefferColorSchemeSetting = settings.value(QSL("prefferColorScheme"), Qz::ColorScheme_Auto).toInt();
|
||||||
|
#if QTGUI_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
ui->prefferColorScheme->addItem(tr("Auto"), Qz::ColorScheme_Auto);
|
||||||
|
#endif
|
||||||
|
ui->prefferColorScheme->addItem(tr("Light"), Qz::ColorScheme_Light);
|
||||||
|
ui->prefferColorScheme->addItem(tr("Dark"), Qz::ColorScheme_Dark);
|
||||||
|
#if QTGUI_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
if (prefferColorSchemeSetting > 0) {
|
||||||
|
prefferColorSchemeSetting--;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ui->prefferColorScheme->setCurrentIndex(prefferColorSchemeSetting);
|
||||||
|
|
||||||
const auto levels = WebView::zoomLevels();
|
const auto levels = WebView::zoomLevels();
|
||||||
for (int level : levels) {
|
for (int level : levels) {
|
||||||
ui->defaultZoomLevel->addItem(tr("%1%").arg(QString::number(level)));
|
ui->defaultZoomLevel->addItem(tr("%1%").arg(QString::number(level)));
|
||||||
@ -1016,6 +1030,7 @@ void Preferences::saveSettings()
|
|||||||
#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||||
settings.setValue(QSL("forceDarkMode"), ui->forceDarkMode->isChecked());
|
settings.setValue(QSL("forceDarkMode"), ui->forceDarkMode->isChecked());
|
||||||
#endif
|
#endif
|
||||||
|
settings.setValue(QSL("prefferColorScheme"), ui->prefferColorScheme->currentData().toInt());
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
settings.setValue(QSL("CheckDefaultBrowser"), ui->checkDefaultBrowser->isChecked());
|
settings.setValue(QSL("CheckDefaultBrowser"), ui->checkDefaultBrowser->isChecked());
|
||||||
#endif
|
#endif
|
||||||
|
@ -160,7 +160,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>783</width>
|
<width>783</width>
|
||||||
<height>651</height>
|
<height>723</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
@ -1145,6 +1145,33 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_16">
|
||||||
|
<property name="text">
|
||||||
|
<string>Preffer color scheme:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="prefferColorScheme"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_40">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
Loading…
Reference in New Issue
Block a user