organize qt includes

This commit is contained in:
Akash Mozumdar 2019-06-29 08:46:31 +05:30
parent e7b5c1eb0c
commit 4192bfc412
10 changed files with 26 additions and 35 deletions

View File

@ -6,8 +6,6 @@
#include <QDropEvent> #include <QDropEvent>
#include <QMimeData> #include <QMimeData>
#include <QUrl> #include <QUrl>
#include <QLabel>
#include <QMessageBox>
extern const char* EXTENSIONS; extern const char* EXTENSIONS;
extern const char* INVALID_EXTENSION; extern const char* INVALID_EXTENSION;

View File

@ -33,3 +33,5 @@ private:
Ui::ExtenWindow* ui; Ui::ExtenWindow* ui;
}; };
inline HMODULE LoadLibraryOnce(std::wstring fileName) { if (HMODULE module = GetModuleHandleW(fileName.c_str())) return module; return LoadLibraryW(fileName.c_str()); }

View File

@ -3,15 +3,7 @@
#include "defs.h" #include "defs.h"
#include "host/util.h" #include "host/util.h"
#include <shellapi.h> #include <shellapi.h>
#include <QFormLayout>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QSpinBox>
#include <QListWidget>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QMessageBox>
#include <QInputDialog>
#include <QFileDialog> #include <QFileDialog>
extern const char* ATTACH; extern const char* ATTACH;
@ -454,12 +446,12 @@ void MainWindow::FindHooks()
if (!dialog.exec()) return; if (!dialog.exec()) return;
QByteArray pattern = QByteArray::fromHex(patternInput.text().replace("??", QString::number(XX, 16)).toUtf8()); QByteArray pattern = QByteArray::fromHex(patternInput.text().replace("??", QString::number(XX, 16)).toUtf8());
memcpy(sp.pattern, pattern.data(), sp.length = min(pattern.size(), 25)); memcpy(sp.pattern, pattern.data(), sp.length = min(pattern.size(), 25));
try { filter = std::wregex(S(filterInput.text())); } catch (std::regex_error) {} try { filter = S(filterInput.text()); } catch (std::regex_error) {}
} }
else else
{ {
// sp.length is 0 in this branch, so default will be used // sp.length is 0 in this branch, so default will be used
filter = cjkCheckbox.isChecked() ? std::wregex(L"[\\u3000-\\ua000]{4,}") : std::wregex(L"[\\u0020-\\u1000]{4,}"); filter = std::wregex(cjkCheckbox.isChecked() ? L"[\\u3000-\\ua000]{4,}" : L"[\\u0020-\\u1000]{4,}");
} }
auto hooks = std::make_shared<QString>(); auto hooks = std::make_shared<QString>();

View File

@ -3,7 +3,6 @@
#include "qtcommon.h" #include "qtcommon.h"
#include "extenwindow.h" #include "extenwindow.h"
#include "host/host.h" #include "host/host.h"
#include <QSettings>
namespace Ui namespace Ui
{ {

View File

@ -1,17 +1,11 @@
#include "qtcommon.h"
#include "extension.h" #include "extension.h"
#include "ui_extrawindow.h" #include "ui_extrawindow.h"
#include "defs.h" #include "defs.h"
#include <QInputDialog>
#include <QColorDialog> #include <QColorDialog>
#include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QFormLayout>
#include <QLineEdit>
#include <QSpinBox>
#include <QPushButton>
#include <QPainter> #include <QPainter>
#include <QMouseEvent> #include <QMouseEvent>
#include <QSettings>
extern const char* EXTRA_WINDOW_INFO; extern const char* EXTRA_WINDOW_INFO;
extern const char* TOPMOST; extern const char* TOPMOST;
@ -164,7 +158,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{ {
if (!sentenceInfo["current select"]) return false; if (!sentenceInfo["current select"]) return false;
QString qSentence = QString::fromStdWString(sentence); QString qSentence = S(sentence);
if (!window.settings.value(SHOW_ORIGINAL).toBool()) qSentence = qSentence.section('\n', qSentence.count('\n') / 2 + 1); if (!window.settings.value(SHOW_ORIGINAL).toBool()) qSentence = qSentence.section('\n', qSentence.count('\n') / 2 + 1);
QMetaObject::invokeMethod(&window, [=] { window.ui.display->setText(qSentence); }); QMetaObject::invokeMethod(&window, [=] { window.ui.display->setText(qSentence); });

View File

@ -1,10 +1,8 @@
#include "extension.h" #include "qtcommon.h"
#include "extension.h"
#include "util.h" #include "util.h"
#include <fstream> #include <fstream>
#include <QMainWindow>
#include <QLayout>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QPushButton>
extern const char* LUA_INTRO; extern const char* LUA_INTRO;
extern const char* LOAD_LUA_SCRIPT; extern const char* LOAD_LUA_SCRIPT;

View File

@ -61,6 +61,7 @@ void Unescape(std::wstring& text)
if (text[i + 1] == L'r') text[i + 1] = 0x200b; // for some reason \r gets displayed as a newline if (text[i + 1] == L'r') text[i + 1] = 0x200b; // for some reason \r gets displayed as a newline
if (text[i + 1] == L'n') text[i + 1] = L'\n'; if (text[i + 1] == L'n') text[i + 1] = L'\n';
if (text[i + 1] == L't') text[i + 1] = L'\t'; if (text[i + 1] == L't') text[i + 1] = L'\t';
if (text[i + 1] == L'\\') ++i;
} }
} }
} }

View File

@ -1,3 +1,4 @@
#include "qtcommon.h"
#include "extension.h" #include "extension.h"
#include "ui_regexfilter.h" #include "ui_regexfilter.h"
@ -22,12 +23,12 @@ public:
} }
private: private:
void setRegex(QString newRegex) void setRegex(QString regex)
{ {
std::lock_guard l(m); std::lock_guard l(m);
try { regex = newRegex.toStdWString(); } try { ::regex = S(regex); }
catch (std::regex_error) { return ui.output->setText(INVALID_REGEX); } catch (std::regex_error) { return ui.output->setText(INVALID_REGEX); }
ui.output->setText(QString(CURRENT_FILTER).arg(newRegex)); ui.output->setText(QString(CURRENT_FILTER).arg(regex));
} }
Ui::FilterWindow ui; Ui::FilterWindow ui;

View File

@ -1,9 +1,5 @@
#include "qtcommon.h"
#include "extension.h" #include "extension.h"
#include <QMainWindow>
#include <QLayout>
#include <QPushButton>
#include <QListWidget>
#include <QInputDialog>
#include <QKeyEvent> #include <QKeyEvent>
extern const char* THREAD_LINKER; extern const char* THREAD_LINKER;

View File

@ -4,12 +4,22 @@
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <QHash> #include <QHash>
#include <QMainWindow>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QDir> #include <QDir>
#include <QSettings>
#include <QMainWindow>
#include <QDialog>
#include <QLayout>
#include <QFormLayout>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QSpinBox>
#include <QListWidget>
#include <QMessageBox>
#include <QInputDialog>
struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } }; struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } };
inline std::wstring S(const QString& S) { return { S.toStdWString() }; } inline std::wstring S(const QString& S) { return { S.toStdWString() }; }
inline QString S(const std::wstring& S) { return QString::fromStdWString(S); } inline QString S(const std::wstring& S) { return QString::fromStdWString(S); }
inline HMODULE LoadLibraryOnce(std::wstring fileName) { if (HMODULE module = GetModuleHandleW(fileName.c_str())) return module; return LoadLibraryW(fileName.c_str()); }