Add option to hide mouse on inactivity (#955)
Also allow user to specify how long to wait before hiding
This commit is contained in:
parent
1494d7aa24
commit
bf0ea26596
|
@ -9,6 +9,7 @@ SET(SOURCES_QT_SDL
|
|||
VideoSettingsDialog.cpp
|
||||
AudioSettingsDialog.cpp
|
||||
WifiSettingsDialog.cpp
|
||||
InterfaceSettingsDialog.cpp
|
||||
Input.cpp
|
||||
LAN_PCap.cpp
|
||||
LAN_Socket.cpp
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright 2016-2021 Arisotura, WaluigiWare64
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include "InterfaceSettingsDialog.h"
|
||||
#include "ui_InterfaceSettingsDialog.h"
|
||||
|
||||
#include "types.h"
|
||||
#include "Platform.h"
|
||||
#include "Config.h"
|
||||
#include "PlatformConfig.h"
|
||||
|
||||
InterfaceSettingsDialog* InterfaceSettingsDialog::currentDlg = nullptr;
|
||||
|
||||
InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::InterfaceSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
ui->cbMouseHide->setChecked(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setEnabled(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds);
|
||||
}
|
||||
|
||||
InterfaceSettingsDialog::~InterfaceSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void InterfaceSettingsDialog::on_cbMouseHide_clicked()
|
||||
{
|
||||
if (ui->spinMouseHideSeconds->isEnabled())
|
||||
{
|
||||
ui->spinMouseHideSeconds->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->spinMouseHideSeconds->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void InterfaceSettingsDialog::done(int r)
|
||||
{
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
Config::MouseHide = ui->cbMouseHide->isChecked() ? 1:0;
|
||||
Config::MouseHideSeconds = ui->spinMouseHideSeconds->value();
|
||||
|
||||
Config::Save();
|
||||
|
||||
emit updateMouseTimer();
|
||||
}
|
||||
|
||||
QDialog::done(r);
|
||||
|
||||
closeDlg();
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
Copyright 2016-2021 Arisotura, WaluigiWare64
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef INTERFACESETTINGSDIALOG_H
|
||||
#define INTERFACESETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui { class InterfaceSettingsDialog; }
|
||||
class InterfaceSettingsDialog;
|
||||
|
||||
class InterfaceSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceSettingsDialog(QWidget* parent);
|
||||
~InterfaceSettingsDialog();
|
||||
|
||||
static InterfaceSettingsDialog* currentDlg;
|
||||
static InterfaceSettingsDialog* openDlg(QWidget* parent)
|
||||
{
|
||||
if (currentDlg)
|
||||
{
|
||||
currentDlg->activateWindow();
|
||||
return currentDlg;
|
||||
}
|
||||
|
||||
currentDlg = new InterfaceSettingsDialog(parent);
|
||||
currentDlg->open();
|
||||
return currentDlg;
|
||||
}
|
||||
static void closeDlg()
|
||||
{
|
||||
currentDlg = nullptr;
|
||||
}
|
||||
|
||||
signals:
|
||||
void updateMouseTimer();
|
||||
|
||||
private slots:
|
||||
void done(int r);
|
||||
|
||||
void on_cbMouseHide_clicked();
|
||||
|
||||
private:
|
||||
Ui::InterfaceSettingsDialog* ui;
|
||||
};
|
||||
|
||||
#endif // INTERFACESETTINGSDIALOG_H
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InterfaceSettingsDialog</class>
|
||||
<widget class="QDialog" name="InterfaceSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>209</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<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">
|
||||
<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">
|
||||
<property name="text">
|
||||
<string>seconds of inactivity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>InterfaceSettingsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>InterfaceSettingsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -77,6 +77,9 @@ char RecentROMList[10][1024];
|
|||
|
||||
int EnableCheats;
|
||||
|
||||
int MouseHide;
|
||||
int MouseHideSeconds;
|
||||
|
||||
bool EnableJIT;
|
||||
|
||||
ConfigEntry PlatformConfigFile[] =
|
||||
|
@ -185,6 +188,9 @@ ConfigEntry PlatformConfigFile[] =
|
|||
|
||||
{"EnableCheats", 0, &EnableCheats, 0, NULL, 0},
|
||||
|
||||
{"MouseHide", 0, &MouseHide, 0, NULL, 0},
|
||||
{"MouseHideSeconds", 0, &MouseHideSeconds, 5, NULL, 0},
|
||||
|
||||
{"", -1, NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ extern char RecentROMList[10][1024];
|
|||
|
||||
extern int EnableCheats;
|
||||
|
||||
extern int MouseHide;
|
||||
extern int MouseHideSeconds;
|
||||
|
||||
}
|
||||
|
||||
#endif // PLATFORMCONFIG_H
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "VideoSettingsDialog.h"
|
||||
#include "AudioSettingsDialog.h"
|
||||
#include "WifiSettingsDialog.h"
|
||||
#include "InterfaceSettingsDialog.h"
|
||||
|
||||
#include "types.h"
|
||||
#include "version.h"
|
||||
|
@ -719,6 +720,9 @@ void ScreenHandler::screenOnMouseRelease(QMouseEvent* event)
|
|||
void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
|
||||
showCursor();
|
||||
|
||||
if (!(event->buttons() & Qt::LeftButton)) return;
|
||||
if (!touching) return;
|
||||
|
||||
|
@ -736,6 +740,21 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
|||
NDS::TouchScreen(x, y);
|
||||
}
|
||||
|
||||
void ScreenHandler::showCursor()
|
||||
{
|
||||
mainWindow->panel->setCursor(Qt::ArrowCursor);
|
||||
mouseTimer->start();
|
||||
}
|
||||
|
||||
QTimer* ScreenHandler::setupMouseTimer()
|
||||
{
|
||||
mouseTimer = new QTimer();
|
||||
mouseTimer->setSingleShot(true);
|
||||
mouseTimer->setInterval(Config::MouseHideSeconds*1000);
|
||||
mouseTimer->start();
|
||||
|
||||
return mouseTimer;
|
||||
}
|
||||
|
||||
ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -753,6 +772,7 @@ ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent)
|
|||
ScreenPanelNative::~ScreenPanelNative()
|
||||
{
|
||||
OSD::DeInit(nullptr);
|
||||
mouseTimer->stop();
|
||||
}
|
||||
|
||||
void ScreenPanelNative::setupScreenLayout()
|
||||
|
@ -836,6 +856,8 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent)
|
|||
|
||||
ScreenPanelGL::~ScreenPanelGL()
|
||||
{
|
||||
mouseTimer->stop();
|
||||
|
||||
makeCurrent();
|
||||
|
||||
OSD::DeInit(this);
|
||||
|
@ -1167,6 +1189,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
|
||||
actWifiSettings = menu->addAction("Wifi settings");
|
||||
connect(actWifiSettings, &QAction::triggered, this, &MainWindow::onOpenWifiSettings);
|
||||
|
||||
actInterfaceSettings = menu->addAction("Interface settings");
|
||||
connect(actInterfaceSettings, &QAction::triggered, this, &MainWindow::onOpenInterfaceSettings);
|
||||
|
||||
{
|
||||
QMenu* submenu = menu->addMenu("Savestate settings");
|
||||
|
@ -1342,9 +1367,11 @@ void MainWindow::createScreenPanel()
|
|||
{
|
||||
hasOGL = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);
|
||||
|
||||
QTimer* mouseTimer;
|
||||
|
||||
if (hasOGL)
|
||||
{
|
||||
ScreenPanelGL* panelGL = new ScreenPanelGL(this);
|
||||
panelGL = new ScreenPanelGL(this);
|
||||
panelGL->show();
|
||||
|
||||
if (!panelGL->isValid())
|
||||
|
@ -1358,17 +1385,25 @@ void MainWindow::createScreenPanel()
|
|||
|
||||
if (!hasOGL)
|
||||
delete panelGL;
|
||||
else
|
||||
panel = panelGL;
|
||||
|
||||
panel = panelGL;
|
||||
panelGL->setMouseTracking(true);
|
||||
mouseTimer = panelGL->setupMouseTimer();
|
||||
connect(mouseTimer, &QTimer::timeout, [=] { if (Config::MouseHide) panelGL->setCursor(Qt::BlankCursor);});
|
||||
}
|
||||
|
||||
if (!hasOGL)
|
||||
{
|
||||
panel = new ScreenPanelNative(this);
|
||||
panelNative = new ScreenPanelNative(this);
|
||||
panel = panelNative;
|
||||
panel->show();
|
||||
|
||||
panelNative->setMouseTracking(true);
|
||||
mouseTimer = panelNative->setupMouseTimer();
|
||||
connect(mouseTimer, &QTimer::timeout, [=] { if (Config::MouseHide) panelNative->setCursor(Qt::BlankCursor);});
|
||||
}
|
||||
|
||||
setCentralWidget(panel);
|
||||
|
||||
connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged()));
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
@ -1997,6 +2032,27 @@ void MainWindow::onWifiSettingsFinished(int res)
|
|||
emuThread->emuUnpause();
|
||||
}
|
||||
|
||||
void MainWindow::onOpenInterfaceSettings()
|
||||
{
|
||||
emuThread->emuPause();
|
||||
InterfaceSettingsDialog* dlg = InterfaceSettingsDialog::openDlg(this);
|
||||
connect(dlg, &InterfaceSettingsDialog::finished, this, &MainWindow::onInterfaceSettingsFinished);
|
||||
connect(dlg, &InterfaceSettingsDialog::updateMouseTimer, this, &MainWindow::onUpdateMouseTimer);
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateMouseTimer()
|
||||
{
|
||||
if (hasOGL)
|
||||
panelGL->mouseTimer->setInterval(Config::MouseHideSeconds*1000);
|
||||
else
|
||||
panelNative->mouseTimer->setInterval(Config::MouseHideSeconds*1000);
|
||||
}
|
||||
|
||||
void MainWindow::onInterfaceSettingsFinished(int res)
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeSavestateSRAMReloc(bool checked)
|
||||
{
|
||||
Config::SavestateRelocSRAM = checked?1:0;
|
||||
|
@ -2182,8 +2238,15 @@ void MainWindow::onUpdateVideoSettings(bool glchange)
|
|||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
if (hasOGL) emuThread->deinitOpenGL();
|
||||
delete panel;
|
||||
if (hasOGL)
|
||||
{
|
||||
emuThread->deinitOpenGL();
|
||||
delete panelGL;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete panelNative;
|
||||
}
|
||||
createScreenPanel();
|
||||
connect(emuThread, SIGNAL(windowUpdate()), panel, SLOT(update()));
|
||||
if (hasOGL) emuThread->initOpenGL();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QImage>
|
||||
#include <QActionGroup>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLWidget>
|
||||
|
@ -91,6 +92,9 @@ class ScreenHandler
|
|||
|
||||
public:
|
||||
virtual ~ScreenHandler() {}
|
||||
QTimer* setupMouseTimer();
|
||||
void updateMouseTimer();
|
||||
QTimer* mouseTimer;
|
||||
|
||||
protected:
|
||||
void screenSetupLayout(int w, int h);
|
||||
|
@ -104,6 +108,8 @@ protected:
|
|||
float screenMatrix[2][6];
|
||||
|
||||
bool touching;
|
||||
|
||||
void showCursor();
|
||||
};
|
||||
|
||||
|
||||
|
@ -219,6 +225,9 @@ private slots:
|
|||
void onAudioSettingsFinished(int res);
|
||||
void onOpenWifiSettings();
|
||||
void onWifiSettingsFinished(int res);
|
||||
void onOpenInterfaceSettings();
|
||||
void onInterfaceSettingsFinished(int res);
|
||||
void onUpdateMouseTimer();
|
||||
void onChangeSavestateSRAMReloc(bool checked);
|
||||
void onChangeScreenSize();
|
||||
void onChangeScreenRotation(QAction* act);
|
||||
|
@ -253,6 +262,8 @@ private:
|
|||
|
||||
public:
|
||||
QWidget* panel;
|
||||
ScreenPanelGL* panelGL;
|
||||
ScreenPanelNative* panelNative;
|
||||
|
||||
QAction* actOpenROM;
|
||||
QAction* actOpenROMArchive;
|
||||
|
@ -274,6 +285,7 @@ public:
|
|||
QAction* actVideoSettings;
|
||||
QAction* actAudioSettings;
|
||||
QAction* actWifiSettings;
|
||||
QAction* actInterfaceSettings;
|
||||
QAction* actSavestateSRAMReloc;
|
||||
QAction* actScreenSize[4];
|
||||
QActionGroup* grpScreenRotation;
|
||||
|
|
Loading…
Reference in New Issue