Commit 49c10796 authored by Jekyll Wu's avatar Jekyll Wu
Browse files

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

BUG: 281268
FIXED-IN: 4.8
REVIEW:102559
parent 050819bb
......@@ -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);
}
......
......@@ -59,7 +59,11 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="1" colspan="2">
<widget class="Konsole::WarningBox" name="emptyNameWarningWidget" native="true">
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Command:</string>
......@@ -69,7 +73,7 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<item row="2" column="1" colspan="2">
<widget class="KLineEdit" name="commandEdit">
<property name="toolTip">
<string>The command to execute when new terminal sessions are created using this profile</string>
......@@ -79,7 +83,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Initial directory:</string>
......@@ -89,7 +93,7 @@
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<item row="3" column="1" colspan="2">
<widget class="KLineEdit" name="initialDirEdit">
<property name="toolTip">
<string>The initial working directory for new terminal sessions using this profile</string>
......@@ -99,7 +103,7 @@
</property>
</widget>
</item>
<item row="2" column="3">
<item row="3" column="3">
<widget class="QToolButton" name="dirSelectButton">
<property name="toolTip">
<string>Browse for initial directory</string>
......@@ -109,7 +113,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="4" column="1" colspan="2">
<widget class="QCheckBox" name="startInSameDirButton">
<property name="text">
<string>Start in same directory as current tab</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Icon:</string>
......@@ -119,7 +130,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QPushButton" name="iconSelectButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -153,7 +164,7 @@
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -166,7 +177,7 @@
</property>
</spacer>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="environmentLabel">
<property name="text">
<string>Environment:</string>
......@@ -176,7 +187,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QPushButton" name="environmentEditButton">
<property name="toolTip">
<string>Edit the list of environment variables and associated values</string>
......@@ -186,13 +197,6 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="startInSameDirButton">
<property name="text">
<string>Start in same directory as current tab</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -397,6 +397,7 @@ void SessionManager::changeProfile(Profile::Ptr info ,
{
Q_ASSERT(info);
// insert the changes into the existing Profile instance
QListIterator<Profile::Property> iter(propertyMap.keys());
while ( iter.hasNext() )
......@@ -404,7 +405,10 @@ void SessionManager::changeProfile(Profile::Ptr info ,
const Profile::Property property = iter.next();
info->setProperty(property,propertyMap[property]);
}
// never save a profile with empty name into disk!
persistent = persistent && !info->name().isEmpty() ;
// when changing a group, iterate through the profiles
// in the group and call changeProfile() on each of them
//
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment