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 <QCursor>
|
||||
#include <QFontDatabase>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
@ -51,6 +53,8 @@ void GeckoCodeWidget::CreateWidgets()
|
|||
m_name_label = new QLabel;
|
||||
m_creator_label = new QLabel;
|
||||
|
||||
m_code_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QFont monospace(QFontDatabase::systemFont(QFontDatabase::FixedFont).family());
|
||||
|
||||
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->model(), &QAbstractItemModel::rowsMoved, this,
|
||||
&GeckoCodeWidget::OnListReordered);
|
||||
connect(m_code_list, &QListWidget::customContextMenuRequested, this,
|
||||
&GeckoCodeWidget::OnContextMenuRequested);
|
||||
|
||||
connect(m_add_code, &QPushButton::pressed, this, &GeckoCodeWidget::AddCode);
|
||||
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");
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
// Reorder codes based on the indices of table item
|
||||
|
|
|
@ -37,6 +37,7 @@ private:
|
|||
void OnSelectionChanged();
|
||||
void OnItemChanged(QListWidgetItem* item);
|
||||
void OnListReordered();
|
||||
void OnContextMenuRequested();
|
||||
|
||||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
|
@ -46,6 +47,7 @@ private:
|
|||
void RemoveCode();
|
||||
void DownloadCodes();
|
||||
void SaveCodes();
|
||||
void SortAlphabetically();
|
||||
|
||||
const UICommon::GameFile& m_game;
|
||||
std::string m_game_id;
|
||||
|
|
Loading…
Reference in New Issue