Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions src/frontend/qt_sdl/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,31 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
actScreenGap[i]->setData(QVariant(data));
actScreenGap[i]->setCheckable(true);
}

submenu->addSeparator();

actScreenGap[6] = submenu->addAction(QString("Custom"));
actScreenGap[6]->setActionGroup(grpScreenGap);
actScreenGap[6]->setCheckable(true);

actScreenGapTextbox = new QLineEdit(QString("0"), submenu);
actScreenGapTextbox->setValidator(new QIntValidator(screengap[0], screengap[5]));
actScreenGapTextbox->setFixedWidth(submenu->width());

QWidgetAction* customGapWidget = new QWidgetAction(submenu);
customGapWidget->setDefaultWidget(actScreenGapTextbox);
submenu->addAction(customGapWidget);

connect(actScreenGapTextbox, &QLineEdit::editingFinished, [&]()
{
if (!actScreenGapTextbox->text().isEmpty())
{
const int customGap = actScreenGapTextbox->text().toInt();
actScreenGap[6]->setData(QVariant(customGap));
actScreenGap[6]->setChecked(true);
onChangeScreenGap(actScreenGap[6]);
}
});
connect(grpScreenGap, &QActionGroup::triggered, this, &MainWindow::onChangeScreenGap);
}
{
Expand Down Expand Up @@ -753,12 +777,16 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
actScreenRotation[windowCfg.GetInt("ScreenRotation")]->setChecked(true);

int screenGap = windowCfg.GetInt("ScreenGap");
for (int i = 0; i < 6; i++)

if (!actScreenGap[6]->isChecked())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is actScreenGap[6] pre-set to checked here? Feels to me like the below for loop should instead be adjusted so that if none of the default gap sizes are checked, the "Custom" checkbox is checked.

{
if (actScreenGap[i]->data().toInt() == screenGap)
for (int i = 0; i < 6; i++)
{
actScreenGap[i]->setChecked(true);
break;
if (actScreenGap[i]->data().toInt() == screenGap)
{
actScreenGap[i]->setChecked(true);
break;
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/frontend/qt_sdl/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <QMutex>
#include <QScreen>
#include <QCloseEvent>
#include <QWidgetAction>
#include <QLineEdit>

#include "Screen.h"
#include "Config.h"
Expand Down Expand Up @@ -335,7 +337,8 @@ private slots:
QActionGroup* grpScreenRotation;
QAction* actScreenRotation[screenRot_MAX];
QActionGroup* grpScreenGap;
QAction* actScreenGap[6];
QAction* actScreenGap[7];
QLineEdit* actScreenGapTextbox;
QActionGroup* grpScreenLayout;
QAction* actScreenLayout[screenLayout_MAX];
QAction* actScreenSwap;
Expand Down