telephant/qml/telephant.qml

302 lines
8.8 KiB
QML
Raw Normal View History

2017-08-29 07:02:56 +02:00
import QtQuick 2.4
import QtQuick.Controls 2.5
2017-08-29 16:28:33 +02:00
import QtQuick.Controls.Material 2.1
2017-08-29 07:02:56 +02:00
import QtQuick.Layouts 1.3
ApplicationWindow {
id: mainWindow
visible: true
Material.theme: settings.style == "Dark" ? Material.Dark : Material.Light
Material.accent: Material.Purple
2017-08-29 07:02:56 +02:00
// flags: Qt.FramelessWindowHint
background: Rectangle {
color: Material.color(Material.Grey, Material.Shade900)
}
minimumWidth: 600
minimumHeight: 590
Component.onCompleted: {
if (settings.firstRun) {
connectDialog.open()
}
}
2017-08-29 07:02:56 +02:00
Item {
2019-05-02 10:37:04 +02:00
MessagePopup {
id: messagePopup
2019-05-09 00:17:51 +02:00
width: mainWindow.width * 0.66
// height: mainWindow.height * 0.8
2017-08-29 07:02:56 +02:00
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
}
SharePopup {
id: sharePopup
width: mainWindow.width * 0.66
// height: mainWindow.height * 0.8
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
}
ConversationPopup {
id: conversationPopup
width: mainWindow.width * 0.8
height: mainWindow.height * 0.8
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
2017-08-29 07:02:56 +02:00
}
AccountPopup {
id: accountPopup
width: mainWindow.width * 0.8
height: mainWindow.height * 0.8
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height
}
2017-08-29 07:02:56 +02:00
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
height: 420
}
2017-08-29 07:02:56 +02: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 15:45:38 +02: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 {
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 15:45:38 +02:00
errorDialog.close()
}
}
}
}
2017-08-29 07:02:56 +02:00
}
header: ToolBar {
ToolButton {
id: drawerButton
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/drawer.png"
2017-08-29 07:02:56 +02:00
}
onClicked: {
drawer.open()
2017-08-29 07:02:56 +02:00
}
}
2017-08-29 07:02:56 +02:00
RowLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
spacing: 8
ImageButton {
opacity: 1.0
rounded: true
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: accountBridge.avatar
sourceSize.height: 32
onClicked: function() {
Qt.openUrlExternally(accountBridge.profileURL)
2017-08-29 07:02:56 +02:00
}
}
Label {
id: titleLabel
text: accountBridge.username
font.pointSize: 13
elide: Label.ElideRight
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Qt.AlignVCenter
2017-08-29 07:02:56 +02:00
}
}
2017-08-29 07:02:56 +02:00
ToolButton {
id: postButton
anchors.right: menuButton.left
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/post.png"
}
onClicked: {
messagePopup.message = null
messagePopup.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 07:02:56 +02:00
}
}
/*
MenuItem {
text: qsTr("Settings")
onTriggered: settingsDialog.open()
}
*/
MenuItem {
text: qsTr("About")
onTriggered: aboutDialog.open()
}
2017-08-29 07:02:56 +02:00
}
}
}
Drawer {
id: drawer
width: mainWindow.width / 3
height: mainWindow.height
dragMargin: 0
2019-05-05 14:57:56 +02:00
ColumnLayout {
2017-08-29 07:02:56 +02:00
anchors.fill: parent
AccountSummary {
profile: accountBridge
}
2019-05-05 14:57:56 +02:00
ToolSeparator {
Layout.fillWidth: true
orientation: Qt.Horizontal
2017-08-29 07:02:56 +02:00
}
2019-05-05 14:57:56 +02: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:
messagePopup.message = null
2019-05-05 14:57:56 +02:00
messagePopup.open()
break
case 1:
2019-05-05 14:57:56 +02:00
Qt.quit()
break
}
}
}
model: ListModel {
ListElement {
title: qsTr("New Post")
property int sid: 0
2019-05-05 14:57:56 +02:00
}
ListElement {
title: qsTr("Exit")
property int sid: 1
2019-05-05 14:57:56 +02:00
}
2017-08-29 07:02:56 +02:00
}
2019-05-05 14:57:56 +02:00
ScrollIndicator.vertical: ScrollIndicator {
2017-08-29 07:02:56 +02:00
}
}
}
}
ScrollView {
id: mainscroll
2017-08-29 07:02:56 +02:00
anchors.fill: parent
ScrollBar.horizontal.policy: contentWidth > width ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
contentWidth: Math.max(maingrid.implicitWidth, 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 07:02:56 +02:00
}
}
}