diff --git a/src/dialogs/CreateRoom.cc b/src/dialogs/CreateRoom.cpp
index 8c2cc641..3c538b49 100644
--- a/src/dialogs/CreateRoom.cc
+++ b/src/dialogs/CreateRoom.cpp
@@ -3,14 +3,14 @@
#include <QStyleOption>
#include <QVBoxLayout>
-#include "Config.h"
-#include "FlatButton.h"
-#include "TextField.h"
-#include "Theme.h"
-#include "ToggleButton.h"
-
#include "dialogs/CreateRoom.h"
+#include "Config.h"
+#include "ui/FlatButton.h"
+#include "ui/TextField.h"
+#include "ui/Theme.h"
+#include "ui/ToggleButton.h"
+
using namespace dialogs;
CreateRoom::CreateRoom(QWidget *parent)
diff --git a/src/dialogs/CreateRoom.h b/src/dialogs/CreateRoom.h
new file mode 100644
index 00000000..46edebdc
--- /dev/null
+++ b/src/dialogs/CreateRoom.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <QFrame>
+
+#include <mtx.hpp>
+
+class FlatButton;
+class TextField;
+class QComboBox;
+class Toggle;
+
+namespace dialogs {
+
+class CreateRoom : public QFrame
+{
+ Q_OBJECT
+public:
+ CreateRoom(QWidget *parent = nullptr);
+
+signals:
+ void closing(bool isCreating, const mtx::requests::CreateRoom &request);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+
+private:
+ void clearFields();
+
+ QComboBox *visibilityCombo_;
+ QComboBox *presetCombo_;
+
+ Toggle *directToggle_;
+
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+
+ TextField *nameInput_;
+ TextField *topicInput_;
+ TextField *aliasInput_;
+
+ mtx::requests::CreateRoom request_;
+};
+
+} // dialogs
diff --git a/src/dialogs/ImageOverlay.cc b/src/dialogs/ImageOverlay.cpp
index 0e4d9d71..7773f97c 100644
--- a/src/dialogs/ImageOverlay.cc
+++ b/src/dialogs/ImageOverlay.cpp
@@ -19,9 +19,10 @@
#include <QDesktopWidget>
#include <QPainter>
-#include "Utils.h"
#include "dialogs/ImageOverlay.h"
+#include "Utils.h"
+
using namespace dialogs;
ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent)
diff --git a/src/dialogs/ImageOverlay.h b/src/dialogs/ImageOverlay.h
new file mode 100644
index 00000000..b4d42acb
--- /dev/null
+++ b/src/dialogs/ImageOverlay.h
@@ -0,0 +1,47 @@
+/*
+ * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QDialog>
+#include <QMouseEvent>
+#include <QPixmap>
+
+namespace dialogs {
+
+class ImageOverlay : public QWidget
+{
+ Q_OBJECT
+public:
+ ImageOverlay(QPixmap image, QWidget *parent = nullptr);
+
+protected:
+ void mousePressEvent(QMouseEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+
+signals:
+ void closing();
+
+private:
+ QPixmap originalImage_;
+ QPixmap image_;
+
+ QRect content_;
+ QRect close_button_;
+ QRect screen_;
+};
+} // dialogs
diff --git a/src/dialogs/InviteUsers.cc b/src/dialogs/InviteUsers.cpp
index 71cfdf20..bcd163b0 100644
--- a/src/dialogs/InviteUsers.cc
+++ b/src/dialogs/InviteUsers.cpp
@@ -6,12 +6,12 @@
#include <QTimer>
#include <QVBoxLayout>
-#include "Config.h"
-#include "FlatButton.h"
-#include "TextField.h"
+#include "dialogs/InviteUsers.h"
+#include "Config.h"
#include "InviteeItem.h"
-#include "dialogs/InviteUsers.h"
+#include "ui/FlatButton.h"
+#include "ui/TextField.h"
#include "mtx.hpp"
diff --git a/src/dialogs/InviteUsers.h b/src/dialogs/InviteUsers.h
new file mode 100644
index 00000000..41e6236a
--- /dev/null
+++ b/src/dialogs/InviteUsers.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <QFrame>
+#include <QLabel>
+#include <QListWidgetItem>
+#include <QStringList>
+
+class FlatButton;
+class TextField;
+class QListWidget;
+
+namespace dialogs {
+
+class InviteUsers : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit InviteUsers(QWidget *parent = nullptr);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+
+signals:
+ void closing(bool isLeaving, QStringList invitees);
+
+private slots:
+ void removeInvitee(QListWidgetItem *item);
+
+private:
+ void addUser();
+ QStringList invitedUsers() const;
+
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+
+ TextField *inviteeInput_;
+ QLabel *errorLabel_;
+
+ QListWidget *inviteeList_;
+};
+} // dialogs
diff --git a/src/dialogs/JoinRoom.cc b/src/dialogs/JoinRoom.cpp
index d6e83014..05c0f455 100644
--- a/src/dialogs/JoinRoom.cc
+++ b/src/dialogs/JoinRoom.cpp
@@ -2,13 +2,13 @@
#include <QStyleOption>
#include <QVBoxLayout>
-#include "Config.h"
-#include "FlatButton.h"
-#include "TextField.h"
-#include "Theme.h"
-
#include "dialogs/JoinRoom.h"
+#include "Config.h"
+#include "ui/FlatButton.h"
+#include "ui/TextField.h"
+#include "ui/Theme.h"
+
using namespace dialogs;
JoinRoom::JoinRoom(QWidget *parent)
diff --git a/src/dialogs/JoinRoom.h b/src/dialogs/JoinRoom.h
new file mode 100644
index 00000000..5919f08f
--- /dev/null
+++ b/src/dialogs/JoinRoom.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <QFrame>
+
+class FlatButton;
+class TextField;
+
+namespace dialogs {
+
+class JoinRoom : public QFrame
+{
+ Q_OBJECT
+public:
+ JoinRoom(QWidget *parent = nullptr);
+
+signals:
+ void closing(bool isJoining, const QString &room);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+
+private:
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+
+ TextField *roomInput_;
+};
+
+} // dialogs
diff --git a/src/dialogs/LeaveRoom.cc b/src/dialogs/LeaveRoom.cpp
index 508353c6..9647d19f 100644
--- a/src/dialogs/LeaveRoom.cc
+++ b/src/dialogs/LeaveRoom.cpp
@@ -2,12 +2,12 @@
#include <QStyleOption>
#include <QVBoxLayout>
-#include "Config.h"
-#include "FlatButton.h"
-#include "Theme.h"
-
#include "dialogs/LeaveRoom.h"
+#include "Config.h"
+#include "ui/FlatButton.h"
+#include "ui/Theme.h"
+
using namespace dialogs;
LeaveRoom::LeaveRoom(QWidget *parent)
diff --git a/src/dialogs/LeaveRoom.h b/src/dialogs/LeaveRoom.h
new file mode 100644
index 00000000..98e4938d
--- /dev/null
+++ b/src/dialogs/LeaveRoom.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <QFrame>
+
+class FlatButton;
+
+namespace dialogs {
+
+class LeaveRoom : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit LeaveRoom(QWidget *parent = nullptr);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+signals:
+ void closing(bool isLeaving);
+
+private:
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+};
+} // dialogs
diff --git a/src/dialogs/Logout.cc b/src/dialogs/Logout.cpp
index 99913b04..e2449817 100644
--- a/src/dialogs/Logout.cc
+++ b/src/dialogs/Logout.cpp
@@ -20,12 +20,12 @@
#include <QStyleOption>
#include <QVBoxLayout>
-#include "Config.h"
-#include "FlatButton.h"
-#include "Theme.h"
-
#include "dialogs/Logout.h"
+#include "Config.h"
+#include "ui/FlatButton.h"
+#include "ui/Theme.h"
+
using namespace dialogs;
Logout::Logout(QWidget *parent)
diff --git a/src/dialogs/Logout.h b/src/dialogs/Logout.h
new file mode 100644
index 00000000..cfefb970
--- /dev/null
+++ b/src/dialogs/Logout.h
@@ -0,0 +1,42 @@
+/*
+ * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QFrame>
+
+class FlatButton;
+
+namespace dialogs {
+
+class Logout : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit Logout(QWidget *parent = nullptr);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+signals:
+ void closing(bool isLoggingOut);
+
+private:
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+};
+} // dialogs
diff --git a/src/dialogs/MemberList.cpp b/src/dialogs/MemberList.cpp
index f0f61686..60c2eb0a 100644
--- a/src/dialogs/MemberList.cpp
+++ b/src/dialogs/MemberList.cpp
@@ -3,15 +3,15 @@
#include <QStyleOption>
#include <QVBoxLayout>
+#include "dialogs/MemberList.h"
+
#include "AvatarProvider.h"
+#include "Cache.h"
#include "ChatPage.h"
#include "Config.h"
-#include "FlatButton.h"
#include "Utils.h"
-
-#include "Avatar.h"
-#include "Cache.h"
-#include "dialogs/MemberList.hpp"
+#include "ui/Avatar.h"
+#include "ui/FlatButton.h"
using namespace dialogs;
diff --git a/src/dialogs/MemberList.h b/src/dialogs/MemberList.h
new file mode 100644
index 00000000..9c3dc5dc
--- /dev/null
+++ b/src/dialogs/MemberList.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <QFrame>
+#include <QListWidget>
+
+class Avatar;
+class FlatButton;
+class QHBoxLayout;
+class QLabel;
+class QVBoxLayout;
+
+struct RoomMember;
+
+template<class T>
+class QSharedPointer;
+
+namespace dialogs {
+
+class MemberItem : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MemberItem(const RoomMember &member, QWidget *parent);
+
+private:
+ QHBoxLayout *topLayout_;
+ QVBoxLayout *textLayout_;
+
+ Avatar *avatar_;
+
+ QLabel *userName_;
+ QLabel *userId_;
+};
+
+class MemberList : public QFrame
+{
+ Q_OBJECT
+public:
+ MemberList(const QString &room_id, QWidget *parent = nullptr);
+
+public slots:
+ void addUsers(const std::vector<RoomMember> &users);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void hideEvent(QHideEvent *event) override
+ {
+ list_->clear();
+ QFrame::hideEvent(event);
+ }
+
+private:
+ void moveButtonToBottom();
+
+ QString room_id_;
+ QLabel *topLabel_;
+ QListWidget *list_;
+ FlatButton *moreBtn_;
+};
+} // dialogs
diff --git a/src/dialogs/PreviewUploadOverlay.cc b/src/dialogs/PreviewUploadOverlay.cpp
index a3fe4228..7e54ba4e 100644
--- a/src/dialogs/PreviewUploadOverlay.cc
+++ b/src/dialogs/PreviewUploadOverlay.cpp
@@ -23,13 +23,13 @@
#include <QMimeDatabase>
#include <QVBoxLayout>
+#include "dialogs/PreviewUploadOverlay.h"
+
#include "Config.h"
-#include "Logging.hpp"
+#include "Logging.h"
#include "MainWindow.h"
#include "Utils.h"
-#include "dialogs/PreviewUploadOverlay.h"
-
using namespace dialogs;
constexpr const char *DEFAULT = "Upload %1?";
diff --git a/src/dialogs/PreviewUploadOverlay.h b/src/dialogs/PreviewUploadOverlay.h
new file mode 100644
index 00000000..8d093c7f
--- /dev/null
+++ b/src/dialogs/PreviewUploadOverlay.h
@@ -0,0 +1,61 @@
+/*
+ * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QPixmap>
+#include <QWidget>
+
+#include "ui/FlatButton.h"
+
+class QMimeData;
+
+namespace dialogs {
+
+class PreviewUploadOverlay : public QWidget
+{
+ Q_OBJECT
+public:
+ PreviewUploadOverlay(QWidget *parent = nullptr);
+
+ void setPreview(const QByteArray data, const QString &mime);
+ void setPreview(const QString &path);
+
+signals:
+ void confirmUpload(const QByteArray data, const QString &media, const QString &filename);
+
+private:
+ void init();
+ void setLabels(const QString &type, const QString &mime, uint64_t upload_size);
+
+ bool isImage_;
+ QPixmap image_;
+
+ QByteArray data_;
+ QString filePath_;
+ QString mediaType_;
+
+ QLabel titleLabel_;
+ QLabel infoLabel_;
+ QLineEdit fileName_;
+
+ FlatButton upload_;
+ FlatButton cancel_;
+};
+} // dialogs
diff --git a/src/dialogs/ReCaptcha.cpp b/src/dialogs/ReCaptcha.cpp
index ba54268c..9181d588 100644
--- a/src/dialogs/ReCaptcha.cpp
+++ b/src/dialogs/ReCaptcha.cpp
@@ -4,13 +4,13 @@
#include <QStyleOption>
#include <QVBoxLayout>
+#include "dialogs/ReCaptcha.h"
+
#include "Config.h"
-#include "FlatButton.h"
#include "MatrixClient.h"
-#include "RaisedButton.h"
-#include "Theme.h"
-
-#include "dialogs/ReCaptcha.hpp"
+#include "ui/FlatButton.h"
+#include "ui/RaisedButton.h"
+#include "ui/Theme.h"
using namespace dialogs;
diff --git a/src/dialogs/ReCaptcha.h b/src/dialogs/ReCaptcha.h
new file mode 100644
index 00000000..5f47b0eb
--- /dev/null
+++ b/src/dialogs/ReCaptcha.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <QWidget>
+
+class FlatButton;
+class RaisedButton;
+
+namespace dialogs {
+
+class ReCaptcha : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ReCaptcha(const QString &session, QWidget *parent = nullptr);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+signals:
+ void closing();
+
+private:
+ FlatButton *openCaptchaBtn_;
+ RaisedButton *confirmBtn_;
+ RaisedButton *cancelBtn_;
+};
+} // dialogs
diff --git a/src/dialogs/ReadReceipts.cc b/src/dialogs/ReadReceipts.cpp
index a2e1faf2..c27146ac 100644
--- a/src/dialogs/ReadReceipts.cc
+++ b/src/dialogs/ReadReceipts.cpp
@@ -6,14 +6,14 @@
#include <QTimer>
#include <QVBoxLayout>
-#include "ChatPage.h"
-#include "Config.h"
-#include "Utils.h"
+#include "dialogs/ReadReceipts.h"
-#include "Avatar.h"
#include "AvatarProvider.h"
#include "Cache.h"
-#include "dialogs/ReadReceipts.h"
+#include "ChatPage.h"
+#include "Config.h"
+#include "Utils.h"
+#include "ui/Avatar.h"
using namespace dialogs;
diff --git a/src/dialogs/ReadReceipts.h b/src/dialogs/ReadReceipts.h
new file mode 100644
index 00000000..5e5615df
--- /dev/null
+++ b/src/dialogs/ReadReceipts.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <QDateTime>
+#include <QFrame>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QListWidget>
+#include <QVBoxLayout>
+
+class Avatar;
+
+namespace dialogs {
+
+class ReceiptItem : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ReceiptItem(QWidget *parent,
+ const QString &user_id,
+ uint64_t timestamp,
+ const QString &room_id);
+
+private:
+ QString dateFormat(const QDateTime &then) const;
+
+ QHBoxLayout *topLayout_;
+ QVBoxLayout *textLayout_;
+
+ Avatar *avatar_;
+
+ QLabel *userName_;
+ QLabel *timestamp_;
+};
+
+class ReadReceipts : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit ReadReceipts(QWidget *parent = nullptr);
+
+public slots:
+ void addUsers(const std::multimap<uint64_t, std::string, std::greater<uint64_t>> &users);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void hideEvent(QHideEvent *event) override
+ {
+ userList_->clear();
+ QFrame::hideEvent(event);
+ }
+
+private:
+ QLabel *topLabel_;
+
+ QListWidget *userList_;
+};
+} // dialogs
diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index 3f40ae89..cfb25997 100644
--- a/src/dialogs/RoomSettings.cpp
+++ b/src/dialogs/RoomSettings.cpp
@@ -1,16 +1,3 @@
-#include "Avatar.h"
-#include "ChatPage.h"
-#include "Config.h"
-#include "FlatButton.h"
-#include "Logging.hpp"
-#include "MatrixClient.h"
-#include "Painter.h"
-#include "TextField.h"
-#include "Theme.h"
-#include "Utils.h"
-#include "dialogs/RoomSettings.hpp"
-#include "ui/ToggleButton.h"
-
#include <QApplication>
#include <QComboBox>
#include <QLabel>
@@ -22,6 +9,20 @@
#include <QStyleOption>
#include <QVBoxLayout>
+#include "dialogs/RoomSettings.h"
+
+#include "ChatPage.h"
+#include "Config.h"
+#include "Logging.h"
+#include "MatrixClient.h"
+#include "Utils.h"
+#include "ui/Avatar.h"
+#include "ui/FlatButton.h"
+#include "ui/Painter.h"
+#include "ui/TextField.h"
+#include "ui/Theme.h"
+#include "ui/ToggleButton.h"
+
using namespace dialogs;
using namespace mtx::events;
diff --git a/src/dialogs/RoomSettings.h b/src/dialogs/RoomSettings.h
new file mode 100644
index 00000000..6cab03b7
--- /dev/null
+++ b/src/dialogs/RoomSettings.h
@@ -0,0 +1,126 @@
+#pragma once
+
+#include <QFrame>
+#include <QImage>
+
+#include "Cache.h"
+
+class Avatar;
+class FlatButton;
+class QComboBox;
+class QHBoxLayout;
+class QLabel;
+class QLabel;
+class QLayout;
+class QPixmap;
+class TextField;
+class TextField;
+class Toggle;
+
+template<class T>
+class QSharedPointer;
+
+class EditModal : public QWidget
+{
+ Q_OBJECT
+
+public:
+ EditModal(const QString &roomId, QWidget *parent = nullptr);
+
+ void setFields(const QString &roomName, const QString &roomTopic);
+
+signals:
+ void nameChanged(const QString &roomName);
+ void nameEventSentCb(const QString &newName);
+ void topicEventSentCb();
+ void stateEventErrorCb(const QString &msg);
+
+private:
+ QString roomId_;
+ QString initialName_;
+ QString initialTopic_;
+
+ QLabel *errorField_;
+
+ TextField *nameInput_;
+ TextField *topicInput_;
+
+ FlatButton *applyBtn_;
+ FlatButton *cancelBtn_;
+};
+
+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);
+ QSize sizeHint() const override;
+ void setRoomName(const QString &name);
+
+ 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, QWidget *parent = nullptr);
+
+signals:
+ void closing();
+ void enableEncryptionError(const QString &msg);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+private slots:
+ void saveSettings();
+
+private:
+ static constexpr int AvatarSize = 64;
+
+ void setAvatar(const QImage &img) { avatarImg_ = img; }
+ void setupEditButton();
+ //! Retrieve the current room information from cache.
+ void retrieveRoomInfo();
+ void enableEncryption();
+
+ //! Whether the user would be able to change the name or the topic of the room.
+ bool hasEditRights_ = true;
+ bool usesEncryption_ = false;
+ QHBoxLayout *editLayout_;
+
+ // Button section
+ FlatButton *okBtn_;
+ FlatButton *cancelBtn_;
+
+ FlatButton *editFieldsBtn_;
+
+ RoomInfo info_;
+ QString room_id_;
+ QImage avatarImg_;
+
+ TopSection *topSection_;
+
+ QComboBox *accessCombo;
+ Toggle *encryptionToggle_;
+};
+
+} // dialogs
|