telephant/qml/telephant.qml

289 lines
8.4 KiB
QML
Raw Normal View History

2017-08-29 05:02:56 +00:00
import QtQuick 2.4
import QtQuick.Controls 2.2
2017-08-29 14:28:33 +00:00
import QtQuick.Controls.Material 2.1
2017-08-29 05:02:56 +00:00
import QtQuick.Layouts 1.3
import "componentCreator.js" as ComponentCreator
2017-08-29 05:02:56 +00:00
ApplicationWindow {
id: mainWindow
visible: true
Material.theme: settings.style == "Dark" ? Material.Dark : Material.Light
Material.accent: Material.Purple
2017-08-29 05:02:56 +00:00
// flags: Qt.FramelessWindowHint
background: Rectangle {
color: Material.color(Material.Grey, Material.Shade900)
}
minimumWidth: 364
minimumHeight: 590
width: settings.width > 0 ? settings.width : minimumWidth * 2
height: settings.height > 0 ? settings.height : minimumWidth * 1.5
Binding on x {
when: settings.positionX > 0
value: settings.positionX
}
Binding on y {
when: settings.positionY > 0
value: settings.positionY
}
Component.onCompleted: {
if (settings.firstRun) {
connectDialog.open()
}
}
onClosing: function() {
console.log("Closing mainWindow")
settings.positionX = mainWindow.x
settings.positionY = mainWindow.y
settings.width = mainWindow.width
settings.height = mainWindow.height
}
2017-08-29 05:02:56 +00:00
Item {
AboutDialog {
id: aboutDialog
x: (mainWindow.width - width) / 2
y: mainWindow.height / 6
width: Math.min(mainWindow.width, mainWindow.height) / 3 * 2
}
ConnectDialog {
id: connectDialog
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
width: 340
2019-05-15 00:08:13 +00:00
height: 500
}
2017-08-29 05:02:56 +00:00
SettingsDialog {
id: settingsDialog
x: (mainWindow.width - width) / 2
y: mainWindow.height / 6
width: Math.min(mainWindow.width, mainWindow.height) / 3 * 2
}
2019-05-10 13:45:38 +00:00
Popup {
id: errorDialog
modal: true
focus: true
contentHeight: errorLayout.height
visible: accountBridge.error.length > 0
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
width: Math.min(mainWindow.width * 0.66, errorLayout.implicitWidth + 32)
ColumnLayout {
id: errorLayout
spacing: 20
width: parent.width
Label {
text: qsTr("Error")
font.bold: true
}
Label {
2019-05-19 00:43:48 +00:00
Layout.fillWidth: true
2019-05-10 13:45:38 +00:00
wrapMode: Label.Wrap
font.pointSize: 14
text: accountBridge.error
}
Button {
id: okButton
Layout.alignment: Qt.AlignCenter
highlighted: true
text: qsTr("Close")
onClicked: {
accountBridge.error = ""
2019-05-10 13:45:38 +00:00
errorDialog.close()
}
}
}
}
2017-08-29 05:02:56 +00:00
}
header: ToolBar {
ToolButton {
id: drawerButton
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/drawer.png"
2017-08-29 05:02:56 +00:00
}
onClicked: {
drawer.open()
2017-08-29 05:02:56 +00:00
}
}
2017-08-29 05:02:56 +00:00
RowLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
spacing: 8
ImageButton {
opacity: 1.0
roundness: 250
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: accountBridge.avatar
sourceSize.height: 32
onClicked: function() {
Qt.openUrlExternally(accountBridge.profileURL)
2017-08-29 05:02:56 +00:00
}
}
Label {
id: titleLabel
text: accountBridge.username
font.pointSize: 13
elide: Label.ElideRight
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Qt.AlignVCenter
2017-08-29 05:02:56 +00:00
}
}
2017-08-29 05:02:56 +00:00
ToolButton {
id: postButton
anchors.right: menuButton.left
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/post.png"
}
onClicked: {
ComponentCreator.createMessagePopup(this, null).open();
}
}
ToolButton {
anchors.right: parent.right
id: menuButton
Layout.alignment: Qt.AlignRight
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/menu.png"
}
onClicked: optionsMenu.open()
Menu {
id: optionsMenu
x: parent.width - width
transformOrigin: Menu.TopRight
MenuItem {
text: qsTr("Connect")
onTriggered: function() {
connectDialog.reset()
connectDialog.open()
2017-08-29 05:02:56 +00:00
}
}
/*
MenuItem {
text: qsTr("Settings")
onTriggered: settingsDialog.open()
}
*/
MenuItem {
text: qsTr("About")
onTriggered: aboutDialog.open()
}
2017-08-29 05:02:56 +00:00
}
}
}
Drawer {
id: drawer
2019-05-14 22:23:32 +00:00
width: drawerLayout.implicitWidth + 16
2017-08-29 05:02:56 +00:00
height: mainWindow.height
dragMargin: 0
2019-05-05 12:57:56 +00:00
ColumnLayout {
2019-05-14 22:23:32 +00:00
id: drawerLayout
2017-08-29 05:02:56 +00:00
anchors.fill: parent
AccountSummary {
profile: accountBridge
}
2019-05-05 12:57:56 +00:00
ToolSeparator {
Layout.fillWidth: true
orientation: Qt.Horizontal
2017-08-29 05:02:56 +00:00
}
2019-05-05 12:57:56 +00:00
ListView {
id: listView
currentIndex: -1
Layout.fillWidth: true
Layout.fillHeight: true
delegate: ItemDelegate {
width: parent.width
text: model.title
highlighted: ListView.isCurrentItem
onClicked: {
listView.currentIndex = -1
drawer.close()
switch (model.sid) {
case 0:
ComponentCreator.createMessagePopup(this, null).open();
2019-05-05 12:57:56 +00:00
break
case 1:
2019-05-05 12:57:56 +00:00
Qt.quit()
break
}
}
}
model: ListModel {
ListElement {
title: qsTr("New Post")
property int sid: 0
2019-05-05 12:57:56 +00:00
}
ListElement {
title: qsTr("Exit")
property int sid: 1
2019-05-05 12:57:56 +00:00
}
2017-08-29 05:02:56 +00:00
}
2019-05-05 12:57:56 +00:00
ScrollIndicator.vertical: ScrollIndicator {
2017-08-29 05:02:56 +00:00
}
}
}
}
ScrollView {
id: mainscroll
2017-08-29 05:02:56 +00:00
anchors.fill: parent
ScrollBar.horizontal.policy: contentWidth > width ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
2019-05-17 13:14:20 +00:00
contentWidth: Math.max(maingrid.implicitWidth, parent.width)
GridLayout {
id: maingrid
// columns: accountBridge.panes.length
rows: 1
anchors.fill: parent
anchors.margins: 0
columnSpacing: 0
rowSpacing: 0
Repeater {
model: accountBridge.panes
MessagePane {
Layout.row: 0
Layout.column: index
idx: index
name: model.panename
sticky: model.panesticky
messageModel: model.msgmodel
}
}
2017-08-29 05:02:56 +00:00
}
}
}