1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-09 09:39:53 +00:00

functor-based Qt signal-slot syntax launcher

This commit is contained in:
mpeco 2022-08-23 14:35:54 -03:00
parent 9040209046
commit aa57d04b54
9 changed files with 63 additions and 67 deletions

View File

@ -128,7 +128,7 @@ bool Launcher::AdvancedPage::loadSettings()
antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked); antialiasAlphaTestCheckBox->setCheckState(Qt::Unchecked);
} }
loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game"); loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
connect(animSourcesCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotAnimSourcesToggled(bool))); connect(animSourcesCheckBox, &QCheckBox::toggled, this, &AdvancedPage::slotAnimSourcesToggled);
loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game"); loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game");
if (animSourcesCheckBox->checkState() != Qt::Unchecked) if (animSourcesCheckBox->checkState() != Qt::Unchecked)
{ {
@ -150,12 +150,12 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game"); loadSettingBool(nightDaySwitchesCheckBox, "day night switches", "Game");
connect(postprocessEnabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotPostProcessToggled(bool))); connect(postprocessEnabledCheckBox, &QCheckBox::toggled, this, &AdvancedPage::slotPostProcessToggled);
loadSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing"); loadSettingBool(postprocessEnabledCheckBox, "enabled", "Post Processing");
loadSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing"); loadSettingBool(postprocessTransparentPostpassCheckBox, "transparent postpass", "Post Processing");
postprocessHDRTimeComboBox->setValue(Settings::Manager::getDouble("auto exposure speed", "Post Processing")); postprocessHDRTimeComboBox->setValue(Settings::Manager::getDouble("auto exposure speed", "Post Processing"));
connect(skyBlendingCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotSkyBlendingToggled(bool))); connect(skyBlendingCheckBox, &QCheckBox::toggled, this, &AdvancedPage::slotSkyBlendingToggled);
loadSettingBool(radialFogCheckBox, "radial fog", "Fog"); loadSettingBool(radialFogCheckBox, "radial fog", "Fog");
loadSettingBool(exponentialFogCheckBox, "exponential fog", "Fog"); loadSettingBool(exponentialFogCheckBox, "exponential fog", "Fog");
loadSettingBool(skyBlendingCheckBox, "sky blending", "Fog"); loadSettingBool(skyBlendingCheckBox, "sky blending", "Fog");
@ -320,7 +320,7 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(skyBlendingCheckBox, "sky blending", "Fog"); saveSettingBool(skyBlendingCheckBox, "sky blending", "Fog");
Settings::Manager::setDouble("sky blending start", "Fog", skyBlendingStartComboBox->value()); Settings::Manager::setDouble("sky blending start", "Fog", skyBlendingStartComboBox->value());
} }
// Audio // Audio
{ {
int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex(); int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex();

View File

@ -132,10 +132,10 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this); mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this); mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this);
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), connect(mNewProfileDialog->lineEdit(), &LineEdit::textChanged,
this, SLOT(updateNewProfileOkButton(QString))); this, &DataFilesPage::updateNewProfileOkButton);
connect(mCloneProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), connect(mCloneProfileDialog->lineEdit(), &LineEdit::textChanged,
this, SLOT(updateCloneProfileOkButton(QString))); this, &DataFilesPage::updateCloneProfileOkButton);
connect(ui.directoryAddSubdirsButton, &QPushButton::released, this, [this]() { this->addSubdirectories(true); }); connect(ui.directoryAddSubdirsButton, &QPushButton::released, this, [this]() { this->addSubdirectories(true); });
connect(ui.directoryInsertButton, &QPushButton::released, this, [this]() { this->addSubdirectories(false); }); connect(ui.directoryInsertButton, &QPushButton::released, this, [this]() { this->addSubdirectories(false); });
connect(ui.directoryUpButton, &QPushButton::released, this, [this]() { this->moveDirectory(-1); }); connect(ui.directoryUpButton, &QPushButton::released, this, [this]() { this->moveDirectory(-1); });
@ -150,8 +150,8 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
// Connect signal and slot after the settings have been loaded. We only care about the user changing // Connect signal and slot after the settings have been loaded. We only care about the user changing
// the addons and don't want to get signals of the system doing it during startup. // the addons and don't want to get signals of the system doing it during startup.
connect(mSelector, SIGNAL(signalAddonDataChanged(QModelIndex,QModelIndex)), connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged,
this, SLOT(slotAddonDataChanged())); this, &DataFilesPage::slotAddonDataChanged);
// Call manually to indicate all changes to addon data during startup. // Call manually to indicate all changes to addon data during startup.
slotAddonDataChanged(); slotAddonDataChanged();
} }
@ -177,23 +177,24 @@ void Launcher::DataFilesPage::buildView()
refreshButton->setDefaultAction(ui.refreshDataFilesAction); refreshButton->setDefaultAction(ui.refreshDataFilesAction);
//establish connections //establish connections
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)), connect (ui.profilesComboBox, qOverload<int>(&::ProfilesComboBox::currentIndexChanged),
this, SLOT (slotProfileChanged(int))); this, &DataFilesPage::slotProfileChanged);
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString, QString)), connect (ui.profilesComboBox, &::ProfilesComboBox::profileRenamed,
this, SLOT (slotProfileRenamed(QString, QString))); this, &DataFilesPage::slotProfileRenamed);
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString, QString)), connect (ui.profilesComboBox, qOverload<const QString&,const QString&>(&::ProfilesComboBox::signalProfileChanged),
this, SLOT (slotProfileChangedByUser(QString, QString))); this, &DataFilesPage::slotProfileChangedByUser);
connect(ui.refreshDataFilesAction, SIGNAL(triggered()),this, SLOT(slotRefreshButtonClicked())); connect(ui.refreshDataFilesAction, &QAction::triggered,
this, &DataFilesPage::slotRefreshButtonClicked);
connect(ui.updateNavMeshButton, SIGNAL(clicked()), this, SLOT(startNavMeshTool())); connect(ui.updateNavMeshButton, &QPushButton::clicked, this, &DataFilesPage::startNavMeshTool);
connect(ui.cancelNavMeshButton, SIGNAL(clicked()), this, SLOT(killNavMeshTool())); connect(ui.cancelNavMeshButton, &QPushButton::clicked, this, &DataFilesPage::killNavMeshTool);
connect(mNavMeshToolInvoker->getProcess(), SIGNAL(readyReadStandardOutput()), this, SLOT(readNavMeshToolStdout())); connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardOutput, this, &DataFilesPage::readNavMeshToolStdout);
connect(mNavMeshToolInvoker->getProcess(), SIGNAL(readyReadStandardError()), this, SLOT(readNavMeshToolStderr())); connect(mNavMeshToolInvoker->getProcess(), &QProcess::readyReadStandardError, this, &DataFilesPage::readNavMeshToolStderr);
connect(mNavMeshToolInvoker->getProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(navMeshToolFinished(int, QProcess::ExitStatus))); connect(mNavMeshToolInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished), this, &DataFilesPage::navMeshToolFinished);
} }
bool Launcher::DataFilesPage::loadSettings() bool Launcher::DataFilesPage::loadSettings()

