mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
feat: remember splitter state
This commit is contained in:
@@ -73,6 +73,7 @@ namespace NekoRay {
|
|||||||
_add(new configItem("log_ignore", &log_ignore, itemType::stringList));
|
_add(new configItem("log_ignore", &log_ignore, itemType::stringList));
|
||||||
_add(new configItem("start_minimal", &start_minimal, itemType::boolean));
|
_add(new configItem("start_minimal", &start_minimal, itemType::boolean));
|
||||||
_add(new configItem("max_log_line", &max_log_line, itemType::integer));
|
_add(new configItem("max_log_line", &max_log_line, itemType::integer));
|
||||||
|
_add(new configItem("splitter_state", &splitter_state, itemType::string));
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
_add(new configItem("vpn_already_admin", &vpn_already_admin, itemType::boolean));
|
_add(new configItem("vpn_already_admin", &vpn_already_admin, itemType::boolean));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ namespace NekoRay {
|
|||||||
QStringList log_ignore = {};
|
QStringList log_ignore = {};
|
||||||
bool start_minimal = false;
|
bool start_minimal = false;
|
||||||
int max_log_line = 200;
|
int max_log_line = 200;
|
||||||
|
QString splitter_state = "";
|
||||||
|
|
||||||
// Subscription
|
// Subscription
|
||||||
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QStringList SplitLinesSkipSharp(const QString &_string) {
|
|||||||
return newLines;
|
return newLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DecodeB64IfValid(const QString &input, QByteArray::Base64Options options) {
|
QByteArray DecodeB64IfValid(const QString &input, QByteArray::Base64Options options) {
|
||||||
Qt515Base64::Base64Options newOptions = Qt515Base64::Base64Option::AbortOnBase64DecodingErrors;
|
Qt515Base64::Base64Options newOptions = Qt515Base64::Base64Option::AbortOnBase64DecodingErrors;
|
||||||
if (options.testFlag(QByteArray::Base64UrlEncoding)) newOptions |= Qt515Base64::Base64Option::Base64UrlEncoding;
|
if (options.testFlag(QByteArray::Base64UrlEncoding)) newOptions |= Qt515Base64::Base64Option::Base64UrlEncoding;
|
||||||
if (options.testFlag(QByteArray::OmitTrailingEquals)) newOptions |= Qt515Base64::Base64Option::OmitTrailingEquals;
|
if (options.testFlag(QByteArray::OmitTrailingEquals)) newOptions |= Qt515Base64::Base64Option::OmitTrailingEquals;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ QStringList SplitLinesSkipSharp(const QString &_string);
|
|||||||
|
|
||||||
// Base64
|
// Base64
|
||||||
|
|
||||||
QString DecodeB64IfValid(const QString &input, QByteArray::Base64Options options = QByteArray::Base64Option::Base64Encoding);
|
QByteArray DecodeB64IfValid(const QString &input, QByteArray::Base64Options options = QByteArray::Base64Option::Base64Encoding);
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace NekoRay::sub {
|
|||||||
if (ent->bean->version == -114514) return;
|
if (ent->bean->version == -114514) return;
|
||||||
auto j = DecodeB64IfValid(link.fragment().toUtf8(), QByteArray::Base64UrlEncoding);
|
auto j = DecodeB64IfValid(link.fragment().toUtf8(), QByteArray::Base64UrlEncoding);
|
||||||
if (j.isEmpty()) return;
|
if (j.isEmpty()) return;
|
||||||
ent->bean->FromJsonBytes(j.toUtf8());
|
ent->bean->FromJsonBytes(j);
|
||||||
MW_show_log("nekoray format: " + ent->bean->DisplayTypeAndName());
|
MW_show_log("nekoray format: " + ent->bean->DisplayTypeAndName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(ui->toolButton_update, &QToolButton::clicked, this, [=] { runOnNewThread([=] { CheckUpdate(); }); });
|
connect(ui->toolButton_update, &QToolButton::clicked, this, [=] { runOnNewThread([=] { CheckUpdate(); }); });
|
||||||
|
|
||||||
// Setup log UI
|
// Setup log UI
|
||||||
|
ui->splitter->restoreState(DecodeB64IfValid(NekoRay::dataStore->splitter_state));
|
||||||
new SyntaxHighlighter(false, qvLogDocument);
|
new SyntaxHighlighter(false, qvLogDocument);
|
||||||
qvLogDocument->setUndoRedoEnabled(false);
|
qvLogDocument->setUndoRedoEnabled(false);
|
||||||
ui->masterLogBrowser->setUndoRedoEnabled(false);
|
ui->masterLogBrowser->setUndoRedoEnabled(false);
|
||||||
@@ -588,20 +589,24 @@ void MainWindow::on_menu_hotkey_settings_triggered() {
|
|||||||
|
|
||||||
void MainWindow::on_commitDataRequest() {
|
void MainWindow::on_commitDataRequest() {
|
||||||
qDebug() << "Start of data save";
|
qDebug() << "Start of data save";
|
||||||
|
//
|
||||||
if (!isMaximized()) {
|
if (!isMaximized()) {
|
||||||
auto olds = NekoRay::dataStore->mw_size;
|
auto olds = NekoRay::dataStore->mw_size;
|
||||||
auto news = QString("%1x%2").arg(size().width()).arg(size().height());
|
auto news = QString("%1x%2").arg(size().width()).arg(size().height());
|
||||||
if (olds != news) {
|
if (olds != news) {
|
||||||
NekoRay::dataStore->mw_size = news;
|
NekoRay::dataStore->mw_size = news;
|
||||||
NekoRay::dataStore->Save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
NekoRay::dataStore->splitter_state = ui->splitter->saveState().toBase64();
|
||||||
|
//
|
||||||
auto last_id = NekoRay::dataStore->started_id;
|
auto last_id = NekoRay::dataStore->started_id;
|
||||||
neko_stop();
|
neko_stop();
|
||||||
if (NekoRay::dataStore->remember_enable && last_id >= 0) {
|
if (NekoRay::dataStore->remember_enable && last_id >= 0) {
|
||||||
NekoRay::dataStore->UpdateStartedId(last_id);
|
NekoRay::dataStore->remember_id = last_id;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
NekoRay::dataStore->Save();
|
||||||
qDebug() << "End of data save";
|
qDebug() << "End of data save";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1497,7 +1502,6 @@ void MainWindow::on_masterLogBrowser_customContextMenuRequested(const QPoint &po
|
|||||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
|
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
|
||||||
if (event->type() == QEvent::MouseButtonPress) {
|
if (event->type() == QEvent::MouseButtonPress) {
|
||||||
auto mouseEvent = dynamic_cast<QMouseEvent *>(event);
|
auto mouseEvent = dynamic_cast<QMouseEvent *>(event);
|
||||||
|
|
||||||
if (obj == ui->label_running && mouseEvent->button() == Qt::LeftButton && running != nullptr) {
|
if (obj == ui->label_running && mouseEvent->button() == Qt::LeftButton && running != nullptr) {
|
||||||
speedtest_current();
|
speedtest_current();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user