mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
minor refactor
This commit is contained in:
2
3rdparty/WinCommander.cpp
vendored
2
3rdparty/WinCommander.cpp
vendored
@@ -60,7 +60,7 @@ uint WinCommander::runProcessElevated(const QString &path,
|
||||
|
||||
LPCTSTR pszParameters = (LPCTSTR)params.utf16();
|
||||
QString dir;
|
||||
if (workingDir.isEmpty())
|
||||
if (workingDir.count() == 0)
|
||||
dir = QDir::toNativeSeparators(QDir::currentPath());
|
||||
else
|
||||
dir = QDir::toNativeSeparators(workingDir);
|
||||
|
||||
4
3rdparty/base64.cpp
vendored
4
3rdparty/base64.cpp
vendored
@@ -1,5 +1,9 @@
|
||||
#include "base64.h"
|
||||
|
||||
#ifndef qsizetype
|
||||
#define qsizetype size_t
|
||||
#endif
|
||||
|
||||
namespace Qt515Base64 {
|
||||
namespace {
|
||||
struct fromBase64_helper_result {
|
||||
|
||||
11
3rdparty/fix_old_qt.h
vendored
Normal file
11
3rdparty/fix_old_qt.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
|
||||
inline QString qEnvironmentVariable(const char *varName) {
|
||||
return qgetenv(varName);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -16,9 +16,10 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QProcess>
|
||||
|
||||
#include "3rdparty/fix_old_qt.h"
|
||||
#include "3rdparty/qv2ray/wrapper.hpp"
|
||||
#include "fmt/Preset.hpp"
|
||||
#include "main/NekoRay.hpp"
|
||||
#include "main/NekoGui.hpp"
|
||||
|
||||
#define QV_MODULE_NAME "SystemProxy"
|
||||
|
||||
@@ -253,7 +254,7 @@ namespace Qv2ray::components::proxy {
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString str = NekoRay::dataStore->system_proxy_format;
|
||||
QString str = NekoGui::dataStore->system_proxy_format;
|
||||
if (str.isEmpty()) str = Preset::Windows::system_proxy_format[0];
|
||||
str = str.replace("{ip}", address)
|
||||
.replace("{http_port}", Int2String(httpPort))
|
||||
|
||||
2
3rdparty/qv2ray/v2/ui/LogHighlighter.cpp
vendored
2
3rdparty/qv2ray/v2/ui/LogHighlighter.cpp
vendored
@@ -118,7 +118,7 @@ namespace Qv2ray::ui {
|
||||
}
|
||||
|
||||
void SyntaxHighlighter::highlightBlock(const QString &text) {
|
||||
for (const HighlightingRule &rule: qAsConst(highlightingRules)) {
|
||||
for (const HighlightingRule &rule: highlightingRules) {
|
||||
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
||||
|
||||
while (matchIterator.hasNext()) {
|
||||
|
||||
56
3rdparty/qv2ray/v2/ui/LogHighlighter.hpp
vendored
56
3rdparty/qv2ray/v2/ui/LogHighlighter.hpp
vendored
@@ -55,36 +55,38 @@
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextDocument>
|
||||
|
||||
namespace Qv2ray::ui {
|
||||
class SyntaxHighlighter : public QSyntaxHighlighter {
|
||||
Q_OBJECT
|
||||
namespace Qv2ray {
|
||||
namespace ui {
|
||||
class SyntaxHighlighter : public QSyntaxHighlighter {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SyntaxHighlighter(bool darkMode, QTextDocument *parent = nullptr);
|
||||
public:
|
||||
explicit SyntaxHighlighter(bool darkMode, QTextDocument *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString &text) override;
|
||||
protected:
|
||||
void highlightBlock(const QString &text) override;
|
||||
|
||||
private:
|
||||
struct HighlightingRule {
|
||||
QRegularExpression pattern;
|
||||
QTextCharFormat format;
|
||||
private:
|
||||
struct HighlightingRule {
|
||||
QRegularExpression pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
|
||||
QTextCharFormat tcpudpFormat;
|
||||
QTextCharFormat dateFormat;
|
||||
QTextCharFormat acceptedFormat;
|
||||
QTextCharFormat rejectedFormat;
|
||||
QTextCharFormat failedFormat;
|
||||
QTextCharFormat warningFormat;
|
||||
QTextCharFormat warningFormat2;
|
||||
QTextCharFormat infoFormat;
|
||||
QTextCharFormat debugFormat;
|
||||
QTextCharFormat timeFormat;
|
||||
QTextCharFormat ipHostFormat;
|
||||
QTextCharFormat v2rayComponentFormat;
|
||||
};
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
|
||||
QTextCharFormat tcpudpFormat;
|
||||
QTextCharFormat dateFormat;
|
||||
QTextCharFormat acceptedFormat;
|
||||
QTextCharFormat rejectedFormat;
|
||||
QTextCharFormat failedFormat;
|
||||
QTextCharFormat warningFormat;
|
||||
QTextCharFormat warningFormat2;
|
||||
QTextCharFormat infoFormat;
|
||||
QTextCharFormat debugFormat;
|
||||
QTextCharFormat timeFormat;
|
||||
QTextCharFormat ipHostFormat;
|
||||
QTextCharFormat v2rayComponentFormat;
|
||||
};
|
||||
} // namespace Qv2ray::ui
|
||||
} // namespace ui
|
||||
} // namespace Qv2ray
|
||||
|
||||
using namespace Qv2ray::ui;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Qv2ray::ui::widgets {
|
||||
c->setWidget(this);
|
||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
QObject::connect(c, QOverload<const QString &>::of(&QCompleter::activated), this, &AutoCompleteTextEdit::insertCompletion);
|
||||
QObject::connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &AutoCompleteTextEdit::insertCompletion);
|
||||
}
|
||||
|
||||
AutoCompleteTextEdit::~AutoCompleteTextEdit() {
|
||||
|
||||
40
3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.hpp
vendored
40
3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.hpp
vendored
@@ -55,27 +55,31 @@ QT_BEGIN_NAMESPACE
|
||||
class QCompleter;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Qv2ray::ui::widgets {
|
||||
class AutoCompleteTextEdit : public QPlainTextEdit {
|
||||
Q_OBJECT
|
||||
namespace Qv2ray {
|
||||
namespace ui {
|
||||
namespace widgets {
|
||||
class AutoCompleteTextEdit : public QPlainTextEdit {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AutoCompleteTextEdit(const QString &prefix, const QStringList &sourceStrings, QWidget *parent = nullptr);
|
||||
~AutoCompleteTextEdit();
|
||||
public:
|
||||
AutoCompleteTextEdit(const QString &prefix, const QStringList &sourceStrings, QWidget *parent = nullptr);
|
||||
~AutoCompleteTextEdit();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void insertCompletion(const QString &completion);
|
||||
private slots:
|
||||
void insertCompletion(const QString &completion);
|
||||
|
||||
private:
|
||||
QString lineUnderCursor() const;
|
||||
QString wordUnderCursor() const;
|
||||
private:
|
||||
QString lineUnderCursor() const;
|
||||
QString wordUnderCursor() const;
|
||||
|
||||
QString prefix;
|
||||
QCompleter *c = nullptr;
|
||||
};
|
||||
} // namespace Qv2ray::ui::widgets
|
||||
QString prefix;
|
||||
QCompleter *c = nullptr;
|
||||
};
|
||||
} // namespace widgets
|
||||
} // namespace ui
|
||||
} // namespace Qv2ray
|
||||
using namespace Qv2ray::ui::widgets;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "w_JsonEditor.hpp"
|
||||
|
||||
#include "main/NekoRay.hpp"
|
||||
#include "main/NekoGui.hpp"
|
||||
|
||||
JsonEditor::JsonEditor(const QJsonObject& rootObject, QWidget* parent) : QDialog(parent) {
|
||||
setupUi(this);
|
||||
|
||||
10
3rdparty/qv2ray/wrapper.hpp
vendored
10
3rdparty/qv2ray/wrapper.hpp
vendored
@@ -7,10 +7,12 @@
|
||||
|
||||
#define LOG(...) Qv2ray::base::log_internal(__VA_ARGS__)
|
||||
#define DEBUG(...) Qv2ray::base::log_internal(__VA_ARGS__)
|
||||
namespace Qv2ray::base {
|
||||
template<typename... T>
|
||||
inline void log_internal(T... v) {}
|
||||
} // namespace Qv2ray::base
|
||||
namespace Qv2ray {
|
||||
namespace base {
|
||||
template<typename... T>
|
||||
inline void log_internal(T... v) {}
|
||||
} // namespace base
|
||||
} // namespace Qv2ray
|
||||
|
||||
#define JsonToString(a) QJsonObject2QString(a, false)
|
||||
#define JsonFromString(a) QString2QJsonObject(a)
|
||||
|
||||
Reference in New Issue
Block a user