Show confirmation dialog on logout
Minor stylistic refactoring
closes #29
3 files changed, 50 insertions, 0 deletions
diff --git a/include/LogoutDialog.h b/include/LogoutDialog.h
new file mode 100644
index 00000000..a2d313c7
--- /dev/null
+++ b/include/LogoutDialog.h
@@ -0,0 +1,36 @@
+/*
+ * 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>
+
+#include "FlatButton.h"
+
+class LogoutDialog : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit LogoutDialog(QWidget *parent = nullptr);
+
+signals:
+ void closing(bool isLoggingOut);
+
+private:
+ FlatButton *confirmBtn_;
+ FlatButton *cancelBtn_;
+};
diff --git a/include/MainWindow.h b/include/MainWindow.h
index 536cea13..9d0a601f 100644
--- a/include/MainWindow.h
+++ b/include/MainWindow.h
@@ -38,6 +38,8 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
+ static MainWindow *instance();
+
protected:
void closeEvent(QCloseEvent *event);
@@ -62,6 +64,8 @@ private slots:
private:
bool hasActiveUser();
+ static MainWindow *instance_;
+
// The initial welcome screen.
WelcomePage *welcome_page_;
diff --git a/include/UserInfoWidget.h b/include/UserInfoWidget.h
index 1b819577..10c770d8 100644
--- a/include/UserInfoWidget.h
+++ b/include/UserInfoWidget.h
@@ -24,6 +24,8 @@
#include "Avatar.h"
#include "FlatButton.h"
+#include "LogoutDialog.h"
+#include "OverlayModal.h"
class UserInfoWidget : public QWidget
{
@@ -45,6 +47,9 @@ signals:
protected:
void resizeEvent(QResizeEvent *event) override;
+private slots:
+ void closeLogoutDialog(bool isLoggingOut);
+
private:
Avatar *userAvatar_;
@@ -62,4 +67,9 @@ private:
QString user_id_;
QImage avatar_image_;
+
+ OverlayModal *logoutModal_;
+ LogoutDialog *logoutDialog_;
+
+ int logoutButtonSize_;
};
|