diff --git a/communicator/CMakeLists.txt b/communicator/CMakeLists.txt index c8ade9a..496ebbd 100644 --- a/communicator/CMakeLists.txt +++ b/communicator/CMakeLists.txt @@ -1,72 +1,22 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) -project(communicator VERSION 0.1 LANGUAGES CXX) +project(communicator VERSION 1.0 LANGUAGES CXX) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) +find_package(Qt6 6.2 COMPONENTS Quick Gui REQUIRED) +qt_standard_project_setup(REQUIRES 6.5) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) - -add_compile_options(-Wall -Wextra -pedantic -Wno-unused-function -Werror) - -set(PROJECT_SOURCES - main.cpp - mainwindow.cpp - mainwindow.h - mainwindow.ui -) - -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(communicator - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ) -# Define target properties for Android with Qt 6 as: -# set_property(TARGET communicator 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(communicator 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(communicator - ${PROJECT_SOURCES} - ) - endif() -endif() - -target_link_libraries(communicator PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) - -# 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.communicator) -endif() -set_target_properties(communicator PROPERTIES - ${BUNDLE_ID_OPTION} - MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - MACOSX_BUNDLE TRUE - WIN32_EXECUTABLE TRUE +qt_add_executable(communicator + main.cpp ) -include(GNUInstallDirs) -install(TARGETS communicator - BUNDLE DESTINATION . - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +qt_add_qml_module(communicator + URI main + QML_FILES + main-window.qml + RESOURCES resources.qrc ) -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(communicator) -endif() +target_link_libraries(communicator PRIVATE Qt6::Gui Qt6::Quick) diff --git a/communicator/main-window.qml b/communicator/main-window.qml new file mode 100644 index 0000000..68a799a --- /dev/null +++ b/communicator/main-window.qml @@ -0,0 +1,35 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 + +ApplicationWindow { + visible: true + width: 600 + height: 400 + minimumWidth: 400 + minimumHeight: 300 + title: "Simple Text Communicator" + color: "#f0f0f0" + + ColumnLayout { + anchors.fill: parent + spacing: 10 + + RowLayout { + width: parent.width + Layout.alignment: Qt.AlignHCenter + Button { + text: "Login" + Layout.alignment: Qt.AlignRight + onClicked: { + } + } + Button { + text: "Register" + Layout.alignment: Qt.AlignRight + onClicked: { + } + } + } + } +} diff --git a/communicator/main.cpp b/communicator/main.cpp index b01139b..9afcd17 100644 --- a/communicator/main.cpp +++ b/communicator/main.cpp @@ -1,10 +1,17 @@ -#include - -#include "mainwindow.h" +#include +#include +#include int main(int argc, char *argv[]) { - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + + const QUrl url(QStringLiteral("qrc:/qt/qml/main/main-window.qml")); + engine.load(url); + if (engine.rootObjects().isEmpty()) + { + return -1; + } + return app.exec(); } diff --git a/communicator/resources.qrc b/communicator/resources.qrc new file mode 100644 index 0000000..6ceb01d --- /dev/null +++ b/communicator/resources.qrc @@ -0,0 +1,5 @@ + + + main-window.qml + +