summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2019-06-21 09:28:24 +0200
committerspycrab <spycrab@users.noreply.github.com>2019-06-22 19:54:13 +0200
commit1d43d9afc11cc7294040a0a7018e1dbf7bc84c88 (patch)
treec0949d111cd92eb3ca0bfa215394988a0badb7a3 /Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp
parent93393a288cc62ffecfb44dc200dca51408bb8eff (diff)
Config/GeckoCodeWidget: Add option for alphabetical sorting
Diffstat (limited to 'Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp
index c82b127235..71972b5c66 100644
--- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp
+++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp
@@ -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