use single line titles in gamelist and recent games menu

This commit is contained in:
Megamouse 2017-09-07 08:52:47 +02:00 committed by Ani
parent 7c897d5019
commit 9a1ee9e984
3 changed files with 21 additions and 8 deletions

View File

@ -712,7 +712,7 @@ bool game_list_frame::Boot(const GameInfo& game)
} }
else else
{ {
Q_EMIT RequestAddRecentGame(q_string_pair(qstr(Emu.GetBoot()), qstr("[" + game.serial + "] " + game.name))); Q_EMIT RequestAddRecentGame(GUI::Recent_Game(qstr(Emu.GetBoot()), qstr("[" + game.serial + "] " + game.name)));
Refresh(true); Refresh(true);
return true; return true;
} }
@ -939,8 +939,7 @@ int game_list_frame::PopulateGameList()
auto l_GetItem = [](const std::string& text) auto l_GetItem = [](const std::string& text)
{ {
// force single line text ("hack" used instead of Qt shenanigans like Qt::TextSingleLine) // force single line text ("hack" used instead of Qt shenanigans like Qt::TextSingleLine)
QString formattedText = qstr(text); QString formattedText = GUI::get_Single_Line(qstr(text));
formattedText.replace("\n", " - ");
QTableWidgetItem* curr = new QTableWidgetItem; QTableWidgetItem* curr = new QTableWidgetItem;
curr->setFlags(curr->flags() & ~Qt::ItemIsEditable); curr->setFlags(curr->flags() & ~Qt::ItemIsEditable);
@ -1053,8 +1052,7 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co
if (category == category::hdd_Game || category == category::disc_Game) if (category == category::hdd_Game || category == category::disc_Game)
{ {
QString title = qstr(m_game_data[i].info.name); QString title = GUI::get_Single_Line(qstr(m_game_data[i].info.name));
title.replace("\n", " - ");
m_xgrid->addItem(m_game_data[i].pxmap, title, i, r, c); m_xgrid->addItem(m_game_data[i].pxmap, title, i, r, c);

View File

@ -63,6 +63,18 @@ namespace GUI
return dummy_color.palette().color(colorRole); return dummy_color.palette().color(colorRole);
}; };
inline QString get_Single_Line(const QString& multi_line_string)
{
QString single_line_string = multi_line_string;
single_line_string.replace("\n"," ");
return single_line_string;
}
inline q_string_pair Recent_Game(const QString& path, const QString& title)
{
return q_string_pair(path, get_Single_Line(title));
}
const QString Default = QObject::tr("default"); const QString Default = QObject::tr("default");
const QString main_window = "main_window"; const QString main_window = "main_window";
const QString game_list = "GameList"; const QString game_list = "GameList";

View File

@ -273,7 +273,7 @@ void main_window::BootElf()
LOG_SUCCESS(LOADER, "(S)ELF: boot done."); LOG_SUCCESS(LOADER, "(S)ELF: boot done.");
const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] "; const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] ";
AddRecentAction(q_string_pair(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle()))); AddRecentAction(GUI::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
gameListFrame->Refresh(true); gameListFrame->Refresh(true);
} }
} }
@ -310,7 +310,7 @@ void main_window::BootGame()
LOG_SUCCESS(LOADER, "Boot Game: boot done."); LOG_SUCCESS(LOADER, "Boot Game: boot done.");
const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] "; const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] ";
AddRecentAction(q_string_pair(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle()))); AddRecentAction(GUI::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
gameListFrame->Refresh(true); gameListFrame->Refresh(true);
} }
} }
@ -936,7 +936,7 @@ void main_window::BootRecentAction(const QAction* act)
else else
{ {
LOG_SUCCESS(LOADER, "Boot from Recent List: done"); LOG_SUCCESS(LOADER, "Boot from Recent List: done");
AddRecentAction(q_string_pair(qstr(Emu.GetBoot()), nam)); AddRecentAction(GUI::Recent_Game(qstr(Emu.GetBoot()), nam));
gameListFrame->Refresh(true); gameListFrame->Refresh(true);
} }
}; };
@ -1447,6 +1447,9 @@ void main_window::ConfigureGuiFromSettings(bool configureAll)
// Fill the recent games menu // Fill the recent games menu
for (int i = 0; i < m_rg_entries.count(); i++) for (int i = 0; i < m_rg_entries.count(); i++)
{ {
// adjust old unformatted entries (avoid duplication)
m_rg_entries[i] = GUI::Recent_Game(m_rg_entries[i].first, m_rg_entries[i].second);
// create new action // create new action
QAction* act = CreateRecentAction(m_rg_entries[i], i + 1); QAction* act = CreateRecentAction(m_rg_entries[i], i + 1);