Konsole should never save a profile with empty name into disk.

BUG: 281268
FIXED-IN: 4.8
REVIEW:102559
This commit is contained in:
Jekyll Wu
2011-09-14 23:31:23 +08:00
parent 050819bb8d
commit 49c107966b
3 changed files with 47 additions and 18 deletions

View File

@@ -42,6 +42,7 @@
#include <KUrlCompletion>
#include <KWindowSystem>
#include <KTextEdit>
#include <KMessageBox>
#include <cmath>
@@ -127,6 +128,18 @@ void EditProfileDialog::reject()
}
void EditProfileDialog::accept()
{
Q_ASSERT( _profile );
Q_ASSERT( _tempProfile );
if ( ( _tempProfile->isPropertySet(Profile::Name) &&
_tempProfile->name().isEmpty() )
|| ( _profile->name().isEmpty() && _tempProfile->name().isEmpty() ) )
{
KMessageBox::sorry(this,
i18n("<p>Each profile must have a name before it can be saved"
"into disk.</p>"));
return;
}
save();
unpreviewAll();
KDialog::accept();
@@ -240,15 +253,21 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr info)
{
_ui->profileNameEdit->setText( info->name() );
_ui->profileNameEdit->setClearButtonShown(true);
_ui->emptyNameWarningWidget->setVisible( info->name().isEmpty() );
_ui->emptyNameWarningWidget->setText(i18n("Profile name is empty."));
}
else
{
_ui->profileNameEdit->setText( groupProfileNames(group,-1) );
_ui->profileNameEdit->setEnabled(false);
_ui->profileNameLabel->setEnabled(false);
_ui->emptyNameWarningWidget->setVisible(false);
}
}
ShellCommand command( info->command() , info->arguments() );
_ui->commandEdit->setText( command.fullCommand() );
KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion);
@@ -423,6 +442,8 @@ void EditProfileDialog::selectIcon()
}
void EditProfileDialog::profileNameChanged(const QString& text)
{
_ui->emptyNameWarningWidget->setVisible(text.isEmpty());
updateTempProfileProperty(Profile::Name,text);
updateCaption(_tempProfile);
}