Skip to content

Commit 9bf6bf4

Browse files
committed
Port Qt plugin to CMake
1 parent 1bfaabb commit 9bf6bf4

19 files changed

+507
-194
lines changed

CMakeLists.txt

Lines changed: 36 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmake.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ include-before = [
99
"cmake/msvc-configurations.cmake",
1010
]
1111

12+
[find-package]
13+
Qt5 = { components = ["Widgets", "Network", "WinExtras"] }
14+
1215
[fetch-content.x64dbg]
1316
url = "https://sourceforge.net/projects/x64dbg/files/snapshots/snapshot_2023-06-10_18-05.zip"
1417
sha1 = "04468bd61fb36d6b10d17f342f03ef12f5b2ce62"
@@ -23,4 +26,16 @@ type = "plugin"
2326
sources = [
2427
"src/*.cpp",
2528
"src/*.h",
26-
]
29+
"src/*.ui",
30+
"src/*.qrc",
31+
]
32+
link-libraries = [
33+
"Qt5::Widgets",
34+
"Qt5::Network",
35+
"Qt5::WinExtras",
36+
]
37+
38+
[target.PluginTemplate.properties]
39+
AUTOMOC = true
40+
AUTORCC = true
41+
AUTOUIC = true

cmake/cmkr.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include_guard()
22

33
# Change these defaults to point to your infrastructure if desired
44
set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE)
5-
set(CMKR_TAG "v0.2.23" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
5+
set(CMKR_TAG "v0.2.44" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
66
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)
77

88
# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake

src/PluginDialog.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "PluginDialog.h"
2+
#include "ui_PluginDialog.h"
3+
#include <QMessageBox>
4+
#include <QDir>
5+
#include <shlwapi.h>
6+
#include "QtPlugin.h"
7+
#include "pluginmain.h"
8+
9+
PluginDialog::PluginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PluginDialog)
10+
{
11+
ui->setupUi(this);
12+
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
13+
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
14+
#endif
15+
setFixedSize(size());
16+
17+
_plugin_logprintf("[QtPlugin] Current directory: \"%s\"\n", QDir::currentPath().toUtf8().constData());
18+
}
19+
20+
PluginDialog::~PluginDialog()
21+
{
22+
delete ui;
23+
}
24+
25+
void PluginDialog::on_pushButton_clicked()
26+
{
27+
QMessageBox::information(this, "QtPlugin", "I like candy bars!");
28+
}
29+
30+
void PluginDialog::on_buttonShowTab_clicked()
31+
{
32+
QtPlugin::ShowTab();
33+
}

src/PluginDialog.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef PLUGINDIALOG_H
2+
#define PLUGINDIALOG_H
3+
4+
#include <QDialog>
5+
#include <windows.h>
6+
7+
namespace Ui
8+
{
9+
class PluginDialog;
10+
}
11+
12+
class PluginDialog : public QDialog
13+
{
14+
Q_OBJECT
15+
16+
public:
17+
explicit PluginDialog(QWidget* parent);
18+
~PluginDialog();
19+
20+
private slots:
21+
void on_pushButton_clicked();
22+
void on_buttonShowTab_clicked();
23+
24+
private:
25+
Ui::PluginDialog *ui;
26+
};
27+
28+
#endif // PLUGINDIALOG_H

src/PluginDialog.ui

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>PluginDialog</class>
4+
<widget class="QDialog" name="PluginDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>234</width>
10+
<height>145</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>QtPlugin</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset resource="resource.qrc">
18+
<normaloff>:/icons/images/icon.png</normaloff>:/icons/images/icon.png</iconset>
19+
</property>
20+
<widget class="QWidget" name="">
21+
<property name="geometry">
22+
<rect>
23+
<x>80</x>
24+
<y>40</y>
25+
<width>77</width>
26+
<height>54</height>
27+
</rect>
28+
</property>
29+
<layout class="QVBoxLayout" name="verticalLayout">
30+
<item>
31+
<widget class="QPushButton" name="buttonClick">
32+
<property name="text">
33+
<string>Click</string>
34+
</property>
35+
</widget>
36+
</item>
37+
<item>
38+
<widget class="QPushButton" name="buttonShowTab">
39+
<property name="text">
40+
<string>Show Tab</string>
41+
</property>
42+
</widget>
43+
</item>
44+
</layout>
45+
</widget>
46+
</widget>
47+
<resources>
48+
<include location="resource.qrc"/>
49+
</resources>
50+
<connections/>
51+
</ui>

