parent
8a3a8b7c68
commit
faf7cf752d
|
@ -34,6 +34,8 @@ InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(pare
|
|||
ui->cbMouseHide->setChecked(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setEnabled(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds);
|
||||
ui->cbPauseLostFocus->setChecked(Config::PauseLostFocus != 0);
|
||||
oldPauseLostFocusVal = ui->cbPauseLostFocus->isChecked() ? 1:0;
|
||||
}
|
||||
|
||||
InterfaceSettingsDialog::~InterfaceSettingsDialog()
|
||||
|
@ -59,6 +61,7 @@ void InterfaceSettingsDialog::done(int r)
|
|||
{
|
||||
Config::MouseHide = ui->cbMouseHide->isChecked() ? 1:0;
|
||||
Config::MouseHideSeconds = ui->spinMouseHideSeconds->value();
|
||||
Config::PauseLostFocus = ui->cbPauseLostFocus->isChecked() ? 1:0;
|
||||
|
||||
Config::Save();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>209</width>
|
||||
<height>110</height>
|
||||
<width>262</width>
|
||||
<height>113</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -20,31 +20,31 @@
|
|||
<string>Interface settings - melonDS</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="cbMouseHide">
|
||||
<property name="text">
|
||||
<string>Hide mouse after inactivity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="0" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Hide after</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinMouseHideSeconds"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="cbPauseLostFocus">
|
||||
<property name="text">
|
||||
<string>seconds of inactivity</string>
|
||||
<string>Pause emulation when window is not in focus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QCheckBox" name="cbMouseHide">
|
||||
<property name="text">
|
||||
<string>Hide mouse after inactivity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="QSpinBox" name="spinMouseHideSeconds"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -54,6 +54,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>seconds of inactivity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -80,6 +80,8 @@ int EnableCheats;
|
|||
int MouseHide;
|
||||
int MouseHideSeconds;
|
||||
|
||||
int PauseLostFocus;
|
||||
|
||||
bool EnableJIT;
|
||||
|
||||
ConfigEntry PlatformConfigFile[] =
|
||||
|
@ -188,8 +190,9 @@ ConfigEntry PlatformConfigFile[] =
|
|||
|
||||
{"EnableCheats", 0, &EnableCheats, 0, NULL, 0},
|
||||
|
||||
{"MouseHide", 0, &MouseHide, 0, NULL, 0},
|
||||
{"MouseHide", 0, &MouseHide, 0, NULL, 0},
|
||||
{"MouseHideSeconds", 0, &MouseHideSeconds, 5, NULL, 0},
|
||||
{"PauseLostFocus", 0, &PauseLostFocus, 0, NULL, 0},
|
||||
|
||||
{"", -1, NULL, 0, NULL, 0}
|
||||
};
|
||||
|
|
|
@ -94,6 +94,7 @@ extern int EnableCheats;
|
|||
|
||||
extern int MouseHide;
|
||||
extern int MouseHideSeconds;
|
||||
extern int PauseLostFocus;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1534,6 +1534,19 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onAppStateChanged(Qt::ApplicationState state)
|
||||
{
|
||||
if (state == Qt::ApplicationInactive)
|
||||
{
|
||||
if (Config::PauseLostFocus && emuThread->emuIsRunning())
|
||||
emuThread->emuPause();
|
||||
}
|
||||
else if (state == Qt::ApplicationActive)
|
||||
{
|
||||
if (Config::PauseLostFocus && !pausedManually)
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
}
|
||||
|
||||
QString MainWindow::loadErrorStr(int error)
|
||||
{
|
||||
|
@ -2002,11 +2015,13 @@ void MainWindow::onPause(bool checked)
|
|||
{
|
||||
emuThread->emuPause();
|
||||
OSD::AddMessage(0, "Paused");
|
||||
pausedManually = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
OSD::AddMessage(0, "Resumed");
|
||||
pausedManually = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2152,6 +2167,7 @@ void MainWindow::onOpenInterfaceSettings()
|
|||
InterfaceSettingsDialog* dlg = InterfaceSettingsDialog::openDlg(this);
|
||||
connect(dlg, &InterfaceSettingsDialog::finished, this, &MainWindow::onInterfaceSettingsFinished);
|
||||
connect(dlg, &InterfaceSettingsDialog::updateMouseTimer, this, &MainWindow::onUpdateMouseTimer);
|
||||
connect(dlg, &InterfaceSettingsDialog::focusUnpauseEmu, emuThread, &EmuThread::emuUnpause);
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateMouseTimer()
|
||||
|
@ -2505,6 +2521,8 @@ int main(int argc, char** argv)
|
|||
emuThread->start();
|
||||
emuThread->emuPause();
|
||||
|
||||
QObject::connect(&melon, &QApplication::applicationStateChanged, mainWindow, &MainWindow::onAppStateChanged);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
char* file = argv[1];
|
||||
|
|
|
@ -184,6 +184,8 @@ public:
|
|||
|
||||
bool hasOGL;
|
||||
QOpenGLContext* getOGLContext();
|
||||
|
||||
void onAppStateChanged(Qt::ApplicationState state);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
@ -262,6 +264,8 @@ private:
|
|||
void createScreenPanel();
|
||||
|
||||
QString loadErrorStr(int error);
|
||||
|
||||
bool pausedManually;
|
||||
|
||||
public:
|
||||
QWidget* panel;
|
||||
|
|
Loading…
Reference in New Issue