mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:50:12 +08:00
feat: Improve log visibility and improve themes
This commit is contained in:
parent
fa5998f89f
commit
cbfcc88f83
@ -1,3 +0,0 @@
|
|||||||
QMessageBox {
|
|
||||||
messagebox-text-interaction-flags: 5;
|
|
||||||
}
|
|
||||||
@ -17,7 +17,6 @@
|
|||||||
<qresource prefix="/neko">
|
<qresource prefix="/neko">
|
||||||
<file alias="nekobox.png">public/nekobox.png</file>
|
<file alias="nekobox.png">public/nekobox.png</file>
|
||||||
<file alias="nekoray.png">public/nekoray.png</file>
|
<file alias="nekoray.png">public/nekoray.png</file>
|
||||||
<file>neko.css</file>
|
|
||||||
<file>vpn/vpn-run-root.sh</file>
|
<file>vpn/vpn-run-root.sh</file>
|
||||||
<file>vpn/sing-box-vpn.json</file>
|
<file>vpn/sing-box-vpn.json</file>
|
||||||
<file>dashboard-notice.html</file>
|
<file>dashboard-notice.html</file>
|
||||||
|
|||||||
@ -9,14 +9,12 @@ ThemeManager *themeManager = new ThemeManager;
|
|||||||
|
|
||||||
extern QString ReadFileText(const QString &path);
|
extern QString ReadFileText(const QString &path);
|
||||||
|
|
||||||
void ThemeManager::ApplyTheme(const QString &theme) {
|
void ThemeManager::ApplyTheme(const QString &theme, bool force) {
|
||||||
auto internal = [=] {
|
|
||||||
|
|
||||||
if (this->system_style_name.isEmpty()) {
|
if (this->system_style_name.isEmpty()) {
|
||||||
this->system_style_name = qApp->style()->name();
|
this->system_style_name = qApp->style()->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->current_theme == theme) {
|
if (this->current_theme == theme && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,9 +25,6 @@ void ThemeManager::ApplyTheme(const QString &theme) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
current_theme = theme;
|
current_theme = theme;
|
||||||
};
|
|
||||||
internal();
|
|
||||||
|
|
||||||
auto nekoray_css = ReadFileText(":/neko/neko.css");
|
emit themeChanged(theme);
|
||||||
qApp->setStyleSheet(qApp->styleSheet().append("\n").append(nekoray_css));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class ThemeManager {
|
#include <QObject>
|
||||||
|
|
||||||
|
class ThemeManager : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QString system_style_name = "";
|
QString system_style_name = "";
|
||||||
QString current_theme = "0"; // int: 0:system 1+:builtin string: QStyleFactory
|
QString current_theme = "0"; // int: 0:system 1+:builtin string: QStyleFactory
|
||||||
|
|
||||||
void ApplyTheme(const QString &theme);
|
void ApplyTheme(const QString &theme, bool force = false);
|
||||||
|
signals:
|
||||||
|
void themeChanged(QString themeName);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ThemeManager *themeManager;
|
extern ThemeManager *themeManager;
|
||||||
|
|||||||
@ -46,6 +46,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QStyleHints>
|
||||||
|
|
||||||
void UI_InitMainWindow() {
|
void UI_InitMainWindow() {
|
||||||
mainwindow = new MainWindow;
|
mainwindow = new MainWindow;
|
||||||
@ -118,17 +119,23 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
|
|
||||||
// Setup log UI
|
// Setup log UI
|
||||||
ui->splitter->restoreState(DecodeB64IfValid(NekoGui::dataStore->splitter_state));
|
ui->splitter->restoreState(DecodeB64IfValid(NekoGui::dataStore->splitter_state));
|
||||||
new SyntaxHighlighter(false, qvLogDocument);
|
new SyntaxHighlighter(qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark, qvLogDocument);
|
||||||
qvLogDocument->setUndoRedoEnabled(false);
|
qvLogDocument->setUndoRedoEnabled(false);
|
||||||
ui->masterLogBrowser->setUndoRedoEnabled(false);
|
ui->masterLogBrowser->setUndoRedoEnabled(false);
|
||||||
ui->masterLogBrowser->setDocument(qvLogDocument);
|
ui->masterLogBrowser->setDocument(qvLogDocument);
|
||||||
ui->masterLogBrowser->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
ui->masterLogBrowser->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||||
{
|
|
||||||
auto font = ui->masterLogBrowser->font();
|
connect(qApp->styleHints(), &QStyleHints::colorSchemeChanged, this, [=](const Qt::ColorScheme& scheme) {
|
||||||
font.setPointSize(9);
|
new SyntaxHighlighter(scheme == Qt::ColorScheme::Dark, qvLogDocument);
|
||||||
ui->masterLogBrowser->setFont(font);
|
themeManager->ApplyTheme(NekoGui::dataStore->theme, true);
|
||||||
qvLogDocument->setDefaultFont(font);
|
});
|
||||||
|
connect(themeManager, &ThemeManager::themeChanged, this, [=](const QString& theme){
|
||||||
|
if (theme.toLower().contains("vista")) {
|
||||||
|
new SyntaxHighlighter(false, qvLogDocument);
|
||||||
|
} else {
|
||||||
|
new SyntaxHighlighter(qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark, qvLogDocument);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
connect(ui->masterLogBrowser->verticalScrollBar(), &QSlider::valueChanged, this, [=](int value) {
|
connect(ui->masterLogBrowser->verticalScrollBar(), &QSlider::valueChanged, this, [=](int value) {
|
||||||
if (ui->masterLogBrowser->verticalScrollBar()->maximum() == value)
|
if (ui->masterLogBrowser->verticalScrollBar()->maximum() == value)
|
||||||
qvLogAutoScoll = true;
|
qvLogAutoScoll = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user