mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-31 09:33:06 +00:00
Config/GeckoCodeWidget: Add option for alphabetical sorting
This commit is contained in:
parent
93393a288c
commit
1d43d9afc1
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
#include "DolphinQt/Config/GeckoCodeWidget.h"
|
#include "DolphinQt/Config/GeckoCodeWidget.h"
|
||||||
|
|
||||||
|
#include <QCursor>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@ -51,6 +53,8 @@ void GeckoCodeWidget::CreateWidgets()
|
|||||||
m_name_label = new QLabel;
|
m_name_label = new QLabel;
|
||||||
m_creator_label = new QLabel;
|
m_creator_label = new QLabel;
|
||||||
|
|
||||||
|
m_code_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
QFont monospace(QFontDatabase::systemFont(QFontDatabase::FixedFont).family());
|
QFont monospace(QFontDatabase::systemFont(QFontDatabase::FixedFont).family());
|
||||||
|
|
||||||
const auto line_height = QFontMetrics(font()).lineSpacing();
|
const auto line_height = QFontMetrics(font()).lineSpacing();
|
||||||
@ -118,6 +122,8 @@ void GeckoCodeWidget::ConnectWidgets()
|
|||||||
connect(m_code_list, &QListWidget::itemChanged, this, &GeckoCodeWidget::OnItemChanged);
|
connect(m_code_list, &QListWidget::itemChanged, this, &GeckoCodeWidget::OnItemChanged);
|
||||||
connect(m_code_list->model(), &QAbstractItemModel::rowsMoved, this,
|
connect(m_code_list->model(), &QAbstractItemModel::rowsMoved, this,
|
||||||
&GeckoCodeWidget::OnListReordered);
|
&GeckoCodeWidget::OnListReordered);
|
||||||
|
connect(m_code_list, &QListWidget::customContextMenuRequested, this,
|
||||||
|
&GeckoCodeWidget::OnContextMenuRequested);
|
||||||
|
|
||||||
connect(m_add_code, &QPushButton::pressed, this, &GeckoCodeWidget::AddCode);
|
connect(m_add_code, &QPushButton::pressed, this, &GeckoCodeWidget::AddCode);
|
||||||
connect(m_remove_code, &QPushButton::pressed, this, &GeckoCodeWidget::RemoveCode);
|
connect(m_remove_code, &QPushButton::pressed, this, &GeckoCodeWidget::RemoveCode);
|
||||||
@ -231,6 +237,21 @@ void GeckoCodeWidget::SaveCodes()
|
|||||||
game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeckoCodeWidget::OnContextMenuRequested()
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
|
||||||
|
menu.addAction(tr("Sort Alphabetically"), this, &GeckoCodeWidget::SortAlphabetically);
|
||||||
|
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeckoCodeWidget::SortAlphabetically()
|
||||||
|
{
|
||||||
|
m_code_list->sortItems();
|
||||||
|
OnListReordered();
|
||||||
|
}
|
||||||
|
|
||||||
void GeckoCodeWidget::OnListReordered()
|
void GeckoCodeWidget::OnListReordered()
|
||||||
{
|
{
|
||||||
// Reorder codes based on the indices of table item
|
// Reorder codes based on the indices of table item
|
||||||
|
@ -37,6 +37,7 @@ private:
|
|||||||
void OnSelectionChanged();
|
void OnSelectionChanged();
|
||||||
void OnItemChanged(QListWidgetItem* item);
|
void OnItemChanged(QListWidgetItem* item);
|
||||||
void OnListReordered();
|
void OnListReordered();
|
||||||
|
void OnContextMenuRequested();
|
||||||
|
|
||||||
void CreateWidgets();
|
void CreateWidgets();
|
||||||
void ConnectWidgets();
|
void ConnectWidgets();
|
||||||
@ -46,6 +47,7 @@ private:
|
|||||||
void RemoveCode();
|
void RemoveCode();
|
||||||
void DownloadCodes();
|
void DownloadCodes();
|
||||||
void SaveCodes();
|
void SaveCodes();
|
||||||
|
void SortAlphabetically();
|
||||||
|
|
||||||
const UICommon::GameFile& m_game;
|
const UICommon::GameFile& m_game;
|
||||||
std::string m_game_id;
|
std::string m_game_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user