mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 06:08:48 +03:00
Make user clickable and improve button cursor look
This commit is contained in:
parent
4f7a45a0a6
commit
993926e189
6 changed files with 61 additions and 39 deletions
34
resources/qml/ImageButton.qml
Normal file
34
resources/qml/ImageButton.qml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import QtQuick 2.3
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
Button {
|
||||||
|
property alias image: buttonImg.source
|
||||||
|
|
||||||
|
id: button
|
||||||
|
|
||||||
|
flat: true
|
||||||
|
|
||||||
|
// disable background, because we don't want a border on hover
|
||||||
|
background: Item {
|
||||||
|
}
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: buttonImg
|
||||||
|
// Workaround, can't get icon.source working for now...
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
ColorOverlay {
|
||||||
|
anchors.fill: buttonImg
|
||||||
|
source: buttonImg
|
||||||
|
color: button.hovered ? colors.highlight : colors.buttonText
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
id: mouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
onPressed: mouse.accepted = false
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import QtGraphicalEffects 1.0
|
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
|
|
||||||
import com.github.nheko 1.0
|
import com.github.nheko 1.0
|
||||||
|
@ -35,64 +34,32 @@ RowLayout {
|
||||||
Layout.preferredHeight: 16
|
Layout.preferredHeight: 16
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
ImageButton {
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
||||||
id: replyButton
|
|
||||||
flat: true
|
|
||||||
Layout.preferredHeight: 16
|
Layout.preferredHeight: 16
|
||||||
|
id: replyButton
|
||||||
|
|
||||||
|
image: "qrc:/icons/icons/ui/mail-reply.png"
|
||||||
ToolTip {
|
ToolTip {
|
||||||
visible: replyButton.hovered
|
visible: replyButton.hovered
|
||||||
text: qsTr("Reply")
|
text: qsTr("Reply")
|
||||||
palette: colors
|
palette: colors
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable background, because we don't want a border on hover
|
|
||||||
background: Item {
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: replyButtonImg
|
|
||||||
// Workaround, can't get icon.source working for now...
|
|
||||||
anchors.fill: parent
|
|
||||||
source: "qrc:/icons/icons/ui/mail-reply.png"
|
|
||||||
}
|
|
||||||
ColorOverlay {
|
|
||||||
anchors.fill: replyButtonImg
|
|
||||||
source: replyButtonImg
|
|
||||||
color: replyButton.hovered ? colors.highlight : colors.buttonText
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: view.model.replyAction(model.id)
|
onClicked: view.model.replyAction(model.id)
|
||||||
}
|
}
|
||||||
Button {
|
ImageButton {
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
||||||
id: optionsButton
|
|
||||||
flat: true
|
|
||||||
Layout.preferredHeight: 16
|
Layout.preferredHeight: 16
|
||||||
|
id: optionsButton
|
||||||
|
|
||||||
|
image: "qrc:/icons/icons/ui/vertical-ellipsis.png"
|
||||||
ToolTip {
|
ToolTip {
|
||||||
visible: optionsButton.hovered
|
visible: optionsButton.hovered
|
||||||
text: qsTr("Options")
|
text: qsTr("Options")
|
||||||
palette: colors
|
palette: colors
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable background, because we don't want a border on hover
|
|
||||||
background: Item {
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: optionsButtonImg
|
|
||||||
// Workaround, can't get icon.source working for now...
|
|
||||||
anchors.fill: parent
|
|
||||||
source: "qrc:/icons/icons/ui/vertical-ellipsis.png"
|
|
||||||
}
|
|
||||||
ColorOverlay {
|
|
||||||
anchors.fill: optionsButtonImg
|
|
||||||
source: optionsButtonImg
|
|
||||||
color: optionsButton.hovered ? colors.highlight : colors.buttonText
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: contextMenu.open()
|
onClicked: contextMenu.open()
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
|
|
|
@ -135,6 +135,12 @@ Rectangle {
|
||||||
height: avatarSize
|
height: avatarSize
|
||||||
url: chat.model.avatarUrl(section.split(" ")[0]).replace("mxc://", "image://MxcImage/")
|
url: chat.model.avatarUrl(section.split(" ")[0]).replace("mxc://", "image://MxcImage/")
|
||||||
displayName: chat.model.displayName(section.split(" ")[0])
|
displayName: chat.model.displayName(section.split(" ")[0])
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: chat.model.openUserProfile(section.split(" ")[0])
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -142,6 +148,12 @@ Rectangle {
|
||||||
text: chat.model.escapeEmoji(chat.model.displayName(section.split(" ")[0]))
|
text: chat.model.escapeEmoji(chat.model.displayName(section.split(" ")[0]))
|
||||||
color: chat.model.userColor(section.split(" ")[0], colors.window)
|
color: chat.model.userColor(section.split(" ")[0], colors.window)
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: chat.model.openUserProfile(section.split(" ")[0])
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>qml/TimelineView.qml</file>
|
<file>qml/TimelineView.qml</file>
|
||||||
<file>qml/Avatar.qml</file>
|
<file>qml/Avatar.qml</file>
|
||||||
|
<file>qml/ImageButton.qml</file>
|
||||||
<file>qml/StatusIndicator.qml</file>
|
<file>qml/StatusIndicator.qml</file>
|
||||||
<file>qml/EncryptionIndicator.qml</file>
|
<file>qml/EncryptionIndicator.qml</file>
|
||||||
<file>qml/TimelineRow.qml</file>
|
<file>qml/TimelineRow.qml</file>
|
||||||
|
|
|
@ -713,6 +713,13 @@ TimelineModel::viewRawMessage(QString id) const
|
||||||
Q_UNUSED(dialog);
|
Q_UNUSED(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
|
||||||
|
TimelineModel::openUserProfile(QString userid) const
|
||||||
|
{
|
||||||
|
MainWindow::instance()->openUserProfile(userid, room_id_);
|
||||||
|
}
|
||||||
|
|
||||||
DecryptionResult
|
DecryptionResult
|
||||||
TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e) const
|
TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,6 +152,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QString escapeEmoji(QString str) const;
|
Q_INVOKABLE QString escapeEmoji(QString str) const;
|
||||||
Q_INVOKABLE void viewRawMessage(QString id) const;
|
Q_INVOKABLE void viewRawMessage(QString id) const;
|
||||||
|
Q_INVOKABLE void openUserProfile(QString userid) const;
|
||||||
Q_INVOKABLE void replyAction(QString id);
|
Q_INVOKABLE void replyAction(QString id);
|
||||||
Q_INVOKABLE void readReceiptsAction(QString id) const;
|
Q_INVOKABLE void readReceiptsAction(QString id) const;
|
||||||
Q_INVOKABLE void redactEvent(QString id);
|
Q_INVOKABLE void redactEvent(QString id);
|
||||||
|
|
Loading…
Reference in a new issue