Center dialogs around the main window

This commit is contained in:
Konstantinos Sideris 2018-09-21 11:30:02 +03:00
parent ce26f041ad
commit 2a2b52e07f
2 changed files with 19 additions and 18 deletions

View file

@ -31,6 +31,7 @@
#include "RegisterPage.h" #include "RegisterPage.h"
#include "TrayIcon.h" #include "TrayIcon.h"
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "Utils.h"
#include "WelcomePage.h" #include "WelcomePage.h"
#include "ui/LoadingIndicator.h" #include "ui/LoadingIndicator.h"
#include "ui/OverlayModal.h" #include "ui/OverlayModal.h"
@ -310,8 +311,7 @@ MainWindow::openUserProfile(const QString &user_id, const QString &room_id)
auto dialog = new dialogs::UserProfile(this); auto dialog = new dialogs::UserProfile(this);
dialog->init(user_id, room_id); dialog->init(user_id, room_id);
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -321,8 +321,7 @@ MainWindow::openRoomSettings(const QString &room_id)
auto dialog = new dialogs::RoomSettings(roomToSearch, this); auto dialog = new dialogs::RoomSettings(roomToSearch, this);
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -331,8 +330,7 @@ MainWindow::openMemberListDialog(const QString &room_id)
const auto roomToSearch = room_id.isEmpty() ? chat_page_->currentRoom() : ""; const auto roomToSearch = room_id.isEmpty() ? chat_page_->currentRoom() : "";
auto dialog = new dialogs::MemberList(roomToSearch, this); auto dialog = new dialogs::MemberList(roomToSearch, this);
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -345,8 +343,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
chat_page_->leaveRoom(roomToLeave); chat_page_->leaveRoom(roomToLeave);
}); });
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -370,8 +367,7 @@ MainWindow::openInviteUsersDialog(std::function<void(const QStringList &invitees
callback(invitees); callback(invitees);
}); });
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -383,8 +379,7 @@ MainWindow::openJoinRoomDialog(std::function<void(const QString &room_id)> callb
callback(room); callback(room);
}); });
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -397,8 +392,7 @@ MainWindow::openCreateRoomDialog(
this, this,
[callback](const mtx::requests::CreateRoom &request) { callback(request); }); [callback](const mtx::requests::CreateRoom &request) { callback(request); });
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -430,8 +424,7 @@ MainWindow::openLogoutDialog()
connect( connect(
dialog, &dialogs::Logout::loggingOut, this, [this]() { chat_page_->initiateLogout(); }); dialog, &dialogs::Logout::loggingOut, this, [this]() { chat_page_->initiateLogout(); });
dialog->raise(); showDialog(dialog);
dialog->show();
} }
void void
@ -452,8 +445,7 @@ MainWindow::openReadReceiptsDialog(const QString &event_id)
return; return;
} }
dialog->raise(); showDialog(dialog);
dialog->show();
} }
bool bool
@ -475,3 +467,11 @@ MainWindow::hideOverlay()
if (modal_) if (modal_)
modal_->hide(); modal_->hide();
} }
inline void
MainWindow::showDialog(QWidget *dialog)
{
utils::centerWidget(dialog, this);
dialog->raise();
dialog->show();
}

View file

@ -129,6 +129,7 @@ private slots:
void removeOverlayProgressBar(); void removeOverlayProgressBar();
private: private:
void showDialog(QWidget *dialog);
bool hasActiveUser(); bool hasActiveUser();
void restoreWindowSize(); void restoreWindowSize();
//! Check if there is an open dialog. //! Check if there is an open dialog.