Skip to content

Commit

Permalink
Window Position
Browse files Browse the repository at this point in the history
Makes the courtroom window remember where you dragged it to when closed, and changes to that position when re-opened.
  • Loading branch information
WisoAltred committed Jan 17, 2024
1 parent e9469a5 commit 3faed2a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,9 @@ private slots:

void preview_emote(QString emote);
void update_emote_preview();

protected:
virtual void closeEvent(QCloseEvent *event) override;
};

#endif // COURTROOM_H
4 changes: 4 additions & 0 deletions include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ class Options {

// Theming Nonesense!
QString getUIAsset(QString f_asset_name);

// Window Position
void setWindowPosition(QPoint value);
QPoint getWindowPosition();
};

#endif // OPTIONS_H
8 changes: 8 additions & 0 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,8 @@ void Courtroom::done_received()
set_mute_list();
set_pair_list();

move(Options::getInstance().getWindowPosition());

show();

ui_spectator->show();
Expand Down Expand Up @@ -5826,3 +5828,9 @@ Courtroom::~Courtroom()
delete objection_player;
delete blip_player;
}

void Courtroom::closeEvent(QCloseEvent *event)
{
Options::getInstance().setWindowPosition(pos());
QMainWindow::closeEvent(event);
}
11 changes: 11 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "options.h"
#include "file_functions.h"
#include "QPoint"

#include <QCoreApplication>
#include <QDebug>
Expand Down Expand Up @@ -572,6 +573,16 @@ void Options::setCallwords(QStringList value)
config.setValue("callwords", value);
}

void Options::setWindowPosition(QPoint value)
{
config.setValue("Window/WindowPos", value);
}

QPoint Options::getWindowPosition()
{
return config.value("Window/WindowPos").toPoint();
}

void Options::clearConfig() { config.clear(); }

QVector<server_type> Options::favorites()
Expand Down

0 comments on commit 3faed2a

Please sign in to comment.