Last active
January 10, 2020 11:48
-
-
Save dsonck92/fc7c5064a474a3f0c6e83ec5f7722fd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r -c kconfig-5.65.0/src/gui/kwindowconfig.cpp kconfig-5.65.0.new/src/gui/kwindowconfig.cpp | |
*** kconfig-5.65.0/src/gui/kwindowconfig.cpp 2020-01-10 12:29:10.837641439 +0100 | |
--- kconfig-5.65.0.new/src/gui/kwindowconfig.cpp 2020-01-10 12:26:56.437406894 +0100 | |
*************** | |
*** 23,28 **** | |
--- 23,29 ---- | |
#include <QScreen> | |
#include <QWindow> | |
+ #include <QtGui/QGuiApplication> | |
static const char s_initialSizePropertyName[] = "_kconfig_initial_size"; | |
static const char s_initialScreenSizePropertyName[] = "_kconfig_initial_screen_size"; | |
*************** | |
*** 33,52 **** | |
if (!window || !window->screen()) { | |
return; | |
} | |
! const QRect desk = window->screen()->geometry(); | |
const QSize sizeToSave = window->size(); | |
const bool isMaximized = window->windowState() & Qt::WindowMaximized; | |
! const QString screenMaximizedString(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width())); | |
// Save size only if window is not maximized | |
if (!isMaximized) { | |
const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); | |
const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize()); | |
const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); | |
if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { | |
! const QString wString(QStringLiteral("Width %1").arg(desk.width())); | |
! const QString hString(QStringLiteral("Height %1").arg(desk.height())); | |
config.writeEntry(wString, sizeToSave.width(), options); | |
config.writeEntry(hString, sizeToSave.height(), options); | |
} | |
--- 34,54 ---- | |
if (!window || !window->screen()) { | |
return; | |
} | |
! QScreen *screen = window->screen(); | |
! const QRect desk = screen->geometry(); | |
const QSize sizeToSave = window->size(); | |
const bool isMaximized = window->windowState() & Qt::WindowMaximized; | |
! const QString screenMaximizedString(QStringLiteral("Window-Maximized %1 %2x%3").arg(screen->name()).arg(desk.height()).arg(desk.width())); | |
// Save size only if window is not maximized | |
if (!isMaximized) { | |
const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); | |
const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize()); | |
const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); | |
if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { | |
! const QString wString(QStringLiteral("Width %1 %2").arg(screen->name()).arg(desk.width())); | |
! const QString hString(QStringLiteral("Height %1 %2").arg(screen->name()).arg(desk.height())); | |
config.writeEntry(wString, sizeToSave.width(), options); | |
config.writeEntry(hString, sizeToSave.height(), options); | |
} | |
*************** | |
*** 56,62 **** | |
} else { | |
config.writeEntry(screenMaximizedString, isMaximized, options); | |
} | |
! | |
} | |
void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config) | |
--- 58,64 ---- | |
} else { | |
config.writeEntry(screenMaximizedString, isMaximized, options); | |
} | |
! config.writeEntry(QStringLiteral("Screen Name"), screen->name(), options); | |
} | |
void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config) | |
*************** | |
*** 65,75 **** | |
return; | |
} | |
! const QRect desk = window->screen()->geometry(); | |
! const int width = config.readEntry(QStringLiteral("Width %1").arg(desk.width()), window->size().width()); | |
! const int height = config.readEntry(QStringLiteral("Height %1").arg(desk.height()), window->size().height()); | |
! const bool isMaximized = config.readEntry(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); | |
// Check default size | |
const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); | |
--- 67,85 ---- | |
return; | |
} | |
! QString screenName = config.readEntry(QStringLiteral("Screen Name"), QString()); | |
! | |
! for(auto screen : QGuiApplication::screens()) { | |
! if(screen -> name() == screenName) | |
! window->setScreen(screen); | |
! } | |
! | |
! const QScreen *screen = window->screen(); | |
! const QRect desk = screen->geometry(); | |
! const int width = config.readEntry(QStringLiteral("Width %1 %2").arg(screen->name()).arg(desk.width()), window->size().width()); | |
! const int height = config.readEntry(QStringLiteral("Height %1 %2").arg(screen->name()).arg(desk.height()), window->size().height()); | |
! const bool isMaximized = config.readEntry(QStringLiteral("Window-Maximized %1 %2x%3").arg(screen->name()).arg(desk.height()).arg(desk.width()), false); | |
// Check default size | |
const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment