Skip to content

Commit

Permalink
Beginning porting to QML
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek committed Mar 28, 2024
1 parent c1adcd3 commit 32fa5a4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,19 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Instruct CMake to run uic automatically when needed.
SET(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC ON)
# Instruct CMake to run rcc automatically when needed.
SET(CMAKE_AUTORCC ON)
set(CMAKE_AUTORCC ON)

# Check Qt
FIND_PACKAGE( Qt6Core REQUIRED )
FIND_PACKAGE( Qt6Widgets REQUIRED )
FIND_PACKAGE( Qt6Network REQUIRED )
FIND_PACKAGE( Qt6Test REQUIRED )
FIND_PACKAGE( Qt6PrintSupport REQUIRED )
FIND_PACKAGE( Qt6DBus REQUIRED )
find_package( Qt6Core REQUIRED )
find_package( Qt6Qml REQUIRED )
find_package( Qt6QuickControls2 REQUIRED )
find_package( Qt6Widgets REQUIRED )
find_package( Qt6Network REQUIRED )
find_package( Qt6Test REQUIRED )
find_package( Qt6PrintSupport REQUIRED )
find_package( Qt6DBus REQUIRED )

# Embedded VNC display
IF( NOT WITHOUT_EMBEDDED_DISPLAY )
Expand Down Expand Up @@ -237,9 +239,11 @@ ADD_EXECUTABLE( aqemu
${aqemu_qrc}
)

target_include_directories(aqemu PUBLIC src/ )
target_include_directories(aqemu PUBLIC src/ src/docopt/ )

TARGET_LINK_LIBRARIES( aqemu
Qt6::Qml
Qt6::QuickControls2
Qt6::Widgets
Qt6::Network
Qt6::Test
Expand Down
32 changes: 31 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QGuiApplication>
#include <QMessageBox>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QResource>
#include <QTranslator>
#include <QtDBus>
Expand Down Expand Up @@ -216,13 +219,40 @@ int AQEMU_Main::main_window()
if (ret != 0)
return ret;

// Show main window
// Show main window
#ifdef QML_USE
QGuiApplication::setOrganizationName("AQEMU");
QGuiApplication::setOrganizationDomain("https://github.com/AQEMU/aqemu");
QGuiApplication::setApplicationName("AQEMU");
//QQuickStyle::setStyle(QStringLiteral("Default"));

app->setWindowIcon(QIcon(":/aqemu.png"));

// Startup
QQmlApplicationEngine engine;
QQuickStyle::setStyle("Basic");
engine.addImportPath("qrc:/modules");
engine.addImportPath(QCoreApplication::applicationDirPath() + "/qml/");

const QUrl url("qrc:/main.qml");
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &app,
[url](QObject* obj, const QUrl& objUrl) {
if (obj == nullptr && url == objUrl)
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
engine.load(url);

return QGuiApplication::exec();
#else
window = std::make_unique<Main_Window>();
window->show();

application->setWindowIcon(QIcon(":/aqemu.png"));

return application->exec();
#endif
}

void AQEMU_Main::load_language()
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class AQEMU_Main : public QObject

std::unique_ptr<QSettings> settings;
std::unique_ptr<QApplication> application;
// TODO: select in config QML or Widgets
std::unique_ptr<Main_Window> window;
std::unique_ptr<QGuiApplication> app;
};

#endif

0 comments on commit 32fa5a4

Please sign in to comment.