Change Settings to singleton and add AutoMouseArea.
Also fixes acceptInvitation issue.
This commit is contained in:
parent
fa4db065f2
commit
e428e9f005
|
@ -32,7 +32,7 @@ RESOURCES += \
|
|||
res.qrc
|
||||
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
QML_IMPORT_PATH =
|
||||
QML_IMPORT_PATH += qml/MatriqueSettings
|
||||
|
||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
||||
QML_DESIGNER_IMPORT_PATH =
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
pragma Singleton
|
||||
import QtQuick 2.9
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
Settings {
|
||||
property bool lazyLoad: true
|
||||
property bool asyncMessageDelegate
|
||||
property bool richText
|
||||
property bool pressAndHold
|
||||
|
||||
property bool darkTheme
|
||||
property bool miniMode
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import QtQuick.tooling 1.2
|
||||
|
||||
// This file describes the plugin-supplied types contained in the library.
|
||||
// It is used for QML tooling purposes only.
|
||||
//
|
||||
// This file was auto-generated by:
|
||||
// 'qmlplugindump -nonrelocatable MatriqueSettings 0.1 qml/'
|
||||
|
||||
Module {
|
||||
dependencies: ["Qt.labs.settings 1.0", "QtQuick 2.9"]
|
||||
Component {
|
||||
prototype: "QQmlSettings"
|
||||
name: "MatriqueSettings 0.1"
|
||||
exports: ["MatriqueSettings 0.1"]
|
||||
exportMetaObjectRevisions: [1]
|
||||
isComposite: true
|
||||
isCreatable: false
|
||||
isSingleton: true
|
||||
Property { name: "lazyLoad"; type: "bool" }
|
||||
Property { name: "asyncMessageDelegate"; type: "bool" }
|
||||
Property { name: "richText"; type: "bool" }
|
||||
Property { name: "pressAndHold"; type: "bool" }
|
||||
Property { name: "darkTheme"; type: "bool" }
|
||||
Property { name: "miniMode"; type: "bool" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
module MatriqueSettings
|
||||
singleton MatriqueSettings 0.1 MatriqueSettings.qml
|
|
@ -2,6 +2,7 @@ import QtQuick 2.9
|
|||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import Matrique 0.1
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
import "qrc:/qml/form"
|
||||
|
||||
|
@ -13,7 +14,7 @@ Page {
|
|||
RoomListModel {
|
||||
id: roomListModel
|
||||
|
||||
onRoomAdded: setting.lazyLoad ? {} : room.getPreviousContent(20)
|
||||
onRoomAdded: MatriqueSettings.lazyLoad ? {} : room.getPreviousContent(20)
|
||||
onNewMessage: window.active ? {} : matriqueController.showMessage(roomName, content, icon)
|
||||
}
|
||||
|
||||
|
@ -25,7 +26,7 @@ Page {
|
|||
id: roomListForm
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: setting.miniMode ? 80 : page.width * 0.35
|
||||
Layout.preferredWidth: MatriqueSettings.miniMode ? 80 : page.width * 0.35
|
||||
Layout.minimumWidth: 80
|
||||
Layout.maximumWidth: 360
|
||||
|
||||
|
|
|
@ -7,13 +7,6 @@ import "component"
|
|||
import "form"
|
||||
|
||||
Page {
|
||||
property alias lazyLoad: generalForm.lazyLoad
|
||||
property alias asyncMessageDelegate: generalForm.asyncMessageDelegate
|
||||
property alias richText: generalForm.richText
|
||||
|
||||
property alias darkTheme: appearanceForm.darkTheme
|
||||
property alias miniMode: appearanceForm.miniMode
|
||||
|
||||
property var connection
|
||||
|
||||
SettingAccountForm {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import QtQuick 2.9
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
MouseArea {
|
||||
signal primaryClicked()
|
||||
signal secondaryClicked()
|
||||
|
||||
propagateComposedEvents: true
|
||||
acceptedButtons: MatriqueSettings.pressAndHold ? Qt.LeftButton : (Qt.LeftButton | Qt.RightButton)
|
||||
onClicked: mouse.button == Qt.RightButton ? secondaryClicked() : primaryClicked()
|
||||
onPressAndHold: MatriqueSettings.pressAndHold ? secondaryClicked() : {}
|
||||
}
|
|
@ -2,6 +2,7 @@ import QtQuick 2.9
|
|||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import Matrique 0.1
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
Item {
|
||||
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
|
||||
|
@ -21,15 +22,15 @@ Item {
|
|||
anchors.right: !isState && sentByMe ? parent.right : undefined
|
||||
anchors.horizontalCenter: isState ? parent.horizontalCenter : undefined
|
||||
|
||||
MouseArea {
|
||||
AutoMouseArea {
|
||||
anchors.fill: parent
|
||||
onPressAndHold: Qt.createComponent("MessageContextMenu.qml").createObject(this)
|
||||
onSecondaryClicked: Qt.createComponent("MessageContextMenu.qml").createObject(this)
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: delegateLoader
|
||||
|
||||
asynchronous: setting.asyncMessageDelegate
|
||||
asynchronous: MatriqueSettings.asyncMessageDelegate
|
||||
|
||||
source: {
|
||||
if (eventType == "redaction" || hidden) return ""
|
||||
|
|
|
@ -2,6 +2,7 @@ import QtQuick 2.9
|
|||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
Rectangle {
|
||||
property bool flat: false
|
||||
|
@ -45,7 +46,7 @@ Rectangle {
|
|||
|
||||
wrapMode: Label.Wrap
|
||||
linkColor: darkBackground ? "white" : Material.accent
|
||||
textFormat: setting.richText ? Text.RichText : Text.StyledText
|
||||
textFormat: MatriqueSettings.richText ? Text.RichText : Text.StyledText
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import QtQuick.Controls.Material 2.2
|
|||
import QtQml.Models 2.3
|
||||
import Matrique 0.1
|
||||
import SortFilterProxyModel 0.2
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
import "qrc:/qml/component"
|
||||
|
||||
|
@ -13,7 +14,7 @@ Item {
|
|||
property alias listModel: roomListProxyModel.sourceModel
|
||||
readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
|
||||
readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null
|
||||
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
||||
readonly property bool mini: MatriqueSettings.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
||||
signal enterRoom()
|
||||
|
||||
ColumnLayout {
|
||||
|
@ -121,9 +122,14 @@ Item {
|
|||
delegate: ItemDelegate {
|
||||
width: parent.width
|
||||
height: 80
|
||||
|
||||
AutoMouseArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onPressed: listView.currentIndex = index
|
||||
onPressAndHold: roomListMenu.popup()
|
||||
onClicked: category === RoomType.Invited ? inviteDialog.open() : enterRoom()
|
||||
onSecondaryClicked: roomListMenu.popup()
|
||||
onPrimaryClicked: category === RoomType.Invited ? inviteDialog.open() : enterRoom()
|
||||
}
|
||||
|
||||
ToolTip.visible: mini && hovered
|
||||
ToolTip.text: name
|
||||
|
@ -209,7 +215,7 @@ Item {
|
|||
contentItem: Label { text: "Accept this invitation?" }
|
||||
|
||||
onAccepted: currentRoom.acceptInvitation()
|
||||
onRejected: currentRoom.rejectInvitation()
|
||||
onRejected: currentRoom.forget()
|
||||
}
|
||||
|
||||
Menu {
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
Page {
|
||||
property alias darkTheme: themeSwitch.checked
|
||||
property alias miniMode: miniModeSwitch.checked
|
||||
|
||||
Column {
|
||||
Switch {
|
||||
id: themeSwitch
|
||||
text: "Dark theme"
|
||||
checked: MatriqueSettings.darkTheme
|
||||
onCheckedChanged: MatriqueSettings.darkTheme = checked
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: miniModeSwitch
|
||||
text: "Mini Room List"
|
||||
checked: MatriqueSettings.miniMode
|
||||
onCheckedChanged: MatriqueSettings.miniMode = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,32 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
Page {
|
||||
property alias lazyLoad: lazyLoadSwitch.checked
|
||||
property alias asyncMessageDelegate: asyncMessageDelegateSwitch.checked
|
||||
property alias richText: richTextSwitch.checked
|
||||
|
||||
Column {
|
||||
Switch {
|
||||
id: lazyLoadSwitch
|
||||
text: "Lazy load at initial sync"
|
||||
checked: true
|
||||
checked: MatriqueSettings.lazyLoad
|
||||
onCheckedChanged: MatriqueSettings.lazyLoad = checked
|
||||
}
|
||||
Switch {
|
||||
id: asyncMessageDelegateSwitch
|
||||
text: "Force loading message delegates asynchronously"
|
||||
checked: MatriqueSettings.asyncMessageDelegate
|
||||
onCheckedChanged: MatriqueSettings.asyncMessageDelegate = checked
|
||||
}
|
||||
Switch {
|
||||
id: richTextSwitch
|
||||
text: "Use RichText instead of StyledText"
|
||||
checked: MatriqueSettings.richText
|
||||
onCheckedChanged: MatriqueSettings.richText = checked
|
||||
}
|
||||
Switch {
|
||||
id: pressAndHoldSwitch
|
||||
text: "Use press and hold instead of right click"
|
||||
checked: MatriqueSettings.pressAndHold
|
||||
onCheckedChanged: MatriqueSettings.pressAndHold = checked
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
20
qml/main.qml
20
qml/main.qml
|
@ -2,9 +2,10 @@ import QtQuick 2.9
|
|||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import Qt.labs.settings 1.0 as Labs
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt.labs.settings 1.0 as Settings
|
||||
import Matrique 0.1
|
||||
import MatriqueSettings 0.1
|
||||
|
||||
import "component"
|
||||
import "form"
|
||||
|
@ -20,25 +21,16 @@ ApplicationWindow {
|
|||
minimumHeight: 480
|
||||
title: qsTr("Matrique")
|
||||
|
||||
Material.theme: setting.darkTheme ? Material.Dark : Material.Light
|
||||
|
||||
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
||||
|
||||
Settings.Settings {
|
||||
id: setting
|
||||
Material.theme: MatriqueSettings.darkTheme ? Material.Dark : Material.Light
|
||||
|
||||
Labs.Settings {
|
||||
property alias homeserver: matriqueController.homeserver
|
||||
property alias userID: matriqueController.userID
|
||||
property alias token: matriqueController.token
|
||||
|
||||
property alias lazyLoad: settingPage.lazyLoad
|
||||
property alias asyncMessageDelegate: settingPage.asyncMessageDelegate
|
||||
property alias richText: settingPage.richText
|
||||
|
||||
property alias darkTheme: settingPage.darkTheme
|
||||
property alias miniMode: settingPage.miniMode
|
||||
}
|
||||
|
||||
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
||||
|
||||
Controller {
|
||||
id: matriqueController
|
||||
|
||||
|
|
4
res.qrc
4
res.qrc
|
@ -34,5 +34,9 @@
|
|||
<file>qml/component/AutoImage.qml</file>
|
||||
<file>asset/img/icon.ico</file>
|
||||
<file>asset/img/icon.icns</file>
|
||||
<file>qml/component/AutoMouseArea.qml</file>
|
||||
<file>qml/MatriqueSettings/MatriqueSettings.qml</file>
|
||||
<file>qml/MatriqueSettings/qmldir</file>
|
||||
<file>qml/MatriqueSettings/plugins.qmltypes</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
|
|||
qmlRegisterUncreatableType<RoomType>("Matrique", 0, 1, "RoomType", "ENUM");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.addImportPath("qrc:/qml");
|
||||
|
||||
ImageProvider *m_provider = new ImageProvider();
|
||||
|
||||
|
|
|
@ -69,12 +69,7 @@ void MatriqueRoom::saveFileAs(QString eventId) {
|
|||
if (!fileName.isEmpty()) downloadFile(eventId, QUrl::fromLocalFile(fileName));
|
||||
}
|
||||
|
||||
void MatriqueRoom::acceptInvitation() { setJoinState(JoinState::Join); }
|
||||
|
||||
void MatriqueRoom::rejectInvitation() {
|
||||
setJoinState(JoinState::Leave);
|
||||
forget();
|
||||
}
|
||||
void MatriqueRoom::acceptInvitation() { connection()->joinRoom(id()); }
|
||||
|
||||
void MatriqueRoom::forget() { connection()->forgetRoom(id()); }
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ class MatriqueRoom : public Room {
|
|||
void chooseAndUploadFile();
|
||||
void saveFileAs(QString eventId);
|
||||
void acceptInvitation();
|
||||
void rejectInvitation();
|
||||
void forget();
|
||||
void sendTypingNotification(bool isTyping);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue