Replace dialog box with window, list authors.

This commit is contained in:
tastytea 2020-02-25 06:54:00 +01:00
parent 9146356383
commit ceb7f688f2
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
6 changed files with 94 additions and 37 deletions

View File

@ -1,5 +1,8 @@
<RCC>
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/">
<file>qml/mainwindow.qml</file>
<file>qml/DialogAbout.qml</file>
<file alias="AUTHORS">../AUTHORS</file>
</qresource>
</RCC>

68
gui/qml/DialogAbout.qml Normal file
View File

@ -0,0 +1,68 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3
Window
{
id: win_about
title: qsTr("About FediPotato") + " " + QMLBridge.get_version()
flags: Qt.Dialog
modality: Qt.NonModal
minimumWidth: label_description.width * 2
minimumHeight: label_description.width
TabBar
{
id: tabbar_about
width: parent.width
TabButton
{
text: qsTr("About")
}
TabButton
{
text: qsTr("Authors")
}
}
StackLayout {
id: layout_about
anchors.top: tabbar_about.bottom
width: parent.width
currentIndex: tabbar_about.currentIndex
ColumnLayout
{
width: parent.width
Label
{
id: label_description
text: "<b>" + qsTr("Client for Fediverse servers.") + "</b>"
}
Label
{
id: label_license
Layout.fillWidth: true
wrapMode: Text.WordWrap
onLinkActivated: Qt.openUrlExternally(link)
text: qsTr("License AGPL-3.0-only: <a href='" +
"https://www.gnu.org/licenses/agpl-3.0.txt'>" +
"GNU Affero GPL version 3</a>.<br>" +
"This program comes with ABSOLUTELY NO WARRANTY. " +
"This is free software, and you are welcome to " +
"redistribute it under certain conditions.")
}
}
Label
{
id: label_authors
text: QMLBridge.get_authors()
}
}
}

View File

@ -19,13 +19,13 @@ ApplicationWindow
{
id: menu_exit
text: qsTr("Exit")
onTriggered: Qt.quit();
onTriggered: Qt.quit()
Shortcut
{
sequence: "Ctrl+Q"
context: Qt.ApplicationShortcut
onActivated: menu_exit.clicked();
onActivated: menu_exit.clicked()
}
}
}
@ -41,37 +41,9 @@ ApplicationWindow
MenuItem
{
text: qsTr("About FediPotato")
onTriggered: dialog_about.open()
}
}
}
onTriggered: win_about.show()
Dialog
{
id: dialog_about
title: qsTr("About FediPotato") + " " + QMLBridge.get_version()
standardButtons: Dialog.Close
ColumnLayout
{
width: parent.width
Label
{
text: qsTr("Client for Fediverse servers.")
}
Label
{
Layout.fillWidth: true
wrapMode: Text.WordWrap
onLinkActivated: Qt.openUrlExternally(link)
text: qsTr("License AGPLv3: <a href='https://www.gnu.org/" +
"licenses/agpl-3.0.txt'>" +
"GNU Affero GPL version 3</a>.<br>" +
"This program comes with ABSOLUTELY NO WARRANTY. " +
"This is free software, and you are welcome to " +
"redistribute it under certain conditions.")
DialogAbout { id: win_about }
}
}
}

View File

@ -1,8 +1,9 @@
include(GNUInstallDirs)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 5.10 COMPONENTS Gui Qml Quick CONFIG REQUIRED)
find_package(Qt5 5.10 COMPONENTS Core Gui Qml Quick CONFIG REQUIRED)
add_executable(${PROJECT_NAME}GUI)
@ -10,13 +11,12 @@ 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}")
PRIVATE "${sources_gui}" "../${PROJECT_NAME}.qrc")
target_link_libraries(${PROJECT_NAME}GUI
PRIVATE ${PROJECT_NAME} Qt5::Gui Qt5::Qml Qt5::Quick)
PRIVATE ${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick)
install(TARGETS ${PROJECT_NAME}GUI
DESTINATION "${CMAKE_INSTALL_BINDIR}")

View File

@ -17,6 +17,8 @@
#include "qmlbridge.hpp"
#include "fedipotato.hpp"
#include <QFile>
namespace FediPotato
{
@ -29,4 +31,15 @@ QString QMLBridge::get_version()
return FediPotato::get_version().data();
}
QString QMLBridge::get_authors()
{
QFile file(":/AUTHORS");
if (file.open(QIODevice::ReadOnly))
{
return file.readAll();
}
return "Could not open :/AUTHORS.";
}
} // namespace FediPotato

View File

@ -31,6 +31,7 @@ public:
explicit QMLBridge(QObject *parent = nullptr);
Q_INVOKABLE static QString get_version();
Q_INVOKABLE static QString get_authors();
};
} // namespace FediPotato