Skip to content

Commit

Permalink
Merge pull request #597 from wheremyfoodat/aac
Browse files Browse the repository at this point in the history
Qt: Fix Linguist issues and format files
  • Loading branch information
wheremyfoodat authored Sep 16, 2024
2 parents c12c3bc + 3567a4b commit 699d2de
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/HTTP_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/Hydra_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
runs-on: macos-13

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Linux_AppImage_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
run: ./.github/linux-appimage.sh

- name: Upload executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Linux executable
path: './Alber-x86_64.AppImage'
4 changes: 2 additions & 2 deletions .github/workflows/Linux_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Upload executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Linux executable
path: './build/Alber'
8 changes: 4 additions & 4 deletions .github/workflows/Qt_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
windeployqt --dir upload upload/Alber.exe
- name: Upload executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Windows executable
path: upload
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
./.github/linux-appimage-qt.sh
- name: Upload executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Linux executable
path: './Alber-x86_64.AppImage'
4 changes: 2 additions & 2 deletions .github/workflows/Windows_Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch submodules
run: git submodule update --init --recursive

Expand All @@ -40,7 +40,7 @@ jobs:
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Upload executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Windows executable
path: './build/${{ env.BUILD_TYPE }}/Alber.exe'
64 changes: 64 additions & 0 deletions include/panda_qt/cheats_window.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#pragma once

#include <QAction>
#include <QCheckBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QTextEdit>
#include <QWidget>
#include <filesystem>
#include <memory>
Expand All @@ -24,3 +31,60 @@ class CheatsWindow final : public QWidget {
std::filesystem::path cheatPath;
Emulator* emu;
};

struct CheatMetadata {
u32 handle = Cheats::badCheatHandle;
std::string name = "New cheat";
std::string code;
bool enabled = true;
};

class CheatEntryWidget : public QWidget {
Q_OBJECT

public:
CheatEntryWidget(Emulator* emu, CheatMetadata metadata, QListWidget* parent);

void Update() {
name->setText(metadata.name.c_str());
enabled->setChecked(metadata.enabled);
update();
}

void Remove() {
emu->getCheats().removeCheat(metadata.handle);
cheatList->takeItem(cheatList->row(listItem));
deleteLater();
}

const CheatMetadata& getMetadata() { return metadata; }
void setMetadata(const CheatMetadata& metadata) { this->metadata = metadata; }

private:
void checkboxChanged(int state);
void editClicked();

Emulator* emu;
CheatMetadata metadata;
u32 handle;
QLabel* name;
QCheckBox* enabled;
QListWidget* cheatList;
QListWidgetItem* listItem;
};

class CheatEditDialog : public QDialog {
Q_OBJECT

public:
CheatEditDialog(Emulator* emu, CheatEntryWidget& cheatEntry);

void accepted();
void rejected();

private:
Emulator* emu;
CheatEntryWidget& cheatEntry;
QTextEdit* codeEdit;
QLineEdit* nameEdit;
};
2 changes: 1 addition & 1 deletion include/panda_qt/main_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MainWindow : public QMainWindow {
MainWindow(QApplication* app, QWidget* parent = nullptr);
~MainWindow();

void closeEvent(QCloseEvent *event) override;
void closeEvent(QCloseEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
Expand Down
4 changes: 3 additions & 1 deletion src/panda_qt/about_window.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "panda_qt/about_window.hpp"
#include "version.hpp"

#include <QHBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QtGlobal>

#include "version.hpp"

// Based on https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DolphinQt/AboutDialog.cpp

AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
Expand Down
84 changes: 12 additions & 72 deletions src/panda_qt/cheats_window.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#include "panda_qt/cheats_window.hpp"

#include <QCheckBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTimer>
#include <QVBoxLayout>
#include <functional>

#include "cheats.hpp"
Expand All @@ -18,71 +12,17 @@

MainWindow* mainWindow = nullptr;

struct CheatMetadata {
u32 handle = Cheats::badCheatHandle;
std::string name = "New cheat";
std::string code;
bool enabled = true;
};

void dispatchToMainThread(std::function<void()> callback) {
QTimer* timer = new QTimer();
timer->moveToThread(qApp->thread());
timer->setSingleShot(true);
QObject::connect(timer, &QTimer::timeout, [=]()
{
callback();
timer->deleteLater();
});
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
QTimer* timer = new QTimer();
timer->moveToThread(qApp->thread());
timer->setSingleShot(true);
QObject::connect(timer, &QTimer::timeout, [=]() {
callback();
timer->deleteLater();
});
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
}

class CheatEntryWidget : public QWidget {
public:
CheatEntryWidget(Emulator* emu, CheatMetadata metadata, QListWidget* parent);

void Update() {
name->setText(metadata.name.c_str());
enabled->setChecked(metadata.enabled);
update();
}

void Remove() {
emu->getCheats().removeCheat(metadata.handle);
cheatList->takeItem(cheatList->row(listItem));
deleteLater();
}

const CheatMetadata& getMetadata() { return metadata; }
void setMetadata(const CheatMetadata& metadata) { this->metadata = metadata; }

private:
void checkboxChanged(int state);
void editClicked();

Emulator* emu;
CheatMetadata metadata;
u32 handle;
QLabel* name;
QCheckBox* enabled;
QListWidget* cheatList;
QListWidgetItem* listItem;
};

class CheatEditDialog : public QDialog {
public:
CheatEditDialog(Emulator* emu, CheatEntryWidget& cheatEntry);

void accepted();
void rejected();

private:
Emulator* emu;
CheatEntryWidget& cheatEntry;
QTextEdit* codeEdit;
QLineEdit* nameEdit;
};

CheatEntryWidget::CheatEntryWidget(Emulator* emu, CheatMetadata metadata, QListWidget* parent)
: QWidget(), emu(emu), metadata(metadata), cheatList(parent) {
QHBoxLayout* layout = new QHBoxLayout;
Expand Down Expand Up @@ -219,7 +159,7 @@ void CheatEditDialog::rejected() {

CheatsWindow::CheatsWindow(Emulator* emu, const std::filesystem::path& cheatPath, QWidget* parent)
: QWidget(parent, Qt::Window), emu(emu), cheatPath(cheatPath) {
mainWindow = static_cast<MainWindow*>(parent);
mainWindow = static_cast<MainWindow*>(parent);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins(6, 6, 6, 6);
Expand Down Expand Up @@ -265,4 +205,4 @@ void CheatsWindow::removeClicked() {

CheatEntryWidget* entry = static_cast<CheatEntryWidget*>(cheatList->itemWidget(item));
entry->Remove();
}
}
4 changes: 2 additions & 2 deletions src/panda_qt/mappings.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "input_mappings.hpp"

#include <QKeyEvent>

#include "input_mappings.hpp"

InputMappings InputMappings::defaultKeyboardMappings() {
InputMappings mappings;
mappings.setMapping(Qt::Key_L, HID::Keys::A);
Expand Down
3 changes: 2 additions & 1 deletion src/panda_qt/shader_editor.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "panda_qt/shader_editor.hpp"

#include <QPushButton>
#include <QVBoxLayout>

#include "panda_qt/main_window.hpp"
#include "panda_qt/shader_editor.hpp"

using namespace Zep;

Expand Down

0 comments on commit 699d2de

Please sign in to comment.