Qt: some code cleanup in gui files

This commit is contained in:
Megamouse 2020-03-07 18:01:09 +01:00
parent 426643c44d
commit 934a2eb9fa
8 changed files with 511 additions and 509 deletions

View File

@ -41,71 +41,71 @@ LOG_CHANNEL(sys_log, "SYS");
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, std::shared_ptr<persistent_settings> persistent_settings, QWidget* parent)
game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget* parent)
: custom_dock_widget(tr("Game List"), parent)
, m_gui_settings(guiSettings)
, m_emu_settings(emuSettings)
, m_gui_settings(gui_settings)
, m_emu_settings(emu_settings)
, m_persistent_settings(persistent_settings)
{
m_Icon_Size = gui::gl_icon_size_min; // ensure a valid size
m_isListLayout = m_gui_settings->GetValue(gui::gl_listMode).toBool();
m_Margin_Factor = m_gui_settings->GetValue(gui::gl_marginFactor).toReal();
m_Text_Factor = m_gui_settings->GetValue(gui::gl_textFactor).toReal();
m_Icon_Color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>();
m_colSortOrder = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
m_sortColumn = m_gui_settings->GetValue(gui::gl_sortCol).toInt();
m_icon_size = gui::gl_icon_size_min; // ensure a valid size
m_is_list_layout = m_gui_settings->GetValue(gui::gl_listMode).toBool();
m_margin_factor = m_gui_settings->GetValue(gui::gl_marginFactor).toReal();
m_text_factor = m_gui_settings->GetValue(gui::gl_textFactor).toReal();
m_icon_color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>();
m_col_sort_order = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
m_sort_column = m_gui_settings->GetValue(gui::gl_sortCol).toInt();
m_hidden_list = gui::utils::list_to_set(m_gui_settings->GetValue(gui::gl_hidden_list).toStringList());
m_oldLayoutIsList = m_isListLayout;
m_old_layout_is_list = m_is_list_layout;
// Save factors for first setup
m_gui_settings->SetValue(gui::gl_iconColor, m_Icon_Color);
m_gui_settings->SetValue(gui::gl_marginFactor, m_Margin_Factor);
m_gui_settings->SetValue(gui::gl_textFactor, m_Text_Factor);
m_gui_settings->SetValue(gui::gl_iconColor, m_icon_color);
m_gui_settings->SetValue(gui::gl_marginFactor, m_margin_factor);
m_gui_settings->SetValue(gui::gl_textFactor, m_text_factor);
m_Game_Dock = new QMainWindow(this);
m_Game_Dock->setWindowFlags(Qt::Widget);
setWidget(m_Game_Dock);
m_game_dock = new QMainWindow(this);
m_game_dock->setWindowFlags(Qt::Widget);
setWidget(m_game_dock);
m_xgrid = new game_list_grid(QSize(), m_Icon_Color, m_Margin_Factor, m_Text_Factor, false);
m_game_grid = new game_list_grid(QSize(), m_icon_color, m_margin_factor, m_text_factor, false);
m_gameList = new game_list();
m_gameList->setShowGrid(false);
m_gameList->setItemDelegate(new table_item_delegate(this, true));
m_gameList->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_gameList->setSelectionBehavior(QAbstractItemView::SelectRows);
m_gameList->setSelectionMode(QAbstractItemView::SingleSelection);
m_gameList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_gameList->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
m_gameList->verticalScrollBar()->installEventFilter(this);
m_gameList->verticalScrollBar()->setSingleStep(20);
m_gameList->horizontalScrollBar()->setSingleStep(20);
m_gameList->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
m_gameList->verticalHeader()->setVisible(false);
m_gameList->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
m_gameList->horizontalHeader()->setHighlightSections(false);
m_gameList->horizontalHeader()->setSortIndicatorShown(true);
m_gameList->horizontalHeader()->setStretchLastSection(true);
m_gameList->horizontalHeader()->setDefaultSectionSize(150);
m_gameList->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
m_gameList->setContextMenuPolicy(Qt::CustomContextMenu);
m_gameList->setAlternatingRowColors(true);
m_gameList->installEventFilter(this);
m_gameList->setColumnCount(gui::column_count);
m_game_list = new game_list();
m_game_list->setShowGrid(false);
m_game_list->setItemDelegate(new table_item_delegate(this, true));
m_game_list->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_game_list->setSelectionBehavior(QAbstractItemView::SelectRows);
m_game_list->setSelectionMode(QAbstractItemView::SingleSelection);
m_game_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_game_list->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
m_game_list->verticalScrollBar()->installEventFilter(this);
m_game_list->verticalScrollBar()->setSingleStep(20);
m_game_list->horizontalScrollBar()->setSingleStep(20);
m_game_list->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
m_game_list->verticalHeader()->setVisible(false);
m_game_list->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
m_game_list->horizontalHeader()->setHighlightSections(false);
m_game_list->horizontalHeader()->setSortIndicatorShown(true);
m_game_list->horizontalHeader()->setStretchLastSection(true);
m_game_list->horizontalHeader()->setDefaultSectionSize(150);
m_game_list->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
m_game_list->setContextMenuPolicy(Qt::CustomContextMenu);
m_game_list->setAlternatingRowColors(true);
m_game_list->installEventFilter(this);
m_game_list->setColumnCount(gui::column_count);
m_game_compat = std::make_unique<game_compatibility>(m_gui_settings);
m_Central_Widget = new QStackedWidget(this);
m_Central_Widget->addWidget(m_gameList);
m_Central_Widget->addWidget(m_xgrid);
m_Central_Widget->setCurrentWidget(m_isListLayout ? m_gameList : m_xgrid);
m_central_widget = new QStackedWidget(this);
m_central_widget->addWidget(m_game_list);
m_central_widget->addWidget(m_game_grid);
m_central_widget->setCurrentWidget(m_is_list_layout ? m_game_list : m_game_grid);
m_Game_Dock->setCentralWidget(m_Central_Widget);
m_game_dock->setCentralWidget(m_central_widget);
// Actions regarding showing/hiding columns
auto AddColumn = [this](gui::game_list_columns col, const QString& header_text, const QString& action_text)
{
m_gameList->setHorizontalHeaderItem(col, new QTableWidgetItem(header_text));
m_game_list->setHorizontalHeaderItem(col, new QTableWidgetItem(header_text));
m_columnActs.append(new QAction(action_text, this));
};
@ -125,21 +125,21 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
AddColumn(gui::column_compat, tr("Compatibility"), tr("Show Compatibility"));
// Events
connect(m_gameList, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_gameList, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_gameList, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_game_list, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_game_list, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
connect(m_gameList->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked);
connect(m_gameList->horizontalHeader(), &QHeaderView::customContextMenuRequested, [this](const QPoint& pos)
connect(m_game_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked);
connect(m_game_list->horizontalHeader(), &QHeaderView::customContextMenuRequested, [this](const QPoint& pos)
{
QMenu* configure = new QMenu(this);
configure->addActions(m_columnActs);
configure->exec(m_gameList->horizontalHeader()->viewport()->mapToGlobal(pos));
configure->exec(m_game_list->horizontalHeader()->viewport()->mapToGlobal(pos));
});
connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_xgrid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_xgrid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
connect(m_game_grid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_game_grid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_game_grid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
connect(m_game_compat.get(), &game_compatibility::DownloadStarted, [this]()
{
@ -187,7 +187,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
return;
}
}
m_gameList->setColumnHidden(col, !checked); // Negate because it's a set col hidden and we have menu say show.
m_game_list->setColumnHidden(col, !checked); // Negate because it's a set col hidden and we have menu say show.
m_gui_settings->SetGamelistColVisibility(col, checked);
if (checked) // handle hidden columns that have zero width after showing them (stuck between others)
@ -200,15 +200,15 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
void game_list_frame::LoadSettings()
{
m_colSortOrder = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
m_sortColumn = m_gui_settings->GetValue(gui::gl_sortCol).toInt();
m_categoryFilters = m_gui_settings->GetGameListCategoryFilters();
m_drawCompatStatusToGrid = m_gui_settings->GetValue(gui::gl_draw_compat).toBool();
m_col_sort_order = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
m_sort_column = m_gui_settings->GetValue(gui::gl_sortCol).toInt();
m_category_filters = m_gui_settings->GetGameListCategoryFilters();
m_draw_compat_status_to_grid = m_gui_settings->GetValue(gui::gl_draw_compat).toBool();
Refresh(true);
QByteArray state = m_gui_settings->GetValue(gui::gl_state).toByteArray();
if (!m_gameList->horizontalHeader()->restoreState(state) && m_gameList->rowCount())
if (!m_game_list->horizontalHeader()->restoreState(state) && m_game_list->rowCount())
{
// If no settings exist, resize to contents.
ResizeColumnsToContents();
@ -218,13 +218,13 @@ void game_list_frame::LoadSettings()
{
bool vis = m_gui_settings->GetGamelistColVisibility(col);
m_columnActs[col]->setChecked(vis);
m_gameList->setColumnHidden(col, !vis);
m_game_list->setColumnHidden(col, !vis);
}
SortGameList();
FixNarrowColumns();
m_gameList->horizontalHeader()->restoreState(m_gameList->horizontalHeader()->saveState());
m_game_list->horizontalHeader()->restoreState(m_game_list->horizontalHeader()->saveState());
}
game_list_frame::~game_list_frame()
@ -239,38 +239,38 @@ void game_list_frame::FixNarrowColumns()
// handle columns (other than the icon column) that have zero width after showing them (stuck between others)
for (int col = 1; col < m_columnActs.count(); ++col)
{
if (m_gameList->isColumnHidden(col))
if (m_game_list->isColumnHidden(col))
{
continue;
}
if (m_gameList->columnWidth(col) <= m_gameList->horizontalHeader()->minimumSectionSize())
if (m_game_list->columnWidth(col) <= m_game_list->horizontalHeader()->minimumSectionSize())
{
m_gameList->setColumnWidth(col, m_gameList->horizontalHeader()->minimumSectionSize());
m_game_list->setColumnWidth(col, m_game_list->horizontalHeader()->minimumSectionSize());
}
}
}
void game_list_frame::ResizeColumnsToContents(int spacing)
{
if (!m_gameList)
if (!m_game_list)
{
return;
}
m_gameList->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
m_gameList->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
m_game_list->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
m_game_list->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
// Make non-icon columns slighty bigger for better visuals
for (int i = 1; i < m_gameList->columnCount(); i++)
for (int i = 1; i < m_game_list->columnCount(); i++)
{
if (m_gameList->isColumnHidden(i))
if (m_game_list->isColumnHidden(i))
{
continue;
}
int size = m_gameList->horizontalHeader()->sectionSize(i) + spacing;
m_gameList->horizontalHeader()->resizeSection(i, size);
const int size = m_game_list->horizontalHeader()->sectionSize(i) + spacing;
m_game_list->horizontalHeader()->resizeSection(i, size);
}
}
@ -278,17 +278,17 @@ void game_list_frame::OnColClicked(int col)
{
if (col == 0) return; // Don't "sort" icons.
if (col == m_sortColumn)
if (col == m_sort_column)
{
m_colSortOrder = (m_colSortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder;
m_col_sort_order = (m_col_sort_order == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder;
}
else
{
m_colSortOrder = Qt::AscendingOrder;
m_col_sort_order = Qt::AscendingOrder;
}
m_sortColumn = col;
m_sort_column = col;
m_gui_settings->SetValue(gui::gl_sortAsc, m_colSortOrder == Qt::AscendingOrder);
m_gui_settings->SetValue(gui::gl_sortAsc, m_col_sort_order == Qt::AscendingOrder);
m_gui_settings->SetValue(gui::gl_sortCol, col);
SortGameList();
@ -299,9 +299,9 @@ bool game_list_frame::IsEntryVisible(const game_info& game)
{
auto matches_category = [&]()
{
if (m_isListLayout)
if (m_is_list_layout)
{
return m_categoryFilters.contains(qstr(game->info.category));
return m_category_filters.contains(qstr(game->info.category));
}
const auto cat_boot = Localized().category.cat_boot;
@ -317,51 +317,51 @@ void game_list_frame::SortGameList()
{
// Back-up old header sizes to handle unwanted column resize in case of zero search results
QList<int> column_widths;
int old_row_count = m_gameList->rowCount();
int old_game_count = m_game_data.count();
const int old_row_count = m_game_list->rowCount();
const int old_game_count = m_game_data.count();
for (int i = 0; i < m_gameList->columnCount(); i++)
for (int i = 0; i < m_game_list->columnCount(); i++)
{
column_widths.append(m_gameList->columnWidth(i));
column_widths.append(m_game_list->columnWidth(i));
}
// Sorting resizes hidden columns, so unhide them as a workaround
QList<int> columns_to_hide;
for (int i = 0; i < m_gameList->columnCount(); i++)
for (int i = 0; i < m_game_list->columnCount(); i++)
{
if (m_gameList->isColumnHidden(i))
if (m_game_list->isColumnHidden(i))
{
m_gameList->setColumnHidden(i, false);
m_game_list->setColumnHidden(i, false);
columns_to_hide << i;
}
}
// Sort the list by column and sort order
m_gameList->sortByColumn(m_sortColumn, m_colSortOrder);
m_game_list->sortByColumn(m_sort_column, m_col_sort_order);
// Hide columns again
for (auto i : columns_to_hide)
{
m_gameList->setColumnHidden(i, true);
m_game_list->setColumnHidden(i, true);
}
// Don't resize the columns if no game is shown to preserve the header settings
if (!m_gameList->rowCount())
if (!m_game_list->rowCount())
{
for (int i = 0; i < m_gameList->columnCount(); i++)
for (int i = 0; i < m_game_list->columnCount(); i++)
{
m_gameList->setColumnWidth(i, column_widths[i]);
m_game_list->setColumnWidth(i, column_widths[i]);
}
m_gameList->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
m_game_list->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
return;
}
// Fixate vertical header and row height
m_gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height());
m_gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height());
m_gameList->resizeRowsToContents();
m_game_list->verticalHeader()->setMinimumSectionSize(m_icon_size.height());
m_game_list->verticalHeader()->setMaximumSectionSize(m_icon_size.height());
m_game_list->resizeRowsToContents();
// Resize columns if the game list was empty before
if (!old_row_count && !old_game_count)
@ -370,14 +370,14 @@ void game_list_frame::SortGameList()
}
else
{
m_gameList->resizeColumnToContents(gui::column_icon);
m_game_list->resizeColumnToContents(gui::column_icon);
}
// Fixate icon column
m_gameList->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
m_game_list->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
// Shorten the last section to remove horizontal scrollbar if possible
m_gameList->resizeColumnToContents(gui::column_count - 1);
m_game_list->resizeColumnToContents(gui::column_count - 1);
}
QString game_list_frame::GetLastPlayedBySerial(const QString& serial)
@ -469,9 +469,9 @@ std::string game_list_frame::GetDataDirBySerial(const std::string& serial)
return fs::get_config_dir() + "data/" + serial;
}
void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
{
if (fromDrive)
if (from_drive)
{
const Localized localized;
@ -788,38 +788,38 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
// Fill Game List / Game Grid
if (m_isListLayout)
if (m_is_list_layout)
{
const int scroll_position = m_gameList->verticalScrollBar()->value();
const int scroll_position = m_game_list->verticalScrollBar()->value();
PopulateGameList();
SortGameList();
if (scrollAfter)
if (scroll_after)
{
m_gameList->scrollTo(m_gameList->currentIndex(), QAbstractItemView::PositionAtCenter);
m_game_list->scrollTo(m_game_list->currentIndex(), QAbstractItemView::PositionAtCenter);
}
else
{
m_gameList->verticalScrollBar()->setValue(scroll_position);
m_game_list->verticalScrollBar()->setValue(scroll_position);
}
}
else
{
int games_per_row = 0;
if (m_Icon_Size.width() > 0 && m_Icon_Size.height() > 0)
if (m_icon_size.width() > 0 && m_icon_size.height() > 0)
{
games_per_row = width() / (m_Icon_Size.width() + m_Icon_Size.width() * m_xgrid->getMarginFactor() * 2);
games_per_row = width() / (m_icon_size.width() + m_icon_size.width() * m_game_grid->getMarginFactor() * 2);
}
const int scroll_position = m_xgrid->verticalScrollBar()->value();
PopulateGameGrid(games_per_row, m_Icon_Size, m_Icon_Color);
connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_xgrid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_xgrid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
m_Central_Widget->addWidget(m_xgrid);
m_Central_Widget->setCurrentWidget(m_xgrid);
m_xgrid->verticalScrollBar()->setValue(scroll_position);
const int scroll_position = m_game_grid->verticalScrollBar()->value();
PopulateGameGrid(games_per_row, m_icon_size, m_icon_color);
connect(m_game_grid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
connect(m_game_grid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot);
connect(m_game_grid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
m_central_widget->addWidget(m_game_grid);
m_central_widget->setCurrentWidget(m_game_grid);
m_game_grid->verticalScrollBar()->setValue(scroll_position);
}
}
@ -827,13 +827,13 @@ void game_list_frame::ToggleCategoryFilter(const QStringList& categories, bool s
{
if (show)
{
m_categoryFilters.append(categories);
m_category_filters.append(categories);
}
else
{
for (const auto& cat : categories)
{
m_categoryFilters.removeAll(cat);
m_category_filters.removeAll(cat);
}
}
@ -846,10 +846,10 @@ void game_list_frame::SaveSettings()
{
m_gui_settings->SetGamelistColVisibility(col, m_columnActs[col]->isChecked());
}
m_gui_settings->SetValue(gui::gl_sortCol, m_sortColumn);
m_gui_settings->SetValue(gui::gl_sortAsc, m_colSortOrder == Qt::AscendingOrder);
m_gui_settings->SetValue(gui::gl_sortCol, m_sort_column);
m_gui_settings->SetValue(gui::gl_sortAsc, m_col_sort_order == Qt::AscendingOrder);
m_gui_settings->SetValue(gui::gl_state, m_gameList->horizontalHeader()->saveState());
m_gui_settings->SetValue(gui::gl_state, m_game_list->horizontalHeader()->saveState());
}
static void open_dir(const std::string& spath)
@ -911,16 +911,16 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
QPoint globalPos;
QTableWidgetItem* item;
if (m_isListLayout)
if (m_is_list_layout)
{
item = m_gameList->item(m_gameList->indexAt(pos).row(), gui::column_icon);
globalPos = m_gameList->viewport()->mapToGlobal(pos);
item = m_game_list->item(m_game_list->indexAt(pos).row(), gui::column_icon);
globalPos = m_game_list->viewport()->mapToGlobal(pos);
}
else
{
QModelIndex mi = m_xgrid->indexAt(pos);
item = m_xgrid->item(mi.row(), mi.column());
globalPos = m_xgrid->viewport()->mapToGlobal(pos);
const QModelIndex mi = m_game_grid->indexAt(pos);
item = m_game_grid->item(mi.row(), mi.column());
globalPos = m_game_grid->viewport()->mapToGlobal(pos);
}
game_info gameinfo = GetGameInfoFromItem(item);
@ -1722,7 +1722,7 @@ QPixmap game_list_frame::PaintedPixmap(const QPixmap& icon, bool paint_config_ic
QPixmap canvas = QPixmap(original_size * device_pixel_ratio);
canvas.setDevicePixelRatio(device_pixel_ratio);
canvas.fill(m_Icon_Color);
canvas.fill(m_icon_color);
QPainter painter(&canvas);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
@ -1732,7 +1732,7 @@ QPixmap game_list_frame::PaintedPixmap(const QPixmap& icon, bool paint_config_ic
painter.drawPixmap(QPoint(0, 0), icon);
}
if (!m_isListLayout && (paint_config_icon || paint_pad_config_icon))
if (!m_is_list_layout && (paint_config_icon || paint_pad_config_icon))
{
const int width = original_size.width() * 0.2;
const QPoint origin = QPoint(original_size.width() - width, 0);
@ -1769,7 +1769,7 @@ QPixmap game_list_frame::PaintedPixmap(const QPixmap& icon, bool paint_config_ic
painter.end();
return canvas.scaled(m_Icon_Size * device_pixel_ratio, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
return canvas.scaled(m_icon_size * device_pixel_ratio, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
}
void game_list_frame::ShowCustomConfigIcon(game_info game)
@ -1795,25 +1795,25 @@ void game_list_frame::ShowCustomConfigIcon(game_info game)
RepaintIcons();
}
void game_list_frame::ResizeIcons(const int& sliderPos)
void game_list_frame::ResizeIcons(const int& slider_pos)
{
m_icon_size_index = sliderPos;
m_Icon_Size = gui_settings::SizeFromSlider(sliderPos);
m_icon_size_index = slider_pos;
m_icon_size = gui_settings::SizeFromSlider(slider_pos);
RepaintIcons();
}
void game_list_frame::RepaintIcons(const bool& fromSettings)
void game_list_frame::RepaintIcons(const bool& from_settings)
{
if (fromSettings)
if (from_settings)
{
if (m_gui_settings->GetValue(gui::m_enableUIColors).toBool())
{
m_Icon_Color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>();
m_icon_color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>();
}
else
{
m_Icon_Color = gui::utils::get_label_color("gamelist_icon_background_color");
m_icon_color = gui::utils::get_label_color("gamelist_icon_background_color");
}
}
@ -1831,16 +1831,16 @@ void game_list_frame::SetShowHidden(bool show)
m_show_hidden = show;
}
void game_list_frame::SetListMode(const bool& isList)
void game_list_frame::SetListMode(const bool& is_list)
{
m_oldLayoutIsList = m_isListLayout;
m_isListLayout = isList;
m_old_layout_is_list = m_is_list_layout;
m_is_list_layout = is_list;
m_gui_settings->SetValue(gui::gl_listMode, isList);
m_gui_settings->SetValue(gui::gl_listMode, is_list);
Refresh(true);
m_Central_Widget->setCurrentWidget(m_isListLayout ? m_gameList : m_xgrid);
m_central_widget->setCurrentWidget(m_is_list_layout ? m_game_list : m_game_grid);
}
void game_list_frame::SetSearchText(const QString& text)
@ -1857,9 +1857,9 @@ void game_list_frame::closeEvent(QCloseEvent *event)
void game_list_frame::resizeEvent(QResizeEvent *event)
{
if (!m_isListLayout)
if (!m_is_list_layout)
{
Refresh(false, m_xgrid->selectedItems().count());
Refresh(false, m_game_grid->selectedItems().count());
}
QDockWidget::resizeEvent(event);
}
@ -1867,7 +1867,7 @@ void game_list_frame::resizeEvent(QResizeEvent *event)
bool game_list_frame::eventFilter(QObject *object, QEvent *event)
{
// Zoom gamelist/gamegrid
if (event->type() == QEvent::Wheel && (object == m_gameList->verticalScrollBar() || object == m_xgrid->verticalScrollBar()))
if (event->type() == QEvent::Wheel && (object == m_game_list->verticalScrollBar() || object == m_game_grid->verticalScrollBar()))
{
QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event);
@ -1879,7 +1879,7 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event)
return true;
}
}
else if (event->type() == QEvent::KeyPress && (object == m_gameList || object == m_xgrid))
else if (event->type() == QEvent::KeyPress && (object == m_game_list || object == m_game_grid))
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
@ -1902,10 +1902,10 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event)
{
QTableWidgetItem* item;
if (object == m_gameList)
item = m_gameList->item(m_gameList->currentRow(), gui::column_icon);
if (object == m_game_list)
item = m_game_list->item(m_game_list->currentRow(), gui::column_icon);
else
item = m_xgrid->currentItem();
item = m_game_grid->currentItem();
if (!item || !item->isSelected())
return false;
@ -1927,16 +1927,16 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event)
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QTableWidgetItem* item;
if (m_isListLayout)
if (m_is_list_layout)
{
item = m_gameList->itemAt(helpEvent->globalPos());
item = m_game_list->itemAt(helpEvent->globalPos());
}
else
{
item = m_xgrid->itemAt(helpEvent->globalPos());
item = m_game_grid->itemAt(helpEvent->globalPos());
}
if (item && !item->toolTip().isEmpty() && (!m_isListLayout || item->column() == gui::column_name || item->column() == gui::column_serial))
if (item && !item->toolTip().isEmpty() && (!m_is_list_layout || item->column() == gui::column_name || item->column() == gui::column_serial))
{
QToolTip::showText(helpEvent->globalPos(), item->toolTip());
}
@ -1961,8 +1961,8 @@ void game_list_frame::PopulateGameList()
std::string selected_item = CurrentSelectionIconPath();
m_gameList->clearContents();
m_gameList->setRowCount(m_game_data.size());
m_game_list->clearContents();
m_game_list->setRowCount(m_game_data.size());
// Default locale. Uses current Qt application language.
const QLocale locale{};
@ -2061,20 +2061,20 @@ void game_list_frame::PopulateGameList()
}
}
m_gameList->setItem(row, gui::column_icon, icon_item);
m_gameList->setItem(row, gui::column_name, title_item);
m_gameList->setItem(row, gui::column_serial, serial_item);
m_gameList->setItem(row, gui::column_firmware, new custom_table_widget_item(game->info.fw));
m_gameList->setItem(row, gui::column_version, new custom_table_widget_item(app_version));
m_gameList->setItem(row, gui::column_category, new custom_table_widget_item(game->localized_category));
m_gameList->setItem(row, gui::column_path, new custom_table_widget_item(game->info.path));
m_gameList->setItem(row, gui::column_move, new custom_table_widget_item(sstr(supports_move ? tr("Supported") : tr("Not Supported")), Qt::UserRole, !supports_move));
m_gameList->setItem(row, gui::column_resolution, new custom_table_widget_item(GetStringFromU32(game->info.resolution, localized.resolution.mode, true)));
m_gameList->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, localized.sound.format, true)));
m_gameList->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, localized.parental.level), Qt::UserRole, game->info.parental_lvl));
m_gameList->setItem(row, gui::column_last_play, new custom_table_widget_item(locale.toString(last_played, gui::persistent::last_played_date_format_new), Qt::UserRole, last_played));
m_gameList->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms));
m_gameList->setItem(row, gui::column_compat, compat_item);
m_game_list->setItem(row, gui::column_icon, icon_item);
m_game_list->setItem(row, gui::column_name, title_item);
m_game_list->setItem(row, gui::column_serial, serial_item);
m_game_list->setItem(row, gui::column_firmware, new custom_table_widget_item(game->info.fw));
m_game_list->setItem(row, gui::column_version, new custom_table_widget_item(app_version));
m_game_list->setItem(row, gui::column_category, new custom_table_widget_item(game->localized_category));
m_game_list->setItem(row, gui::column_path, new custom_table_widget_item(game->info.path));
m_game_list->setItem(row, gui::column_move, new custom_table_widget_item(sstr(supports_move ? tr("Supported") : tr("Not Supported")), Qt::UserRole, !supports_move));
m_game_list->setItem(row, gui::column_resolution, new custom_table_widget_item(GetStringFromU32(game->info.resolution, localized.resolution.mode, true)));
m_game_list->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, localized.sound.format, true)));
m_game_list->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, localized.parental.level), Qt::UserRole, game->info.parental_lvl));
m_game_list->setItem(row, gui::column_last_play, new custom_table_widget_item(locale.toString(last_played, gui::persistent::last_played_date_format_new), Qt::UserRole, last_played));
m_game_list->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms));
m_game_list->setItem(row, gui::column_compat, compat_item);
if (selected_item == game->info.icon_path)
{
@ -2084,8 +2084,8 @@ void game_list_frame::PopulateGameList()
row++;
}
m_gameList->setRowCount(row);
m_gameList->selectRow(selected_row);
m_game_list->setRowCount(row);
m_game_list->selectRow(selected_row);
}
void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color)
@ -2095,17 +2095,17 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
const std::string selected_item = CurrentSelectionIconPath();
m_xgrid->deleteLater();
m_game_grid->deleteLater();
const bool showText = m_icon_size_index > gui::gl_max_slider_pos * 2 / 5;
if (m_icon_size_index < gui::gl_max_slider_pos * 2 / 3)
{
m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor * 2, showText);
m_game_grid = new game_list_grid(image_size, image_color, m_margin_factor, m_text_factor * 2, showText);
}
else
{
m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor, showText);
m_game_grid = new game_list_grid(image_size, image_color, m_margin_factor, m_text_factor, showText);
}
// Get list of matching apps
@ -2131,8 +2131,8 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
const int needsExtraRow = (entries % maxCols) != 0;
const int maxRows = needsExtraRow + entries / maxCols;
m_xgrid->setRowCount(maxRows);
m_xgrid->setColumnCount(maxCols);
m_game_grid->setRowCount(maxRows);
m_game_grid->setColumnCount(maxCols);
for (const auto& app : matching_apps)
{
@ -2140,21 +2140,21 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
const QString title = m_titles.value(serial, qstr(app->info.name));
const QString notes = m_notes.value(serial);
m_xgrid->addItem(app->pxmap, title, r, c);
m_xgrid->item(r, c)->setData(gui::game_role, QVariant::fromValue(app));
m_game_grid->addItem(app->pxmap, title, r, c);
m_game_grid->item(r, c)->setData(gui::game_role, QVariant::fromValue(app));
if (!notes.isEmpty())
{
m_xgrid->item(r, c)->setToolTip(tr("%0 [%1]\n\nNotes:\n%2").arg(title).arg(serial).arg(notes));
m_game_grid->item(r, c)->setToolTip(tr("%0 [%1]\n\nNotes:\n%2").arg(title).arg(serial).arg(notes));
}
else
{
m_xgrid->item(r, c)->setToolTip(tr("%0 [%1]").arg(title).arg(serial));
m_game_grid->item(r, c)->setToolTip(tr("%0 [%1]").arg(title).arg(serial));
}
if (selected_item == app->info.icon_path)
{
m_xgrid->setCurrentCell(r, c);
m_game_grid->setCurrentCell(r, c);
}
if (++c >= maxCols)
@ -2170,14 +2170,14 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
{
QTableWidgetItem* emptyItem = new QTableWidgetItem();
emptyItem->setFlags(Qt::NoItemFlags);
m_xgrid->setItem(r, col, emptyItem);
m_game_grid->setItem(r, col, emptyItem);
}
}
m_xgrid->resizeColumnsToContents();
m_xgrid->resizeRowsToContents();
m_xgrid->installEventFilter(this);
m_xgrid->verticalScrollBar()->installEventFilter(this);
m_game_grid->resizeColumnsToContents();
m_game_grid->resizeRowsToContents();
m_game_grid->installEventFilter(this);
m_game_grid->verticalScrollBar()->installEventFilter(this);
}
/**
@ -2199,18 +2199,18 @@ std::string game_list_frame::CurrentSelectionIconPath()
QTableWidgetItem* item = nullptr;
if (m_oldLayoutIsList)
if (m_old_layout_is_list)
{
if (!m_gameList->selectedItems().isEmpty())
if (!m_game_list->selectedItems().isEmpty())
{
item = m_gameList->item(m_gameList->currentRow(), 0);
item = m_game_list->item(m_game_list->currentRow(), 0);
}
}
else
{
if (!m_xgrid->selectedItems().isEmpty())
if (!m_game_grid->selectedItems().isEmpty())
{
item = m_xgrid->currentItem();
item = m_game_grid->currentItem();
}
}
@ -2228,7 +2228,7 @@ std::string game_list_frame::CurrentSelectionIconPath()
}
}
m_oldLayoutIsList = m_isListLayout;
m_old_layout_is_list = m_is_list_layout;
return selection;
}
@ -2270,9 +2270,9 @@ game_info game_list_frame::GetGameInfoByMode(const QTableWidgetItem* item)
return nullptr;
}
if (m_isListLayout)
if (m_is_list_layout)
{
return GetGameInfoFromItem(m_gameList->item(item->row(), gui::column_icon));
return GetGameInfoFromItem(m_game_list->item(item->row(), gui::column_icon));
}
return GetGameInfoFromItem(item);
@ -2285,7 +2285,7 @@ game_info game_list_frame::GetGameInfoFromItem(const QTableWidgetItem* item)
return nullptr;
}
QVariant var = item->data(gui::game_role);
const QVariant var = item->data(gui::game_role);
if (!var.canConvert<game_info>())
{
return nullptr;
@ -2296,7 +2296,7 @@ game_info game_list_frame::GetGameInfoFromItem(const QTableWidgetItem* item)
QColor game_list_frame::getGridCompatibilityColor(const QString& string)
{
if (m_drawCompatStatusToGrid && !m_isListLayout)
if (m_draw_compat_status_to_grid && !m_is_list_layout)
{
return QColor(string);
}
@ -2305,7 +2305,7 @@ QColor game_list_frame::getGridCompatibilityColor(const QString& string)
void game_list_frame::SetShowCompatibilityInGrid(bool show)
{
m_drawCompatStatusToGrid = show;
m_draw_compat_status_to_grid = show;
RepaintIcons();
m_gui_settings->SetValue(gui::gl_draw_compat, show);
}

View File

@ -39,7 +39,7 @@ class game_list_frame : public custom_dock_widget
Q_OBJECT
public:
explicit game_list_frame(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = nullptr);
explicit game_list_frame(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = nullptr);
~game_list_frame();
/** Fix columns with width smaller than the minimal section size */
@ -49,7 +49,7 @@ public:
void ResizeColumnsToContents(int spacing = 20);
/** Refresh the gamelist with/without loading game data from files. Public so that main frame can refresh after vfs or install */
void Refresh(const bool fromDrive = false, const bool scrollAfter = true);
void Refresh(const bool from_drive = false, const bool scroll_after = true);
/** Adds/removes categories that should be shown on gamelist. Public so that main frame menu actions can apply them */
void ToggleCategoryFilter(const QStringList& categories, bool show);
@ -61,10 +61,10 @@ public:
void SaveSettings();
/** Resize Gamelist Icons to size given by slider position */
void ResizeIcons(const int& sliderPos);
void ResizeIcons(const int& slider_pos);
/** Repaint Gamelist Icons with new background color */
void RepaintIcons(const bool& fromSettings = false);
void RepaintIcons(const bool& from_settings = false);
void SetShowHidden(bool show);
@ -75,7 +75,7 @@ public Q_SLOTS:
void BatchRemoveCustomConfigurations();
void BatchRemoveCustomPadConfigurations();
void BatchRemoveShaderCaches();
void SetListMode(const bool& isList);
void SetListMode(const bool& is_list);
void SetSearchText(const QString& text);
void SetShowCompatibilityInGrid(bool show);
@ -123,27 +123,27 @@ private:
game_info GetGameInfoFromItem(const QTableWidgetItem* item);
// Which widget we are displaying depends on if we are in grid or list mode.
QMainWindow* m_Game_Dock;
QStackedWidget* m_Central_Widget;
QMainWindow* m_game_dock;
QStackedWidget* m_central_widget;
// Game Grid
game_list_grid* m_xgrid;
game_list_grid* m_game_grid;
// Game List
game_list* m_gameList;
game_list* m_game_list;
std::unique_ptr<game_compatibility> m_game_compat;
QList<QAction*> m_columnActs;
Qt::SortOrder m_colSortOrder;
int m_sortColumn;
Qt::SortOrder m_col_sort_order;
int m_sort_column;
QMap<QString, QString> m_notes;
QMap<QString, QString> m_titles;
// Categories
QStringList m_categoryFilters;
QStringList m_category_filters;
// List Mode
bool m_isListLayout = true;
bool m_oldLayoutIsList = true;
bool m_is_list_layout = true;
bool m_old_layout_is_list = true;
// Data
std::shared_ptr<gui_settings> m_gui_settings;
@ -160,9 +160,9 @@ private:
int m_icon_size_index = 0;
// Icons
QColor m_Icon_Color;
QSize m_Icon_Size;
qreal m_Margin_Factor;
qreal m_Text_Factor;
bool m_drawCompatStatusToGrid = false;
QColor m_icon_color;
QSize m_icon_size;
qreal m_margin_factor;
qreal m_text_factor;
bool m_draw_compat_status_to_grid = false;
};

