summary refs log tree commit diff
path: root/include/dialogs
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-04-30 21:41:47 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-04-30 21:41:47 +0300
commit3097037c3dc882be2efe64dce6aefeea43d5f040 (patch)
tree1e3375fbd423c3bd18513e6d2a502b7fa1e4cfb8 /include/dialogs
parentShow room tooltips when the sidebar is collapsed (diff)
downloadnheko-3097037c3dc882be2efe64dce6aefeea43d5f040.tar.xz
Add prototype room settings menu
Diffstat (limited to 'include/dialogs')
-rw-r--r--include/dialogs/RoomSettings.hpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/dialogs/RoomSettings.hpp b/include/dialogs/RoomSettings.hpp
new file mode 100644
index 00000000..fbbc2e02
--- /dev/null
+++ b/include/dialogs/RoomSettings.hpp
@@ -0,0 +1,88 @@
+#pragma once
+
+#include <QFrame>
+#include <QImage>
+
+#include "Cache.h"
+
+class FlatButton;
+class TextField;
+class Avatar;
+class QPixmap;
+class QLayout;
+class QLabel;
+
+template<class T>
+class QSharedPointer;
+
+class TopSection : public QWidget
+{
+        Q_OBJECT
+
+        Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
+
+public:
+        TopSection(const RoomInfo &info, const QImage &img, QWidget *parent = nullptr)
+          : QWidget{parent}
+          , info_{std::move(info)}
+        {
+                textColor_ = palette().color(QPalette::Text);
+                avatar_    = QPixmap::fromImage(img.scaled(
+                  AvatarSize, AvatarSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+        }
+
+        QSize sizeHint() const override
+        {
+                QFont font;
+                font.setPixelSize(18);
+                return QSize(200, AvatarSize + QFontMetrics(font).ascent() + 6 * Padding);
+        }
+
+        QColor textColor() const { return textColor_; }
+        void setTextColor(QColor &color) { textColor_ = color; }
+
+protected:
+        void paintEvent(QPaintEvent *event) override;
+
+private:
+        static constexpr int AvatarSize = 72;
+        static constexpr int Padding    = 5;
+
+        RoomInfo info_;
+        QPixmap avatar_;
+        QColor textColor_;
+};
+
+namespace dialogs {
+
+class RoomSettings : public QFrame
+{
+        Q_OBJECT
+public:
+        RoomSettings(const QString &room_id,
+                     QSharedPointer<Cache> cache,
+                     QWidget *parent = nullptr);
+
+signals:
+        void closing();
+
+protected:
+        void paintEvent(QPaintEvent *event) override;
+
+private:
+        static constexpr int AvatarSize = 64;
+
+        void setAvatar(const QImage &img) { avatarImg_ = img; }
+
+        QSharedPointer<Cache> cache_;
+
+        // Button section
+        FlatButton *saveBtn_;
+        FlatButton *cancelBtn_;
+
+        RoomInfo info_;
+        QString room_id_;
+        QImage avatarImg_;
+};
+
+} // dialogs