Add menu bar and about dialog.
This commit is contained in:
parent
0d6a39c8e5
commit
a6d0cb84cf
|
@ -1,6 +1,6 @@
|
|||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.10
|
||||
import QtQuick.Layouts 1.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
|
@ -9,4 +9,70 @@ ApplicationWindow
|
|||
visible: true
|
||||
width: 400
|
||||
height: 500
|
||||
|
||||
menuBar: MenuBar
|
||||
{
|
||||
Menu
|
||||
{
|
||||
title: "&FediPotato"
|
||||
MenuItem
|
||||
{
|
||||
id: menu_exit
|
||||
text: qsTr("Exit")
|
||||
onTriggered: Qt.quit();
|
||||
|
||||
Shortcut
|
||||
{
|
||||
sequence: "Ctrl+Q"
|
||||
context: Qt.ApplicationShortcut
|
||||
onActivated: menu_exit.clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
title: qsTr("&Help")
|
||||
MenuItem
|
||||
{
|
||||
text: qsTr("Website")
|
||||
onTriggered: Qt.openUrlExternally("http://fedipotato.org/")
|
||||
}
|
||||
MenuItem
|
||||
{
|
||||
text: qsTr("About FediPotato")
|
||||
onTriggered: dialog_about.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,23 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qmlbridge.hpp"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
|
||||
using namespace FediPotato;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QMLBridge qmlbridge;
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
// Make qmlbridge callable as QMLBridge in QML files.
|
||||
engine.rootContext()->setContextProperty("QMLBridge", &qmlbridge);
|
||||
engine.load(QUrl(QStringLiteral("qrc:/qml/mainwindow.qml")));
|
||||
|
||||
return QGuiApplication::exec();
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* This file is part of FediPotato.
|
||||
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qmlbridge.hpp"
|
||||
#include "fedipotato.hpp"
|
||||
|
||||
namespace FediPotato
|
||||
{
|
||||
|
||||
QMLBridge::QMLBridge(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
QString QMLBridge::get_version()
|
||||
{
|
||||
return FediPotato::get_version().data();
|
||||
}
|
||||
|
||||
} // namespace FediPotato
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef FEDIPOTATO_GUI_QMLBRIDGE_HPP
|
||||
#define FEDIPOTATO_GUI_QMLBRIDGE_HPP
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace FediPotato
|
||||
{
|
||||
|
||||
class QMLBridge : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QMLBridge(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE static QString get_version();
|
||||
};
|
||||
|
||||
} // namespace FediPotato
|
||||
|
||||
#endif // FEDIPOTATO_GUI_QMLBRIDGE_HPP
|
|
@ -17,9 +17,47 @@
|
|||
#ifndef FEDIPOTATO_HPP
|
||||
#define FEDIPOTATO_HPP
|
||||
|
||||
#include <string_view>
|
||||
|
||||
/*!
|
||||
* @brief High-level interface to fediverse accounts and their data.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
namespace FediPotato
|
||||
{
|
||||
|
||||
using std::string_view;
|
||||
|
||||
class FediPotato
|
||||
{
|
||||
public:
|
||||
//! Default constructor
|
||||
FediPotato() = default;
|
||||
|
||||
//! Copy constructor
|
||||
FediPotato(const FediPotato &other) = default;
|
||||
|
||||
//! Move constructor
|
||||
FediPotato(FediPotato &&other) noexcept = default;
|
||||
|
||||
//! Destructor
|
||||
virtual ~FediPotato() noexcept = default;
|
||||
|
||||
//! Copy assignment operator
|
||||
FediPotato& operator=(const FediPotato &other) = default;
|
||||
|
||||
//! Move assignment operator
|
||||
FediPotato& operator=(FediPotato &&other) noexcept = default;
|
||||
|
||||
/*!
|
||||
* @brief Return the version.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
static string_view get_version();
|
||||
};
|
||||
|
||||
} // namespace FediPotato
|
||||
|
||||
#endif // FEDIPOTATO_HPP
|
||||
|
|
|
@ -15,8 +15,14 @@
|
|||
*/
|
||||
|
||||
#include "fedipotato.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
namespace FediPotato
|
||||
{
|
||||
|
||||
string_view FediPotato::get_version()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
} // namespace FediPotato
|
||||
|
|
Reference in New Issue