Make emote popup remember last position (#1580)
* Use existing moveTo to ensure window stay within desktop geometry
This commit is contained in:
@@ -274,6 +274,16 @@ Window *WindowManager::windowAt(int index)
|
|||||||
return this->windows_.at(index);
|
return this->windows_.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint WindowManager::emotePopupPos()
|
||||||
|
{
|
||||||
|
return this->emotePopupPos_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowManager::setEmotePopupPos(QPoint pos)
|
||||||
|
{
|
||||||
|
this->emotePopupPos_ = pos;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::initialize(Settings &settings, Paths &paths)
|
void WindowManager::initialize(Settings &settings, Paths &paths)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
@@ -401,6 +411,10 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
|
|||||||
}
|
}
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
|
QJsonObject emote_popup_obj = window_obj.value("emotePopup").toObject();
|
||||||
|
this->emotePopupPos_ = QPoint(emote_popup_obj.value("x").toInt(),
|
||||||
|
emote_popup_obj.value("y").toInt());
|
||||||
|
|
||||||
if (window_obj.value("state") == "minimized")
|
if (window_obj.value("state") == "minimized")
|
||||||
{
|
{
|
||||||
window.setWindowState(Qt::WindowMinimized);
|
window.setWindowState(Qt::WindowMinimized);
|
||||||
@@ -478,6 +492,11 @@ void WindowManager::save()
|
|||||||
window_obj.insert("width", rect.width());
|
window_obj.insert("width", rect.width());
|
||||||
window_obj.insert("height", rect.height());
|
window_obj.insert("height", rect.height());
|
||||||
|
|
||||||
|
QJsonObject emote_popup_obj;
|
||||||
|
emote_popup_obj.insert("x", this->emotePopupPos_.x());
|
||||||
|
emote_popup_obj.insert("y", this->emotePopupPos_.y());
|
||||||
|
window_obj.insert("emotePopup", emote_popup_obj);
|
||||||
|
|
||||||
// window tabs
|
// window tabs
|
||||||
QJsonArray tabs_arr;
|
QJsonArray tabs_arr;
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ public:
|
|||||||
int windowCount();
|
int windowCount();
|
||||||
Window *windowAt(int index);
|
Window *windowAt(int index);
|
||||||
|
|
||||||
|
QPoint emotePopupPos();
|
||||||
|
void setEmotePopupPos(QPoint pos);
|
||||||
|
|
||||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||||
virtual void save() override;
|
virtual void save() override;
|
||||||
void closeAll();
|
void closeAll();
|
||||||
@@ -89,6 +92,8 @@ private:
|
|||||||
|
|
||||||
bool initialized_ = false;
|
bool initialized_ = false;
|
||||||
|
|
||||||
|
QPoint emotePopupPos_;
|
||||||
|
|
||||||
std::atomic<int> generation_{0};
|
std::atomic<int> generation_{0};
|
||||||
|
|
||||||
std::vector<Window *> windows_;
|
std::vector<Window *> windows_;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/Shortcut.hpp"
|
#include "util/Shortcut.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
@@ -113,6 +114,8 @@ namespace {
|
|||||||
EmotePopup::EmotePopup(QWidget *parent)
|
EmotePopup::EmotePopup(QWidget *parent)
|
||||||
: BasePopup(BaseWindow::EnableCustomFrame, parent)
|
: BasePopup(BaseWindow::EnableCustomFrame, parent)
|
||||||
{
|
{
|
||||||
|
this->moveTo(this, getApp()->windows->emotePopupPos());
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
this->getLayoutContainer()->setLayout(layout);
|
this->getLayoutContainer()->setLayout(layout);
|
||||||
|
|
||||||
@@ -220,4 +223,9 @@ void EmotePopup::loadEmojis()
|
|||||||
this->viewEmojis_->setChannel(emojiChannel);
|
this->viewEmojis_->setChannel(emojiChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmotePopup::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
getApp()->windows->setEmotePopupPos(this->pos());
|
||||||
|
QWidget::closeEvent(event);
|
||||||
|
}
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public:
|
|||||||
void loadChannel(ChannelPtr channel);
|
void loadChannel(ChannelPtr channel);
|
||||||
void loadEmojis();
|
void loadEmojis();
|
||||||
|
|
||||||
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
pajlada::Signals::Signal<Link> linkClicked;
|
pajlada::Signals::Signal<Link> linkClicked;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user