update gui

This commit is contained in:
Logan McNaughton committed 2020-06-04 15:40:34 -06:00
1 parent b91567adf9
commit 2ab0a9b139
5 files changed
+65

No files matched your search

+29
View File
@@ -35,6 +35,7 @@ void MainWindow::updatePlugins()
Filter.append("");
QStringList current;
QString default_value;
if (!settings->contains("videoPlugin")) {
Filter.replace(0,"mupen64plus-video*");
current = PluginDir.entryList(Filter);
@@ -402,6 +403,14 @@ MainWindow::MainWindow(QWidget *parent) :
qtConfigDir = settings->value("configDirPath").toString();
updatePlugins();
if (!settings->contains("volume"))
settings->setValue("volume", 100);
VolumeAction * volumeAction = new VolumeAction(tr("Volume"));
connect(volumeAction->slider(), SIGNAL(valueChanged(int)), this, SLOT(volumeValueChanged(int)));
volumeAction->slider()->setValue(settings->value("volume").toInt());
ui->menuFile->insertAction(ui->actionTake_Screenshot, volumeAction);
ui->menuFile->insertSeparator(volumeAction);
}
MainWindow::~MainWindow()
@@ -410,6 +419,16 @@ MainWindow::~MainWindow()
delete ui;
}
void MainWindow::volumeValueChanged(int value)
{
if (value != settings->value("volume").toInt())
{
settings->setValue("volume", value);
if (coreStarted)
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_AUDIO_VOLUME, &value);
}
}
void MainWindow::setVerbose()
{
verbose = 1;
@@ -598,6 +617,16 @@ void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port,
connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
workerThread->start();
while (!coreStarted) QCoreApplication::processEvents();
int response = 0;
while (response != M64EMU_RUNNING)
{
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &response);
QCoreApplication::processEvents();
}
int volume = w->getSettings()->value("volume").toInt();
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_AUDIO_VOLUME, &volume);
QStringList list;
if (settings->contains("RecentROMs"))
list = settings->value("RecentROMs").toString().split(";");
+30
View File
@@ -9,6 +9,9 @@
#include <QMainWindow>
#include <QSettings>
#include <QSurfaceFormat>
#include <QWidgetAction>
#include <QSlider>
#include <QLabel>
namespace Ui {
class MainWindow;
@@ -49,6 +52,8 @@ public slots:
void showMessage(QString message);
private slots:
void volumeValueChanged(int value);
void on_actionOpen_ROM_triggered();
void on_actionPlugin_Paths_triggered();
@@ -120,4 +125,29 @@ private:
extern MainWindow *w;
class VolumeAction : public QWidgetAction {
public:
VolumeAction (const QString& title) :
QWidgetAction (NULL) {
QWidget* pWidget = new QWidget (NULL);
QHBoxLayout* pLayout = new QHBoxLayout();
QLabel* pLabel = new QLabel (title);
pLayout->addWidget (pLabel);
pSlider = new QSlider(Qt::Horizontal);
pSlider->setMinimum(0);
pSlider->setMaximum(100);
pLayout->addWidget (pSlider);
pWidget->setLayout (pLayout);
setDefaultWidget(pWidget);
}
QSlider * slider () {
return pSlider;
}
private:
QSlider * pSlider;
};
#endif // MAINWINDOW_H
+2
View File
@@ -34,6 +34,8 @@ CreateRoom::CreateRoom(QWidget *parent)
QLabel *playerNameLabel = new QLabel("Player Name", this);
layout->addWidget(playerNameLabel, 3, 0);
playerNameEdit = new QLineEdit(this);
if (w->getSettings()->contains("netplay_name"))
playerNameEdit->setText(w->getSettings()->value("netplay_name").toString());
layout->addWidget(playerNameEdit, 3, 1);
QLabel *serverLabel = new QLabel("Server", this);
+2
View File
@@ -19,6 +19,8 @@ JoinRoom::JoinRoom(QWidget *parent)
layout->setColumnMinimumWidth(1, 500);
playerName = new QLineEdit(this);
if (w->getSettings()->contains("netplay_name"))
playerName->setText(w->getSettings()->value("netplay_name").toString());
playerName->setPlaceholderText("Player Name");
layout->addWidget(playerName, 0, 0);
+2
View File
@@ -13,6 +13,8 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
room_name = room.value("room_name").toString();
file_name = filename;
w->getSettings()->setValue("netplay_name", player_name);
webSocket = socket;
connect(webSocket, &QWebSocket::binaryMessageReceived,
this, &WaitRoom::processBinaryMessage);