View File

@ -42,11 +42,11 @@ Launcher::GraphicsPage::GraphicsPage(QWidget *parent)
customWidthSpinBox->setMaximum(res.width()); customWidthSpinBox->setMaximum(res.width());
customHeightSpinBox->setMaximum(res.height()); customHeightSpinBox->setMaximum(res.height());
connect(windowModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotFullScreenChanged(int))); connect(windowModeComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &GraphicsPage::slotFullScreenChanged);
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); connect(standardRadioButton, &QRadioButton::toggled, this, &GraphicsPage::slotStandardToggled);
connect(screenComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(screenChanged(int))); connect(screenComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &GraphicsPage::screenChanged);
connect(framerateLimitCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotFramerateLimitToggled(bool))); connect(framerateLimitCheckBox, &QCheckBox::toggled, this, &GraphicsPage::slotFramerateLimitToggled);
connect(shadowDistanceCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotShadowDistLimitToggled(bool))); connect(shadowDistanceCheckBox, &QCheckBox::toggled, this, &GraphicsPage::slotShadowDistLimitToggled);
} }
bool Launcher::GraphicsPage::setupSDL() bool Launcher::GraphicsPage::setupSDL()

View File

@ -38,11 +38,11 @@ Launcher::MainDialog::MainDialog(QWidget *parent)
mGameInvoker = new ProcessInvoker(); mGameInvoker = new ProcessInvoker();
mWizardInvoker = new ProcessInvoker(); mWizardInvoker = new ProcessInvoker();
connect(mWizardInvoker->getProcess(), SIGNAL(started()), connect(mWizardInvoker->getProcess(), &QProcess::started,
this, SLOT(wizardStarted())); this, &MainDialog::wizardStarted);
connect(mWizardInvoker->getProcess(), SIGNAL(finished(int,QProcess::ExitStatus)), connect(mWizardInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, SLOT(wizardFinished(int,QProcess::ExitStatus))); this, &MainDialog::wizardFinished);
iconWidget->setViewMode(QListView::IconMode); iconWidget->setViewMode(QListView::IconMode);
iconWidget->setWrapping(false); iconWidget->setWrapping(false);
@ -60,9 +60,9 @@ Launcher::MainDialog::MainDialog(QWidget *parent)
buttonBox->addButton(helpButton, QDialogButtonBox::HelpRole); buttonBox->addButton(helpButton, QDialogButtonBox::HelpRole);
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(buttonBox, &QDialogButtonBox::rejected, this, &MainDialog::close);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play())); connect(buttonBox, &QDialogButtonBox::accepted, this, &MainDialog::play);
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); connect(buttonBox, &QDialogButtonBox::helpRequested, this, &MainDialog::help);
// Remove what's this? button // Remove what's this? button
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -111,9 +111,7 @@ void Launcher::MainDialog::createIcons()
advancedButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom); advancedButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom);
advancedButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); advancedButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(iconWidget, connect(iconWidget, &QListWidget::currentItemChanged, this, &MainDialog::changePage);
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
} }
@ -143,12 +141,12 @@ void Launcher::MainDialog::createPages()
// Select the first page // Select the first page
iconWidget->setCurrentItem(iconWidget->item(0), QItemSelectionModel::Select); iconWidget->setCurrentItem(iconWidget->item(0), QItemSelectionModel::Select);
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play())); connect(mPlayPage, &PlayPage::playButtonClicked, this, &MainDialog::play);
connect(mPlayPage, SIGNAL(signalProfileChanged(int)), mDataFilesPage, SLOT(slotProfileChanged(int))); connect(mPlayPage, &PlayPage::signalProfileChanged, mDataFilesPage, &DataFilesPage::slotProfileChanged);
connect(mDataFilesPage, SIGNAL(signalProfileChanged(int)), mPlayPage, SLOT(setProfilesIndex(int))); connect(mDataFilesPage, &DataFilesPage::signalProfileChanged, mPlayPage, &PlayPage::setProfilesIndex);
// Using Qt::QueuedConnection because signal is emitted in a subthread and slot is in the main thread // Using Qt::QueuedConnection because signal is emitted in a subthread and slot is in the main thread
connect(mDataFilesPage, SIGNAL(signalLoadedCellsChanged(QStringList)), mAdvancedPage, SLOT(slotLoadedCellsChanged(QStringList)), Qt::QueuedConnection); connect(mDataFilesPage, &DataFilesPage::signalLoadedCellsChanged, mAdvancedPage, &AdvancedPage::slotLoadedCellsChanged, Qt::QueuedConnection);
} }
Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog() Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()

