From 0d6a39c8e5845d977c8750e8b447920849f90517 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 24 Feb 2020 20:59:45 +0100 Subject: [PATCH] Set up GUI. --- CMakeLists.txt | 2 +- gui/FediPotato.qrc | 5 +++++ gui/qml/mainwindow.qml | 12 ++++++++++++ gui/src/CMakeLists.txt | 22 ++++++++++++++++++++++ gui/src/main.cpp | 29 +++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 gui/FediPotato.qrc create mode 100644 gui/qml/mainwindow.qml create mode 100644 gui/src/CMakeLists.txt create mode 100644 gui/src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a759606..774f64c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ if(WITH_CLANG-TIDY) endif() add_subdirectory(lib) -# add_subdirectory(gui) +add_subdirectory(gui) # if(WITH_TESTS) # add_subdirectory(tests) diff --git a/gui/FediPotato.qrc b/gui/FediPotato.qrc new file mode 100644 index 0000000..e7f18ef --- /dev/null +++ b/gui/FediPotato.qrc @@ -0,0 +1,5 @@ + + + qml/mainwindow.qml + + diff --git a/gui/qml/mainwindow.qml b/gui/qml/mainwindow.qml new file mode 100644 index 0000000..57848b7 --- /dev/null +++ b/gui/qml/mainwindow.qml @@ -0,0 +1,12 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.10 +import QtQuick.Layouts 1.10 + +ApplicationWindow +{ + id: win_main + title: "FediPotato" + visible: true + width: 400 + height: 500 +} diff --git a/gui/src/CMakeLists.txt b/gui/src/CMakeLists.txt new file mode 100644 index 0000000..151b685 --- /dev/null +++ b/gui/src/CMakeLists.txt @@ -0,0 +1,22 @@ +include(GNUInstallDirs) + +set(CMAKE_AUTOMOC ON) + +find_package(Qt5 5.10 COMPONENTS Gui Qml Quick CONFIG REQUIRED) + +add_executable(${PROJECT_NAME}GUI) + +set_target_properties(${PROJECT_NAME}GUI PROPERTIES + OUTPUT_NAME "${PROJECT_NAME}" + CXX_CLANG_TIDY "") # The autogenerated code from Qt throws a lot of warnings. + +qt5_add_resources(qml_ressources "../${PROJECT_NAME}.qrc") +file(GLOB_RECURSE sources_gui *.cpp) +target_sources(${PROJECT_NAME}GUI + PRIVATE "${sources_gui}" "${qml_ressources}") + +target_link_libraries(${PROJECT_NAME}GUI + PRIVATE ${PROJECT_NAME} Qt5::Gui Qt5::Qml Qt5::Quick) + +install(TARGETS ${PROJECT_NAME}GUI + DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/gui/src/main.cpp b/gui/src/main.cpp new file mode 100644 index 0000000..984c111 --- /dev/null +++ b/gui/src/main.cpp @@ -0,0 +1,29 @@ +/* This file is part of FediPotato. + * Copyright © 2020 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + + engine.load(QUrl(QStringLiteral("qrc:/qml/mainwindow.qml"))); + + return QGuiApplication::exec(); +}