Add Courtroom position restore
This commit is contained in:
parent
efd2571459
commit
d9aada2900
@ -230,9 +230,9 @@ void Courtroom::on_char_button_context_menu_requested(const QPoint &pos)
|
||||
}
|
||||
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->addAction(QString("Edit " + char_name + "/char.ini"), this, [=] { QDesktopServices::openUrl(QUrl::fromLocalFile(char_ini_path)); });
|
||||
menu->addAction(QString("Edit " + char_name + "/char.ini"), this, [=, this] { QDesktopServices::openUrl(QUrl::fromLocalFile(char_ini_path)); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(QString("Open character folder " + char_name), this, [=] {
|
||||
menu->addAction(QString("Open character folder " + char_name), this, [=, this] {
|
||||
QString p_path = ao_app->get_real_path(VPath("characters/" + char_name + "/"));
|
||||
if (!dir_exists(p_path))
|
||||
{
|
||||
|
@ -7,14 +7,12 @@
|
||||
// #define DEBUG_TRANSITION
|
||||
|
||||
Courtroom::Courtroom(AOApplication *p_ao_app)
|
||||
: QMainWindow()
|
||||
: QMainWindow(),
|
||||
ao_app{p_ao_app}
|
||||
{
|
||||
ao_app = p_ao_app;
|
||||
|
||||
this->setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint);
|
||||
setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint);
|
||||
|
||||
ao_app->initBASS();
|
||||
|
||||
keepalive_timer = new QTimer(this);
|
||||
keepalive_timer->start(45000);
|
||||
|
||||
@ -1372,6 +1370,14 @@ void Courtroom::done_received()
|
||||
|
||||
show();
|
||||
|
||||
if (Options::getInstance().restoreWindowPositionEnabled()) {
|
||||
auto maybe_point = Options::getInstance().windowPosition("courtroom");
|
||||
if (maybe_point.has_value()) {
|
||||
qDebug() << maybe_point.value();
|
||||
QMainWindow::move(maybe_point.value());
|
||||
}
|
||||
}
|
||||
|
||||
ui_spectator->show();
|
||||
}
|
||||
|
||||
@ -1907,6 +1913,13 @@ void Courtroom::set_judge_buttons()
|
||||
show_judge_controls(ao_app->get_pos_is_judge(current_or_default_side()));
|
||||
}
|
||||
|
||||
void Courtroom::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Options::getInstance().setWindowPosition("courtroom", pos());
|
||||
qDebug() << pos();
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void Courtroom::on_chat_return_pressed()
|
||||
{
|
||||
if (is_muted)
|
||||
@ -5191,7 +5204,7 @@ void Courtroom::on_pos_dropdown_context_menu_requested(const QPoint &pos)
|
||||
QMenu *menu = new QMenu(ui_iniswap_dropdown);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
menu->addAction(QString("Open background " + current_background), this, [=] {
|
||||
menu->addAction(QString("Open background " + current_background), this, [=, this] {
|
||||
QString p_path = ao_app->get_real_path(VPath("background/" + current_background + "/"));
|
||||
if (!dir_exists(p_path))
|
||||
{
|
||||
@ -5303,7 +5316,7 @@ void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos)
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(QString("Open character folder " + current_char), this, [=] {
|
||||
menu->addAction(QString("Open character folder " + current_char), this, [=, this] {
|
||||
QString p_path = ao_app->get_real_path(VPath("characters/" + current_char + "/"));
|
||||
if (!dir_exists(p_path))
|
||||
{
|
||||
@ -6127,7 +6140,7 @@ void Courtroom::on_text_color_context_menu_requested(const QPoint &pos)
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
menu->addAction(QString("Open currently used chat_config.ini"), this, [=] {
|
||||
menu->addAction(QString("Open currently used chat_config.ini"), this, [=, this] {
|
||||
QString p_path = ao_app->get_asset("chat_config.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, ao_app->get_chat(current_char));
|
||||
if (!file_exists(p_path))
|
||||
{
|
||||
|
@ -297,6 +297,9 @@ public:
|
||||
void set_judge_state(JudgeState new_state);
|
||||
void set_judge_buttons();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
AOApplication *ao_app;
|
||||
|
||||
|
@ -162,7 +162,7 @@ void Lobby::loadUI()
|
||||
FROM_UI(QTextBrowser, server_description_text);
|
||||
FROM_UI(QPushButton, connect_button);
|
||||
connect(ui_connect_button, &QPushButton::released, net_manager, &NetworkManager::join_to_server);
|
||||
connect(ui_connect_button, &QPushButton::released, this, [=] { ui_server_player_count_lbl->setText(tr("Joining Server...")); });
|
||||
connect(ui_connect_button, &QPushButton::released, this, [=, this] { ui_server_player_count_lbl->setText(tr("Joining Server...")); });
|
||||
connect(net_manager, &NetworkManager::server_connected, ui_connect_button, &QPushButton::setEnabled);
|
||||
|
||||
FROM_UI(QTextBrowser, motd_text);
|
||||
|
@ -763,3 +763,28 @@ QString Options::getUIAsset(QString f_asset_name)
|
||||
qWarning() << "Unable to locate ui-asset" << f_asset_name << "in theme" << theme() << "Defaulting to embeeded asset.";
|
||||
return QString(":/data/ui/" + f_asset_name);
|
||||
}
|
||||
|
||||
void Options::setWindowPosition(QString widget, QPoint position)
|
||||
{
|
||||
config.setValue("windows/position_" + widget, position);
|
||||
}
|
||||
|
||||
std::optional<QPoint> Options::windowPosition(QString widget)
|
||||
{
|
||||
QPoint point = config.value("windows/position_" + widget, QPoint()).toPoint();
|
||||
if (point.isNull())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return std::optional<QPoint>(point);
|
||||
}
|
||||
|
||||
bool Options::restoreWindowPositionEnabled() const
|
||||
{
|
||||
return config.value("windows/restore", false).toBool();
|
||||
}
|
||||
|
||||
void Options::setRestoreWindowPositionEnabled(bool state)
|
||||
{
|
||||
config.setValue("windows/restore", state);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QPoint>
|
||||
|
||||
class Options
|
||||
{
|
||||
public:
|
||||
@ -269,6 +271,12 @@ public:
|
||||
// Theming Nonesense!
|
||||
QString getUIAsset(QString f_asset_name);
|
||||
|
||||
void setWindowPosition(QString widget, QPoint position);
|
||||
std::optional<QPoint> windowPosition(QString widget);
|
||||
|
||||
bool restoreWindowPositionEnabled() const;
|
||||
void setRestoreWindowPositionEnabled(bool state);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief QSettings object for config.ini
|
||||
@ -280,6 +288,8 @@ private:
|
||||
*/
|
||||
QSettings favorite;
|
||||
|
||||
QSettings windows;
|
||||
|
||||
void migrateCallwords();
|
||||
|
||||
/**
|
||||
|
@ -157,10 +157,10 @@ void AOOptionsDialog::registerOption(const QString &widgetName, V (Options::*get
|
||||
}
|
||||
|
||||
OptionEntry entry;
|
||||
entry.load = [=] {
|
||||
entry.load = [=, this] {
|
||||
setWidgetData<T, V>(widget, (Options::getInstance().*getter)());
|
||||
};
|
||||
entry.save = [=] {
|
||||
entry.save = [=, this] {
|
||||
(Options::getInstance().*setter)(widgetData<T, V>(widget));
|
||||
};
|
||||
|
||||
@ -323,7 +323,7 @@ void AOOptionsDialog::setupUI()
|
||||
connect(ui_theme_reload_button, &QPushButton::clicked, this, &::AOOptionsDialog::onReloadThemeClicked);
|
||||
|
||||
FROM_UI(QPushButton, theme_folder_button);
|
||||
connect(ui_theme_folder_button, &QPushButton::clicked, this, [=] {
|
||||
connect(ui_theme_folder_button, &QPushButton::clicked, this, [=, this] {
|
||||
QString p_path = ao_app->get_real_path(ao_app->get_theme_path("", ui_theme_combobox->itemText(ui_theme_combobox->currentIndex())));
|
||||
if (!dir_exists(p_path))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user