mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Resolution and FPS Settings
This commit is contained in:
parent
cbf51a7f82
commit
686ef011f8
5 changed files with 115 additions and 0 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "host.h"
|
||||
|
||||
#include <chiaki/session.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
class Settings : public QObject
|
||||
|
@ -40,6 +42,12 @@ class Settings : public QObject
|
|||
bool GetDiscoveryEnabled() { return settings.value("settings/auto_discovery", true).toBool(); }
|
||||
void SetDiscoveryEnabled(bool enabled) { settings.setValue("settings/auto_discovery", enabled); }
|
||||
|
||||
ChiakiVideoResolutionPreset GetResolution() const;
|
||||
void SetResolution(ChiakiVideoResolutionPreset resolution);
|
||||
|
||||
ChiakiVideoFPSPreset GetFPS() const;
|
||||
void SetFPS(ChiakiVideoFPSPreset fps);
|
||||
|
||||
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
||||
void AddRegisteredHost(const RegisteredHost &host);
|
||||
void RemoveRegisteredHost(const HostMAC &mac);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
class Settings;
|
||||
class QListWidget;
|
||||
class QComboBox;
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
|
@ -30,10 +31,16 @@ class SettingsDialog : public QDialog
|
|||
private:
|
||||
Settings *settings;
|
||||
|
||||
QComboBox *resolution_combo_box;
|
||||
QComboBox *fps_combo_box;
|
||||
|
||||
QListWidget *registered_hosts_list_widget;
|
||||
QPushButton *delete_registered_host_button;
|
||||
|
||||
private slots:
|
||||
void ResolutionSelected();
|
||||
void FPSSelected();
|
||||
|
||||
void UpdateRegisteredHosts();
|
||||
void UpdateRegisteredHostsButtons();
|
||||
void RegisterNewHost();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <settings.h>
|
||||
#include <registdialog.h>
|
||||
#include <settingsdialog.h>
|
||||
#include <streamsession.h>
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
|
|
@ -17,11 +17,53 @@
|
|||
|
||||
#include <settings.h>
|
||||
|
||||
#define SETTINGS_VERSION 1
|
||||
|
||||
Settings::Settings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
settings.setValue("version", SETTINGS_VERSION);
|
||||
LoadRegisteredHosts();
|
||||
}
|
||||
|
||||
static const QMap<ChiakiVideoResolutionPreset, QString> resolutions = {
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p"}
|
||||
};
|
||||
|
||||
static const ChiakiVideoResolutionPreset resolution_default = CHIAKI_VIDEO_RESOLUTION_PRESET_720p;
|
||||
|
||||
ChiakiVideoResolutionPreset Settings::GetResolution() const
|
||||
{
|
||||
auto s = settings.value("settings/resolution", resolutions[resolution_default]).toString();
|
||||
return resolutions.key(s, resolution_default);
|
||||
}
|
||||
|
||||
void Settings::SetResolution(ChiakiVideoResolutionPreset resolution)
|
||||
{
|
||||
settings.setValue("settings/resolution", resolutions[resolution]);
|
||||
}
|
||||
|
||||
static const QMap<ChiakiVideoFPSPreset, int> fps_values = {
|
||||
{ CHIAKI_VIDEO_FPS_PRESET_30, 30 },
|
||||
{ CHIAKI_VIDEO_FPS_PRESET_60, 60 }
|
||||
};
|
||||
|
||||
static const ChiakiVideoFPSPreset fps_default = CHIAKI_VIDEO_FPS_PRESET_60;
|
||||
|
||||
ChiakiVideoFPSPreset Settings::GetFPS() const
|
||||
{
|
||||
auto v = settings.value("settings/fps", fps_values[fps_default]).toInt();
|
||||
return fps_values.key(v, fps_default);
|
||||
}
|
||||
|
||||
void Settings::SetFPS(ChiakiVideoFPSPreset fps)
|
||||
{
|
||||
settings.setValue("settings/fps", fps_values[fps]);
|
||||
}
|
||||
|
||||
|
||||
void Settings::LoadRegisteredHosts()
|
||||
{
|
||||
registered_hosts.clear();
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QMap>
|
||||
|
||||
SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
@ -33,6 +36,50 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
|||
auto layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
// Stream Settings
|
||||
|
||||
auto stream_settings_group_box = new QGroupBox(tr("Stream Settings"));
|
||||
layout->addWidget(stream_settings_group_box);
|
||||
|
||||
auto stream_settings_layout = new QFormLayout();
|
||||
stream_settings_group_box->setLayout(stream_settings_layout);
|
||||
|
||||
resolution_combo_box = new QComboBox(this);
|
||||
static const QList<QPair<ChiakiVideoResolutionPreset, const char *>> resolution_strings = {
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p"},
|
||||
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p"}
|
||||
};
|
||||
auto current_res = settings->GetResolution();
|
||||
for(const auto &p : resolution_strings)
|
||||
{
|
||||
resolution_combo_box->addItem(tr(p.second), (int)p.first);
|
||||
if(current_res == p.first)
|
||||
resolution_combo_box->setCurrentIndex(resolution_combo_box->count() - 1);
|
||||
}
|
||||
connect(resolution_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(ResolutionSelected()));
|
||||
stream_settings_layout->addRow(tr("Resolution:"), resolution_combo_box);
|
||||
|
||||
fps_combo_box = new QComboBox(this);
|
||||
static const QList<QPair<ChiakiVideoFPSPreset, QString>> fps_strings = {
|
||||
{ CHIAKI_VIDEO_FPS_PRESET_30, "30" },
|
||||
{ CHIAKI_VIDEO_FPS_PRESET_60, "60" }
|
||||
};
|
||||
auto current_fps = settings->GetFPS();
|
||||
for(const auto &p : fps_strings)
|
||||
{
|
||||
fps_combo_box->addItem(p.second, (int)p.first);
|
||||
if(current_fps == p.first)
|
||||
fps_combo_box->setCurrentIndex(fps_combo_box->count() - 1);
|
||||
}
|
||||
connect(fps_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(FPSSelected()));
|
||||
stream_settings_layout->addRow(tr("FPS:"), fps_combo_box);
|
||||
|
||||
|
||||
// Registered Consoles
|
||||
|
||||
auto registered_hosts_group_box = new QGroupBox(tr("Registered Consoles"));
|
||||
layout->addWidget(registered_hosts_group_box);
|
||||
|
||||
|
@ -66,6 +113,16 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
|||
connect(registered_hosts_list_widget, &QListWidget::itemSelectionChanged, this, &SettingsDialog::UpdateRegisteredHostsButtons);
|
||||
}
|
||||
|
||||
void SettingsDialog::ResolutionSelected()
|
||||
{
|
||||
settings->SetResolution((ChiakiVideoResolutionPreset)resolution_combo_box->currentData().toInt());
|
||||
}
|
||||
|
||||
void SettingsDialog::FPSSelected()
|
||||
{
|
||||
settings->SetFPS((ChiakiVideoFPSPreset)fps_combo_box->currentData().toInt());
|
||||
}
|
||||
|
||||
void SettingsDialog::UpdateRegisteredHosts()
|
||||
{
|
||||
registered_hosts_list_widget->clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue