Init theming support.
This commit is contained in:
parent
4b9c416b4a
commit
f66e62d499
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
import QtQuick.Controls.Material 2.2
|
||||||
import Matrique 0.1
|
import Matrique 0.1
|
||||||
import Matrique.Settings 0.1
|
import Matrique.Settings 0.1
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ Page {
|
||||||
id: accountSettingsListView
|
id: accountSettingsListView
|
||||||
|
|
||||||
delegate: Column {
|
delegate: Column {
|
||||||
|
spacing: 16
|
||||||
|
|
||||||
SwipeDelegate {
|
SwipeDelegate {
|
||||||
width: accountSettingsListView.width
|
width: accountSettingsListView.width
|
||||||
height: 64
|
height: 64
|
||||||
|
@ -80,19 +82,35 @@ Page {
|
||||||
onClicked: accountSettingsListView.currentIndex == index ? accountSettingsListView.currentIndex = -1 : accountSettingsListView.currentIndex = index
|
onClicked: accountSettingsListView.currentIndex == index ? accountSettingsListView.currentIndex = -1 : accountSettingsListView.currentIndex = index
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: parent.width
|
|
||||||
height: 2
|
|
||||||
visible: accountSettingsListView.currentIndex == index
|
|
||||||
|
|
||||||
color: Material.accent
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
visible: accountSettingsListView.currentIndex == index
|
visible: accountSettingsListView.currentIndex == index
|
||||||
width: parent.width - 32
|
width: parent.width - 32
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: 32
|
||||||
|
|
||||||
|
orientation: ListView.Horizontal
|
||||||
|
|
||||||
|
model: ["#498882", "#2196F3"]
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: parent.height
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
color: modelData
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
onClicked: matriqueController.setColor(connection.localUserId, modelData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ Drawer {
|
||||||
|
|
||||||
id: roomNameField
|
id: roomNameField
|
||||||
text: room && room.name ? room.name : ""
|
text: room && room.name ? room.name : ""
|
||||||
|
selectByMouse: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
|
@ -77,6 +78,7 @@ Drawer {
|
||||||
id: roomTopicField
|
id: roomTopicField
|
||||||
|
|
||||||
text: room && room.topic ? room.topic : ""
|
text: room && room.topic ? room.topic : ""
|
||||||
|
selectByMouse: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
|
|
|
@ -25,6 +25,8 @@ ApplicationWindow {
|
||||||
|
|
||||||
Material.theme: MSettings.darkTheme ? Material.Dark : Material.Light
|
Material.theme: MSettings.darkTheme ? Material.Dark : Material.Light
|
||||||
|
|
||||||
|
Material.accent: matriqueController.color(currentConnection ? currentConnection.localUserId : "")
|
||||||
|
|
||||||
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
||||||
|
|
||||||
Controller {
|
Controller {
|
||||||
|
|
|
@ -222,3 +222,11 @@ QImage Controller::safeImage(QImage image) {
|
||||||
if (image.isNull()) return QImage();
|
if (image.isNull()) return QImage();
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor Controller::color(QString userId) {
|
||||||
|
return QColor(SettingsGroup("UI/Color").value(userId, "#498882").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::setColor(QString userId, QColor newColor) {
|
||||||
|
SettingsGroup("UI/Color").setValue(userId, newColor.name());
|
||||||
|
}
|
||||||
|
|
|
@ -40,12 +40,14 @@ class Controller : public QObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Connection*> m_connections;
|
Q_INVOKABLE QColor color(QString userId);
|
||||||
|
Q_INVOKABLE void setColor(QString userId, QColor newColor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QClipboard* m_clipboard = QApplication::clipboard();
|
QClipboard* m_clipboard = QApplication::clipboard();
|
||||||
QSystemTrayIcon* tray = new QSystemTrayIcon();
|
QSystemTrayIcon* tray = new QSystemTrayIcon();
|
||||||
QMenu* trayMenu = new QMenu();
|
QMenu* trayMenu = new QMenu();
|
||||||
|
QVector<Connection*> m_connections;
|
||||||
|
|
||||||
bool m_busy = false;
|
bool m_busy = false;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class MatriqueRoom : public Room {
|
||||||
explicit MatriqueRoom(Connection* connection, QString roomId,
|
explicit MatriqueRoom(Connection* connection, QString roomId,
|
||||||
JoinState joinState = {});
|
JoinState joinState = {});
|
||||||
|
|
||||||
QImage getAvatar() { return avatar(64); }
|
QImage getAvatar() { return avatar(128); }
|
||||||
|
|
||||||
const QString& cachedInput() const { return m_cachedInput; }
|
const QString& cachedInput() const { return m_cachedInput; }
|
||||||
void setCachedInput(const QString& input) {
|
void setCachedInput(const QString& input) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ class MatriqueUser : public User {
|
||||||
public:
|
public:
|
||||||
MatriqueUser(QString userId, Connection* connection);
|
MatriqueUser(QString userId, Connection* connection);
|
||||||
|
|
||||||
QImage getAvatar() { return avatar(64); }
|
QImage getAvatar() { return avatar(128); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void inheritedAvatarChanged(User* user, const Room* roomContext); // https://bugreports.qt.io/browse/QTBUG-7684
|
void inheritedAvatarChanged(User* user, const Room* roomContext); // https://bugreports.qt.io/browse/QTBUG-7684
|
||||||
|
|
|
@ -15,7 +15,7 @@ RoomListModel::~RoomListModel() {}
|
||||||
|
|
||||||
void RoomListModel::setConnection(Connection* connection) {
|
void RoomListModel::setConnection(Connection* connection) {
|
||||||
if (connection == m_connection) return;
|
if (connection == m_connection) return;
|
||||||
m_connection->disconnect(this);
|
if (m_connection) m_connection->disconnect(this);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
qDebug() << "Removing current connection...";
|
qDebug() << "Removing current connection...";
|
||||||
m_connection = nullptr;
|
m_connection = nullptr;
|
||||||
|
|
|
@ -69,7 +69,7 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
|
||||||
}
|
}
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
if (!user->avatarUrl(m_currentRoom).isEmpty())
|
if (!user->avatarUrl(m_currentRoom).isEmpty())
|
||||||
return user->avatar(32, m_currentRoom);
|
return user->avatar(64, m_currentRoom);
|
||||||
return QImage();
|
return QImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue