1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 20:39:40 +00:00

Reimplemented the old new profile dialog behaviour

This commit is contained in:
pvdk 2014-04-17 02:17:18 +02:00
parent 5d94cb112f
commit af883991e2
3 changed files with 25 additions and 7 deletions

View file

@ -30,6 +30,11 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
setObjectName ("DataFilesPage"); setObjectName ("DataFilesPage");
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget); mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
mProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
this, SLOT(updateOkButton(QString)));
buildView(); buildView();
setupDataFiles(); setupDataFiles();
} }
@ -212,12 +217,10 @@ void Launcher::DataFilesPage::slotProfileChanged(int index)
void Launcher::DataFilesPage::on_newProfileAction_triggered() void Launcher::DataFilesPage::on_newProfileAction_triggered()
{ {
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this); if (!mProfileDialog->exec() == QDialog::Accepted)
if (newDialog.exec() != QDialog::Accepted)
return; return;
QString profile = newDialog.lineEdit()->text(); QString profile = mProfileDialog->lineEdit()->text();
if (profile.isEmpty()) if (profile.isEmpty())
return; return;
@ -271,6 +274,19 @@ void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
checkForDefaultProfile(); checkForDefaultProfile();
} }
void Launcher::DataFilesPage::updateOkButton(const QString &text)
{
// We do this here because we need the profiles combobox text
if (text.isEmpty()) {
mProfileDialog->setOkButtonEnabled(false);
return;
}
(ui.profilesComboBox->findText(text) == -1)
? mProfileDialog->setOkButtonEnabled(true)
: mProfileDialog->setOkButtonEnabled(false);
}
void Launcher::DataFilesPage::checkForDefaultProfile() void Launcher::DataFilesPage::checkForDefaultProfile()
{ {
//don't allow deleting "Default" profile //don't allow deleting "Default" profile

View file

@ -55,12 +55,14 @@ namespace Launcher
void slotProfileRenamed(const QString &previous, const QString &current); void slotProfileRenamed(const QString &previous, const QString &current);
void slotProfileDeleted(const QString &item); void slotProfileDeleted(const QString &item);
void updateOkButton(const QString &text);
void on_newProfileAction_triggered(); void on_newProfileAction_triggered();
void on_deleteProfileAction_triggered(); void on_deleteProfileAction_triggered();
private: private:
QMenu *mContextMenu; TextInputDialog *mProfileDialog;
Files::ConfigurationManager &mCfgMgr; Files::ConfigurationManager &mCfgMgr;

View file

@ -222,7 +222,7 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
void Launcher::SettingsPage::updateOkButton(const QString &text) void Launcher::SettingsPage::updateOkButton(const QString &text)
{ {
// We do this here because we need the profiles combobox text // We do this here because we need to access the profiles
if (text.isEmpty()) { if (text.isEmpty()) {
mProfileDialog->setOkButtonEnabled(false); mProfileDialog->setOkButtonEnabled(false);
return; return;