mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Fix centering dialogs
This commit is contained in:
parent
1d6d9e65af
commit
392a4be858
4 changed files with 13 additions and 21 deletions
|
@ -422,23 +422,19 @@ MainWindow::openCreateRoomDialog(
|
|||
showDialog(dialog);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::hasActiveDialogs() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::pageSupportsTray() const
|
||||
{
|
||||
return false; //! welcome_page_->isVisible() && !login_page_->isVisible() &&
|
||||
//! !register_page_->isVisible();
|
||||
return !http::client()->access_token().empty();
|
||||
}
|
||||
|
||||
inline void
|
||||
MainWindow::showDialog(QWidget *dialog)
|
||||
{
|
||||
// utils::centerWidget(dialog, this);
|
||||
dialog->setWindowFlags(Qt::WindowType::Dialog | Qt::WindowType::WindowCloseButtonHint |
|
||||
Qt::WindowType::WindowTitleHint);
|
||||
dialog->raise();
|
||||
dialog->show();
|
||||
utils::centerWidget(dialog, this);
|
||||
dialog->window()->windowHandle()->setTransientParent(this);
|
||||
}
|
||||
|
|
|
@ -83,8 +83,6 @@ private:
|
|||
void showDialog(QWidget *dialog);
|
||||
bool hasActiveUser();
|
||||
void restoreWindowSize();
|
||||
//! Check if there is an open dialog.
|
||||
bool hasActiveDialogs() const;
|
||||
//! Check if the current page supports the "minimize to tray" functionality.
|
||||
bool pageSupportsTray() const;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QStringBuilder>
|
||||
#include <QTextBoundaryFinder>
|
||||
#include <QTextDocument>
|
||||
#include <QWindow>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include <array>
|
||||
|
@ -770,20 +771,17 @@ utils::luminance(const QColor &col)
|
|||
}
|
||||
|
||||
void
|
||||
utils::centerWidget(QWidget *widget, QWidget *parent)
|
||||
utils::centerWidget(QWidget *widget, QWindow *parent)
|
||||
{
|
||||
if (parent) {
|
||||
widget->window()->windowHandle()->setTransientParent(parent);
|
||||
return;
|
||||
}
|
||||
|
||||
auto findCenter = [childRect = widget->rect()](QRect hostRect) -> QPoint {
|
||||
return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
|
||||
hostRect.center().y() - (childRect.height() * 0.5));
|
||||
};
|
||||
|
||||
if (parent) {
|
||||
widget->move(parent->window()->frameGeometry().topLeft() +
|
||||
parent->window()->rect().center() - widget->rect().center());
|
||||
return;
|
||||
}
|
||||
|
||||
// Deprecated in 5.13: widget->move(findCenter(QApplication::desktop()->screenGeometry()));
|
||||
widget->move(findCenter(QGuiApplication::primaryScreen()->geometry()));
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ luminance(const QColor &col);
|
|||
|
||||
//! Center a widget in relation to another widget.
|
||||
void
|
||||
centerWidget(QWidget *widget, QWidget *parent);
|
||||
centerWidget(QWidget *widget, QWindow *parent);
|
||||
|
||||
void
|
||||
restoreCombobox(QComboBox *combo, const QString &value);
|
||||
|
|
Loading…
Reference in a new issue