Initial UI
This commit is contained in:
1 parent
4d52c8cc60
commit
3c0037cfc9
29 files changed
+1367
-2
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Dialogs
|
||||
import Asteria
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
width: 1024
|
||||
height: 768
|
||||
visible: true
|
||||
title: "Asteria"
|
||||
color: Theme.backgroundDeepest
|
||||
|
||||
FontLoader {
|
||||
id: materialIcons
|
||||
source: "qrc:/Asteria/src/assets/MaterialIconsOutlined-Regular.otf"
|
||||
}
|
||||
|
||||
property bool sidebarOpen: false
|
||||
property string currentPage: "starter"
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
|
||||
SideBar {
|
||||
id: sidebar
|
||||
height: parent.height
|
||||
sidebarOpen: window.sidebarOpen
|
||||
onCloseDrawer: window.sidebarOpen = false
|
||||
onNavigateTo: function(page) {
|
||||
window.currentPage = page
|
||||
window.sidebarOpen = false
|
||||
}
|
||||
onOpenFile: {
|
||||
fileDialog.open()
|
||||
window.sidebarOpen = false
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - sidebar.width
|
||||
height: parent.height
|
||||
|
||||
Header {
|
||||
id: header
|
||||
width: parent.width
|
||||
sidebarOpen: window.sidebarOpen
|
||||
currentPage: window.currentPage
|
||||
onMenuClicked: window.sidebarOpen = true
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: contentLoader
|
||||
width: parent.width
|
||||
height: parent.height - header.height - (footerLoader.active ? Theme.footerHeight : 0)
|
||||
sourceComponent: {
|
||||
switch (window.currentPage) {
|
||||
case "reader": return readerComponent
|
||||
case "settings": return settingsComponent
|
||||
default: return starterComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: footerLoader
|
||||
width: parent.width
|
||||
active: window.currentPage === "reader"
|
||||
sourceComponent: Footer {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: starterComponent
|
||||
StarterPage {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: readerComponent
|
||||
ReaderPage {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: settingsComponent
|
||||
SettingsPage {}
|
||||
}
|
||||
|
||||
ErrorPopup {
|
||||
anchors.fill: parent
|
||||
z: 3000
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
title: "Open Book"
|
||||
nameFilters: ["Book files (*.txt *.fb2 *.epub *.pdf *.doc *.rtf *.html *.htm *.docx *.djvu *.odt *.chm)", "All files (*)"]
|
||||
onAccepted: bookController.openBook(selectedFile)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: bookController
|
||||
function onBookReady() {
|
||||
window.currentPage = "reader"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
readonly property color backgroundDeepest: "#010620"
|
||||
readonly property color backgroundDefault: "#01082b"
|
||||
readonly property color surface: "#191d35"
|
||||
readonly property color headerBg: "#14172c"
|
||||
readonly property color footerBg: "#1a1e36"
|
||||
readonly property color scrollbarTrack: "#131628"
|
||||
readonly property color scrollbarThumb: "#36486a"
|
||||
readonly property color primaryAccent: "#3a5688"
|
||||
readonly property color buttonAccent: "#5785c1"
|
||||
readonly property color sidebarButtonText: "#98aaf4"
|
||||
readonly property color readingText: "#c4c8d8"
|
||||
readonly property color uiText: "#a2a5b4"
|
||||
readonly property color headerText: "#8488aa"
|
||||
readonly property color dimText: "#71738c"
|
||||
readonly property color counterText: "#606175"
|
||||
|
||||
readonly property int sidebarWidth: 240
|
||||
|
||||
readonly property color gradientTop: "#0e1125"
|
||||
readonly property color gradientBottom: "#191d35"
|
||||
readonly property color divider: Qt.rgba(1, 1, 1, 0.12)
|
||||
readonly property color overlayBg: Qt.rgba(0.055, 0.055, 0.067, 0.4)
|
||||
readonly property color actionDisabled: "#141724"
|
||||
|
||||
readonly property int headerHeight: 64
|
||||
readonly property int footerHeight: 28
|
||||
readonly property int animDurationOpen: 225
|
||||
readonly property int animDurationClose: 195
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
id: overlay
|
||||
color: Theme.overlayBg
|
||||
visible: bookController.errorMessage !== ""
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {} // Block clicks through overlay
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: 20
|
||||
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: bookController.errorMessage
|
||||
font.pixelSize: 15
|
||||
color: Theme.readingText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.Wrap
|
||||
width: Math.min(overlay.width * 0.6, 400)
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Ok"
|
||||
contentItem: Text {
|
||||
text: parent.text
|
||||
font.pixelSize: 14
|
||||
color: "#ffffff"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
background: Rectangle {
|
||||
implicitWidth: 80
|
||||
implicitHeight: 36
|
||||
radius: 4
|
||||
color: parent.hovered ? Qt.lighter(Theme.primaryAccent, 1.15) : Theme.primaryAccent
|
||||
}
|
||||
onClicked: bookController.errorMessage = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import QtQuick
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
height: Theme.footerHeight
|
||||
color: Theme.footerBg
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.divider
|
||||
anchors.top: parent.top
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: parent.width * 0.5
|
||||
text: bookController.hasBook
|
||||
? "Chapter " + (readingModel.currentChapter + 1) + " / " + readingModel.totalChapters
|
||||
: ""
|
||||
font.pixelSize: 11
|
||||
font.bold: true
|
||||
color: Theme.dimText
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
id: header
|
||||
height: Theme.headerHeight
|
||||
color: Theme.surface
|
||||
|
||||
property bool sidebarOpen: false
|
||||
property string currentPage: "starter"
|
||||
|
||||
signal menuClicked()
|
||||
|
||||
Button {
|
||||
id: menuButton
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: !header.sidebarOpen
|
||||
flat: true
|
||||
contentItem: Text {
|
||||
text: "\u2630"
|
||||
font.pixelSize: 24
|
||||
color: Theme.buttonAccent
|
||||
}
|
||||
background: Item {}
|
||||
onClicked: header.menuClicked()
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: {
|
||||
switch (header.currentPage) {
|
||||
case "settings": return "Settings"
|
||||
case "reader": return bookController.bookTitle || ""
|
||||
default: return ""
|
||||
}
|
||||
}
|
||||
font.pixelSize: 16
|
||||
color: Theme.headerText
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: parent.width * 0.02
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
id: clockText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.pixelSize: 16
|
||||
font.bold: true
|
||||
color: Theme.dimText
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 1000
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
var d = new Date()
|
||||
var h = d.getHours() % 12
|
||||
if (h === 0) h = 12
|
||||
var m = d.getMinutes().toString().padStart(2, '0')
|
||||
var s = d.getSeconds().toString().padStart(2, '0')
|
||||
var ampm = d.getHours() >= 12 ? "PM" : "AM"
|
||||
clockText.text = h + ":" + m + ":" + s + " " + ampm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.pixelSize: 12
|
||||
font.bold: true
|
||||
color: Theme.counterText
|
||||
visible: header.currentPage === "reader" && bookController.hasBook
|
||||
text: bookController.hasBook
|
||||
? (readingModel.currentChapter + 1) + "/" + readingModel.totalChapters
|
||||
: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: Theme.gradientTop }
|
||||
GradientStop { position: 1.0; color: Theme.gradientBottom }
|
||||
}
|
||||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
contentHeight: contentText.implicitHeight
|
||||
clip: true
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
policy: ScrollBar.AsNeeded
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: 18
|
||||
radius: 3
|
||||
color: Theme.scrollbarThumb
|
||||
}
|
||||
background: Rectangle {
|
||||
implicitWidth: 18
|
||||
color: Theme.scrollbarTrack
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: contentText
|
||||
width: parent.width
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
textFormat: Text.RichText
|
||||
font.pixelSize: 16
|
||||
lineHeight: 1.6
|
||||
color: Theme.readingText
|
||||
text: bookController.hasBook ? readingModel.chapterContent : "Open a book to start reading"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
id: sidebar
|
||||
width: sidebarOpen ? Theme.sidebarWidth : 0
|
||||
clip: true
|
||||
color: Theme.surface
|
||||
|
||||
property bool sidebarOpen: false
|
||||
|
||||
signal closeDrawer()
|
||||
signal navigateTo(string page)
|
||||
signal openFile()
|
||||
|
||||
Behavior on width {
|
||||
NumberAnimation {
|
||||
duration: sidebarOpen ? Theme.animDurationOpen : Theme.animDurationClose
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 16
|
||||
y: Theme.headerHeight / 2 - height / 2
|
||||
text: "Asteria"
|
||||
font.pixelSize: 18
|
||||
font.bold: true
|
||||
color: Theme.uiText
|
||||
}
|
||||
|
||||
// Close button aligned with main header row
|
||||
Button {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
y: Theme.headerHeight / 2 - height / 2
|
||||
z: 1
|
||||
flat: true
|
||||
contentItem: Text {
|
||||
text: "\ue5cb"
|
||||
font.family: "Material Icons Outlined"
|
||||
font.pixelSize: 24
|
||||
color: Theme.sidebarButtonText
|
||||
}
|
||||
background: Item {}
|
||||
onClicked: sidebar.closeDrawer()
|
||||
}
|
||||
|
||||
Column {
|
||||
y: Theme.headerHeight
|
||||
width: Theme.sidebarWidth
|
||||
|
||||
SideBarButton {
|
||||
iconText: "\ue86d"
|
||||
title: "Book"
|
||||
onClicked: sidebar.navigateTo("reader")
|
||||
}
|
||||
|
||||
SideBarButton {
|
||||
iconText: "\ue30a"
|
||||
title: "Files"
|
||||
onClicked: sidebar.openFile()
|
||||
}
|
||||
|
||||
// Divider
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.divider
|
||||
}
|
||||
|
||||
SideBarButton {
|
||||
iconText: "\ue3a9"
|
||||
title: "Dark Theme"
|
||||
onClicked: {} // Non-functional
|
||||
}
|
||||
|
||||
SideBarButton {
|
||||
iconText: "\ue3a6"
|
||||
title: "Light Theme"
|
||||
onClicked: {} // Non-functional
|
||||
}
|
||||
|
||||
// Divider
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.divider
|
||||
}
|
||||
|
||||
SideBarButton {
|
||||
iconText: "\ue8b8"
|
||||
title: "Settings"
|
||||
onClicked: sidebar.navigateTo("settings")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
height: 48
|
||||
width: parent ? parent.width : 240
|
||||
color: mouseArea.containsMouse ? Qt.lighter(Theme.headerBg, 1.3) : "transparent"
|
||||
|
||||
property string iconText: ""
|
||||
property string title: ""
|
||||
signal clicked()
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 16
|
||||
spacing: 16
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.iconText
|
||||
font.family: "Material Icons Outlined"
|
||||
font.pixelSize: 24
|
||||
color: Theme.sidebarButtonText
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.title
|
||||
font.pixelSize: 14
|
||||
color: Theme.sidebarButtonText
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import QtQuick
|
||||
import Asteria
|
||||
|
||||
PageView {
|
||||
anchors.fill: parent
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import QtQuick
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: Theme.gradientTop }
|
||||
GradientStop { position: 1.0; color: Theme.gradientBottom }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import QtQuick
|
||||
import Asteria
|
||||
|
||||
Rectangle {
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: Theme.gradientTop }
|
||||
GradientStop { position: 1.0; color: Theme.gradientBottom }
|
||||
}
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: "qrc:/Asteria/src/assets/moon1.svg"
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
opacity: 0.15
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user