View File

@ -9,8 +9,8 @@ Launcher::PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
profilesComboBox->setView(new QListView()); profilesComboBox->setView(new QListView());
connect(profilesComboBox, SIGNAL(activated(int)), this, SIGNAL (signalProfileChanged(int))); connect(profilesComboBox, qOverload<int>(&QComboBox::activated), this, &PlayPage::signalProfileChanged);
connect(playButton, SIGNAL(clicked()), this, SLOT(slotPlayClicked())); connect(playButton, &QPushButton::clicked, this, &PlayPage::slotPlayClicked);
} }

View File

@ -36,22 +36,22 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
mImporterInvoker = new ProcessInvoker(); mImporterInvoker = new ProcessInvoker();
resetProgressBar(); resetProgressBar();
connect(mWizardInvoker->getProcess(), SIGNAL(started()), connect(mWizardInvoker->getProcess(), &QProcess::started,
this, SLOT(wizardStarted())); this, &SettingsPage::wizardStarted);
connect(mWizardInvoker->getProcess(), SIGNAL(finished(int,QProcess::ExitStatus)), connect(mWizardInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, SLOT(wizardFinished(int,QProcess::ExitStatus))); this, &SettingsPage::wizardFinished);
connect(mImporterInvoker->getProcess(), SIGNAL(started()), connect(mImporterInvoker->getProcess(), &QProcess::started,
this, SLOT(importerStarted())); this, &SettingsPage::importerStarted);
connect(mImporterInvoker->getProcess(), SIGNAL(finished(int,QProcess::ExitStatus)), connect(mImporterInvoker->getProcess(), qOverload<int,QProcess::ExitStatus>(&QProcess::finished),
this, SLOT(importerFinished(int,QProcess::ExitStatus))); this, &SettingsPage::importerFinished);
mProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this); mProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), connect(mProfileDialog->lineEdit(), &LineEdit::textChanged,
this, SLOT(updateOkButton(QString))); this, &SettingsPage::updateOkButton);
// Detect Morrowind configuration files // Detect Morrowind configuration files
QStringList iniPaths; QStringList iniPaths;

