telephant/qml/chirp.qml

232 lines
6.5 KiB
QML
Raw Normal View History

2017-08-29 05:02:56 +00:00
import QtQuick 2.4
2017-08-29 14:28:33 +00:00
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
2017-08-29 05:02:56 +00:00
import QtQuick.Layouts 1.3
ApplicationWindow {
id: mainWindow
visible: true
Material.theme: Material.Dark
Material.accent: Material.Purple
// flags: Qt.FramelessWindowHint
minimumWidth: 800
minimumHeight: 480
Item {
2019-05-02 08:37:04 +00:00
MessagePopup {
id: messagePopup
2017-08-29 05:02:56 +00:00
width: 480
height: 300
x: mainWindow.width / 2 - width / 2
y: mainWindow.height / 2 - height / 2 - mainWindow.header.height / 2
}
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 / 2
width: 340
height: 340
}
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
}
}
Component {
id: messagesDelegate
2019-05-02 08:37:04 +00:00
MessageDelegate { }
2017-08-29 05:02:56 +00:00
}
header: ToolBar {
/* MouseArea {
anchors.fill: parent;
property variant clickPos: "1,1"
onPressed: {
clickPos = Qt.point(mouse.x,mouse.y)
}
onPositionChanged: {
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
mainWindow.x += delta.x;
mainWindow.y += delta.y;
}
} */
2017-08-29 05:02:56 +00:00
RowLayout {
spacing: 20
anchors.fill: parent
ToolButton {
id: drawerButton
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "images/drawer.png"
}
onClicked: {
drawer.open()
}
}
RowLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
spacing: 8
Layout.topMargin: 4
Layout.bottomMargin: 4
ImageButton {
opacity: 1.0
rounded: true
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: accountBridge.avatar
sourceSize.height: 32
onClicked: function() {
2019-05-02 08:37:29 +00:00
Qt.openUrlExternally(accountBridge.profileURL)
}
2017-08-29 05:02:56 +00:00
}
Label {
id: titleLabel
text: accountBridge.username
font.pixelSize: 16
elide: Label.ElideRight
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
}
ToolButton {
id: menuButton
anchors.right: parent.right
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 {
2017-08-31 18:55:29 +00:00
text: qsTr("Settings")
2017-08-29 05:02:56 +00:00
onTriggered: settingsDialog.open()
}
MenuItem {
2017-08-31 18:55:29 +00:00
text: qsTr("About")
2017-08-29 05:02:56 +00:00
onTriggered: aboutDialog.open()
}
}
}
}
}
Drawer {
id: drawer
width: mainWindow.width / 3
height: mainWindow.height
dragMargin: 0
2019-05-05 12:57:56 +00:00
ColumnLayout {
2017-08-29 05:02:56 +00:00
anchors.fill: parent
2019-05-05 12:57:56 +00:00
AccountSummary {}
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:
connectDialog.open()
break
case 1:
messagePopup.messageid = 0
messagePopup.open()
break
case 2:
Qt.quit()
break
}
}
}
model: ListModel {
ListElement {
title: qsTr("Connect")
property int sid: 0
}
ListElement {
title: qsTr("New Post")
property int sid: 1
}
ListElement {
title: qsTr("Exit")
property int sid: 2
}
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
}
}
}
}
GridLayout {
id: maingrid
columns: 2
rows: 1
anchors.fill: parent
2017-08-30 12:48:06 +00:00
anchors.margins: 0
columnSpacing: 0
rowSpacing: 0
2017-08-29 05:02:56 +00:00
2019-05-02 08:37:04 +00:00
MessagePane {
2017-08-29 05:02:56 +00:00
Layout.row: 0
Layout.column: 0
name: qsTr("Messages")
messageModel: accountBridge.messages
}
2019-05-02 08:37:04 +00:00
MessagePane {
2017-08-29 05:02:56 +00:00
Layout.row: 0
Layout.column: 1
name: qsTr("Notifications")
messageModel: accountBridge.notifications
}
}
}