summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/CMakeLists.txt4
-rw-r--r--application/KonamiCode.cpp42
-rw-r--r--application/KonamiCode.h17
-rw-r--r--application/MainWindow.cpp13
-rw-r--r--application/MainWindow.h4
5 files changed, 80 insertions, 0 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index 148b6d9f..48c1a359 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -31,6 +31,10 @@ SET(MULTIMC_SOURCES
ColorCache.cpp
HoeDown.h
+ # Super secret!
+ KonamiCode.h
+ KonamiCode.cpp
+
# GUI - windows
MainWindow.h
MainWindow.cpp
diff --git a/application/KonamiCode.cpp b/application/KonamiCode.cpp
new file mode 100644
index 00000000..07c285bc
--- /dev/null
+++ b/application/KonamiCode.cpp
@@ -0,0 +1,42 @@
+#include "KonamiCode.h"
+
+#include <array>
+#include <QDebug>
+
+namespace {
+const std::array<Qt::Key, 10> konamiCode =
+{
+ Qt::Key_Up, Qt::Key_Up,
+ Qt::Key_Down, Qt::Key_Down,
+ Qt::Key_Left, Qt::Key_Right,
+ Qt::Key_Left, Qt::Key_Right,
+ Qt::Key_B, Qt::Key_A
+};
+}
+
+KonamiCode::KonamiCode(QObject* parent) : QObject(parent)
+{
+}
+
+
+void KonamiCode::input(QEvent* event)
+{
+ if( event->type() == QEvent::KeyPress )
+ {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>( event );
+ auto key = Qt::Key(keyEvent->key());
+ if(key == konamiCode[m_progress])
+ {
+ m_progress ++;
+ }
+ else
+ {
+ m_progress = 0;
+ }
+ if(m_progress == konamiCode.size())
+ {
+ m_progress = 0;
+ emit triggered();
+ }
+ }
+}
diff --git a/application/KonamiCode.h b/application/KonamiCode.h
new file mode 100644
index 00000000..ad17f8be
--- /dev/null
+++ b/application/KonamiCode.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <QKeyEvent>
+
+class KonamiCode : public QObject
+{
+ Q_OBJECT
+public:
+ KonamiCode(QObject *parent = 0);
+ void input(QEvent *event);
+
+signals:
+ void triggered();
+
+private:
+ int m_progress = 0;
+};
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 1d36ef8c..e690e1b7 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -89,6 +89,7 @@
#include <FolderInstanceProvider.h>
#include <InstanceImportTask.h>
#include "UpdateController.h"
+#include "KonamiCode.h"
// WHY: to hold the pre-translation strings together with the T pointer, so it can be retranslated without a lot of ugly code
template <typename T>
@@ -631,6 +632,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
connect(q, SIGNAL(activated()), qApp, SLOT(quit()));
}
+ // Konami Code
+ {
+ secretEventFilter = new KonamiCode(this);
+ connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered);
+ }
+
// Add the news label to the news toolbar.
{
m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL));
@@ -806,6 +813,11 @@ MainWindow::~MainWindow()
{
}
+void MainWindow::konamiTriggered()
+{
+ qDebug() << "Super Secret Mode ACTIVATED!";
+}
+
void MainWindow::skinJobFinished()
{
activeAccountChanged();
@@ -1064,6 +1076,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::KeyPress)
{
+ secretEventFilter->input(ev);
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
switch (keyEvent->key())
{
diff --git a/application/MainWindow.h b/application/MainWindow.h
index e4c281dc..25dc36ed 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -38,6 +38,7 @@ class MinecraftLauncher;
class BaseProfilerFactory;
class GroupView;
class ServerStatus;
+class KonamiCode;
class MainWindow : public QMainWindow
{
@@ -176,6 +177,8 @@ private slots:
void droppedURLs(QList<QUrl> urls);
+ void konamiTriggered();
+
private:
void addInstance(QString url = QString());
void activateInstance(InstancePtr instance);
@@ -200,6 +203,7 @@ private:
ServerStatus *m_statusRight = nullptr;
QMenu *accountMenu = nullptr;
QToolButton *accountMenuButton = nullptr;
+ KonamiCode * secretEventFilter = nullptr;
unique_qobject_ptr<NetJob> skin_download_job;
unique_qobject_ptr<NewsChecker> m_newsChecker;