add:去除boost依赖,修正编译。
This commit is contained in:
parent
b5b11a6056
commit
489f4fff58
@ -1,34 +1,17 @@
|
|||||||
# .clang-format
|
|
||||||
|
|
||||||
# 风格格式化
|
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
# 4 空格缩进
|
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
# 连续对齐变量的声明
|
|
||||||
AlignConsecutiveDeclarations: true
|
|
||||||
# 指针左侧对齐
|
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
# 访问说明符(public、private等)的偏移
|
|
||||||
AccessModifierOffset: -4
|
AccessModifierOffset: -4
|
||||||
# 大括号
|
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
# 函数定义后面大括号在新行
|
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
# class定义后面
|
|
||||||
AfterClass: true
|
AfterClass: true
|
||||||
|
|
||||||
# 去除C++11的列表初始化的大括号{后和}前的空格
|
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
# 允许重新排版注释
|
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
# 允许排序#include
|
|
||||||
SortIncludes: true
|
|
||||||
# 在尾随的评论前添加的空格数(只适用于//)
|
|
||||||
SpacesBeforeTrailingComments: 3
|
SpacesBeforeTrailingComments: 3
|
||||||
# tab宽度
|
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
# 构造函数的初始化列表要么都在同一行,要么都各自一行
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
# 每行字符的限制,0表示没有限制
|
ColumnLimit: 110
|
||||||
ColumnLimit: 150
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "ofen"]
|
||||||
|
path = ofen
|
||||||
|
url = https://www.sinxmiao.cn/taynpg/ofen
|
117
.vscode/settings.json
vendored
117
.vscode/settings.json
vendored
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"files.autoSave": "onFocusChange",
|
"files.autoSave": "onFocusChange",
|
||||||
"editor.fontSize": 16,
|
"editor.fontSize": 13,
|
||||||
"editor.fontFamily": "'Operator Mono Lig', 'Operator Mono Lig', 'Operator Mono Lig'",
|
"editor.fontFamily": "'Source Code Pro', 'Source Code Pro', 'Source Code Pro'",
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.configureOnOpen": true,
|
||||||
|
"terminal.integrated.fontFamily": "Source Code Pro",
|
||||||
"cmake.debugConfig": {
|
"cmake.debugConfig": {
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
@ -19,29 +20,109 @@
|
|||||||
"visualizerFile": "${workspaceRoot}/.vscode/qt6.natvis"
|
"visualizerFile": "${workspaceRoot}/.vscode/qt6.natvis"
|
||||||
},
|
},
|
||||||
"cmake.environment": {
|
"cmake.environment": {
|
||||||
"PATH": "${env:PATH};/home/typ/Qt5.14.2/5.14.2/gcc_64/bin"
|
"PATH": "${env:PATH};C:/Qt/6.7.2/bin;C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin;D:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin"
|
||||||
},
|
},
|
||||||
"cmake.options.statusBarVisibility": "visible",
|
"cmake.options.statusBarVisibility": "visible",
|
||||||
"cmake.generator": "Ninja",
|
"cmake.generator": "Ninja",
|
||||||
"C_Cpp.intelliSenseEngine": "disabled",
|
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||||
"clangd.arguments": [
|
"C_Cpp.default.cppStandard": "c++14",
|
||||||
"--header-insertion=never",
|
|
||||||
"--all-scopes-completion",
|
|
||||||
"--completion-style=detailed",
|
|
||||||
"--clang-tidy",
|
|
||||||
"-j=4",
|
|
||||||
"--pch-storage=memory",
|
|
||||||
"--compile-commands-dir=build",
|
|
||||||
"--background-index",
|
|
||||||
"--ranking-model=heuristics",
|
|
||||||
"--function-arg-placeholders=false",
|
|
||||||
"--query-driver=/usr/bin/g++"
|
|
||||||
],
|
|
||||||
"editor.inlayHints.enabled": "off",
|
"editor.inlayHints.enabled": "off",
|
||||||
"editor.unicodeHighlight.allowedLocales": {
|
"editor.unicodeHighlight.allowedLocales": {
|
||||||
"ja": true,
|
"ja": true,
|
||||||
"zh-hant": true,
|
"zh-hant": true,
|
||||||
"zh-hans": true
|
"zh-hans": true
|
||||||
|
},
|
||||||
|
"files.associations": {
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"filesystem": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"ios": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"locale": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"variant": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"xfacet": "cpp",
|
||||||
|
"xhash": "cpp",
|
||||||
|
"xiosbase": "cpp",
|
||||||
|
"xlocale": "cpp",
|
||||||
|
"xlocbuf": "cpp",
|
||||||
|
"xlocinfo": "cpp",
|
||||||
|
"xlocmes": "cpp",
|
||||||
|
"xlocmon": "cpp",
|
||||||
|
"xlocnum": "cpp",
|
||||||
|
"xloctime": "cpp",
|
||||||
|
"xmemory": "cpp",
|
||||||
|
"xmemory0": "cpp",
|
||||||
|
"xstddef": "cpp",
|
||||||
|
"xstring": "cpp",
|
||||||
|
"xtr1common": "cpp",
|
||||||
|
"xtree": "cpp",
|
||||||
|
"xutility": "cpp",
|
||||||
|
"qtablewidget": "cpp",
|
||||||
|
"qmenu": "cpp",
|
||||||
|
"qmessagebox": "cpp",
|
||||||
|
"qaction": "cpp",
|
||||||
|
"codecvt": "cpp",
|
||||||
|
"qregexp": "cpp",
|
||||||
|
"qregularexpression": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"charconv": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"format": "cpp",
|
||||||
|
"forward_list": "cpp",
|
||||||
|
"future": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"regex": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"cinttypes": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(packqt VERSION 0.1 LANGUAGES CXX)
|
project(packqt VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
|
# 获取环境变量 HOME
|
||||||
|
if (UNIX)
|
||||||
|
set(USER_HOME $ENV{HOME})
|
||||||
|
else()
|
||||||
|
set(USER_HOME "C:/Qt")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 打印用户目录
|
||||||
|
message(STATUS "User home directory: ${USER_HOME}")
|
||||||
|
|
||||||
set(CMAKE_PREFIX_PATH
|
set(CMAKE_PREFIX_PATH
|
||||||
"/home/typ/Qt5.14.2/5.14.2/gcc_64"
|
${CMAKE_PREFIX_PATH}
|
||||||
"/home/typ/Dev/Boost"
|
"${USER_HOME}/Qt5.14.2/5.14.2/gcc_64/"
|
||||||
"/home/yun/Qt5.14.2/5.14.2/gcc_64"
|
"${USER_HOME}/Qt5.14.2/5.14.2/msvc2017_64/"
|
||||||
"/home/yun/Dev/Boost"
|
"D:/Qt/Qt5.14.2/5.14.2/msvc2017_64/"
|
||||||
|
"C:/Qt/6.7.2"
|
||||||
|
"/opt/homebrew/Cellar/qt/6.7.0_2/"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
@ -27,9 +39,7 @@ if (MSVC)
|
|||||||
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
|
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
add_subdirectory(ofen)
|
||||||
find_package(Boost REQUIRED filesystem)
|
|
||||||
include_directories(${Boost_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(PROJECT_SOURCES
|
set(PROJECT_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
@ -65,7 +75,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(packqt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${Boost_LIBRARIES})
|
target_link_libraries(packqt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ofen)
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||||
# If you are developing for iOS or macOS you should consider setting an
|
# If you are developing for iOS or macOS you should consider setting an
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
#include "adddesktop.h"
|
#include "adddesktop.h"
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <of_path.h>
|
||||||
|
#include <of_str.h>
|
||||||
|
|
||||||
|
using namespace ofen;
|
||||||
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
|
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -12,11 +15,15 @@ MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget
|
|||||||
control_init();
|
control_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWidget::~MainWidget() { delete ui; }
|
MainWidget::~MainWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::connect_operator()
|
void MainWidget::connect_operator()
|
||||||
{
|
{
|
||||||
connect(ui->btnSelcetBinary, &QPushButton::clicked, this, [=]() { SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); });
|
connect(ui->btnSelcetBinary, &QPushButton::clicked, this,
|
||||||
|
[=]() { SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); });
|
||||||
connect(ui->btnSelectOut, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edOutDir); });
|
connect(ui->btnSelectOut, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edOutDir); });
|
||||||
connect(ui->btnSelectQt, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edQtDir); });
|
connect(ui->btnSelectQt, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edQtDir); });
|
||||||
connect(ui->btnAddEnv, &QPushButton::clicked, this, [=]() { add_env_btn(); });
|
connect(ui->btnAddEnv, &QPushButton::clicked, this, [=]() { add_env_btn(); });
|
||||||
@ -73,7 +80,7 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path des_parent_dir = fs::path(des_dir).append(fs::path(source_dir).filename());
|
fs::path des_parent_dir = fs::path(des_dir).append(fs::path(source_dir).filename().string());
|
||||||
if (!fs::exists(des_parent_dir)) {
|
if (!fs::exists(des_parent_dir)) {
|
||||||
fs::create_directories(des_parent_dir);
|
fs::create_directories(des_parent_dir);
|
||||||
}
|
}
|
||||||
@ -86,7 +93,7 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
|||||||
fs::path path = paths.front();
|
fs::path path = paths.front();
|
||||||
paths.pop_front();
|
paths.pop_front();
|
||||||
|
|
||||||
fs::path destination(boost::replace_all_copy(path.string(), source_dir, des_parent_dir.string()));
|
fs::path destination(COfStr::replace(path.string(), source_dir, des_parent_dir.string()));
|
||||||
if (fs::is_directory(path)) {
|
if (fs::is_directory(path)) {
|
||||||
if (!fs::exists(destination)) {
|
if (!fs::exists(destination)) {
|
||||||
fs::create_directories(destination);
|
fs::create_directories(destination);
|
||||||
@ -101,10 +108,11 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> MainWidget::get_depend_on(const std::string& name, const std::vector<std::string>& env)
|
std::vector<std::string> MainWidget::get_depend_on(const std::string& name,
|
||||||
|
const std::vector<std::string>& env)
|
||||||
{
|
{
|
||||||
std::vector<std::string> vec;
|
std::vector<std::string> vec;
|
||||||
std::string cmd{};
|
std::string cmd{};
|
||||||
|
|
||||||
if (!env.empty()) {
|
if (!env.empty()) {
|
||||||
cmd.append("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH");
|
cmd.append("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH");
|
||||||
@ -113,7 +121,7 @@ std::vector<std::string> MainWidget::get_depend_on(const std::string& name, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd.append(" && ldd " + name);
|
cmd.append(" && ldd " + name);
|
||||||
char buffer[1024]{};
|
char buffer[1024]{};
|
||||||
FILE* pf = nullptr;
|
FILE* pf = nullptr;
|
||||||
if ((pf = popen(cmd.c_str(), "r")) == nullptr) {
|
if ((pf = popen(cmd.c_str(), "r")) == nullptr) {
|
||||||
return vec;
|
return vec;
|
||||||
@ -123,7 +131,7 @@ std::vector<std::string> MainWidget::get_depend_on(const std::string& name, cons
|
|||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::split(vec, result, boost::is_any_of("\t"));
|
vec = COfStr::split(result, "\t");
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,20 +143,19 @@ std::list<std::string> MainWidget::handle_result(const std::vector<std::string>&
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost::contains(data, "not found")) {
|
if (data.find("not found") == 0) {
|
||||||
simple_log(QString::fromStdString("未找到依赖:" + data), false);
|
simple_log(QString::fromStdString("未找到依赖:" + data), false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tdata = boost::replace_all_copy(data, "=>", "");
|
std::string tdata = COfStr::replace(data, "=>", "");
|
||||||
std::vector<std::string> vt;
|
std::vector<std::string> vt = COfStr::split(tdata, " ");
|
||||||
boost::split(vt, tdata, boost::is_any_of(" "));
|
|
||||||
if (vt.size() != 4) {
|
if (vt.size() != 4) {
|
||||||
// QString info = "原始数据:" + QString::fromStdString(data);
|
// QString info = "原始数据:" + QString::fromStdString(data);
|
||||||
// simple_log(info, false);
|
// simple_log(info, false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (boost::starts_with(vt[2], "/lib")) {
|
if (vt[2].find("/lib") == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret.push_back(vt[2]);
|
ret.push_back(vt[2]);
|
||||||
@ -169,7 +176,7 @@ void MainWidget::del_env_btn()
|
|||||||
QString MainWidget::SelectDirectory(QWidget* parent, QLineEdit* pEdit, const QString& pre_path)
|
QString MainWidget::SelectDirectory(QWidget* parent, QLineEdit* pEdit, const QString& pre_path)
|
||||||
{
|
{
|
||||||
QString start_path = pre_path;
|
QString start_path = pre_path;
|
||||||
QDir folder(start_path);
|
QDir folder(start_path);
|
||||||
if (start_path.isEmpty() || !folder.exists()) {
|
if (start_path.isEmpty() || !folder.exists()) {
|
||||||
start_path = QDir::homePath();
|
start_path = QDir::homePath();
|
||||||
}
|
}
|
||||||
@ -209,7 +216,10 @@ bool MainWidget::isOk(QWidget* parent, const QString& title, const QString& cont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::message(QWidget* parent, const QString& content) { QMessageBox::information(parent, "提示", content); }
|
void MainWidget::message(QWidget* parent, const QString& content)
|
||||||
|
{
|
||||||
|
QMessageBox::information(parent, "提示", content);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::cmd_exec(const std::string& cmd)
|
void MainWidget::cmd_exec(const std::string& cmd)
|
||||||
{
|
{
|
||||||
@ -241,7 +251,7 @@ void MainWidget::generate()
|
|||||||
|
|
||||||
// 处理 platform文件夹
|
// 处理 platform文件夹
|
||||||
std::list<fs::path> platform{};
|
std::list<fs::path> platform{};
|
||||||
fs::path qt_platform(ui->edQtDir->text().trimmed().toStdString());
|
fs::path qt_platform(ui->edQtDir->text().trimmed().toStdString());
|
||||||
qt_platform.append("plugins/platforms");
|
qt_platform.append("plugins/platforms");
|
||||||
for (const auto& entry : fs::directory_iterator(qt_platform)) {
|
for (const auto& entry : fs::directory_iterator(qt_platform)) {
|
||||||
result.push_back(entry.path().string());
|
result.push_back(entry.path().string());
|
||||||
@ -269,7 +279,7 @@ void MainWidget::generate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& data : dynamic_so) {
|
for (const auto& data : dynamic_so) {
|
||||||
std::string purpose = fs::path(out_dir).append(fs::path(data).filename()).string();
|
std::string purpose = fs::path(out_dir).append(fs::path(data).filename().string()).string();
|
||||||
fs::copy_file(data, purpose, fs::copy_options::overwrite_existing);
|
fs::copy_file(data, purpose, fs::copy_options::overwrite_existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +287,7 @@ void MainWidget::generate()
|
|||||||
copy_dir(qt_platform.string(), out_dir.string());
|
copy_dir(qt_platform.string(), out_dir.string());
|
||||||
|
|
||||||
// 复制主体文件
|
// 复制主体文件
|
||||||
fs::path out_binary = fs::path(out_dir).append(fs::path(binary_.toStdString()).filename());
|
fs::path out_binary = fs::path(out_dir).append(fs::path(binary_.toStdString()).filename().string());
|
||||||
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
||||||
if (!add_run_sh(out_dir.string(), filename)) {
|
if (!add_run_sh(out_dir.string(), filename)) {
|
||||||
return;
|
return;
|
||||||
@ -285,7 +295,6 @@ void MainWidget::generate()
|
|||||||
message(this, "完成");
|
message(this, "完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_name)
|
bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_name)
|
||||||
{
|
{
|
||||||
// 生成一个启动文件夹
|
// 生成一个启动文件夹
|
||||||
@ -299,9 +308,10 @@ bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_n
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
std::string run_sh = content.toStdString();
|
std::string run_sh = content.toStdString();
|
||||||
boost::replace_all(run_sh, "replace_string", exe_name);
|
|
||||||
|
|
||||||
std::string out_sh = fs::path(out_dir).append(exe_name + ".sh").string();
|
run_sh = COfStr::replace(run_sh, "replace_string", exe_name);
|
||||||
|
|
||||||
|
std::string out_sh = fs::path(out_dir).append(exe_name + ".sh").string();
|
||||||
std::ofstream out(out_sh, std::ios::out);
|
std::ofstream out(out_sh, std::ios::out);
|
||||||
if (!out.is_open()) {
|
if (!out.is_open()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,12 +6,11 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <filesystem>
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "ui_adddesktop.h"
|
#include "ui_adddesktop.h"
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <of_str.h>
|
||||||
|
|
||||||
|
using namespace ofen;
|
||||||
|
|
||||||
AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop)
|
AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop)
|
||||||
{
|
{
|
||||||
@ -36,8 +39,10 @@ AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop
|
|||||||
connect(ui->ckUseDefault, &QCheckBox::toggled, this, &AddDesktop::checkchange);
|
connect(ui->ckUseDefault, &QCheckBox::toggled, this, &AddDesktop::checkchange);
|
||||||
connect(ui->btnSelectBinary, &QPushButton::clicked, this,
|
connect(ui->btnSelectBinary, &QPushButton::clicked, this,
|
||||||
[=]() { MainWidget::SelectFile(this, ui->edBinary, "请选择二进制文件", "所有文件 (*)"); });
|
[=]() { MainWidget::SelectFile(this, ui->edBinary, "请选择二进制文件", "所有文件 (*)"); });
|
||||||
connect(ui->btnSelectIco, &QPushButton::clicked, this,
|
connect(ui->btnSelectIco, &QPushButton::clicked, this, [=]() {
|
||||||
[=]() { MainWidget::SelectFile(this, ui->edIco, "请选择ico图标文件", "png图标(*.png);;ico图标(*.ico);;svg图标(*.svg);;所有文件 (*)"); });
|
MainWidget::SelectFile(this, ui->edIco, "请选择ico图标文件",
|
||||||
|
"png图标(*.png);;ico图标(*.ico);;svg图标(*.svg);;所有文件 (*)");
|
||||||
|
});
|
||||||
connect(ui->btnInstall, &QPushButton::clicked, this, &AddDesktop::install_to_desktop);
|
connect(ui->btnInstall, &QPushButton::clicked, this, &AddDesktop::install_to_desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +70,7 @@ void AddDesktop::install_to_desktop()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string binaryName = fs::path(binaryPath).filename().string();
|
std::string binaryName = fs::path(binaryPath).filename().string();
|
||||||
fs::path sh_path = fs::path(binaryPath).parent_path().append(binaryName + ".sh");
|
fs::path sh_path = fs::path(binaryPath).parent_path().append(binaryName + ".sh");
|
||||||
|
|
||||||
std::string cmodBin = "chmod +x " + binaryPath;
|
std::string cmodBin = "chmod +x " + binaryPath;
|
||||||
std::string cmodSh = "chmod +x " + sh_path.string();
|
std::string cmodSh = "chmod +x " + sh_path.string();
|
||||||
@ -81,12 +86,12 @@ void AddDesktop::install_to_desktop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
QString content = stream.readAll();
|
QString content = stream.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
std::string ct = content.toStdString();
|
std::string ct = content.toStdString();
|
||||||
boost::replace_all(ct, "re_name", binaryName);
|
ct = COfStr::replace(ct, "re_name", binaryName);
|
||||||
boost::replace_all(ct, "re_describe", binaryName);
|
ct = COfStr::replace(ct, "re_describe", binaryName);
|
||||||
boost::replace_all(ct, "re_path", "sh " + sh_path.string());
|
ct = COfStr::replace(ct, "re_path", "sh " + sh_path.string());
|
||||||
|
|
||||||
fs::path default_ico_path = fs::path(tmp).append("packqt");
|
fs::path default_ico_path = fs::path(tmp).append("packqt");
|
||||||
if (!fs::exists(default_ico_path)) {
|
if (!fs::exists(default_ico_path)) {
|
||||||
@ -95,7 +100,7 @@ void AddDesktop::install_to_desktop()
|
|||||||
if (ui->ckUseDefault->isChecked()) {
|
if (ui->ckUseDefault->isChecked()) {
|
||||||
default_ico_path.append("Tools.svg");
|
default_ico_path.append("Tools.svg");
|
||||||
QFile::copy("://resource/Tools.svg", QString::fromStdString(default_ico_path.string()));
|
QFile::copy("://resource/Tools.svg", QString::fromStdString(default_ico_path.string()));
|
||||||
boost::replace_all(ct, "re_icon", default_ico_path.string());
|
ct = COfStr::replace(ct, "re_icon", default_ico_path.string());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::string icn = ui->edIco->text().trimmed().toStdString();
|
std::string icn = ui->edIco->text().trimmed().toStdString();
|
||||||
@ -103,12 +108,12 @@ void AddDesktop::install_to_desktop()
|
|||||||
MainWidget::message(this, "图标路径为空");
|
MainWidget::message(this, "图标路径为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default_ico_path.append(fs::path(icn).filename());
|
default_ico_path.append(fs::path(icn).filename().string());
|
||||||
boost::replace_all(ct, "re_icon", default_ico_path.string());
|
ct = COfStr::replace(ct, "re_icon", default_ico_path.string());
|
||||||
fs::copy_file(icn, default_ico_path, fs::copy_options::overwrite_existing);
|
fs::copy_file(icn, default_ico_path, fs::copy_options::overwrite_existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::replace_all(ct, "re_category", ui->cbCategories->currentText().toStdString());
|
ct = COfStr::replace(ct, "re_category", ui->cbCategories->currentText().toStdString());
|
||||||
tmp.append(binaryName + ".desktop");
|
tmp.append(binaryName + ".desktop");
|
||||||
;
|
;
|
||||||
std::ofstream out(tmp.string(), std::ios::out);
|
std::ofstream out(tmp.string(), std::ios::out);
|
||||||
@ -123,4 +128,7 @@ void AddDesktop::install_to_desktop()
|
|||||||
MainWidget::message(this, "完成");
|
MainWidget::message(this, "完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDesktop::~AddDesktop() { delete ui; }
|
AddDesktop::~AddDesktop()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
1
ofen
Submodule
1
ofen
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 71948320b735e33db511f756b5df83ef3ddcf2c7
|
Loading…
x
Reference in New Issue
Block a user