add book
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(21-ApplicationWindow VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app21-ApplicationWindow
|
||||
main.cpp resource.qrc
|
||||
)
|
||||
|
||||
qt_add_qml_module(app21-ApplicationWindow
|
||||
URI 21-ApplicationWindow
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml Page1.qml Page2.qml Page3.qml
|
||||
)
|
||||
|
||||
set_target_properties(app21-ApplicationWindow PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(app21-ApplicationWindow
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app21-ApplicationWindow
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
ApplicationWindow {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("ApplicationWindow Demo")
|
||||
|
||||
menuBar: MenuBar {
|
||||
Menu {
|
||||
title: qsTr("&File")
|
||||
Action {
|
||||
id: newActionId
|
||||
text: qsTr("&New")
|
||||
icon.source: "qrc:/images/newFileIcon.png"
|
||||
onTriggered: {
|
||||
console.log("Clicked on new")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Action {
|
||||
id: openActionId
|
||||
text: qsTr("&Open...")
|
||||
icon.source: "qrc:/images/openIcon.png"
|
||||
|
||||
}
|
||||
Action {
|
||||
id: saveActionId
|
||||
text: qsTr("&Save")
|
||||
icon.source: "qrc:/images/saveIcon.png"
|
||||
}
|
||||
Action {
|
||||
id: saveAsActionId
|
||||
text: qsTr("Save &As...")
|
||||
icon.source: "qrc:/images/saveAsIcon.png"
|
||||
}
|
||||
|
||||
MenuSeparator{}
|
||||
Action {
|
||||
id: quitActionId
|
||||
text: qsTr("Quit")
|
||||
icon.source: "qrc:/images/quitIcon.png"
|
||||
onTriggered: Qt.quit()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: qsTr("&Edit")
|
||||
Action {id: cutMenuId; icon.source: "qrc:/images/cutIcon.png"; text: qsTr("Cut") }
|
||||
Action {
|
||||
text: qsTr("Copy")
|
||||
icon.source: "qrc:/images/copyIcon.png"
|
||||
}
|
||||
Action { text: qsTr("Paste") ; icon.source: "qrc:/images/pasteIcon.png"}
|
||||
MenuSeparator { }
|
||||
Action { text: qsTr("Undo"); icon.source: "qrc:/images/undoIcon.png" }
|
||||
Action { text: qsTr("Redo") ; icon.source: "qrc:/images/redoIcon.png"}
|
||||
}
|
||||
Menu {
|
||||
id: helpMenu
|
||||
title: qsTr("&Help")
|
||||
Action {
|
||||
text: qsTr("&About")
|
||||
icon.source: "qrc:/images/info.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header: ToolBar {
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
ToolButton{
|
||||
action: newActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: saveActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: saveAsActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: quitActionId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer: TabBar {
|
||||
id: mTabBar
|
||||
width: parent.width
|
||||
|
||||
TabButton {
|
||||
text : qsTr("Page1")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page1.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
TabButton {
|
||||
text : qsTr("Page2")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page2.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
TabButton {
|
||||
text : qsTr("Page3")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page3.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Main Content
|
||||
StackView {
|
||||
id : mStackId
|
||||
anchors.fill: parent
|
||||
initialItem: Page1{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "red"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "green"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "blue"
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("21-ApplicationWindow", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/copyIcon.png</file>
|
||||
<file>images/cutIcon.png</file>
|
||||
<file>images/info.png</file>
|
||||
<file>images/newFileIcon.png</file>
|
||||
<file>images/openIcon.png</file>
|
||||
<file>images/pasteIcon.png</file>
|
||||
<file>images/quitIcon.png</file>
|
||||
<file>images/redoIcon.png</file>
|
||||
<file>images/saveAsIcon.png</file>
|
||||
<file>images/saveIcon.png</file>
|
||||
<file>images/undoIcon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||