Use MainWindow instead of QApplication::activeWindow to reference the main window
The latter will not always return a valid pointer. fixes #363
This commit is contained in:
parent
31d09dbd68
commit
fde066e236
@ -1,5 +1,5 @@
|
|||||||
#include "Cache.h"
|
|
||||||
#include "CommunitiesList.h"
|
#include "CommunitiesList.h"
|
||||||
|
#include "Cache.h"
|
||||||
#include "Logging.hpp"
|
#include "Logging.hpp"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Logging.hpp"
|
#include "Logging.hpp"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "dialogs/PreviewUploadOverlay.h"
|
#include "dialogs/PreviewUploadOverlay.h"
|
||||||
@ -61,9 +62,16 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
|
|||||||
void
|
void
|
||||||
PreviewUploadOverlay::init()
|
PreviewUploadOverlay::init()
|
||||||
{
|
{
|
||||||
auto window = QApplication::activeWindow();
|
QSize winsize;
|
||||||
auto winsize = window->frameGeometry().size();
|
QPoint center;
|
||||||
auto center = window->frameGeometry().center();
|
|
||||||
|
auto window = MainWindow::instance();
|
||||||
|
if (window) {
|
||||||
|
winsize = window->frameGeometry().size();
|
||||||
|
center = window->frameGeometry().center();
|
||||||
|
} else {
|
||||||
|
nhlog::ui()->warn("unable to load the retrieve MainWindow's size");
|
||||||
|
}
|
||||||
|
|
||||||
fileName_.setText(QFileInfo{filePath_}.fileName());
|
fileName_.setText(QFileInfo{filePath_}.fileName());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user