mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
infowindow: Pop up infowindow at screen center (#318)
Currently info window will pop up at the topleft corner of the screen, which is rather bothering. This patch will move the window to screen center when popped up. Since QGuiApplication::ScreenAt() is introduced since Qt 5.10, the code will only take effect when compiled against Qt >= 5.10. Signed-off-by: Boyuan Yang <073plan@gmail.com>
This commit is contained in:
@@ -23,6 +23,13 @@
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#include <QCursor>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QGuiApplication>
|
||||
#endif
|
||||
|
||||
// InfoWindow show basic information about the usage of Flameshot
|
||||
|
||||
InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
|
||||
@@ -30,6 +37,13 @@ InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
|
||||
setWindowIcon(QIcon(":img/app/flameshot.svg"));
|
||||
setWindowTitle(tr("About"));
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QRect position = frameGeometry();
|
||||
QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
|
||||
position.moveCenter(screen->availableGeometry().center());
|
||||
move(position.topLeft());
|
||||
#endif
|
||||
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setAlignment(Qt::AlignHCenter);
|
||||
initLabels();
|
||||
|
||||
Reference in New Issue
Block a user