mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 16:15:45 -04:00
GameList: Add custom title/regions
Largely inspired by https://github.com/PCSX2/pcsx2/pull/9330, but almost entirely rewritten.
This commit is contained in:
@ -254,6 +254,11 @@ void GameListWidget::refresh(bool invalidate_cache)
|
||||
m_refresh_thread->start();
|
||||
}
|
||||
|
||||
void GameListWidget::refreshModel()
|
||||
{
|
||||
m_model->refresh();
|
||||
}
|
||||
|
||||
void GameListWidget::cancelRefresh()
|
||||
{
|
||||
if (!m_refresh_thread)
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
void resizeTableViewColumnsToFit();
|
||||
|
||||
void refresh(bool invalidate_cache);
|
||||
void refreshModel();
|
||||
void cancelRefresh();
|
||||
void reloadThemeSpecificImages();
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "gamesummarywidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "qthost.h"
|
||||
#include "qtprogresscallback.h"
|
||||
#include "settingswindow.h"
|
||||
@ -54,6 +55,17 @@ GameSummaryWidget::GameSummaryWidget(const std::string& path, const std::string&
|
||||
connect(m_ui.compatibilityComments, &QToolButton::clicked, this, &GameSummaryWidget::onCompatibilityCommentsClicked);
|
||||
connect(m_ui.inputProfile, &QComboBox::currentIndexChanged, this, &GameSummaryWidget::onInputProfileChanged);
|
||||
connect(m_ui.computeHashes, &QAbstractButton::clicked, this, &GameSummaryWidget::onComputeHashClicked);
|
||||
|
||||
connect(m_ui.title, &QLineEdit::editingFinished, this, [this]() {
|
||||
if (m_ui.title->isModified())
|
||||
{
|
||||
setCustomTitle(m_ui.title->text().toStdString());
|
||||
m_ui.title->setModified(false);
|
||||
}
|
||||
});
|
||||
connect(m_ui.restoreTitle, &QAbstractButton::clicked, this, [this]() { setCustomTitle(std::string()); });
|
||||
connect(m_ui.region, &QComboBox::currentIndexChanged, this, [this](int index) { setCustomRegion(index); });
|
||||
connect(m_ui.restoreRegion, &QAbstractButton::clicked, this, [this]() { setCustomRegion(-1); });
|
||||
}
|
||||
|
||||
GameSummaryWidget::~GameSummaryWidget() = default;
|
||||
@ -157,7 +169,56 @@ void GameSummaryWidget::populateUi(const std::string& path, const std::string& s
|
||||
else
|
||||
m_ui.inputProfile->setCurrentIndex(0);
|
||||
|
||||
populateCustomAttributes();
|
||||
populateTracksInfo();
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void GameSummaryWidget::populateCustomAttributes()
|
||||
{
|
||||
auto lock = GameList::GetLock();
|
||||
const GameList::Entry* entry = GameList::GetEntryForPath(m_path);
|
||||
if (!entry || entry->IsDiscSet())
|
||||
return;
|
||||
|
||||
{
|
||||
QSignalBlocker sb(m_ui.title);
|
||||
m_ui.title->setText(QString::fromStdString(entry->title));
|
||||
m_ui.restoreTitle->setEnabled(entry->has_custom_title);
|
||||
}
|
||||
|
||||
{
|
||||
QSignalBlocker sb(m_ui.region);
|
||||
m_ui.region->setCurrentIndex(static_cast<int>(entry->region));
|
||||
m_ui.restoreRegion->setEnabled(entry->has_custom_region);
|
||||
}
|
||||
}
|
||||
|
||||
void GameSummaryWidget::updateWindowTitle()
|
||||
{
|
||||
const QString window_title = tr("%1 [%2]").arg(m_ui.title->text()).arg(m_ui.serial->text());
|
||||
m_dialog->setWindowTitle(window_title);
|
||||
}
|
||||
|
||||
void GameSummaryWidget::setCustomTitle(const std::string& text)
|
||||
{
|
||||
m_ui.restoreTitle->setEnabled(!text.empty());
|
||||
|
||||
GameList::SaveCustomTitleForPath(m_path, text);
|
||||
populateCustomAttributes();
|
||||
updateWindowTitle();
|
||||
g_main_window->refreshGameListModel();
|
||||
}
|
||||
|
||||
void GameSummaryWidget::setCustomRegion(int region)
|
||||
{
|
||||
m_ui.restoreRegion->setEnabled(region >= 0);
|
||||
|
||||
GameList::SaveCustomRegionForPath(m_path, (region >= 0) ? std::optional<DiscRegion>(static_cast<DiscRegion>(region)) :
|
||||
std::optional<DiscRegion>());
|
||||
populateCustomAttributes();
|
||||
updateWindowTitle();
|
||||
g_main_window->refreshGameListModel();
|
||||
}
|
||||
|
||||
static QString MSFTotString(const CDImage::Position& position)
|
||||
|
@ -32,6 +32,11 @@ private Q_SLOTS:
|
||||
private:
|
||||
void populateUi(const std::string& path, const std::string& serial, DiscRegion region,
|
||||
const GameDatabase::Entry* entry);
|
||||
void populateCustomAttributes();
|
||||
void updateWindowTitle();
|
||||
void setCustomTitle(const std::string& text);
|
||||
void setCustomRegion(int region);
|
||||
|
||||
void populateTracksInfo();
|
||||
|
||||
Ui::GameSummaryWidget m_ui;
|
||||
|
@ -38,18 +38,49 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="title">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="title">
|
||||
<property name="placeholderText">
|
||||
<string>Clear the line to restore the original title...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restoreTitle">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="region">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QComboBox" name="region">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restoreRegion">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
@ -2821,6 +2821,11 @@ void MainWindow::refreshGameList(bool invalidate_cache)
|
||||
m_game_list_widget->refresh(invalidate_cache);
|
||||
}
|
||||
|
||||
void MainWindow::refreshGameListModel()
|
||||
{
|
||||
m_game_list_widget->refreshModel();
|
||||
}
|
||||
|
||||
void MainWindow::cancelGameListRefresh()
|
||||
{
|
||||
m_game_list_widget->cancelRefresh();
|
||||
|
@ -107,6 +107,7 @@ public Q_SLOTS:
|
||||
void updateDebugMenuVisibility();
|
||||
|
||||
void refreshGameList(bool invalidate_cache);
|
||||
void refreshGameListModel();
|
||||
void cancelGameListRefresh();
|
||||
|
||||
void runOnUIThread(const std::function<void()>& func);
|
||||
|
@ -653,11 +653,7 @@ void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std
|
||||
if (FileSystem::FileExists(sif->GetFileName().c_str()))
|
||||
sif->Load();
|
||||
|
||||
const QString window_title(
|
||||
tr("%1 [%2]").arg(QString::fromStdString(dentry ? dentry->title : title)).arg(QString::fromStdString(real_serial)));
|
||||
|
||||
SettingsWindow* dialog = new SettingsWindow(path, real_serial, region, dentry, std::move(sif));
|
||||
dialog->setWindowTitle(window_title);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user