mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 10:50:23 +08:00

- Removed Travis and Appveyor, we now focus on the Github Action
- Changed a MACRO
- Rewrited config searching algorithm, PATCH needed #69
- Removed global Mux Config
- PARTLY supporting custom v2ray path
- Added graph on the MainWindow
- Fixed a ContentType error in ToolBar API
- Added LICENSE for 7z.exe
Signed-off-by: Leroy.H.Y <me@lhy0403.top>
Former-commit-id: ea8ba9a55b
74 lines
2.0 KiB
C++
74 lines
2.0 KiB
C++
#ifndef UTILS_H
|
|
#define UTILS_H
|
|
|
|
#include "Qv2rayBase.h"
|
|
#include <QMessageBox>
|
|
#include <QUuid>
|
|
|
|
namespace Qv2ray
|
|
{
|
|
namespace Utils
|
|
{
|
|
QTranslator *getTranslator(const QString *lang);
|
|
|
|
QStringList getFileList(QDir dir);
|
|
|
|
QString Base64Encode(QString string);
|
|
QString Base64Decode(QString string);
|
|
|
|
bool CheckFile(QDir dir, QString fileName);
|
|
|
|
void SetConfigDirPath(const QString *path);
|
|
QString GetConfigDirPath();
|
|
|
|
void SetGlobalConfig(Qv2rayConfig conf);
|
|
Qv2rayConfig GetGlobalConfig();
|
|
|
|
void LoadGlobalConfig();
|
|
|
|
void QvMessageBox(QWidget *parent, QString title, QString text);
|
|
int QvMessageBoxAsk(QWidget *parent, QString title, QString text, QMessageBox::StandardButton extraButtons = QMessageBox::NoButton);
|
|
//
|
|
QString StringFromFile(QFile *source);
|
|
bool StringToFile(const QString *text, QFile *target);
|
|
//
|
|
QJsonObject JsonFromString(QString string);
|
|
QString JsonToString(QJsonObject json);
|
|
QString VerifyJsonString(const QString *source);
|
|
//
|
|
QString Stringify(list<string> list, QString saperator = ";");
|
|
QString Stringify(QList<QString> list, QString saperator = ";");
|
|
//
|
|
//
|
|
template <typename TYPE>
|
|
QString StructToJsonString(const TYPE t)
|
|
{
|
|
return QString::fromStdString(X::tojson(t, "", 4, ' '));
|
|
}
|
|
//
|
|
//
|
|
template <typename TYPE>
|
|
TYPE StructFromJsonString(const QString &str)
|
|
{
|
|
TYPE v;
|
|
X::loadjson(str.toStdString(), v, false);
|
|
return v;
|
|
}
|
|
//
|
|
|
|
|
|
template <typename T>
|
|
void RemoveItem(std::vector<T> &vec, size_t pos)
|
|
{
|
|
auto it = vec.begin();
|
|
std::advance(it, pos);
|
|
vec.erase(it);
|
|
}
|
|
|
|
QString FormatBytes(long long bytes);
|
|
}
|
|
}
|
|
|
|
using namespace Qv2ray::Utils;
|
|
#endif // UTILS_H
|