mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Remember Popped-up Chat Size (#5635)
This commit is contained in:
parent
bc1850ce2d
commit
2d818a7657
|
@ -30,6 +30,7 @@
|
||||||
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
|
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
|
||||||
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
|
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
|
||||||
- Minor: Removed experimental IRC support. (#5547)
|
- Minor: Removed experimental IRC support. (#5547)
|
||||||
|
- Minor: Remember last popup size for next popup. (#5635)
|
||||||
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
|
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
|
||||||
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
|
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
|
||||||
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
|
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "util/QMagicEnum.hpp"
|
#include "util/QMagicEnum.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings.hpp>
|
#include <pajlada/settings.hpp>
|
||||||
|
#include <QSize>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -55,6 +56,7 @@ using DoubleSetting = ChatterinoSetting<double>;
|
||||||
using IntSetting = ChatterinoSetting<int>;
|
using IntSetting = ChatterinoSetting<int>;
|
||||||
using StringSetting = ChatterinoSetting<std::string>;
|
using StringSetting = ChatterinoSetting<std::string>;
|
||||||
using QStringSetting = ChatterinoSetting<QString>;
|
using QStringSetting = ChatterinoSetting<QString>;
|
||||||
|
using QSizeSetting = ChatterinoSetting<QSize>;
|
||||||
|
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
class EnumSetting
|
class EnumSetting
|
||||||
|
|
|
@ -212,6 +212,10 @@ public:
|
||||||
BoolSetting useCustomFfzVipBadges = {
|
BoolSetting useCustomFfzVipBadges = {
|
||||||
"/appearance/badges/useCustomFfzVipBadges", true};
|
"/appearance/badges/useCustomFfzVipBadges", true};
|
||||||
BoolSetting showBadgesSevenTV = {"/appearance/badges/seventv", true};
|
BoolSetting showBadgesSevenTV = {"/appearance/badges/seventv", true};
|
||||||
|
QSizeSetting lastPopupSize = {
|
||||||
|
"/appearance/lastPopup/size",
|
||||||
|
{300, 500},
|
||||||
|
};
|
||||||
|
|
||||||
/// Behaviour
|
/// Behaviour
|
||||||
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
|
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
|
||||||
|
|
52
src/util/RapidJsonSerializeQSize.hpp
Normal file
52
src/util/RapidJsonSerializeQSize.hpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
|
#include <pajlada/serialize.hpp>
|
||||||
|
#include <QSize>
|
||||||
|
|
||||||
|
namespace pajlada {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Serialize<QSize> {
|
||||||
|
static rapidjson::Value get(const QSize &value,
|
||||||
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "width", value.width(), a);
|
||||||
|
chatterino::rj::set(ret, "height", value.height(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<QSize> {
|
||||||
|
static QSize get(const rapidjson::Value &value, bool *error = nullptr)
|
||||||
|
{
|
||||||
|
if (!value.IsObject())
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
int width{};
|
||||||
|
int height{};
|
||||||
|
|
||||||
|
if (!chatterino::rj::getSafe(value, "width", width))
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (!chatterino::rj::getSafe(value, "height", height))
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {width, height};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pajlada
|
|
@ -18,6 +18,7 @@
|
||||||
#include "singletons/Updates.hpp"
|
#include "singletons/Updates.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/InitUpdateButton.hpp"
|
#include "util/InitUpdateButton.hpp"
|
||||||
|
#include "util/RapidJsonSerializeQSize.hpp"
|
||||||
#include "widgets/AccountSwitchPopup.hpp"
|
#include "widgets/AccountSwitchPopup.hpp"
|
||||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||||
#include "widgets/dialogs/switcher/QuickSwitcherPopup.hpp"
|
#include "widgets/dialogs/switcher/QuickSwitcherPopup.hpp"
|
||||||
|
@ -75,7 +76,13 @@ Window::Window(WindowType type, QWidget *parent)
|
||||||
}
|
}
|
||||||
else
|
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,
|
this->signalHolder_.managedConnect(getApp()->getHotkeys()->onItemsUpdated,
|
||||||
|
@ -142,7 +149,12 @@ void Window::closeEvent(QCloseEvent *)
|
||||||
getApp()->getWindows()->save();
|
getApp()->getWindows()->save();
|
||||||
getApp()->getWindows()->closeAll();
|
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.
|
// Ensure selectedWindow_ is never an invalid pointer.
|
||||||
// WindowManager will return the main window if no window is pointed to by
|
// WindowManager will return the main window if no window is pointed to by
|
||||||
// `selectedWindow_`.
|
// `selectedWindow_`.
|
||||||
|
|
Loading…
Reference in a new issue