diff options
| author | ruki <[email protected]> | 2025-11-28 12:05:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-28 12:05:12 +0800 |
| commit | ec0c0d458a14c6a9aff1a01d5e1cf264c8dcfeb2 (patch) | |
| tree | 648c6e438c1ee829c4f61f8f83c6fef20057ebbb /tests/plugins | |
| parent | 4be95ee920757c2c813b84af5f07653c191c0215 (diff) | |
| parent | 2766d4d1065f8daee0b7b5c95f9fd85b03144eb5 (diff) | |
Merge pull request #7071 from xmake-io/qt
Add Qt pack support
Diffstat (limited to 'tests/plugins')
| -rw-r--r-- | tests/plugins/pack/qtapp/src/assets/xmake.ico | bin | 0 -> 119943 bytes | |||
| -rw-r--r-- | tests/plugins/pack/qtapp/src/assets/xmake.png | bin | 0 -> 24378 bytes | |||
| -rw-r--r-- | tests/plugins/pack/qtapp/src/main.cpp | 10 | ||||
| -rw-r--r-- | tests/plugins/pack/qtapp/src/mainwindow.cpp | 14 | ||||
| -rw-r--r-- | tests/plugins/pack/qtapp/src/mainwindow.h | 23 | ||||
| -rw-r--r-- | tests/plugins/pack/qtapp/src/mainwindow.ui | 46 | ||||
| -rw-r--r-- | tests/plugins/pack/qtapp/xmake.lua | 33 |
7 files changed, 126 insertions, 0 deletions
diff --git a/tests/plugins/pack/qtapp/src/assets/xmake.ico b/tests/plugins/pack/qtapp/src/assets/xmake.ico Binary files differnew file mode 100644 index 000000000..52c8ef389 --- /dev/null +++ b/tests/plugins/pack/qtapp/src/assets/xmake.ico diff --git a/tests/plugins/pack/qtapp/src/assets/xmake.png b/tests/plugins/pack/qtapp/src/assets/xmake.png Binary files differnew file mode 100644 index 000000000..be7f6c4f2 --- /dev/null +++ b/tests/plugins/pack/qtapp/src/assets/xmake.png diff --git a/tests/plugins/pack/qtapp/src/main.cpp b/tests/plugins/pack/qtapp/src/main.cpp new file mode 100644 index 000000000..a1cfd8dea --- /dev/null +++ b/tests/plugins/pack/qtapp/src/main.cpp @@ -0,0 +1,10 @@ +#include "mainwindow.h" +#include <QApplication> + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} + diff --git a/tests/plugins/pack/qtapp/src/mainwindow.cpp b/tests/plugins/pack/qtapp/src/mainwindow.cpp new file mode 100644 index 000000000..a20d45d1a --- /dev/null +++ b/tests/plugins/pack/qtapp/src/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) { + ui->setupUi(this); + setWindowTitle("Qt Widget App"); +} + +MainWindow::~MainWindow() { + delete ui; +} + diff --git a/tests/plugins/pack/qtapp/src/mainwindow.h b/tests/plugins/pack/qtapp/src/mainwindow.h new file mode 100644 index 000000000..1f2d99bae --- /dev/null +++ b/tests/plugins/pack/qtapp/src/mainwindow.h @@ -0,0 +1,23 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H + diff --git a/tests/plugins/pack/qtapp/src/mainwindow.ui b/tests/plugins/pack/qtapp/src/mainwindow.ui new file mode 100644 index 000000000..6772bd4b0 --- /dev/null +++ b/tests/plugins/pack/qtapp/src/mainwindow.ui @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Qt Widget App</string> + </property> + <widget class="QWidget" name="centralWidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Welcome to Qt Widget App!</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menuBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusBar"/> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> + diff --git a/tests/plugins/pack/qtapp/xmake.lua b/tests/plugins/pack/qtapp/xmake.lua new file mode 100644 index 000000000..fb10ae741 --- /dev/null +++ b/tests/plugins/pack/qtapp/xmake.lua @@ -0,0 +1,33 @@ +set_version("1.0.0") +add_rules("mode.debug", "mode.release") + +includes("@builtin/xpack") + +target("qtapp") + add_rules("qt.widgetapp") + add_headerfiles("src/*.h") + add_files("src/*.cpp") + add_files("src/mainwindow.ui") + add_files("src/mainwindow.h") + +xpack("qtapp") + set_formats("nsis", "dmg", "appimage", "zip", "targz") + set_title("Qt Widget App") + set_author("ruki <[email protected]>") + set_description("A Qt Widget Application example for xpack.") + set_homepage("https://xmake.io") + set_license("Apache-2.0") + set_licensefile("LICENSE.md") + add_targets("qtapp") + + on_load(function (package) + package:set("basename", "qtapp-$(plat)-$(arch)-v$(version)") + -- set icon file based on format (use PNG for appimage, ICO for other formats) + local scriptdir = os.scriptdir() + if package:format() == "appimage" then + package:set("iconfile", path.join(scriptdir, "src/assets/xmake.png")) + else + package:set("iconfile", path.join(scriptdir, "src/assets/xmake.ico")) + end + end) + |
