mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
BrowserWindow: Fix crash when restoring geometry of fullscreen window
This commit is contained in:
parent
4a4d5b72ad
commit
2d698edd21
|
@ -336,40 +336,9 @@ void BrowserWindow::postLaunch()
|
||||||
|
|
||||||
void BrowserWindow::setupUi()
|
void BrowserWindow::setupUi()
|
||||||
{
|
{
|
||||||
QHash<QString, QVariant> uiState;
|
|
||||||
|
|
||||||
QDesktopWidget* desktop = mApp->desktop();
|
|
||||||
int windowWidth = desktop->availableGeometry().width() / 1.3;
|
|
||||||
int windowHeight = desktop->availableGeometry().height() / 1.3;
|
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("Browser-View-Settings");
|
settings.beginGroup("Browser-View-Settings");
|
||||||
|
const QByteArray windowGeometry = settings.value(QSL("WindowGeometry")).toByteArray();
|
||||||
// Let the WM decides where to put new browser window
|
|
||||||
if (m_windowType != Qz::BW_FirstAppWindow && m_windowType != Qz::BW_MacFirstWindow && mApp->getWindow()) {
|
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
// Windows WM places every new window in the middle of screen .. for some reason
|
|
||||||
QPoint p = mApp->getWindow()->geometry().topLeft();
|
|
||||||
p.setX(p.x() + 30);
|
|
||||||
p.setY(p.y() + 30);
|
|
||||||
|
|
||||||
if (!desktop->availableGeometry(mApp->getWindow()).contains(p)) {
|
|
||||||
p.setX(desktop->availableGeometry(mApp->getWindow()).x() + 30);
|
|
||||||
p.setY(desktop->availableGeometry(mApp->getWindow()).y() + 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
setGeometry(QRect(p, mApp->getWindow()->size()));
|
|
||||||
#else
|
|
||||||
resize(mApp->getWindow()->size());
|
|
||||||
#endif
|
|
||||||
} else if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) {
|
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
setGeometry(QRect(desktop->availableGeometry(mApp->getWindow()).x() + 30,
|
|
||||||
desktop->availableGeometry(mApp->getWindow()).y() + 30, windowWidth, windowHeight));
|
|
||||||
#else
|
|
||||||
resize(windowWidth, windowHeight);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList keys = {
|
const QStringList keys = {
|
||||||
QSL("LocationBarWidth"),
|
QSL("LocationBarWidth"),
|
||||||
|
@ -378,12 +347,12 @@ void BrowserWindow::setupUi()
|
||||||
QSL("WebViewWidth"),
|
QSL("WebViewWidth"),
|
||||||
QSL("SideBar")
|
QSL("SideBar")
|
||||||
};
|
};
|
||||||
|
QHash<QString, QVariant> uiState;
|
||||||
for (const QString &key : keys) {
|
for (const QString &key : keys) {
|
||||||
if (settings.contains(key)) {
|
if (settings.contains(key)) {
|
||||||
uiState[key] = settings.value(key);
|
uiState[key] = settings.value(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
QWidget* widget = new QWidget(this);
|
QWidget* widget = new QWidget(this);
|
||||||
|
@ -423,6 +392,36 @@ void BrowserWindow::setupUi()
|
||||||
|
|
||||||
m_navigationToolbar->addToolButton(new AdBlockIcon(this));
|
m_navigationToolbar->addToolButton(new AdBlockIcon(this));
|
||||||
|
|
||||||
|
QDesktopWidget* desktop = mApp->desktop();
|
||||||
|
int windowWidth = desktop->availableGeometry().width() / 1.3;
|
||||||
|
int windowHeight = desktop->availableGeometry().height() / 1.3;
|
||||||
|
|
||||||
|
// Let the WM decides where to put new browser window
|
||||||
|
if (m_windowType != Qz::BW_FirstAppWindow && m_windowType != Qz::BW_MacFirstWindow && mApp->getWindow()) {
|
||||||
|
#ifdef Q_WS_WIN
|
||||||
|
// Windows WM places every new window in the middle of screen .. for some reason
|
||||||
|
QPoint p = mApp->getWindow()->geometry().topLeft();
|
||||||
|
p.setX(p.x() + 30);
|
||||||
|
p.setY(p.y() + 30);
|
||||||
|
|
||||||
|
if (!desktop->availableGeometry(mApp->getWindow()).contains(p)) {
|
||||||
|
p.setX(desktop->availableGeometry(mApp->getWindow()).x() + 30);
|
||||||
|
p.setY(desktop->availableGeometry(mApp->getWindow()).y() + 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
setGeometry(QRect(p, mApp->getWindow()->size()));
|
||||||
|
#else
|
||||||
|
resize(mApp->getWindow()->size());
|
||||||
|
#endif
|
||||||
|
} else if (!restoreGeometry(windowGeometry)) {
|
||||||
|
#ifdef Q_WS_WIN
|
||||||
|
setGeometry(QRect(desktop->availableGeometry(mApp->getWindow()).x() + 30,
|
||||||
|
desktop->availableGeometry(mApp->getWindow()).y() + 30, windowWidth, windowHeight));
|
||||||
|
#else
|
||||||
|
resize(windowWidth, windowHeight);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround for Oxygen tooltips not having transparent background
|
// Workaround for Oxygen tooltips not having transparent background
|
||||||
QPalette pal = QToolTip::palette();
|
QPalette pal = QToolTip::palette();
|
||||||
QColor col = pal.window().color();
|
QColor col = pal.window().color();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user