diff --git a/src/qml/Desktop.qml b/src/qml/Desktop.qml index f543b9a2..db71d6df 100644 --- a/src/qml/Desktop.qml +++ b/src/qml/Desktop.qml @@ -1,351 +1,378 @@ /* * * Copyright 2016 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Controls 2.0 as QQC2 import QtQuick.Controls.Styles 1.2 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 import Qt.labs.settings 1.0 import QtGraphicalEffects 1.0 import KDE.Ruqola.Ruqola 1.0 import KDE.Ruqola.DDPClient 1.0 //import KDE.Ruqola.Notification 1.0 // import "Log.js" as Log // import "Data.js" as Data import org.kde.kirigami 2.1 as Kirigami Kirigami.ApplicationWindow { id: appid property int margin: 11 property string statusText property string lightGreen: "#6ab141"; property string darkGreen: "#00613a"; property string selectedRoomID: ""; property QtObject selectedRoom property QtObject model width: Kirigami.Units.gridUnit * 55 height: Kirigami.Units.gridUnit * 40 title: qsTr("Ruqola") header: Kirigami.ApplicationHeader {} pageStack.initialPage: [roomsComponent, mainComponent] pageStack.visible: Ruqola.loginStatus == DDPClient.LoggedIn // Keys.onShortcutOverride: event.accepted = (event.key === StandardKey.Quit) // Shortcut { // sequence: StandardKey.Quit // context: Qt.ApplicationShortcut // onActivated: { // console.log("QUITTING (trying)"); // Qt.quit(); // } // } globalDrawer: Kirigami.GlobalDrawer { drawerOpen: false handleVisible: true resetMenuOnTriggered: true topContent: [ Text { text: qsTr("Hello, %1").arg(Ruqola.userName) } ] actions: [ Kirigami.Action { text: "Preferences" iconName: "user-available" Kirigami.Action { text: "Change theme" iconName: "preferences-desktop-theme" } Kirigami.Action { text: "action 2" } Kirigami.Action { text: "action 3" } }, Kirigami.Action { text: "Log out" iconName: "system-log-out" onTriggered: { Ruqola.logOut(); appid.globalDrawer.drawerOpen = false; } }, Kirigami.Action { - shortcut: "Ctrl+Q" //StandardKey.Quit + shortcut: StandardKey.Quit text: "Quit" iconName: "application-exit" onTriggered: { Qt.quit(); } } ] } Login { id: loginTab anchors.fill: parent visible: Ruqola.loginStatus != DDPClient.LoggedIn serverURL: Ruqola.serverURL username: Ruqola.userName onAccepted: { Ruqola.password = loginTab.password; Ruqola.userName = loginTab.username; Ruqola.serverURL = loginTab.serverURL; // DDPClient.loginType = Password; Ruqola.tryLogin(); } } BusyIndicator { id: busy // indeterminate: true anchors.centerIn: parent visible: Ruqola.loginStatus == DDPClient.LoggingIn } Component { id: roomsComponent Kirigami.ScrollablePage { id: roomsPage actions.main: Kirigami.Action { + id: editAction + iconName: "list-add" +// checkable: true + onTriggered: { + channelsList.open(); + } + } + actions.left: Kirigami.Action { +// enabled: editAction.checked iconName: "edit-symbolic" checkable: true onToggled: { if (checked) { roomsList.editingMode = true } else { roomsList.editingMode = false } // do stuff } } background: Rectangle { color: Kirigami.Theme.viewBackgroundColor } - RoomsView { - id: roomsList - implicitWidth: Kirigami.Units.gridUnit * 10 - anchors.fill: parent - - model: Ruqola.roomModel() - selectedRoomID: appid.selectedRoomID; - onRoomSelected: { - if (roomID == selectedRoomID) { - return; + + mainItem: + +// QQC2.TextField { +// id: searchField +// placeholderText: qsTr("Search...") +// width: parent.width +// } + RoomsView { + + id: roomsList + implicitWidth: Kirigami.Units.gridUnit * 10 + anchors.fill: parent +// width: parent.width +// height: parent.height + model: Ruqola.roomModel() + selectedRoomID: appid.selectedRoomID; + onRoomSelected: { + if (roomID == selectedRoomID) { + return; + } + console.log("Choosing room", roomID); + appid.selectedRoomID = roomID; + appid.model = Ruqola.getModelForRoom(roomID) + appid.selectedRoom = Ruqola.getRoom(roomID) } - console.log("Choosing room", roomID); - appid.selectedRoomID = roomID; - appid.model = Ruqola.getModelForRoom(roomID) - appid.selectedRoom = Ruqola.getRoom(roomID) - } + } //RoomsView - + Kirigami.OverlaySheet { + id: channelsList + contentItem: ChannelsList { +// anchors.fill: parent + + } + + } } } Component { id: mainComponent Kirigami.ScrollablePage { // anchors.right: parent.right // anchors.top: parent.top // anchors.bottom: parent.bottom // anchors.left: roomsComponent.right // anchors.fill: parent id: mainWidget leftPadding: Kirigami.Units.smallSpacing rightPadding: Kirigami.Units.smallSpacing topPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing title: appid.selectedRoom ? "" : "#" + appid.selectedRoom.name ListView { id: activeChat model: appid.model // model: Ruqola.getModelForRoom(selectedRoomID) anchors.fill: parent onCountChanged: { positionViewAtIndex(count - 1, ListView.Beginning) } Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning) visible : count > 0 z: -1 delegate: Message { width: parent.width i_messageText: messageText i_username: username i_systemMessage: systemMessage i_systemMessageType: type i_timestamp: timestamp //width: parent.width } } footer: Item { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right id: input height: 40 TextField { id: messageLine anchors.left: parent.left anchors.bottom: parent.bottom anchors.top: parent.top anchors.right: emoticonsButton.left placeholderText: if (Ruqola.loginStatus != DDPClient.LoggedIn || (selectedRoomID=="")){ qsTr("Please Select a room") } else{ qsTr("Enter message") } // height: 2.7*font.pixelSize property string type: "text"; onAccepted: { if (text != "" && Ruqola.loginStatus == DDPClient.LoggedIn && !(selectedRoomID=="")) { Ruqola.sendMessage(selectedRoomID, text, type); text = ""; } } } Button { anchors.bottom: parent.bottom anchors.top: parent.top anchors.right: attachmentsButton.left width: 50 id : emoticonsButton iconName: "emoticonsButton" iconSource: "qrc:/Emoticon.png" visible: true } Button { anchors.bottom: parent.bottom anchors.top: parent.top anchors.right: parent.right width: 50 id : attachmentsButton iconName: "attachmentsButton" iconSource: "qrc:/icons/attach-button.jpg" visible: true onClicked: Ruqola.attachmentButtonClicked(); } }//Item input }// mainWidget Item } // Image { // id: receivedImage // source:" " // width: 60 // height: 80 // fillMode: Image.PreserveAspectFit //// visible: //only when an image is recieved from server // sourceSize.width: 1024 // sourceSize.height: 1024 // } onClosing: { console.log("Minimizing to systray..."); hide(); } function toggleShow() { if (visible) { hide(); } else { show(); raise(); requestActivate(); } } Component.onCompleted: { systrayIcon.activated.connect(toggleShow); systrayIcon.messageClicked.connect(toggleShow); // roomsList.model = Ruqola.roomModel(); // timer.start(); // timer.fire(); } /* Timer { id: timer interval: 1000 onTriggered: { // console.log("FIRE"); switch (Ruqola.loginStatus) { case Ruqola.NotConnected: statusText = qsTr("Not connected."); break; case Ruqola.LoggedIn: statusText = qsTr("Connected to " + Ruqola.serverURL); break; } } repeat: true }*/ // onStatusTextChanged: timer.restart(); } diff --git a/src/qml/RoomDelegate.qml b/src/qml/RoomDelegate.qml index 9a28eb8d..9aa0501e 100644 --- a/src/qml/RoomDelegate.qml +++ b/src/qml/RoomDelegate.qml @@ -1,97 +1,100 @@ /* * * Copyright 2016 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ import QtQuick 2.0 import org.kde.kirigami 2.1 as Kirigami import QtQuick.Layouts 1.1 Kirigami.BasicListItem { property int d_unread: 0; property string d_name: "roomName"; property bool d_selected: false; property string d_roomID : ""; property bool d_editingMode: false; id: root signal roomSelected(string roomID) + signal leaveRoom(string roomID) + signal hideRoom(string roomID) icon: "irc-channel-active" visible: !d_name.empty label: d_name checked: d_selected onClicked: { root.roomSelected(d_roomID); } Row { - visible: editingMode + visible: editingMode // && root.hover ? + id: editingActions anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right // anchors.left: parent.left width: 50 spacing: Kirigami.Units.smallSpacing Kirigami.Icon { id: hideAction source: "hide_table_row" height: parent.height width: height opacity: d_selected ? 1 : .5 MouseArea { anchors.fill: parent hoverEnabled: true onEntered: parent.active = true; onExited: parent.active = false; onClicked: { console.log("Hide action - unimplemented") } } Layout.alignment: Qt.AlignVCenter | Qt.AlignRight } Kirigami.Icon { id: quitAction source: "dialog-close" height: parent.height width: height opacity: d_selected ? 1 : .5 MouseArea { anchors.fill: parent hoverEnabled: true onEntered: parent.active = true; onExited: parent.active = false; onClicked: { console.log("Leave action: unimplemented") } } Layout.alignment: Qt.AlignVCenter | Qt.AlignRight } } } // Item closed diff --git a/src/qml/RoomsView.qml b/src/qml/RoomsView.qml index 3f1a12d0..f9d1371c 100644 --- a/src/qml/RoomsView.qml +++ b/src/qml/RoomsView.qml @@ -1,49 +1,54 @@ /* * * Copyright 2016 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ import QtQuick 2.0 import org.kde.kirigami 2.1 as Kirigami +// import QtQuick.Controls 2.2 as QQC ListView { id: roomsList - + property string selectedRoomID; property bool editingMode: false; +// property QtObject model signal roomSelected(string roomID) - + + +// model: roomsList.model delegate: RoomDelegate { // anchors.fill: parent // implicitWidth: roomsList.width // width: roomsList.width d_name: name d_unread: unread d_roomID: room_id d_selected: selectedRoomID == room_id d_editingMode: editingMode onRoomSelected : { roomsList.roomSelected(roomID) applicationWindow().pageStack.currentIndex = 1; } } + } diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 1ced206e..c7c289b9 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -1,19 +1,20 @@ JSONListModel.qml RoomModel.qml Desktop.qml Message.qml RoomsView.qml RoomDelegate.qml + ChannelsList.qml Login.qml js/jsonpath.js js/marked.js icons/systray.png icons/attach-button.jpg