src/PluginMainWindow.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "PluginMainWindow.h"
2+
#include "ui_PluginMainWindow.h"
3+
4+
PluginMainWindow::PluginMainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::PluginMainWindow)
5+
{
6+
ui->setupUi(this);
7+
}
8+
9+
PluginMainWindow::~PluginMainWindow()
10+
{
11+
delete ui;
12+
}

src/PluginMainWindow.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef PLUGINMAINWINDOW_H
2+
#define PLUGINMAINWINDOW_H
3+
4+
#include <QMainWindow>
5+
6+
namespace Ui {
7+
class PluginMainWindow;
8+
}
9+
10+
class PluginMainWindow : public QMainWindow
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit PluginMainWindow(QWidget* parent = nullptr);
16+
~PluginMainWindow();
17+
18+
private:
19+
Ui::PluginMainWindow* ui;
20+
};
21+
22+
#endif // PLUGINMAINWINDOW_H

src/PluginMainWindow.ui

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>PluginMainWindow</class>
4+
<widget class="QMainWindow" name="PluginMainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>800</width>
10+
<height>600</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>QtPlugin</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset resource="resource.qrc">
18+
<normaloff>:/icons/images/icon.png</normaloff>:/icons/images/icon.png</iconset>
19+
</property>
20+
<widget class="QWidget" name="centralwidget">
21+
<layout class="QHBoxLayout" name="horizontalLayout">
22+
<item>
23+
<layout class="QVBoxLayout" name="verticalLayout">
24+
<item>
25+
<widget class="QPlainTextEdit" name="editText">
26+
<property name="font">
27+
<font>
28+
<family>Lucida Console</family>
29+
<pointsize>9</pointsize>
30+
</font>
31+
</property>
32+
<property name="plainText">
33+
<string></string>
34+
</property>
35+
</widget>
36+
</item>
37+
<item>
38+
<widget class="QPushButton" name="buttonClear">
39+
<property name="text">
40+
<string>Clear</string>
41+
</property>
42+
</widget>
43+
</item>
44+
</layout>
45+
</item>
46+
</layout>
47+
</widget>
48+
<widget class="QMenuBar" name="menubar">
49+
<property name="geometry">
50+
<rect>
51+
<x>0</x>
52+
<y>0</y>
53+
<width>800</width>
54+
<height>21</height>
55+
</rect>
56+
</property>
57+
<widget class="QMenu" name="menuQtPlugin">
58+
<property name="title">
59+
<string>QtPlugin</string>
60+
</property>
61+
<addaction name="actionClearText"/>
62+
</widget>
63+
<addaction name="menuQtPlugin"/>
64+
</widget>
65+
<action name="actionClearText">
66+
<property name="text">
67+
<string>&amp;Clear Text</string>
68+
</property>
69+
<property name="toolTip">
70+
<string>Clear Text</string>
71+
</property>
72+
</action>
73+
</widget>
74+
<resources>
75+
<include location="resource.qrc"/>
76+
</resources>
77+
<connections>
78+
<connection>
79+
<sender>actionClearText</sender>
80+
<signal>triggered()</signal>
81+
<receiver>buttonClear</receiver>
82+
<slot>click()</slot>
83+
<hints>
84+
<hint type="sourcelabel">
85+
<x>-1</x>
86+
<y>-1</y>
87+
</hint>
88+
<hint type="destinationlabel">
89+
<x>399</x>
90+
<y>558</y>
91+
</hint>
92+
</hints>
93+
</connection>
94+
<connection>
95+
<sender>buttonClear</sender>
96+
<signal>clicked()</signal>
97+
<receiver>editText</receiver>
98+
<slot>clear()</slot>
99+
<hints>
100+
<hint type="sourcelabel">
101+
<x>399</x>
102+
<y>558</y>
103+
</hint>
104+
<hint type="destinationlabel">
105+
<x>399</x>
106+
<y>285</y>
107+
</hint>
108+
</hints>
109+
</connection>
110+
</connections>
111+
</ui>

0 commit comments

Comments
 (0)