Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 329c063d authored by Robert Knight's avatar Robert Knight

Fix setting newly created profiles as the default. Update color scheme...

Fix setting newly created profiles as the default.  Update color scheme setting in profile when double clicking on entry in color scheme list.

svn path=/branches/work/konsole-split-view/; revision=660443
parent e6e46e60
......@@ -98,6 +98,9 @@ ColorScheme::~ColorScheme()
delete[] _table;
}
void ColorScheme::setDescription(const QString& description) { _description = description; }
QString ColorScheme::description() const { return _description; }
void ColorScheme::setName(const QString& name) { _name = name; }
QString ColorScheme::name() const { return _name; }
......@@ -132,7 +135,7 @@ void ColorScheme::read(KConfig& config)
{
KConfigGroup configGroup = config.group("General");
_name = configGroup.readEntry("Name",i18n("Un-named Color Scheme"));
_description = configGroup.readEntry("Description",i18n("Un-named Color Scheme"));
_opacity = configGroup.readEntry("Opacity",qreal(1.0));
for (int i=0 ; i < TABLE_COLORS ; i++)
......@@ -144,7 +147,7 @@ void ColorScheme::write(KConfig& config) const
{
KConfigGroup configGroup = config.group("General");
configGroup.writeEntry("Name",_name);
configGroup.writeEntry("Description",_description);
configGroup.writeEntry("Opacity",_opacity);
for (int i=0 ; i < TABLE_COLORS ; i++)
......@@ -256,7 +259,7 @@ void KDE3ColorSchemeReader::readTitleLine(const QString& line,ColorScheme* schem
int spacePos = line.indexOf(' ');
Q_ASSERT( spacePos != -1 );
scheme->setName(line.mid(spacePos+1));
scheme->setDescription(line.mid(spacePos+1));
}
ColorSchemeManager::ColorSchemeManager()
: _haveLoadedAll(false)
......@@ -322,6 +325,7 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
KDE3ColorSchemeReader reader(&file);
ColorScheme* scheme = reader.read();
scheme->setName(QFileInfo(file).baseName());
file.close();
Q_ASSERT( !scheme->name().isEmpty() );
......@@ -333,8 +337,8 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
if ( !_colorSchemes.contains(info.baseName()) )
{
qDebug() << "added color scheme - " << info.baseName();
_colorSchemes.insert(info.baseName(),scheme);
_colorSchemes.insert(scheme->name(),scheme);
}
else
{
......@@ -347,22 +351,24 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
}
bool ColorSchemeManager::loadColorScheme(const QString& filePath)
{
QFileInfo info(filePath);
qDebug() << "loading KDE 4 native color scheme from " << filePath;
KConfig config(filePath , KConfig::NoGlobals);
ColorScheme* scheme = new ColorScheme();
scheme->setName(info.baseName());
scheme->read(config);
Q_ASSERT( !scheme->name().isEmpty() );
qDebug() << "found KDE 4 native color scheme - " << scheme->name();
QFileInfo info(filePath);
if ( !_colorSchemes.contains(info.baseName()) )
{
qDebug() << "added color scheme - " << info.baseName();
_colorSchemes.insert(info.baseName(),scheme);
_colorSchemes.insert(scheme->name(),scheme);
}
else
{
......@@ -416,6 +422,8 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
return findColorScheme(name);
}
qDebug() << "Could not find color scheme - " << name;
return 0;
}
}
......
......@@ -53,6 +53,11 @@ public:
ColorScheme();
~ColorScheme();
/** Sets the descriptive name of the color scheme. */
void setDescription(const QString& description);
/** Returns the descriptive name of the color scheme. */
QString description() const;
/** Sets the name of the color scheme */
void setName(const QString& name);
/** Returns the name of the color scheme */
......@@ -114,6 +119,7 @@ private:
// writes a single colour entry to a KConfig source
void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry) const;
QString _description;
QString _name;
qreal _opacity;
ColorEntry* _table; // pointer to custom color table or 0 if the default
......
......@@ -237,7 +237,7 @@ void EditProfileDialog::setupAppearencePage(const Profile* info)
while (schemeIter.hasNext())
{
ColorScheme* colors = schemeIter.next();
QStandardItem* item = new QStandardItem(colors->name());
QStandardItem* item = new QStandardItem(colors->description());
item->setData( QVariant::fromValue(colors) , Qt::UserRole + 1);
model->appendRow(item);
......@@ -245,7 +245,12 @@ void EditProfileDialog::setupAppearencePage(const Profile* info)
_ui->colorSchemeList->setModel(model);
_ui->colorSchemeList->setItemDelegate(new ColorSchemeViewDelegate(this));
connect( _ui->colorSchemeList , SIGNAL(doubleClicked(const QModelIndex&)) , this ,
SLOT(colorSchemeSelected()) );
connect( _ui->selectColorSchemeButton , SIGNAL(clicked()) , this ,
SLOT(colorSchemeSelected()) );
// setup font preview
const QFont& font = info->font();
_ui->fontPreviewLabel->setFont( font );
......@@ -256,6 +261,20 @@ void EditProfileDialog::setupAppearencePage(const Profile* info)
connect( _ui->editFontButton , SIGNAL(clicked()) , this ,
SLOT(showFontDialog()) );
}
void EditProfileDialog::colorSchemeSelected()
{
QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
if ( !selected.isEmpty() )
{
QAbstractItemModel* model = _ui->colorSchemeList->model();
ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<ColorScheme*>();
_tempProfile->setProperty(Profile::ColorScheme,colors->name());
qDebug() << "Color scheme selected: " << _tempProfile->colorScheme();
}
}
void EditProfileDialog::setupKeyboardPage(const Profile* )
{
}
......@@ -383,6 +402,9 @@ void EditProfileDialog::setupAdvancedPage(const Profile* profile)
void EditProfileDialog::customCursorColorChanged(const QColor& color)
{
_tempProfile->setProperty(Profile::CustomCursorColor,color);
// ensure that custom cursor colors are enabled
_ui->customCursorColorButton->click();
}
void EditProfileDialog::wordCharactersChanged(const QString& text)
{
......
......@@ -92,6 +92,7 @@ private slots:
// appearence page
void setFontSize(int pointSize);
void showFontDialog();
void colorSchemeSelected();
// scrolling page
void noScrollBack();
......
......@@ -50,6 +50,7 @@ FallbackProfile::FallbackProfile()
// Fallback settings
setProperty(Name,i18n("Shell"));
setProperty(Command,getenv("SHELL"));
setProperty(Icon,"konsole");
setProperty(Arguments,QStringList() << getenv("SHELL"));
setProperty(LocalTabTitleFormat,"%d : %n");
setProperty(RemoteTabTitleFormat,"%H : %u");
......@@ -291,10 +292,8 @@ void KDE4ProfileReader::readStandardElement(const KConfigGroup& group ,
Profile* info ,
Profile::Property property)
{
static T aDefault;
if ( group.hasKey(name) )
info->setProperty(property,group.readEntry(name,aDefault));
info->setProperty(property,group.readEntry(name,T()));
}
QStringList KDE3ProfileReader::findProfiles()
......@@ -456,7 +455,11 @@ void SessionManager::loadAllProfiles()
_loadedAllProfiles = true;
}
SessionManager::~SessionManager()
{
{
// save default profile
setDefaultProfile( _defaultProfile );
// free profiles
QListIterator<Profile*> infoIter(_types.values());
while (infoIter.hasNext())
......@@ -674,10 +677,10 @@ QString SessionManager::addProfile(Profile* type)
break;
}
}
if ( _types.isEmpty() )
_defaultProfile = key;
_types.insert(key,type);
emit profileAdded(key);
......@@ -726,9 +729,13 @@ void SessionManager::setDefaultProfile(const QString& key)
_defaultProfile = key;
Profile* info = profile(key);
Q_ASSERT( QFile::exists(info->path()) );
QFileInfo fileInfo(info->path());
QString path = info->path();
if ( path.isEmpty() )
path = KDE4ProfileWriter().getPath(info);
QFileInfo fileInfo(path);
qDebug() << "setting default session type to " << fileInfo.fileName();
......
......@@ -507,7 +507,8 @@ void ViewManager::loadViewSettings(TerminalDisplay* view , Profile* info)
const ColorScheme* colorScheme = ColorSchemeManager::instance()->
findColorScheme(info->colorScheme());
if ( !colorScheme )
colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
Q_ASSERT( colorScheme );
// load colour scheme
......
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