Remember Popped-up Chat Size (#5635)

This commit is contained in:
maliByatzes
2024-10-12 12:35:39 +02:00
committed by GitHub
parent bc1850ce2d
commit 2d818a7657
5 changed files with 73 additions and 2 deletions
+14 -2
View File
@@ -18,6 +18,7 @@
#include "singletons/Updates.hpp"
#include "singletons/WindowManager.hpp"
#include "util/InitUpdateButton.hpp"
#include "util/RapidJsonSerializeQSize.hpp"
#include "widgets/AccountSwitchPopup.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
#include "widgets/dialogs/switcher/QuickSwitcherPopup.hpp"
@@ -75,7 +76,13 @@ Window::Window(WindowType type, QWidget *parent)
}
else
{
this->resize(int(300 * this->scale()), int(500 * this->scale()));
auto lastPopup = getSettings()->lastPopupSize.getValue();
if (lastPopup.isEmpty())
{
// The size in the setting was invalid, use the default value
lastPopup = getSettings()->lastPopupSize.getDefaultValue();
}
this->resize(lastPopup.width(), lastPopup.height());
}
this->signalHolder_.managedConnect(getApp()->getHotkeys()->onItemsUpdated,
@@ -142,7 +149,12 @@ void Window::closeEvent(QCloseEvent *)
getApp()->getWindows()->save();
getApp()->getWindows()->closeAll();
}
else
{
QRect rect = this->getBounds();
QSize newSize(rect.width(), rect.height());
getSettings()->lastPopupSize.setValue(newSize);
}
// Ensure selectedWindow_ is never an invalid pointer.
// WindowManager will return the main window if no window is pointed to by
// `selectedWindow_`.