View File

@ -41,24 +41,24 @@ QString gui_settings::GetCurrentUser()
return QString();
}
bool gui_settings::ChangeToConfig(const QString& friendly_name)
bool gui_settings::ChangeToConfig(const QString& config_name)
{
if (m_current_name == friendly_name)
if (m_current_name == config_name)
{
return false;
}
if (friendly_name != gui::Settings)
if (config_name != gui::Settings)
{
if (m_current_name == gui::Settings)
{
SetValue(gui::m_currentConfig, friendly_name);
SetValue(gui::m_currentConfig, config_name);
}
else
{
QSettings tmp(m_settings_dir.absoluteFilePath(gui::Settings + ".ini"), QSettings::Format::IniFormat, parent());
tmp.beginGroup(gui::m_currentConfig.key);
tmp.setValue(gui::m_currentConfig.name, friendly_name);
tmp.setValue(gui::m_currentConfig.name, config_name);
tmp.endGroup();
}
}
@ -67,25 +67,25 @@ bool gui_settings::ChangeToConfig(const QString& friendly_name)
Reset(true);
QSettings other(m_settings_dir.absoluteFilePath(friendly_name + ".ini"), QSettings::IniFormat);
const QSettings other(m_settings_dir.absoluteFilePath(config_name + ".ini"), QSettings::IniFormat);
for (const QString& key : other.allKeys())
{
m_settings->setValue(key, other.value(key));
}
SetValue(gui::m_currentConfig, friendly_name);
SetValue(gui::m_currentConfig, config_name);
m_settings->sync();
m_current_name = friendly_name;
m_current_name = config_name;
return true;
}
void gui_settings::Reset(bool removeMeta)
void gui_settings::Reset(bool remove_meta)
{
if (removeMeta)
if (remove_meta)
{
m_settings->clear();
}
@ -277,10 +277,11 @@ QColor gui_settings::GetCustomColor(int col)
QStringList gui_settings::GetConfigEntries()
{
QStringList nameFilter;
nameFilter << "*.ini";
QFileInfoList entries = m_settings_dir.entryInfoList(nameFilter, QDir::Files);
const QStringList name_filter = QStringList("*.ini");
const QFileInfoList entries = m_settings_dir.entryInfoList(name_filter, QDir::Files);
QStringList res;
for (const QFileInfo &entry : entries)
{
res.append(entry.baseName());
@ -306,8 +307,8 @@ void gui_settings::BackupSettingsToTarget(const QString& friendly_name)
QStringList gui_settings::GetStylesheetEntries()
{
QStringList nameFilter = QStringList("*.qss");
QStringList res = gui::utils::get_dir_entries(m_settings_dir, nameFilter);
const QStringList name_filter = QStringList("*.qss");
QStringList res = gui::utils::get_dir_entries(m_settings_dir, name_filter);
#if !defined(_WIN32)
// Makes stylesheets load if using AppImage (App Bundle) or installed to /usr/bin
#ifdef __APPLE__
@ -326,7 +327,7 @@ QString gui_settings::GetCurrentStylesheetPath()
{
const Localized localized;
QString stylesheet = GetValue(gui::m_currentStylesheet).toString();
const QString stylesheet = GetValue(gui::m_currentStylesheet).toString();
if (stylesheet == gui::Default)
{
@ -348,6 +349,6 @@ QSize gui_settings::SizeFromSlider(int pos)
gui_save gui_settings::GetGuiSaveForColumn(int col)
{
// hide sound format, parental level, firmware version and path by default
bool show = col != gui::column_sound && col != gui::column_parental && col != gui::column_firmware && col != gui::column_path;
const bool show = col != gui::column_sound && col != gui::column_parental && col != gui::column_firmware && col != gui::column_path;
return gui_save{ gui::game_list, "visibility_" + gui::get_game_list_column_name(static_cast<gui::game_list_columns>(col)), show };
}

View File

@ -233,7 +233,7 @@ public:
QString GetCurrentUser();
/** Changes the settings file to the destination preset*/
bool ChangeToConfig(const QString& friendly_name);
bool ChangeToConfig(const QString& config_name);
bool GetCategoryVisibility(int cat);
@ -249,7 +249,7 @@ public:
QStringList GetGameListCategoryFilters();
public Q_SLOTS:
void Reset(bool removeMeta = false);
void Reset(bool remove_meta = false);
/** Sets the visibility of the chosen category. */
void SetCategoryVisibility(int cat, const bool& val);

View File

@ -49,11 +49,11 @@ LOG_CHANNEL(gui_log, "GUI");
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
main_window::main_window(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent)
main_window::main_window(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::main_window)
, guiSettings(guiSettings)
, emuSettings(emuSettings)
, m_gui_settings(gui_settings)
, m_emu_settings(emu_settings)
, m_persistent_settings(persistent_settings)
{
Q_INIT_RESOURCE(resources);
@ -87,7 +87,7 @@ void main_window::Init()
setMinimumSize(350, minimumSizeHint().height()); // seems fine on win 10
setWindowTitle(QString::fromStdString("RPCS3 " + rpcs3::get_version().to_string()));
Q_EMIT RequestGlobalStylesheetChange(guiSettings->GetCurrentStylesheetPath());
Q_EMIT RequestGlobalStylesheetChange(m_gui_settings->GetCurrentStylesheetPath());
ConfigureGuiFromSettings(true);
#ifdef BRANCH
@ -126,9 +126,9 @@ void main_window::Init()
show(); // needs to be done before creating the thumbnail toolbar
// enable play options if a recent game exists
const bool enable_play_last = !m_recentGameActs.isEmpty() && m_recentGameActs.first();
const bool enable_play_last = !m_recent_game_acts.isEmpty() && m_recent_game_acts.first();
const QString start_toolip = enable_play_last ? tr("Play %0").arg(m_recentGameActs.first()->text()) : tr("Play");
const QString start_toolip = enable_play_last ? tr("Play %0").arg(m_recent_game_acts.first()->text()) : tr("Play");
if (enable_play_last)
{
@ -171,10 +171,10 @@ void main_window::Init()
#endif
// Fix possible hidden game list columns. The game list has to be visible already. Use this after show()
m_gameListFrame->FixNarrowColumns();
m_game_list_frame->FixNarrowColumns();
#if defined(_WIN32) || defined(__linux__)
if (guiSettings->GetValue(gui::m_check_upd_start).toBool())
if (m_gui_settings->GetValue(gui::m_check_upd_start).toBool())
{
m_updater.check_for_updates(true, this);
}
@ -194,7 +194,7 @@ QString main_window::GetCurrentTitle()
// returns appIcon
QIcon main_window::GetAppIcon()
{
return m_appIcon;
return m_app_icon;
}
void main_window::ResizeIcons(int index)
@ -208,13 +208,13 @@ void main_window::ResizeIcons(int index)
if (m_save_slider_pos)
{
m_save_slider_pos = false;
guiSettings->SetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid, index);
m_gui_settings->SetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid, index);
// this will also fire when we used the actions, but i didn't want to add another boolean member
SetIconSizeActions(index);
}
m_gameListFrame->ResizeIcons(index);
m_game_list_frame->ResizeIcons(index);
}
void main_window::OnPlayOrPause()
@ -245,9 +245,9 @@ void main_window::OnPlayOrPause()
show_boot_error(error);
}
}
else if (!m_recentGameActs.isEmpty())
else if (!m_recent_game_acts.isEmpty())
{
BootRecentAction(m_recentGameActs.first());
BootRecentAction(m_recent_game_acts.first());
}
}
}
@ -303,7 +303,7 @@ void main_window::Boot(const std::string& path, const std::string& title_id, boo
if (!Emu.IsStopped())
{
int result = QMessageBox::Yes;
guiSettings->ShowConfirmationBox(tr("Close Running Game?"),
m_gui_settings->ShowConfirmationBox(tr("Close Running Game?"),
tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n"),
gui::ib_confirm_boot, &result, this);
@ -313,7 +313,7 @@ void main_window::Boot(const std::string& path, const std::string& title_id, boo
}
}
m_appIcon = gui::utils::get_app_icon_from_path(path, title_id);
m_app_icon = gui::utils::get_app_icon_from_path(path, title_id);
Emu.SetForceBoot(true);
Emu.Stop();
@ -332,7 +332,7 @@ void main_window::Boot(const std::string& path, const std::string& title_id, boo
}
}
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
}
void main_window::BootElf()
@ -345,7 +345,7 @@ void main_window::BootElf()
stopped = true;
}
QString path_last_ELF = guiSettings->GetValue(gui::fd_boot_elf).toString();
QString path_last_ELF = m_gui_settings->GetValue(gui::fd_boot_elf).toString();
QString filePath = QFileDialog::getOpenFileName(this, tr("Select (S)ELF To Boot"), path_last_ELF, tr(
"(S)ELF files (*BOOT.BIN *.elf *.self);;"
"ELF files (BOOT.BIN *.elf);;"
@ -364,7 +364,7 @@ void main_window::BootElf()
// If we resolved the filepath earlier we would end up setting the last opened dir to the unwanted
// game folder in case of having e.g. a Game Folder with collected links to elf files.
// Don't set last path earlier in case of cancelled dialog
guiSettings->SetValue(gui::fd_boot_elf, filePath);
m_gui_settings->SetValue(gui::fd_boot_elf, filePath);
const std::string path = sstr(QFileInfo(filePath).absoluteFilePath());
gui_log.notice("Booting from BootElf...");
@ -381,20 +381,19 @@ void main_window::BootGame()
stopped = true;
}
QString path_last_Game = guiSettings->GetValue(gui::fd_boot_game).toString();
QString dirPath = QFileDialog::getExistingDirectory(this, tr("Select Game Folder"), path_last_Game, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
const QString path_last_Game = m_gui_settings->GetValue(gui::fd_boot_game).toString();
const QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Game Folder"), path_last_Game, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dirPath == NULL)
if (dir_path.isEmpty())
{
if (stopped) Emu.Resume();
return;
}
guiSettings->SetValue(gui::fd_boot_game, QFileInfo(dirPath).path());
const std::string path = sstr(dirPath);
m_gui_settings->SetValue(gui::fd_boot_game, QFileInfo(dir_path).path());
gui_log.notice("Booting from BootGame...");
Boot(path);
Boot(sstr(dir_path));
}
void main_window::BootRsxCapture(std::string path)
@ -439,8 +438,8 @@ void main_window::InstallPackages(QStringList file_paths, bool show_confirm)
{
if (file_paths.isEmpty())
{
QString path_last_PKG = guiSettings->GetValue(gui::fd_install_pkg).toString();
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select PKG To Install"), path_last_PKG, tr("PKG files (*.pkg);;All files (*.*)"));
const QString path_last_pkg = m_gui_settings->GetValue(gui::fd_install_pkg).toString();
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select PKG To Install"), path_last_pkg, tr("PKG files (*.pkg);;All files (*.*)"));
if (!file_path.isEmpty())
{
@ -498,7 +497,7 @@ void main_window::HandlePackageInstallation(QStringList file_paths)
const std::string path = sstr(file_path);
const std::string file_name = sstr(file_info.fileName());
guiSettings->SetValue(gui::fd_install_pkg, file_info.path());
m_gui_settings->SetValue(gui::fd_install_pkg, file_info.path());
// Run PKG unpacking asynchronously
named_thread worker("PKG Installer", [path, &progress]
@ -536,12 +535,12 @@ void main_window::HandlePackageInstallation(QStringList file_paths)
if (worker())
{
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
gui_log.success("Successfully installed %s.", file_name);
if (i == (count - 1))
{
guiSettings->ShowInfoBox(tr("Success!"), tr("Successfully installed software from package(s)!"), gui::ib_pkg_success, this);
m_gui_settings->ShowInfoBox(tr("Success!"), tr("Successfully installed software from package(s)!"), gui::ib_pkg_success, this);
}
}
else
@ -566,8 +565,8 @@ void main_window::InstallPup(QString file_path)
{
if (file_path.isEmpty())
{
QString path_last_PUP = guiSettings->GetValue(gui::fd_install_pup).toString();
file_path = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To Install"), path_last_PUP, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)"));
const QString path_last_pup = m_gui_settings->GetValue(gui::fd_install_pup).toString();
file_path = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To Install"), path_last_pup, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)"));
}
else
{
@ -599,7 +598,7 @@ void main_window::HandlePupInstallation(QString file_path)
Emu.SetForceBoot(true);
Emu.Stop();
guiSettings->SetValue(gui::fd_install_pup, QFileInfo(file_path).path());
m_gui_settings->SetValue(gui::fd_install_pup, QFileInfo(file_path).path());
const std::string path = sstr(file_path);
fs::file pup_f(path);
@ -734,7 +733,7 @@ void main_window::HandlePupInstallation(QString file_path)
if (progress > 0)
{
gui_log.success("Successfully installed PS3 firmware version %s.", version_string);
guiSettings->ShowInfoBox(tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), gui::ib_pup_success, this);
m_gui_settings->ShowInfoBox(tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), gui::ib_pup_success, this);
Emu.SetForceBoot(true);
Emu.BootGame(g_cfg.vfs.get_dev_flash() + "sys/external/", "", true);
@ -746,8 +745,8 @@ extern void sysutil_send_system_cmd(u64 status, u64 param);
void main_window::DecryptSPRXLibraries()
{
QString path_last_SPRX = guiSettings->GetValue(gui::fd_decrypt_sprx).toString();
QStringList modules = QFileDialog::getOpenFileNames(this, tr("Select binary files"), path_last_SPRX, tr("All Binaries (*.BIN *.self *.sprx);;BIN files (*.BIN);;SELF files (*.self);;SPRX files (*.sprx);;All files (*.*)"));
const QString path_last_sprx = m_gui_settings->GetValue(gui::fd_decrypt_sprx).toString();
const QStringList modules = QFileDialog::getOpenFileNames(this, tr("Select binary files"), path_last_sprx, tr("All Binaries (*.BIN *.self *.sprx);;BIN files (*.BIN);;SELF files (*.self);;SPRX files (*.sprx);;All files (*.*)"));
if (modules.isEmpty())
{
@ -757,7 +756,7 @@ void main_window::DecryptSPRXLibraries()
Emu.SetForceBoot(true);
Emu.Stop();
guiSettings->SetValue(gui::fd_decrypt_sprx, QFileInfo(modules.first()).path());
m_gui_settings->SetValue(gui::fd_decrypt_sprx, QFileInfo(modules.first()).path());
gui_log.notice("Decrypting binaries...");
@ -802,14 +801,14 @@ void main_window::DecryptSPRXLibraries()
void main_window::SaveWindowState()
{
// Save gui settings
guiSettings->SetValue(gui::mw_geometry, saveGeometry());
guiSettings->SetValue(gui::mw_windowState, saveState());
guiSettings->SetValue(gui::mw_mwState, m_mw->saveState());
m_gui_settings->SetValue(gui::mw_geometry, saveGeometry());
m_gui_settings->SetValue(gui::mw_windowState, saveState());
m_gui_settings->SetValue(gui::mw_mwState, m_mw->saveState());
// Save column settings
m_gameListFrame->SaveSettings();
m_game_list_frame->SaveSettings();
// Save splitter state
m_debuggerFrame->SaveSettings();
m_debugger_frame->SaveSettings();
}
void main_window::RepaintThumbnailIcons()
@ -917,7 +916,7 @@ void main_window::OnEmuRun(bool /*start_playtime*/)
const QString pause_tooltip = tr("Pause %0").arg(title);
const QString stop_tooltip = tr("Stop %0").arg(title);
m_debuggerFrame->EnableButtons(true);
m_debugger_frame->EnableButtons(true);
#ifdef _WIN32
m_thumb_stop->setToolTip(stop_tooltip);
@ -972,9 +971,9 @@ void main_window::OnEmuPause()
ui->toolbar_start->setToolTip(resume_tooltip);
// Refresh game list in order to update time played
if (m_gameListFrame)
if (m_game_list_frame)
{
m_gameListFrame->Refresh();
m_game_list_frame->Refresh();
}
}
@ -984,8 +983,8 @@ void main_window::OnEmuStop()
const QString play_tooltip = Emu.IsReady() ? tr("Play %0").arg(title) : tr("Resume %0").arg(title);
const QString restart_tooltip = tr("Restart %0").arg(title);
m_debuggerFrame->EnableButtons(false);
m_debuggerFrame->ClearBreakpoints();
m_debugger_frame->EnableButtons(false);
m_debugger_frame->ClearBreakpoints();
ui->sysPauseAct->setText(Emu.IsReady() ? tr("&Play\tCtrl+E") : tr("&Resume\tCtrl+E"));
ui->sysPauseAct->setIcon(m_icon_play);
@ -1017,9 +1016,9 @@ void main_window::OnEmuStop()
ui->actionManage_Users->setEnabled(true);
// Refresh game list in order to update time played
if (m_gameListFrame)
if (m_game_list_frame)
{
m_gameListFrame->Refresh();
m_game_list_frame->Refresh();
}
}
@ -1028,7 +1027,7 @@ void main_window::OnEmuReady()
const QString title = GetCurrentTitle();
const QString play_tooltip = Emu.IsReady() ? tr("Play %0").arg(title) : tr("Resume %0").arg(title);
m_debuggerFrame->EnableButtons(true);
m_debugger_frame->EnableButtons(true);
#ifdef _WIN32
m_thumb_playPause->setToolTip(play_tooltip);
m_thumb_playPause->setIcon(m_icon_thumb_play);
@ -1103,25 +1102,25 @@ void main_window::BootRecentAction(const QAction* act)
if (containsPath)
{
// clear menu of actions
for (auto act : m_recentGameActs)
for (auto act : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(act);
}
// remove action from list
m_rg_entries.removeAt(idx);
m_recentGameActs.removeAt(idx);
m_recent_game_acts.removeAt(idx);
guiSettings->SetValue(gui::rg_entries, guiSettings->List2Var(m_rg_entries));
m_gui_settings->SetValue(gui::rg_entries, m_gui_settings->List2Var(m_rg_entries));
gui_log.error("Recent Game not valid, removed from Boot Recent list: %s", path);
// refill menu with actions
for (int i = 0; i < m_recentGameActs.count(); i++)
for (int i = 0; i < m_recent_game_acts.count(); i++)
{
m_recentGameActs[i]->setShortcut(tr("Ctrl+%1").arg(i + 1));
m_recentGameActs[i]->setToolTip(m_rg_entries.at(i).second);
ui->bootRecentMenu->addAction(m_recentGameActs[i]);
m_recent_game_acts[i]->setShortcut(tr("Ctrl+%1").arg(i + 1));
m_recent_game_acts[i]->setToolTip(m_rg_entries.at(i).second);
ui->bootRecentMenu->addAction(m_recent_game_acts[i]);
}
gui_log.warning("Boot Recent list refreshed");
@ -1148,7 +1147,7 @@ QAction* main_window::CreateRecentAction(const q_string_pair& entry, const uint&
int idx = m_rg_entries.indexOf(entry);
m_rg_entries.removeAt(idx);
guiSettings->SetValue(gui::rg_entries, guiSettings->List2Var(m_rg_entries));
m_gui_settings->SetValue(gui::rg_entries, m_gui_settings->List2Var(m_rg_entries));
}
return nullptr;
}
@ -1194,7 +1193,7 @@ void main_window::AddRecentAction(const q_string_pair& entry)
}
// clear menu of actions
for (auto act : m_recentGameActs)
for (auto act : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(act);
}
@ -1205,7 +1204,7 @@ void main_window::AddRecentAction(const q_string_pair& entry)
if (m_rg_entries[i].first == entry.first)
{
m_rg_entries.removeAt(i);
m_recentGameActs.removeAt(i);
m_recent_game_acts.removeAt(i);
}
}
@ -1213,7 +1212,7 @@ void main_window::AddRecentAction(const q_string_pair& entry)
if (m_rg_entries.count() == 9)
{
m_rg_entries.removeLast();
m_recentGameActs.removeLast();
m_recent_game_acts.removeLast();
}
else if (m_rg_entries.count() > 9)
{
@ -1224,18 +1223,18 @@ void main_window::AddRecentAction(const q_string_pair& entry)
{
// add new action at the beginning
m_rg_entries.prepend(entry);
m_recentGameActs.prepend(act);
m_recent_game_acts.prepend(act);
}
// refill menu with actions
for (int i = 0; i < m_recentGameActs.count(); i++)
for (int i = 0; i < m_recent_game_acts.count(); i++)
{
m_recentGameActs[i]->setShortcut(tr("Ctrl+%1").arg(i+1));
m_recentGameActs[i]->setToolTip(m_rg_entries.at(i).second);
ui->bootRecentMenu->addAction(m_recentGameActs[i]);
m_recent_game_acts[i]->setShortcut(tr("Ctrl+%1").arg(i+1));
m_recent_game_acts[i]->setToolTip(m_rg_entries.at(i).second);
ui->bootRecentMenu->addAction(m_recent_game_acts[i]);
}
guiSettings->SetValue(gui::rg_entries, guiSettings->List2Var(m_rg_entries));
m_gui_settings->SetValue(gui::rg_entries, m_gui_settings->List2Var(m_rg_entries));
}
void main_window::UpdateLanguageActions(const QStringList& language_codes, const QString& language_code)
@ -1266,19 +1265,19 @@ void main_window::UpdateLanguageActions(const QStringList& language_codes, const
void main_window::RepaintGui()
{
if (m_gameListFrame)
if (m_game_list_frame)
{
m_gameListFrame->RepaintIcons(true);
m_game_list_frame->RepaintIcons(true);
}
if (m_logFrame)
if (m_log_frame)
{
m_logFrame->RepaintTextColors();
m_log_frame->RepaintTextColors();
}
if (m_debuggerFrame)
if (m_debugger_frame)
{
m_debuggerFrame->ChangeColors();
m_debugger_frame->ChangeColors();
}
RepaintToolBarIcons();
@ -1293,17 +1292,17 @@ void main_window::RetranslateUI(const QStringList& language_codes, const QString
ui->retranslateUi(this);
if (m_gameListFrame)
if (m_game_list_frame)
{
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
}
}
void main_window::ShowTitleBars(bool show)
{
m_gameListFrame->SetTitleBarVisible(show);
m_debuggerFrame->SetTitleBarVisible(show);
m_logFrame->SetTitleBarVisible(show);
m_game_list_frame->SetTitleBarVisible(show);
m_debugger_frame->SetTitleBarVisible(show);
m_log_frame->SetTitleBarVisible(show);
}
void main_window::CreateActions()
@ -1313,28 +1312,28 @@ void main_window::CreateActions()
ui->toolbar_start->setEnabled(false);
ui->toolbar_stop->setEnabled(false);
m_categoryVisibleActGroup = new QActionGroup(this);
m_categoryVisibleActGroup->addAction(ui->showCatHDDGameAct);
m_categoryVisibleActGroup->addAction(ui->showCatDiscGameAct);
m_categoryVisibleActGroup->addAction(ui->showCatPS1GamesAct);
m_categoryVisibleActGroup->addAction(ui->showCatPS2GamesAct);
m_categoryVisibleActGroup->addAction(ui->showCatPSPGamesAct);
m_categoryVisibleActGroup->addAction(ui->showCatHomeAct);
m_categoryVisibleActGroup->addAction(ui->showCatAudioVideoAct);
m_categoryVisibleActGroup->addAction(ui->showCatGameDataAct);
m_categoryVisibleActGroup->addAction(ui->showCatUnknownAct);
m_categoryVisibleActGroup->addAction(ui->showCatOtherAct);
m_categoryVisibleActGroup->setExclusive(false);
m_category_visible_act_group = new QActionGroup(this);
m_category_visible_act_group->addAction(ui->showCatHDDGameAct);
m_category_visible_act_group->addAction(ui->showCatDiscGameAct);
m_category_visible_act_group->addAction(ui->showCatPS1GamesAct);
m_category_visible_act_group->addAction(ui->showCatPS2GamesAct);
m_category_visible_act_group->addAction(ui->showCatPSPGamesAct);
m_category_visible_act_group->addAction(ui->showCatHomeAct);
m_category_visible_act_group->addAction(ui->showCatAudioVideoAct);
m_category_visible_act_group->addAction(ui->showCatGameDataAct);
m_category_visible_act_group->addAction(ui->showCatUnknownAct);
m_category_visible_act_group->addAction(ui->showCatOtherAct);
m_category_visible_act_group->setExclusive(false);
m_iconSizeActGroup = new QActionGroup(this);
m_iconSizeActGroup->addAction(ui->setIconSizeTinyAct);
m_iconSizeActGroup->addAction(ui->setIconSizeSmallAct);
m_iconSizeActGroup->addAction(ui->setIconSizeMediumAct);
m_iconSizeActGroup->addAction(ui->setIconSizeLargeAct);
m_icon_size_act_group = new QActionGroup(this);
m_icon_size_act_group->addAction(ui->setIconSizeTinyAct);
m_icon_size_act_group->addAction(ui->setIconSizeSmallAct);
m_icon_size_act_group->addAction(ui->setIconSizeMediumAct);
m_icon_size_act_group->addAction(ui->setIconSizeLargeAct);
m_listModeActGroup = new QActionGroup(this);
m_listModeActGroup->addAction(ui->setlistModeListAct);
m_listModeActGroup->addAction(ui->setlistModeGridAct);
m_list_mode_act_group = new QActionGroup(this);
m_list_mode_act_group->addAction(ui->setlistModeListAct);
m_list_mode_act_group->addAction(ui->setlistModeGridAct);
}
void main_window::CreateConnects()
@ -1355,7 +1354,7 @@ void main_window::CreateConnects()
{
AddGamesFromDir(path);
}
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
}
});
@ -1376,29 +1375,29 @@ void main_window::CreateConnects()
{
if (ui->freezeRecentAct->isChecked()) { return; }
m_rg_entries.clear();
for (auto act : m_recentGameActs)
for (auto act : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(act);
}
m_recentGameActs.clear();
guiSettings->SetValue(gui::rg_entries, guiSettings->List2Var(q_pair_list()));
m_recent_game_acts.clear();
m_gui_settings->SetValue(gui::rg_entries, m_gui_settings->List2Var(q_pair_list()));
});
connect(ui->freezeRecentAct, &QAction::triggered, [this](bool checked)
{
guiSettings->SetValue(gui::rg_freeze, checked);
m_gui_settings->SetValue(gui::rg_freeze, checked);
});
connect(ui->bootInstallPkgAct, &QAction::triggered, [this] {InstallPackages(); });
connect(ui->bootInstallPupAct, &QAction::triggered, [this] {InstallPup(); });
connect(ui->exitAct, &QAction::triggered, this, &QWidget::close);
connect(ui->batchCreatePPUCachesAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchCreatePPUCaches);
connect(ui->batchRemovePPUCachesAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemovePPUCaches);
connect(ui->batchRemoveSPUCachesAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveSPUCaches);
connect(ui->batchRemoveShaderCachesAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveShaderCaches);
connect(ui->batchRemoveCustomConfigurationsAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveCustomConfigurations);
connect(ui->batchRemoveCustomPadConfigurationsAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveCustomPadConfigurations);
connect(ui->batchCreatePPUCachesAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchCreatePPUCaches);
connect(ui->batchRemovePPUCachesAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchRemovePPUCaches);
connect(ui->batchRemoveSPUCachesAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchRemoveSPUCaches);
connect(ui->batchRemoveShaderCachesAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchRemoveShaderCaches);
connect(ui->batchRemoveCustomConfigurationsAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchRemoveCustomConfigurations);
connect(ui->batchRemoveCustomPadConfigurationsAct, &QAction::triggered, m_game_list_frame, &game_list_frame::BatchRemoveCustomPadConfigurations);
connect(ui->removeDiskCacheAct, &QAction::triggered, this, &main_window::RemoveDiskCache);
@ -1420,13 +1419,13 @@ void main_window::CreateConnects()
auto openSettings = [this](int tabIndex)
{
settings_dialog dlg(guiSettings, emuSettings, tabIndex, this);
settings_dialog dlg(m_gui_settings, m_emu_settings, tabIndex, this);
connect(&dlg, &settings_dialog::GuiSettingsSaveRequest, this, &main_window::SaveWindowState);
connect(&dlg, &settings_dialog::GuiSettingsSyncRequest, this, &main_window::ConfigureGuiFromSettings);
connect(&dlg, &settings_dialog::GuiStylesheetRequest, this, &main_window::RequestGlobalStylesheetChange);
connect(&dlg, &settings_dialog::GuiRepaintRequest, this, &main_window::RepaintGui);
connect(&dlg, &settings_dialog::EmuSettingsApplied, this, &main_window::NotifyEmuSettingsChange);
connect(&dlg, &settings_dialog::EmuSettingsApplied, m_logFrame, &log_frame::LoadSettings);
connect(&dlg, &settings_dialog::EmuSettingsApplied, m_log_frame, &log_frame::LoadSettings);
dlg.exec();
};
@ -1468,21 +1467,21 @@ void main_window::CreateConnects()
connect(ui->confVFSDialogAct, &QAction::triggered, [this]()
{
vfs_dialog dlg(guiSettings, emuSettings, this);
vfs_dialog dlg(m_gui_settings, m_emu_settings, this);
dlg.exec();
m_gameListFrame->Refresh(true); // dev-hdd0 may have changed. Refresh just in case.
m_game_list_frame->Refresh(true); // dev-hdd0 may have changed. Refresh just in case.
});
connect(ui->confSavedataManagerAct, &QAction::triggered, [this]
{
save_manager_dialog* save_manager = new save_manager_dialog(guiSettings);
save_manager_dialog* save_manager = new save_manager_dialog(m_gui_settings);
connect(this, &main_window::RequestTrophyManagerRepaint, save_manager, &save_manager_dialog::HandleRepaintUiRequest);
save_manager->show();
});
connect(ui->actionManage_Trophy_Data, &QAction::triggered, [this]
{
trophy_manager_dialog* trop_manager = new trophy_manager_dialog(guiSettings);
trophy_manager_dialog* trop_manager = new trophy_manager_dialog(m_gui_settings);
connect(this, &main_window::RequestTrophyManagerRepaint, trop_manager, &trophy_manager_dialog::HandleRepaintUiRequest);
trop_manager->show();
});
@ -1501,14 +1500,14 @@ void main_window::CreateConnects()
connect(ui->actionManage_Users, &QAction::triggered, [this]
{
user_manager_dialog user_manager(guiSettings, this);
user_manager_dialog user_manager(m_gui_settings, this);
user_manager.exec();
m_gameListFrame->Refresh(true); // New user may have different games unlocked.
m_game_list_frame->Refresh(true); // New user may have different games unlocked.
});
connect(ui->toolsCgDisasmAct, &QAction::triggered, [this]
{
cg_disasm_window* cgdw = new cg_disasm_window(guiSettings);
cg_disasm_window* cgdw = new cg_disasm_window(m_gui_settings);
cgdw->show();
});
@ -1526,7 +1525,7 @@ void main_window::CreateConnects()
connect(ui->toolsRsxDebuggerAct, &QAction::triggered, [this]
{
rsx_debugger* rsx = new rsx_debugger(guiSettings);
rsx_debugger* rsx = new rsx_debugger(m_gui_settings);
rsx->show();
});
@ -1540,49 +1539,49 @@ void main_window::CreateConnects()
connect(ui->showDebuggerAct, &QAction::triggered, [this](bool checked)
{
checked ? m_debuggerFrame->show() : m_debuggerFrame->hide();
guiSettings->SetValue(gui::mw_debugger, checked);
checked ? m_debugger_frame->show() : m_debugger_frame->hide();
m_gui_settings->SetValue(gui::mw_debugger, checked);
});
connect(ui->showLogAct, &QAction::triggered, [this](bool checked)
{
checked ? m_logFrame->show() : m_logFrame->hide();
guiSettings->SetValue(gui::mw_logger, checked);
checked ? m_log_frame->show() : m_log_frame->hide();
m_gui_settings->SetValue(gui::mw_logger, checked);
});
connect(ui->showGameListAct, &QAction::triggered, [this](bool checked)
{
checked ? m_gameListFrame->show() : m_gameListFrame->hide();
guiSettings->SetValue(gui::mw_gamelist, checked);
checked ? m_game_list_frame->show() : m_game_list_frame->hide();
m_gui_settings->SetValue(gui::mw_gamelist, checked);
});
connect(ui->showTitleBarsAct, &QAction::triggered, [this](bool checked)
{
ShowTitleBars(checked);
guiSettings->SetValue(gui::mw_titleBarsVisible, checked);
m_gui_settings->SetValue(gui::mw_titleBarsVisible, checked);
});
connect(ui->showToolBarAct, &QAction::triggered, [this](bool checked)
{
ui->toolBar->setVisible(checked);
guiSettings->SetValue(gui::mw_toolBarVisible, checked);
m_gui_settings->SetValue(gui::mw_toolBarVisible, checked);
});
connect(ui->showHiddenEntriesAct, &QAction::triggered, [this](bool checked)
{
guiSettings->SetValue(gui::gl_show_hidden, checked);
m_gameListFrame->SetShowHidden(checked);
m_gameListFrame->Refresh();
m_gui_settings->SetValue(gui::gl_show_hidden, checked);
m_game_list_frame->SetShowHidden(checked);
m_game_list_frame->Refresh();
});
connect(ui->showCompatibilityInGridAct, &QAction::triggered, m_gameListFrame, &game_list_frame::SetShowCompatibilityInGrid);
connect(ui->showCompatibilityInGridAct, &QAction::triggered, m_game_list_frame, &game_list_frame::SetShowCompatibilityInGrid);
connect(ui->refreshGameListAct, &QAction::triggered, [this]
{
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
});
connect(m_categoryVisibleActGroup, &QActionGroup::triggered, [this](QAction* act)
connect(m_category_visible_act_group, &QActionGroup::triggered, [this](QAction* act)
{
QStringList categories;
int id = 0;
@ -1602,8 +1601,8 @@ void main_window::CreateConnects()
if (!categories.isEmpty())
{
m_gameListFrame->ToggleCategoryFilter(categories, checked);
guiSettings->SetCategoryVisibility(id, checked);
m_game_list_frame->ToggleCategoryFilter(categories, checked);
m_gui_settings->SetCategoryVisibility(id, checked);
}
});
@ -1629,7 +1628,7 @@ void main_window::CreateConnects()
connect(ui->aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
connect(m_iconSizeActGroup, &QActionGroup::triggered, [this](QAction* act)
connect(m_icon_size_act_group, &QActionGroup::triggered, [this](QAction* act)
{
static const int index_small = gui::get_Index(gui::gl_icon_size_small);
static const int index_medium = gui::get_Index(gui::gl_icon_size_medium);
@ -1649,14 +1648,14 @@ void main_window::CreateConnects()
ResizeIcons(index);
});
connect (m_gameListFrame, &game_list_frame::RequestIconSizeChange, [this](const int& val)
connect(m_game_list_frame, &game_list_frame::RequestIconSizeChange, [this](const int& val)
{
const int idx = ui->sizeSlider->value() + val;
m_save_slider_pos = true;
ResizeIcons(idx);
});
connect(m_listModeActGroup, &QActionGroup::triggered, [this](QAction* act)
connect(m_list_mode_act_group, &QActionGroup::triggered, [this](QAction* act)
{
bool is_list_act = act == ui->setlistModeListAct;
if (is_list_act == m_is_list_mode)
@ -1668,12 +1667,12 @@ void main_window::CreateConnects()
m_other_slider_pos = slider_pos;
m_is_list_mode = is_list_act;
m_gameListFrame->SetListMode(m_is_list_mode);
m_categoryVisibleActGroup->setEnabled(m_is_list_mode);
m_game_list_frame->SetListMode(m_is_list_mode);
m_category_visible_act_group->setEnabled(m_is_list_mode);
});
connect(ui->toolbar_open, &QAction::triggered, this, &main_window::BootGame);
connect(ui->toolbar_refresh, &QAction::triggered, [this]() { m_gameListFrame->Refresh(true); });
connect(ui->toolbar_refresh, &QAction::triggered, [this]() { m_game_list_frame->Refresh(true); });
connect(ui->toolbar_stop, &QAction::triggered, [this]() { Emu.Stop(); });
connect(ui->toolbar_start, &QAction::triggered, this, &main_window::OnPlayOrPause);
@ -1700,7 +1699,7 @@ void main_window::CreateConnects()
connect(ui->sizeSlider, &QSlider::sliderReleased, this, [&]
{
const int index = ui->sizeSlider->value();
guiSettings->SetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid, index);
m_gui_settings->SetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid, index);
SetIconSizeActions(index);
});
connect(ui->sizeSlider, &QSlider::actionTriggered, [&](int action)
@ -1711,7 +1710,7 @@ void main_window::CreateConnects()
}
});
connect(ui->mw_searchbar, &QLineEdit::textChanged, m_gameListFrame, &game_list_frame::SetSearchText);
connect(ui->mw_searchbar, &QLineEdit::textChanged, m_game_list_frame, &game_list_frame::SetSearchText);
}
void main_window::CreateDockWindows()
@ -1720,48 +1719,48 @@ void main_window::CreateDockWindows()
m_mw = new QMainWindow();
m_mw->setContextMenuPolicy(Qt::PreventContextMenu);
m_gameListFrame = new game_list_frame(guiSettings, emuSettings, m_persistent_settings, m_mw);
m_gameListFrame->setObjectName("gamelist");
m_debuggerFrame = new debugger_frame(guiSettings, m_mw);
m_debuggerFrame->setObjectName("debugger");
m_logFrame = new log_frame(guiSettings, m_mw);
m_logFrame->setObjectName("logger");
m_game_list_frame = new game_list_frame(m_gui_settings, m_emu_settings, m_persistent_settings, m_mw);
m_game_list_frame->setObjectName("gamelist");
m_debugger_frame = new debugger_frame(m_gui_settings, m_mw);
m_debugger_frame->setObjectName("debugger");
m_log_frame = new log_frame(m_gui_settings, m_mw);
m_log_frame->setObjectName("logger");
m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_gameListFrame);
m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_logFrame);
m_mw->addDockWidget(Qt::RightDockWidgetArea, m_debuggerFrame);
m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_game_list_frame);
m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_log_frame);
m_mw->addDockWidget(Qt::RightDockWidgetArea, m_debugger_frame);
m_mw->setDockNestingEnabled(true);
m_mw->resizeDocks({ m_logFrame }, { m_mw->sizeHint().height() / 10 }, Qt::Orientation::Vertical);
m_mw->resizeDocks({ m_log_frame }, { m_mw->sizeHint().height() / 10 }, Qt::Orientation::Vertical);
setCentralWidget(m_mw);
connect(m_logFrame, &log_frame::LogFrameClosed, [this]()
connect(m_log_frame, &log_frame::LogFrameClosed, [this]()
{
if (ui->showLogAct->isChecked())
{
ui->showLogAct->setChecked(false);
guiSettings->SetValue(gui::mw_logger, false);
m_gui_settings->SetValue(gui::mw_logger, false);
}
});
connect(m_debuggerFrame, &debugger_frame::DebugFrameClosed, [this]()
connect(m_debugger_frame, &debugger_frame::DebugFrameClosed, [this]()
{
if (ui->showDebuggerAct->isChecked())
{
ui->showDebuggerAct->setChecked(false);
guiSettings->SetValue(gui::mw_debugger, false);
m_gui_settings->SetValue(gui::mw_debugger, false);
}
});
connect(m_gameListFrame, &game_list_frame::GameListFrameClosed, [this]()
connect(m_game_list_frame, &game_list_frame::GameListFrameClosed, [this]()
{
if (ui->showGameListAct->isChecked())
{
ui->showGameListAct->setChecked(false);
guiSettings->SetValue(gui::mw_gamelist, false);
m_gui_settings->SetValue(gui::mw_gamelist, false);
}
});
connect(m_gameListFrame, &game_list_frame::NotifyGameSelection, [this](const game_info& game)
connect(m_game_list_frame, &game_list_frame::NotifyGameSelection, [this](const game_info& game)
{
// Only change the button logic while the emulator is stopped.
if (Emu.IsStopped())
@ -1802,9 +1801,9 @@ void main_window::CreateDockWindows()
ui->toolbar_start->setIcon(m_icon_restart);
ui->toolbar_start->setText(tr("Restart"));
}
else if (!m_recentGameActs.isEmpty()) // Get last played game
else if (!m_recent_game_acts.isEmpty()) // Get last played game
{
tooltip = tr("Play %0").arg(m_recentGameActs.first()->text());
tooltip = tr("Play %0").arg(m_recent_game_acts.first()->text());
}
else
{
@ -1824,36 +1823,36 @@ void main_window::CreateDockWindows()
m_selected_game = game;
});
connect(m_gameListFrame, &game_list_frame::RequestBoot, [this](const game_info& game, bool force_global_config)
connect(m_game_list_frame, &game_list_frame::RequestBoot, [this](const game_info& game, bool force_global_config)
{
Boot(game->info.path, game->info.serial, false, false, force_global_config);
});
connect(m_gameListFrame, &game_list_frame::NotifyEmuSettingsChange, this, &main_window::NotifyEmuSettingsChange);
connect(m_game_list_frame, &game_list_frame::NotifyEmuSettingsChange, this, &main_window::NotifyEmuSettingsChange);
}
void main_window::ConfigureGuiFromSettings(bool configure_all)
{
// Restore GUI state if needed. We need to if they exist.
if (!restoreGeometry(guiSettings->GetValue(gui::mw_geometry).toByteArray()))
if (!restoreGeometry(m_gui_settings->GetValue(gui::mw_geometry).toByteArray()))
{
// By default, set the window to 70% of the screen and the debugger frame is hidden.
m_debuggerFrame->hide();
m_debugger_frame->hide();
resize(QGuiApplication::primaryScreen()->availableSize() * 0.7);
}
restoreState(guiSettings->GetValue(gui::mw_windowState).toByteArray());
m_mw->restoreState(guiSettings->GetValue(gui::mw_mwState).toByteArray());
restoreState(m_gui_settings->GetValue(gui::mw_windowState).toByteArray());
m_mw->restoreState(m_gui_settings->GetValue(gui::mw_mwState).toByteArray());
ui->freezeRecentAct->setChecked(guiSettings->GetValue(gui::rg_freeze).toBool());
m_rg_entries = guiSettings->Var2List(guiSettings->GetValue(gui::rg_entries));
ui->freezeRecentAct->setChecked(m_gui_settings->GetValue(gui::rg_freeze).toBool());
m_rg_entries = m_gui_settings->Var2List(m_gui_settings->GetValue(gui::rg_entries));
// clear recent games menu of actions
for (auto act : m_recentGameActs)
for (auto act : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(act);
}
m_recentGameActs.clear();
m_recent_game_acts.clear();
// Fill the recent games menu
for (int i = 0; i < m_rg_entries.count(); i++)
@ -1867,7 +1866,7 @@ void main_window::ConfigureGuiFromSettings(bool configure_all)
// add action to menu
if (act)
{
m_recentGameActs.append(act);
m_recent_game_acts.append(act);
ui->bootRecentMenu->addAction(act);
}
else
@ -1877,57 +1876,57 @@ void main_window::ConfigureGuiFromSettings(bool configure_all)
}
// hide utilities from the average user
ui->menuUtilities->menuAction()->setVisible(guiSettings->GetValue(gui::m_showDebugTab).toBool());
ui->menuUtilities->menuAction()->setVisible(m_gui_settings->GetValue(gui::m_showDebugTab).toBool());
ui->showLogAct->setChecked(guiSettings->GetValue(gui::mw_logger).toBool());
ui->showGameListAct->setChecked(guiSettings->GetValue(gui::mw_gamelist).toBool());
ui->showDebuggerAct->setChecked(guiSettings->GetValue(gui::mw_debugger).toBool());
ui->showToolBarAct->setChecked(guiSettings->GetValue(gui::mw_toolBarVisible).toBool());
ui->showTitleBarsAct->setChecked(guiSettings->GetValue(gui::mw_titleBarsVisible).toBool());
ui->showLogAct->setChecked(m_gui_settings->GetValue(gui::mw_logger).toBool());
ui->showGameListAct->setChecked(m_gui_settings->GetValue(gui::mw_gamelist).toBool());
ui->showDebuggerAct->setChecked(m_gui_settings->GetValue(gui::mw_debugger).toBool());
ui->showToolBarAct->setChecked(m_gui_settings->GetValue(gui::mw_toolBarVisible).toBool());
ui->showTitleBarsAct->setChecked(m_gui_settings->GetValue(gui::mw_titleBarsVisible).toBool());
m_debuggerFrame->setVisible(ui->showDebuggerAct->isChecked());
m_logFrame->setVisible(ui->showLogAct->isChecked());
m_gameListFrame->setVisible(ui->showGameListAct->isChecked());
m_debugger_frame->setVisible(ui->showDebuggerAct->isChecked());
m_log_frame->setVisible(ui->showLogAct->isChecked());
m_game_list_frame->setVisible(ui->showGameListAct->isChecked());
ui->toolBar->setVisible(ui->showToolBarAct->isChecked());
ShowTitleBars(ui->showTitleBarsAct->isChecked());
ui->showHiddenEntriesAct->setChecked(guiSettings->GetValue(gui::gl_show_hidden).toBool());
m_gameListFrame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_gameListFrame->LoadSettings
ui->showHiddenEntriesAct->setChecked(m_gui_settings->GetValue(gui::gl_show_hidden).toBool());
m_game_list_frame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_game_list_frame->LoadSettings
ui->showCompatibilityInGridAct->setChecked(guiSettings->GetValue(gui::gl_draw_compat).toBool());
ui->showCompatibilityInGridAct->setChecked(m_gui_settings->GetValue(gui::gl_draw_compat).toBool());
ui->showCatHDDGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::HDD_Game));
ui->showCatDiscGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::Disc_Game));
ui->showCatPS1GamesAct->setChecked(guiSettings->GetCategoryVisibility(Category::PS1_Game));
ui->showCatPS2GamesAct->setChecked(guiSettings->GetCategoryVisibility(Category::PS2_Game));
ui->showCatPSPGamesAct->setChecked(guiSettings->GetCategoryVisibility(Category::PSP_Game));
ui->showCatHomeAct->setChecked(guiSettings->GetCategoryVisibility(Category::Home));
ui->showCatAudioVideoAct->setChecked(guiSettings->GetCategoryVisibility(Category::Media));
ui->showCatGameDataAct->setChecked(guiSettings->GetCategoryVisibility(Category::Data));
ui->showCatUnknownAct->setChecked(guiSettings->GetCategoryVisibility(Category::Unknown_Cat));
ui->showCatOtherAct->setChecked(guiSettings->GetCategoryVisibility(Category::Others));
ui->showCatHDDGameAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::HDD_Game));
ui->showCatDiscGameAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Disc_Game));
ui->showCatPS1GamesAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::PS1_Game));
ui->showCatPS2GamesAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::PS2_Game));
ui->showCatPSPGamesAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::PSP_Game));
ui->showCatHomeAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Home));
ui->showCatAudioVideoAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Media));
ui->showCatGameDataAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Data));
ui->showCatUnknownAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Unknown_Cat));
ui->showCatOtherAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Others));
// handle icon size options
m_is_list_mode = guiSettings->GetValue(gui::gl_listMode).toBool();
m_is_list_mode = m_gui_settings->GetValue(gui::gl_listMode).toBool();
if (m_is_list_mode)
ui->setlistModeListAct->setChecked(true);
else
ui->setlistModeGridAct->setChecked(true);
m_categoryVisibleActGroup->setEnabled(m_is_list_mode);
m_category_visible_act_group->setEnabled(m_is_list_mode);
int icon_size_index = guiSettings->GetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid).toInt();
m_other_slider_pos = guiSettings->GetValue(!m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid).toInt();
int icon_size_index = m_gui_settings->GetValue(m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid).toInt();
m_other_slider_pos = m_gui_settings->GetValue(!m_is_list_mode ? gui::gl_iconSize : gui::gl_iconSizeGrid).toInt();
ui->sizeSlider->setSliderPosition(icon_size_index);
SetIconSizeActions(icon_size_index);
if (configure_all)
{
// Handle log settings
m_logFrame->LoadSettings();
m_log_frame->LoadSettings();
// Gamelist
m_gameListFrame->LoadSettings();
m_game_list_frame->LoadSettings();
}
}
@ -1996,11 +1995,11 @@ void main_window::mouseDoubleClickEvent(QMouseEvent *event)
*/
void main_window::closeEvent(QCloseEvent* closeEvent)
{
if (!Emu.IsStopped() && guiSettings->GetValue(gui::ib_confirm_exit).toBool())
if (!Emu.IsStopped() && m_gui_settings->GetValue(gui::ib_confirm_exit).toBool())
{
int result = QMessageBox::Yes;
guiSettings->ShowConfirmationBox(tr("Exit RPCS3?"),
m_gui_settings->ShowConfirmationBox(tr("Exit RPCS3?"),
tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n"),
gui::ib_confirm_exit, &result, nullptr);
@ -2180,14 +2179,14 @@ void main_window::dropEvent(QDropEvent* event)
}
// Refresh game list since we probably unlocked some games now.
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
break;
case drop_type::drop_dir: // import valid games to gamelist (games.yaml)
for (const auto& path : dropPaths)
{
AddGamesFromDir(path);
}
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
break;
case drop_type::drop_game: // import valid games to gamelist (games.yaml)
if (const auto error = Emu.BootGame(sstr(dropPaths.first()), "", true); error != game_boot_result::no_errors)
@ -2198,7 +2197,7 @@ void main_window::dropEvent(QDropEvent* event)
else
{
gui_log.success("Elf Boot from drag and drop done: %s", sstr(dropPaths.first()));
m_gameListFrame->Refresh(true);
m_game_list_frame->Refresh(true);
}
break;
case drop_type::drop_rrc: // replay a rsx capture file

View File

@ -41,7 +41,7 @@ class main_window : public QMainWindow
bool m_save_slider_pos = false;
int m_other_slider_pos = 0;
QIcon m_appIcon;
QIcon m_app_icon;
QIcon m_icon_play;
QIcon m_icon_pause;
QIcon m_icon_stop;
@ -73,14 +73,14 @@ class main_window : public QMainWindow
};
public:
explicit main_window(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = 0);
explicit main_window(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = 0);
void Init();
~main_window();
QIcon GetAppIcon();
Q_SIGNALS:
void RequestLanguageChange(const QString& language);
void RequestGlobalStylesheetChange(const QString& sheetFilePath);
void RequestGlobalStylesheetChange(const QString& stylesheet_path);
void RequestTrophyManagerRepaint();
void NotifyEmuSettingsChange();
@ -146,21 +146,21 @@ private:
QString GetCurrentTitle();
q_pair_list m_rg_entries;
QList<QAction*> m_recentGameActs;
QList<QAction*> m_recent_game_acts;
std::shared_ptr<gui_game_info> m_selected_game;
QActionGroup* m_iconSizeActGroup = nullptr;
QActionGroup* m_listModeActGroup = nullptr;
QActionGroup* m_categoryVisibleActGroup = nullptr;
QActionGroup* m_icon_size_act_group = nullptr;
QActionGroup* m_list_mode_act_group = nullptr;
QActionGroup* m_category_visible_act_group = nullptr;
// Dockable widget frames
QMainWindow *m_mw = nullptr;
log_frame* m_logFrame = nullptr;
debugger_frame* m_debuggerFrame = nullptr;
game_list_frame* m_gameListFrame = nullptr;
std::shared_ptr<gui_settings> guiSettings;
std::shared_ptr<emu_settings> emuSettings;
log_frame* m_log_frame = nullptr;
debugger_frame* m_debugger_frame = nullptr;
game_list_frame* m_game_list_frame = nullptr;
std::shared_ptr<gui_settings> m_gui_settings;
std::shared_ptr<emu_settings> m_emu_settings;
std::shared_ptr<persistent_settings> m_persistent_settings;
update_manager m_updater;

View File

@ -39,12 +39,12 @@ LOG_CHANNEL(cfg_log, "CFG");
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); }
settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, const int& tabIndex, QWidget *parent, const GameInfo* game)
settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, const int& tab_index, QWidget *parent, const GameInfo* game)
: QDialog(parent)
, m_tab_Index(tabIndex)
, m_tab_index(tab_index)
, ui(new Ui::settings_dialog)
, xgui_settings(guiSettings)
, xemu_settings(emuSettings)
, xgui_settings(gui_settings)
, xemu_settings(emu_settings)
{
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
@ -522,7 +522,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
}
}
m_oldRender = ui->renderBox->currentText();
m_old_renderer = ui->renderBox->currentText();
auto setRenderer = [=, this](QString text)
{
@ -563,7 +563,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
}
// Reset Adapter to old config
int idx = ui->graphicsAdapterBox->findText(renderer.old_adapter);
if (idx == -1)
if (idx < 0)
{
idx = 0;
if (renderer.old_adapter.isEmpty())
@ -597,15 +597,15 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
}
// don't set adapter if signal was created by switching render
QString newRender = ui->renderBox->currentText();
if (m_oldRender != newRender)
const QString new_renderer = ui->renderBox->currentText();
if (m_old_renderer != new_renderer)
{
m_oldRender = newRender;
m_old_renderer = new_renderer;
return;
}
for (const auto& render : render_creator.renderers)
{
if (render->name == newRender && render->has_adapters && render->adapters.contains(text))
if (render->name == new_renderer && render->has_adapters && render->adapters.contains(text))
{
xemu_settings->SetSetting(render->type, sstr(text));
break;
@ -1582,17 +1582,17 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
{
if (reset)
{
m_currentConfig = gui::Default;
m_currentStylesheet = gui::Default;
m_current_gui_config = gui::Default;
m_current_stylesheet = gui::Default;
ui->combo_configs->setCurrentIndex(0);
ui->combo_stylesheets->setCurrentIndex(0);
}
// Only attempt to load a config if changes occurred.
if (m_currentConfig != ui->combo_configs->currentText())
if (m_current_gui_config != ui->combo_configs->currentText())
{
OnApplyConfig();
}
if (m_currentStylesheet != xgui_settings->GetValue(gui::m_currentStylesheet).toString())
if (m_current_stylesheet != xgui_settings->GetValue(gui::m_currentStylesheet).toString())
{
OnApplyStylesheet();
}
@ -1791,17 +1791,17 @@ void settings_dialog::SnapSlider(QSlider *slider, int interval)
{
connect(slider, &QSlider::sliderPressed, [this, slider]()
{
m_currentSlider = slider;
m_current_slider = slider;
});
connect(slider, &QSlider::sliderReleased, [this]()
{
m_currentSlider = nullptr;
m_current_slider = nullptr;
});
connect(slider, &QSlider::valueChanged, [this, slider, interval](int value)
{
if (slider != m_currentSlider)
if (slider != m_current_slider)
{
return;
}
@ -1823,10 +1823,10 @@ void settings_dialog::AddConfigs()
}
}
m_currentConfig = xgui_settings->GetValue(gui::m_currentConfig).toString();
m_current_gui_config = xgui_settings->GetValue(gui::m_currentConfig).toString();
int index = ui->combo_configs->findText(m_currentConfig);
if (index != -1)
const int index = ui->combo_configs->findText(m_current_gui_config);
if (index >= 0)
{
ui->combo_configs->setCurrentIndex(index);
}
@ -1851,16 +1851,16 @@ void settings_dialog::AddStylesheets()
}
}
m_currentStylesheet = xgui_settings->GetValue(gui::m_currentStylesheet).toString();
m_current_stylesheet = xgui_settings->GetValue(gui::m_currentStylesheet).toString();
int index = ui->combo_stylesheets->findData(m_currentStylesheet);
if (index != -1)
const int index = ui->combo_stylesheets->findData(m_current_stylesheet);
if (index >= 0)
{
ui->combo_stylesheets->setCurrentIndex(index);
}
else
{
cfg_log.warning("Trying to set an invalid stylesheets index: %d (%s)", index, sstr(m_currentStylesheet));
cfg_log.warning("Trying to set an invalid stylesheets index: %d (%s)", index, sstr(m_current_stylesheet));
}
}
@ -1874,27 +1874,29 @@ void settings_dialog::OnBackupCurrentConfig()
while (dialog->exec() != QDialog::Rejected)
{
dialog->resize(500, 100);
QString friendly_name = dialog->textValue();
if (friendly_name == "")
const QString gui_config_name = dialog->textValue();
if (gui_config_name.isEmpty())
{
QMessageBox::warning(this, tr("Error"), tr("Name cannot be empty"));
continue;
}
if (friendly_name.contains("."))
if (gui_config_name.contains("."))
{
QMessageBox::warning(this, tr("Error"), tr("Must choose a name with no '.'"));
continue;
}
if (ui->combo_configs->findText(friendly_name) != -1)
if (ui->combo_configs->findText(gui_config_name) != -1)
{
QMessageBox::warning(this, tr("Error"), tr("Please choose a non-existing name"));
continue;
}
Q_EMIT GuiSettingsSaveRequest();
xgui_settings->SaveCurrentConfig(friendly_name);
ui->combo_configs->addItem(friendly_name);
ui->combo_configs->setCurrentText(friendly_name);
m_currentConfig = friendly_name;
xgui_settings->SaveCurrentConfig(gui_config_name);
ui->combo_configs->addItem(gui_config_name);
ui->combo_configs->setCurrentText(gui_config_name);
m_current_gui_config = gui_config_name;
break;
}
}
@ -1903,7 +1905,7 @@ void settings_dialog::OnApplyConfig()
{
const QString new_config = ui->combo_configs->currentText();
if (new_config == m_currentConfig)
if (new_config == m_current_gui_config)
{
return;
}
@ -1911,19 +1913,19 @@ void settings_dialog::OnApplyConfig()
if (!xgui_settings->ChangeToConfig(new_config))
{
const int new_config_idx = ui->combo_configs->currentIndex();
ui->combo_configs->setCurrentText(m_currentConfig);
ui->combo_configs->setCurrentText(m_current_gui_config);
ui->combo_configs->removeItem(new_config_idx);
return;
}
m_currentConfig = new_config;
m_current_gui_config = new_config;
Q_EMIT GuiSettingsSyncRequest(true);
}
void settings_dialog::OnApplyStylesheet()
{
m_currentStylesheet = ui->combo_stylesheets->currentData().toString();
xgui_settings->SetValue(gui::m_currentStylesheet, m_currentStylesheet);
m_current_stylesheet = ui->combo_stylesheets->currentData().toString();
xgui_settings->SetValue(gui::m_currentStylesheet, m_current_stylesheet);
Q_EMIT GuiStylesheetRequest(xgui_settings->GetCurrentStylesheetPath());
}
@ -1934,7 +1936,7 @@ int settings_dialog::exec()
// switch to the cpu tab after conjuring the settings_dialog with another tab opened first.
// Weirdly enough this won't happen if we change the tab order so that anything else is at index 0.
ui->tab_widget_settings->setCurrentIndex(0);
QTimer::singleShot(0, [=, this]{ ui->tab_widget_settings->setCurrentIndex(m_tab_Index); });
QTimer::singleShot(0, [=, this]{ ui->tab_widget_settings->setCurrentIndex(m_tab_index); });
// Open a dialog if your config file contained invalid entries
QTimer::singleShot(10, [this] { xemu_settings->OpenCorrectionDialog(this); });
@ -1962,20 +1964,20 @@ bool settings_dialog::eventFilter(QObject* object, QEvent* event)
return QDialog::eventFilter(object, event);
}
const int i = ui->tab_widget_settings->currentIndex();
QLabel* label = m_description_labels[i].first;
if (event->type() == QEvent::Enter)
if (event->type() == QEvent::Enter || event->type() == QEvent::Leave)
{
label->setText(m_descriptions[object]);
return QDialog::eventFilter(object, event);
}
const int i = ui->tab_widget_settings->currentIndex();
QLabel* label = m_description_labels[i].first;
QString description = m_description_labels[i].second;
if (event->type() == QEvent::Leave)
{
label->setText(description);
if (event->type() == QEvent::Enter)
{
label->setText(m_descriptions[object]);
}
else if (event->type() == QEvent::Leave)
{
const QString description = m_description_labels[i].second;
label->setText(description);
}
}
return QDialog::eventFilter(object, event);

View File

@ -21,7 +21,7 @@ class settings_dialog : public QDialog
Q_OBJECT
public:
explicit settings_dialog(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, const int& tabIndex = 0, QWidget *parent = 0, const GameInfo *game = nullptr);
explicit settings_dialog(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, const int& tab_index = 0, QWidget *parent = 0, const GameInfo *game = nullptr);
~settings_dialog();
int exec() override;
Q_SIGNALS:
@ -39,19 +39,19 @@ private:
// Snapping of sliders when moved with mouse
void SnapSlider(QSlider* slider, int interval);
QSlider* m_currentSlider = nullptr;
QSlider* m_current_slider = nullptr;
// Emulator tab
void AddConfigs();
void AddStylesheets();
QString m_currentStylesheet;
QString m_currentConfig;
QString m_current_stylesheet;
QString m_current_gui_config;
// Gpu tab
QString m_oldRender = "";
QString m_old_renderer = "";
// Audio tab
QComboBox *mics_combo[4];
int m_tab_Index;
int m_tab_index;
Ui::settings_dialog *ui;
std::shared_ptr<gui_settings> xgui_settings;
std::shared_ptr<emu_settings> xemu_settings;