View File

@ -15,8 +15,8 @@ void LineEdit::setupClearButton()
mClearButton->setCursor(Qt::ArrowCursor); mClearButton->setCursor(Qt::ArrowCursor);
mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
mClearButton->hide(); mClearButton->hide();
connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(mClearButton, &QToolButton::clicked, this, &LineEdit::clear);
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateClearButton(const QString&))); connect(this, &LineEdit::textChanged, this, &LineEdit::updateClearButton);
} }
void LineEdit::resizeEvent(QResizeEvent *) void LineEdit::resizeEvent(QResizeEvent *)

View File

@ -6,8 +6,8 @@
ProfilesComboBox::ProfilesComboBox(QWidget *parent) : ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
ContentSelectorView::ComboBox(parent) ContentSelectorView::ComboBox(parent)
{ {
connect(this, SIGNAL(activated(int)), this, connect(this, qOverload<int>(&ProfilesComboBox::activated),
SLOT(slotIndexChangedByUser(int))); this, &ProfilesComboBox::slotIndexChangedByUser);
setInsertPolicy(QComboBox::NoInsert); setInsertPolicy(QComboBox::NoInsert);
} }
@ -18,8 +18,8 @@ void ProfilesComboBox::setEditEnabled(bool editable)
return; return;
if (!editable) { if (!editable) {
disconnect(lineEdit(), SIGNAL(editingFinished()), this, SLOT(slotEditingFinished())); disconnect(lineEdit(), &QLineEdit::editingFinished, this, &ProfilesComboBox::slotEditingFinished);
disconnect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString))); disconnect(lineEdit(), &QLineEdit::textChanged, this, &ProfilesComboBox::slotTextChanged);
return setEditable(false); return setEditable(false);
} }
@ -32,14 +32,11 @@ void ProfilesComboBox::setEditEnabled(bool editable)
setLineEdit(edit); setLineEdit(edit);
setCompleter(nullptr); setCompleter(nullptr);
connect(lineEdit(), SIGNAL(editingFinished()), this, connect(lineEdit(), &QLineEdit::editingFinished, this, &ProfilesComboBox::slotEditingFinished);
SLOT(slotEditingFinished()));
connect(lineEdit(), SIGNAL(textChanged(QString)), this, connect(lineEdit(), &QLineEdit::textChanged, this, &ProfilesComboBox::slotTextChanged);
SLOT(slotTextChanged(QString)));
connect (lineEdit(), SIGNAL(textChanged(QString)), this, connect(lineEdit(), &QLineEdit::textChanged, this, &ProfilesComboBox::signalProfileTextChanged);
SIGNAL (signalProfileTextChanged (QString)));
} }
void ProfilesComboBox::slotTextChanged(const QString &text) void ProfilesComboBox::slotTextChanged(const QString &text)

View File

@ -39,8 +39,8 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString &
setModal(true); setModal(true);
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(mButtonBox, &QDialogButtonBox::accepted, this, &TextInputDialog::accept);
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(mButtonBox, &QDialogButtonBox::rejected, this, &TextInputDialog::reject);
} }
Launcher::TextInputDialog::~TextInputDialog() Launcher::TextInputDialog::~TextInputDialog()