Add screen utilities for screen and center widget on screen
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QScreen>
|
||||
#include <QWindow>
|
||||
#include <QMainWindow>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QtAlgorithms>
|
||||
@@ -58,6 +57,7 @@
|
||||
|
||||
#include "core/iconloader.h"
|
||||
#include "core/mainwindow.h"
|
||||
#include "utilities/screenutils.h"
|
||||
#include "widgets/fileview.h"
|
||||
#include "transcodedialog.h"
|
||||
#include "transcoder.h"
|
||||
@@ -194,17 +194,7 @@ void TranscodeDialog::LoadGeometry() {
|
||||
s.endGroup();
|
||||
|
||||
// Center the window on the same screen as the mainwindow.
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QScreen *screen = mainwindow_->screen();
|
||||
#else
|
||||
QScreen *screen = (mainwindow_->window() && mainwindow_->window()->windowHandle() ? mainwindow_->window()->windowHandle()->screen() : nullptr);
|
||||
#endif
|
||||
if (screen) {
|
||||
const QRect sr = screen->availableGeometry();
|
||||
const QRect wr({}, size().boundedTo(sr.size()));
|
||||
resize(wr.size());
|
||||
move(sr.center() - wr.center());
|
||||
}
|
||||
Utilities::CenterWidgetOnScreen(Utilities::GetScreen(mainwindow_), this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user