diff --git a/CMakeLists.txt b/CMakeLists.txt index d073fb8..6232892 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ project(packqt VERSION 0.1 LANGUAGES CXX) set(CMAKE_PREFIX_PATH "/home/typ/Qt5.14.2/5.14.2/gcc_64" "/home/typ/Dev/Boost" + "/home/yun/Qt5.14.2/5.14.2/gcc_64" + "/home/yun/Dev/Boost" ) set(CMAKE_AUTOUIC ON) diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 0000000..f1b1d02 --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,346 @@ + + + + + + EnvironmentId + {7888b70a-9172-4814-af57-f591229b769b} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 GCC 64bit + Desktop Qt 5.14.2 GCC 64bit + qt.qt5.5142.gcc_64_kit + 0 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + /home/yun/code/build-packqt-Desktop_Qt_5_14_2_GCC_64bit-Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + /home/yun/code/build-packqt-Desktop_Qt_5_14_2_GCC_64bit-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + /home/yun/code/build-packqt-Desktop_Qt_5_14_2_GCC_64bit-RelWithDebInfo + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + /home/yun/code/build-packqt-Desktop_Qt_5_14_2_GCC_64bit-MinSizeRel + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + packqt + CMakeProjectManager.CMakeRunConfiguration.packqt + packqt + + false + + false + true + true + false + false + true + + /home/yun/code/build-packqt-Desktop_Qt_5_14_2_GCC_64bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/MainWidget.cpp b/MainWidget.cpp index 347e2cc..984f313 100644 --- a/MainWidget.cpp +++ b/MainWidget.cpp @@ -6,7 +6,7 @@ MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget) { ui->setupUi(this); - setWindowTitle("打包Qt工具 v0.9"); + setWindowTitle("packqt v1.0.0"); connect_operator(); control_init(); } @@ -28,9 +28,8 @@ void MainWidget::control_init() { ui->plainTextEdit->setEnabled(false); #if !defined(NDEBUG) - ui->edBinary->setText("/home/typ/Downloads/build-QXmlEdit-Desktop_Qt_5_14_2_GCC_64bit-Release/build/qxmledit"); - ui->edQtDir->setText("/home/typ/Qt5.14.2/5.14.2/gcc_64"); - ui->edOutDir->setText("/home/typ/testpack"); + ui->edQtDir->setText(QDir::homePath() + "/Qt5.14.2/5.14.2/gcc_64"); + ui->edOutDir->setText(QDir::homePath() + "/testpack"); #endif } @@ -296,4 +295,4 @@ void MainWidget::generate() int r = system(std::string("chmod +x " + out_sh).c_str()); (void)r; message(this, "完成"); -} \ No newline at end of file +} diff --git a/adddesktop.cpp b/adddesktop.cpp index 9dd97a2..d538695 100644 --- a/adddesktop.cpp +++ b/adddesktop.cpp @@ -9,6 +9,8 @@ AddDesktop::AddDesktop(QWidget *parent) : { ui->setupUi(this); + setWindowTitle("添加到菜单"); + // Audio:音频应用程序,如播放器、编辑器等。 // Video:视频应用程序,如播放器、编辑器等。 // Development:开发工具,如IDE、编辑器等。 @@ -33,9 +35,9 @@ AddDesktop::AddDesktop(QWidget *parent) : ui->cbCategories->addItem("Utility"); ui->cbCategories->setCurrentIndex(ui->cbCategories->count() - 1); - connect(ui->cbIsCustomIco, &QCheckBox::toggled, this, &AddDesktop::checkchange); + connect(ui->ckUseDefault, &QCheckBox::toggled, this, &AddDesktop::checkchange); connect(ui->btnSelectBinary, &QPushButton::clicked, this, [=](){ - MainWidget::SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); + MainWidget::SelectFile(this, ui->edBinary, "请选择二进制文件", "所有文件 (*)"); }); connect(ui->btnSelectIco, &QPushButton::clicked, this, [=](){ MainWidget::SelectFile(this, ui->edIco, "请选择ico图标文件", "图标文件(*.ico);;所有文件 (*)"); @@ -45,7 +47,7 @@ AddDesktop::AddDesktop(QWidget *parent) : void AddDesktop::checkchange() { - if (ui->cbIsCustomIco->isChecked()) { + if (ui->ckUseDefault->isChecked()) { ui->edIco->setEnabled(false); ui->btnSelectIco->setEnabled(false); } @@ -61,6 +63,12 @@ void AddDesktop::install_to_desktop() if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return; } + + fs::path tmp = fs::path(QDir::homePath().toStdString()).append(".config"); + if (!fs::exists(tmp)) { + fs::create_directories(tmp); + } + QTextStream stream(&file); QString content = stream.readAll(); file.close(); @@ -69,13 +77,21 @@ void AddDesktop::install_to_desktop() boost::replace_all(ct, "re_name", tool_name); boost::replace_all(ct, "re_describe", tool_name); boost::replace_all(ct, "re_path", ui->edBinary->text().trimmed().toStdString()); - boost::replace_all(ct, "re_icon", ui->edIco->text().trimmed().toStdString()); - boost::replace_all(ct, "re_category", ui->cbCategories->currentText().toStdString()); - fs::path tmp = fs::path(QDir::homePath().toStdString()).append(".config"); - if (!fs::exists(tmp)) { - fs::create_directories(tmp); + if (!ui->ckUseDefault->isChecked()) { + boost::replace_all(ct, "re_icon", ui->edIco->text().trimmed().toStdString()); } + else { + fs::path default_ico_path = fs::path(tmp).append("packqt"); + if (!fs::exists(default_ico_path)) { + fs::create_directories(default_ico_path); + } + default_ico_path.append("Tools.svg"); + QFile::copy("://resource/Tools.svg", QString::fromStdString(default_ico_path.string())); + boost::replace_all(ct, "re_icon", default_ico_path.string()); + } + + boost::replace_all(ct, "re_category", ui->cbCategories->currentText().toStdString()); tmp.append(tool_name + ".desktop");; std::ofstream out(tmp.string(), std::ios::out); if (!out.is_open()) { @@ -83,9 +99,10 @@ void AddDesktop::install_to_desktop() } out << ct; out.close(); - MainWidget::message(this, "完成"); std::string cp_cmd("pkexec cp " + tmp.string() + " /usr/share/applications"); system(cp_cmd.c_str()); + fs::remove(tmp); + MainWidget::message(this, "完成"); } AddDesktop::~AddDesktop() diff --git a/adddesktop.ui b/adddesktop.ui index 0fe606f..37ccdc2 100644 --- a/adddesktop.ui +++ b/adddesktop.ui @@ -53,7 +53,7 @@ - + 使用默认图标 diff --git a/packqt.qrc b/packqt.qrc index 25a4ac2..fde8f18 100644 --- a/packqt.qrc +++ b/packqt.qrc @@ -2,5 +2,6 @@ resource/run.sh resource/desktop.txt + resource/Tools.svg diff --git a/resource/Tools.svg b/resource/Tools.svg new file mode 100644 index 0000000..fc01603 --- /dev/null +++ b/resource/Tools.svg @@ -0,0 +1 @@ + \ No newline at end of file