Skip to content

Commit 237ad98

Browse files
author
Gin
committed
fix menubar not shown and wrong button mapping path
1 parent 64c9ef4 commit 237ad98

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

SerialPrograms/Source/CommonFramework/Main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ void set_working_directory(){
4646

4747
int main(int argc, char *argv[]){
4848
setup_crash_handler();
49+
#if defined(__linux) || defined(__APPLE__)
50+
// fix for menubar not showing in macOS and potentially on Linux
51+
// we use menubar in our ButtonDiagram window to choose which controller's button mapping image to show
52+
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
53+
#endif
4954

5055
//#if QT_VERSION_MAJOR == 5 // AA_EnableHighDpiScaling is deprecated in Qt6
5156
// QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

SerialPrograms/Source/CommonFramework/Windows/ButtonDiagram.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
#include "WindowTracker.h"
1212
#include "ButtonDiagram.h"
1313

14-
//#include <iostream>
15-
//using std::cout;
16-
//using std::endl;
14+
// #include <iostream>
15+
// using std::cout;
16+
// using std::endl;
1717

1818

1919
namespace PokemonAutomation{
2020

21+
const char* PRO_CONTROLLER_MAPPING_PATH = "/NintendoSwitch/Layout-ProController.png";
22+
const char* JOYCON_VERTICAL_MAPPING_PATH = "/NintendoSwitch/Layout-JoyconVertical.png";
23+
const char* JOYCON_HORIZONTAL_MAPPING_PATH = "/NintendoSwitch/Layout-JoyconHorizontal.png";
24+
2125

2226
ButtonDiagram::ButtonDiagram(QWidget* parent)
2327
: QMainWindow(parent)
@@ -34,25 +38,22 @@ ButtonDiagram::ButtonDiagram(QWidget* parent)
3438
connect(
3539
pro_controller, &QMenu::aboutToShow,
3640
this, [this](){
37-
set_image("/NintendoSwitch/Layout-ProController.png");
41+
set_image(PRO_CONTROLLER_MAPPING_PATH);
3842
}
3943
);
4044
connect(
4145
joycon_vertical, &QMenu::aboutToShow,
4246
this, [this](){
43-
set_image("/NintendoSwitch/Layout-JoyconVertical.png");
47+
set_image(JOYCON_VERTICAL_MAPPING_PATH);
4448
}
4549
);
4650
connect(
4751
joycon_horizontal, &QMenu::aboutToShow,
4852
this, [this](){
49-
set_image("/NintendoSwitch/Layout-JoyconHorizontal.png");
53+
set_image(JOYCON_HORIZONTAL_MAPPING_PATH);
5054
}
5155
);
5256

53-
54-
// m_image = QPixmap(QString::fromStdString(RESOURCE_PATH() + "/NintendoSwitch/Layout-ProController.jpg"));
55-
5657
m_image_label = new QLabel(this);
5758
setCentralWidget(m_image_label);
5859
m_image_label->setAlignment(Qt::AlignCenter);
@@ -66,7 +67,7 @@ ButtonDiagram::ButtonDiagram(QWidget* parent)
6667

6768
resize(800, 600 + menu->sizeHint().height());
6869

69-
set_image("/NintendoSwitch/Layout-ProController.jpg");
70+
set_image(PRO_CONTROLLER_MAPPING_PATH);
7071

7172
add_window(*this);
7273
}
@@ -75,7 +76,8 @@ ButtonDiagram::~ButtonDiagram(){
7576
}
7677

7778
void ButtonDiagram::set_image(const std::string& resource_name){
78-
m_image = QPixmap(QString::fromStdString(RESOURCE_PATH() + resource_name));
79+
const std::string image_path = RESOURCE_PATH() + resource_name;
80+
m_image = QPixmap(QString::fromStdString(image_path));
7981
ButtonDiagram::resizeEvent(nullptr);
8082
}
8183
void ButtonDiagram::resizeEvent(QResizeEvent*){

SerialPrograms/Source/CommonFramework/Windows/ButtonDiagram.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace PokemonAutomation{
1111

12+
// The window that shows button mapping: which keyboard keys are mapped to which
13+
// Switch controller buttons.
1214
class ButtonDiagram : public QMainWindow{
1315
public:
1416
ButtonDiagram(QWidget* parent = nullptr);

0 commit comments

Comments
 (0)