diff --git a/.vscode/settings.json b/.vscode/settings.json index 2137cc5..ddf3e56 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "files.autoSave": "onFocusChange", - "editor.fontSize": 13, + "editor.fontSize": 14, "editor.fontFamily": "'Source Code Pro', 'Source Code Pro', 'Source Code Pro'", "cmake.configureOnOpen": true, "terminal.integrated.fontFamily": "Source Code Pro", @@ -25,7 +25,7 @@ "cmake.options.statusBarVisibility": "visible", "cmake.generator": "Ninja", "C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json", - "C_Cpp.default.cppStandard": "c++14", + "C_Cpp.default.cppStandard": "c++17", "editor.inlayHints.enabled": "off", "editor.unicodeHighlight.allowedLocales": { "ja": true, diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b7c562..8293665 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(packqt VERSION 0.1 LANGUAGES CXX) +project(binpack VERSION 0.1 LANGUAGES CXX) # 获取环境变量 HOME if (UNIX) @@ -49,41 +49,41 @@ set(PROJECT_SOURCES adddesktop.ui adddesktop.h adddesktop.cpp - packqt.qrc + binpack.qrc ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(packqt + qt_add_executable(binpack MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: -# set_property(TARGET packqt APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# set_property(TARGET binpack APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) - add_library(packqt SHARED + add_library(binpack SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() - add_executable(packqt + add_executable(binpack ${PROJECT_SOURCES} ) endif() endif() -target_link_libraries(packqt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ofen) +target_link_libraries(binpack PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ofen) # 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 # explicit, fixed bundle identifier manually though. if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.packqt) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.binpack) endif() -set_target_properties(packqt PROPERTIES +set_target_properties(binpack PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} @@ -92,12 +92,12 @@ set_target_properties(packqt PROPERTIES ) include(GNUInstallDirs) -install(TARGETS packqt +install(TARGETS binpack BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(packqt) + qt_finalize_executable(binpack) endif() diff --git a/MainWidget.cpp b/MainWidget.cpp index ba6871e..738bc4c 100644 --- a/MainWidget.cpp +++ b/MainWidget.cpp @@ -10,7 +10,7 @@ using namespace ofen; MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget) { ui->setupUi(this); - setWindowTitle("packqt v1.0.4"); + setWindowTitle("binpack v1.0.5"); connect_operator(); control_init(); } @@ -23,9 +23,8 @@ MainWidget::~MainWidget() void MainWidget::connect_operator() { connect(ui->btnSelcetBinary, &QPushButton::clicked, this, - [=]() { SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); }); + [=]() { SelectFile(this, ui->edBinary, "请选择二进制文件", "所有文件 (*)"); }); connect(ui->btnSelectOut, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edOutDir); }); - connect(ui->btnSelectQt, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edQtDir); }); connect(ui->btnAddEnv, &QPushButton::clicked, this, [=]() { add_env_btn(); }); connect(ui->btnDelEnv, &QPushButton::clicked, this, [=]() { del_env_btn(); }); connect(ui->btnGenerate, &QPushButton::clicked, this, [=]() { generate(); }); @@ -36,7 +35,6 @@ void MainWidget::connect_operator() void MainWidget::control_init() { ui->plainTextEdit->setReadOnly(true); - ui->edQtDir->setText(QDir::homePath() + "/Qt5.14.2/5.14.2/gcc_64"); ui->edOutDir->setText(QDir::homePath() + "/program"); #if !defined(NDEBUG) #endif @@ -249,14 +247,6 @@ void MainWidget::generate() std::vector dynamic_so{}; std::copy(result.begin(), result.end(), std::back_inserter(dynamic_so)); - // 处理 platform文件夹 - std::list platform{}; - fs::path qt_platform(ui->edQtDir->text().trimmed().toStdString()); - qt_platform.append("plugins/platforms"); - for (const auto& entry : fs::directory_iterator(qt_platform)) { - result.push_back(entry.path().string()); - } - while (!result.empty()) { std::string bin = result.front(); result.pop_front(); @@ -283,9 +273,6 @@ void MainWidget::generate() fs::copy_file(data, purpose, fs::copy_options::overwrite_existing); } - // 复制platform文件夹 - copy_dir(qt_platform.string(), out_dir.string()); - // 复制主体文件 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); diff --git a/MainWidget.h b/MainWidget.h index 9d1deaa..e469ea4 100644 --- a/MainWidget.h +++ b/MainWidget.h @@ -45,10 +45,10 @@ private: public: static QString SelectDirectory(QWidget* parent, QLineEdit* pEdit, const QString& pre_path = ""); static QString SelectFile(QWidget* parent, QLineEdit* pEdit, const QString& info, const QString& filter); - static bool isOk(QWidget* parent, const QString& title, const QString& content); - static void message(QWidget* parent, const QString& content); - static void cmd_exec(const std::string& cmd); - static bool add_run_sh(const std::string& out_dir, const std::string& exe_name); + static bool isOk(QWidget* parent, const QString& title, const QString& content); + static void message(QWidget* parent, const QString& content); + static void cmd_exec(const std::string& cmd); + static bool add_run_sh(const std::string& out_dir, const std::string& exe_name); private: Ui::MainWidget* ui; diff --git a/MainWidget.ui b/MainWidget.ui index 67229c4..b33a93f 100644 --- a/MainWidget.ui +++ b/MainWidget.ui @@ -6,8 +6,8 @@ 0 0 - 1057 - 778 + 965 + 591 @@ -60,44 +60,6 @@ - - - - - - Qt路径(选到bin的父目录): - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - 选择 - - - - - @@ -142,7 +104,7 @@ - 2.LD_LIBRARY_PATH配置 + 2.要搜寻的LD_LIBRARY_PATH位置 diff --git a/adddesktop.cpp b/adddesktop.cpp index 125559d..a0913f7 100644 --- a/adddesktop.cpp +++ b/adddesktop.cpp @@ -44,6 +44,8 @@ AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop "png图标(*.png);;ico图标(*.ico);;svg图标(*.svg);;所有文件 (*)"); }); connect(ui->btnInstall, &QPushButton::clicked, this, &AddDesktop::install_to_desktop); + connect(ui->envAdd, &QPushButton::clicked, this, &AddDesktop::add_env_btn); + connect(ui->envDel, &QPushButton::clicked, this, &AddDesktop::del_env_btn); } void AddDesktop::checkchange() @@ -132,3 +134,21 @@ AddDesktop::~AddDesktop() { delete ui; } + +void AddDesktop::add_env_btn() +{ + QString env = MainWidget::SelectDirectory(this, nullptr); + if (env.isEmpty()) { + return; + } + ui->listWidget->addItem(env); +} + +void AddDesktop::del_env_btn() +{ + QListWidgetItem* item = ui->listWidget->currentItem(); + if (!item) { + return; + } + delete ui->listWidget->takeItem(ui->listWidget->currentRow()); +} diff --git a/adddesktop.h b/adddesktop.h index 79ff7e7..3da4185 100644 --- a/adddesktop.h +++ b/adddesktop.h @@ -16,6 +16,10 @@ public: explicit AddDesktop(QWidget *parent = nullptr); ~AddDesktop(); +private: + void add_env_btn(); + void del_env_btn(); + private: void checkchange(); void install_to_desktop(); diff --git a/adddesktop.ui b/adddesktop.ui index 37ccdc2..6393739 100644 --- a/adddesktop.ui +++ b/adddesktop.ui @@ -6,8 +6,8 @@ 0 0 - 429 - 259 + 485 + 411 @@ -124,6 +124,47 @@ + + + + + + 附加环境目录: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 添加 + + + + + + + 删除 + + + + + + + + diff --git a/packqt.qrc b/binpack.qrc similarity index 100% rename from packqt.qrc rename to binpack.qrc diff --git a/resource/run.sh b/resource/run.sh index f6c2695..80ae83e 100644 --- a/resource/run.sh +++ b/resource/run.sh @@ -10,7 +10,7 @@ cd "$SCRIPT_DIR" || exit echo "当前目录是:$SCRIPT_DIR" # 将脚本所在目录添加到 LD_LIBRARY_PATH 环境变量 -export LD_LIBRARY_PATH="$SCRIPT_DIR" +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$SCRIPT_DIR":REPLACE # 定义 replace_string 脚本的绝对路径 REPLACE_STRING_SCRIPT="$SCRIPT_DIR/replace_string"