mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +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);
|
showDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
MainWindow::hasActiveDialogs() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MainWindow::pageSupportsTray() const
|
MainWindow::pageSupportsTray() const
|
||||||
{
|
{
|
||||||
return false; //! welcome_page_->isVisible() && !login_page_->isVisible() &&
|
return !http::client()->access_token().empty();
|
||||||
//! !register_page_->isVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
MainWindow::showDialog(QWidget *dialog)
|
MainWindow::showDialog(QWidget *dialog)
|
||||||
{
|
{
|
||||||
// utils::centerWidget(dialog, this);
|
dialog->setWindowFlags(Qt::WindowType::Dialog | Qt::WindowType::WindowCloseButtonHint |
|
||||||
|
Qt::WindowType::WindowTitleHint);
|
||||||
dialog->raise();
|
dialog->raise();
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
utils::centerWidget(dialog, this);
|
||||||
|
dialog->window()->windowHandle()->setTransientParent(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,6 @@ private:
|
||||||
void showDialog(QWidget *dialog);
|
void showDialog(QWidget *dialog);
|
||||||
bool hasActiveUser();
|
bool hasActiveUser();
|
||||||
void restoreWindowSize();
|
void restoreWindowSize();
|
||||||
//! Check if there is an open dialog.
|
|
||||||
bool hasActiveDialogs() const;
|
|
||||||
//! Check if the current page supports the "minimize to tray" functionality.
|
//! Check if the current page supports the "minimize to tray" functionality.
|
||||||
bool pageSupportsTray() const;
|
bool pageSupportsTray() const;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QTextBoundaryFinder>
|
#include <QTextBoundaryFinder>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
#include <QWindow>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -770,20 +771,17 @@ utils::luminance(const QColor &col)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 {
|
auto findCenter = [childRect = widget->rect()](QRect hostRect) -> QPoint {
|
||||||
return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
|
return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
|
||||||
hostRect.center().y() - (childRect.height() * 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()));
|
widget->move(findCenter(QGuiApplication::primaryScreen()->geometry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ luminance(const QColor &col);
|
||||||
|
|
||||||
//! Center a widget in relation to another widget.
|
//! Center a widget in relation to another widget.
|
||||||
void
|
void
|
||||||
centerWidget(QWidget *widget, QWidget *parent);
|
centerWidget(QWidget *widget, QWindow *parent);
|
||||||
|
|
||||||
void
|
void
|
||||||
restoreCombobox(QComboBox *combo, const QString &value);
|
restoreCombobox(QComboBox *combo, const QString &value);
|
||||||
|
|
Loading…
Reference in a new issue