mirror of
https://github.com/KDE/konsole.git
synced 2026-05-05 13:14:22 -04:00
Save, load & apply cursor shape, cursor color and double click word characters. Add fallback defaults for more properties.
svn path=/branches/work/konsole-split-view/; revision=660406
This commit is contained in:
@@ -355,6 +355,50 @@ void EditProfileDialog::setupAdvancedPage(const Profile* profile)
|
||||
{ 0 , 0 , 0 }
|
||||
};
|
||||
setupCombo( options , profile );
|
||||
|
||||
// interaction options
|
||||
_ui->wordCharacterEdit->setText( profile->property(Profile::WordCharacters).value<QString>() );
|
||||
|
||||
connect( _ui->wordCharacterEdit , SIGNAL(textChanged(const QString&)) , this ,
|
||||
SLOT(wordCharactersChanged(const QString&)) );
|
||||
|
||||
// cursor options
|
||||
if ( profile->property(Profile::UseCustomCursorColor).value<bool>() )
|
||||
_ui->customCursorColorButton->setChecked(true);
|
||||
else
|
||||
_ui->autoCursorColorButton->setChecked(true);
|
||||
|
||||
_ui->customColorSelectButton->setColor( profile->property(Profile::CustomCursorColor).value<QColor>() );
|
||||
|
||||
connect( _ui->customCursorColorButton , SIGNAL(clicked()) , this , SLOT(customCursorColor()) );
|
||||
connect( _ui->autoCursorColorButton , SIGNAL(clicked()) , this , SLOT(autoCursorColor()) );
|
||||
connect( _ui->customColorSelectButton , SIGNAL(changed(const QColor&)) ,
|
||||
SLOT(customCursorColorChanged(const QColor&)) );
|
||||
|
||||
int shape = profile->property(Profile::CursorShape).value<int>();
|
||||
_ui->cursorShapeCombo->setCurrentIndex(shape);
|
||||
|
||||
connect( _ui->cursorShapeCombo , SIGNAL(activated(int)) , this , SLOT(setCursorShape(int)) );
|
||||
}
|
||||
void EditProfileDialog::customCursorColorChanged(const QColor& color)
|
||||
{
|
||||
_tempProfile->setProperty(Profile::CustomCursorColor,color);
|
||||
}
|
||||
void EditProfileDialog::wordCharactersChanged(const QString& text)
|
||||
{
|
||||
_tempProfile->setProperty(Profile::WordCharacters,text);
|
||||
}
|
||||
void EditProfileDialog::autoCursorColor()
|
||||
{
|
||||
_tempProfile->setProperty(Profile::UseCustomCursorColor,false);
|
||||
}
|
||||
void EditProfileDialog::customCursorColor()
|
||||
{
|
||||
_tempProfile->setProperty(Profile::UseCustomCursorColor,true);
|
||||
}
|
||||
void EditProfileDialog::setCursorShape(int index)
|
||||
{
|
||||
_tempProfile->setProperty(Profile::CursorShape,index);
|
||||
}
|
||||
void EditProfileDialog::toggleBlinkingCursor(bool enable)
|
||||
{
|
||||
|
||||
@@ -110,6 +110,12 @@ private slots:
|
||||
void toggleResizeWindow(bool);
|
||||
void toggleBlinkingCursor(bool);
|
||||
|
||||
void setCursorShape(int);
|
||||
void autoCursorColor();
|
||||
void customCursorColor();
|
||||
void customCursorColorChanged(const QColor&);
|
||||
void wordCharactersChanged(const QString&);
|
||||
|
||||
private:
|
||||
// initialize various pages of the dialog
|
||||
void setupGeneralPage(const Profile* info);
|
||||
|
||||
@@ -580,6 +580,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_9" >
|
||||
<property name="title" >
|
||||
<string>Interaction options:</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11" >
|
||||
<property name="text" >
|
||||
<string>Word characters for double-click selection: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="wordCharacterEdit" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_8" >
|
||||
<property name="title" >
|
||||
<string>Cursor Options:</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enableBlinkingCursorButton" >
|
||||
<property name="text" >
|
||||
@@ -587,6 +625,61 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8" >
|
||||
<property name="text" >
|
||||
<string>Cursor shape:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cursorShapeCombo" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Block</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>I-Beam</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="autoCursorColorButton" >
|
||||
<property name="text" >
|
||||
<string>Set cursor color to match current character</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="customCursorColorButton" >
|
||||
<property name="text" >
|
||||
<string>Custom cursor color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorButton" name="customColorSelectButton" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -615,6 +708,11 @@
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global" >klineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header location="global" >kcolorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -51,8 +51,29 @@ FallbackProfile::FallbackProfile()
|
||||
setProperty(Name,i18n("Shell"));
|
||||
setProperty(Command,getenv("SHELL"));
|
||||
setProperty(Arguments,QStringList() << getenv("SHELL"));
|
||||
setProperty(LocalTabTitleFormat,"%d : %n");
|
||||
setProperty(RemoteTabTitleFormat,"%H : %u");
|
||||
setProperty(TabBarMode,AlwaysShowTabBar);
|
||||
setProperty(ShowMenuBar,true);
|
||||
|
||||
setProperty(Font,QFont("Monospace"));
|
||||
|
||||
setProperty(HistoryMode,FixedSizeHistory);
|
||||
setProperty(HistorySize,1000);
|
||||
setProperty(ScrollBarPosition,ScrollBarRight);
|
||||
|
||||
setProperty(FlowControlEnabled,true);
|
||||
setProperty(AllowProgramsToResizeWindow,true);
|
||||
setProperty(BlinkingTextEnabled,true);
|
||||
|
||||
setProperty(BlinkingCursorEnabled,false);
|
||||
setProperty(CursorShape,BlockCursor);
|
||||
setProperty(UseCustomCursorColor,false);
|
||||
setProperty(CustomCursorColor,Qt::black);
|
||||
|
||||
// default taken from KDE 3
|
||||
setProperty(WordCharacters,":@-./_~?&=%+#");
|
||||
|
||||
// Fallback should not be shown in menus
|
||||
setHidden(true);
|
||||
}
|
||||
@@ -180,6 +201,16 @@ bool KDE4ProfileWriter::writeProfile(const QString& path , const Profile* profil
|
||||
writeStandardElement( terminalFeatures , "FlowControl" , profile , Profile::FlowControlEnabled );
|
||||
writeStandardElement( terminalFeatures , "BlinkingCursor" , profile , Profile::BlinkingCursorEnabled );
|
||||
|
||||
KConfigGroup cursorOptions = config.group("Cursor Options");
|
||||
|
||||
writeStandardElement( cursorOptions , "UseCustomCursorColor" , profile , Profile::UseCustomCursorColor );
|
||||
writeStandardElement( cursorOptions , "CustomCursorColor" , profile , Profile::CustomCursorColor );
|
||||
writeStandardElement( cursorOptions , "CursorShape" , profile , Profile::CursorShape );
|
||||
|
||||
KConfigGroup interactionOptions = config.group("Interaction Options");
|
||||
|
||||
writeStandardElement( interactionOptions , "WordCharacters" , profile , Profile::WordCharacters );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -210,43 +241,60 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile)
|
||||
profile->setProperty(Profile::Arguments,shellCommand.arguments());
|
||||
}
|
||||
|
||||
readStandardElement(general,"Icon",profile,Profile::Icon);
|
||||
readStandardElement(general,"LocalTabTitleFormat",profile,Profile::LocalTabTitleFormat);
|
||||
readStandardElement(general,"RemoteTabTitleFormat",profile,Profile::RemoteTabTitleFormat);
|
||||
readStandardElement<QString>(general,"Icon",profile,Profile::Icon);
|
||||
readStandardElement<QString>(general,"LocalTabTitleFormat",profile,Profile::LocalTabTitleFormat);
|
||||
readStandardElement<QString>(general,"RemoteTabTitleFormat",profile,Profile::RemoteTabTitleFormat);
|
||||
|
||||
readStandardElement(general,"TabBarMode",profile,Profile::TabBarMode);
|
||||
readStandardElement(general,"ShowMenuBar",profile,Profile::ShowMenuBar);
|
||||
readStandardElement<int>(general,"TabBarMode",profile,Profile::TabBarMode);
|
||||
readStandardElement<bool>(general,"ShowMenuBar",profile,Profile::ShowMenuBar);
|
||||
|
||||
// keyboard
|
||||
KConfigGroup keyboard = config.group("Keyboard");
|
||||
readStandardElement(keyboard,"KeyBindings",profile,Profile::KeyBindings);
|
||||
readStandardElement<QString>(keyboard,"KeyBindings",profile,Profile::KeyBindings);
|
||||
|
||||
// appearence
|
||||
KConfigGroup appearence = config.group("Appearence");
|
||||
|
||||
readStandardElement(appearence,"ColorScheme",profile,Profile::ColorScheme);
|
||||
readStandardElement(appearence,"Font",profile,Profile::Font);
|
||||
readStandardElement<QString>(appearence,"ColorScheme",profile,Profile::ColorScheme);
|
||||
readStandardElement<QFont>(appearence,"Font",profile,Profile::Font);
|
||||
|
||||
// scrolling
|
||||
KConfigGroup scrolling = config.group("Scrolling");
|
||||
|
||||
readStandardElement(scrolling,"HistoryMode",profile,Profile::HistoryMode);
|
||||
readStandardElement(scrolling,"HistorySize",profile,Profile::HistorySize);
|
||||
readStandardElement(scrolling,"ScrollBarPosition",profile,Profile::ScrollBarPosition);
|
||||
readStandardElement<int>(scrolling,"HistoryMode",profile,Profile::HistoryMode);
|
||||
readStandardElement<int>(scrolling,"HistorySize",profile,Profile::HistorySize);
|
||||
readStandardElement<int>(scrolling,"ScrollBarPosition",profile,Profile::ScrollBarPosition);
|
||||
|
||||
// terminal features
|
||||
KConfigGroup terminalFeatures = config.group("Terminal Features");
|
||||
|
||||
readStandardElement(terminalFeatures,"FlowControl",profile,Profile::FlowControlEnabled);
|
||||
readStandardElement(terminalFeatures,"BlinkingCursor",profile,Profile::BlinkingCursorEnabled);
|
||||
readStandardElement<bool>(terminalFeatures,"FlowControl",profile,Profile::FlowControlEnabled);
|
||||
readStandardElement<bool>(terminalFeatures,"BlinkingCursor",profile,Profile::BlinkingCursorEnabled);
|
||||
|
||||
// cursor settings
|
||||
KConfigGroup cursorOptions = config.group("Cursor Options");
|
||||
|
||||
readStandardElement<bool>(cursorOptions,"UseCustomCursorColor",profile,Profile::UseCustomCursorColor);
|
||||
readStandardElement<QColor>(cursorOptions,"CustomCursorColor",profile,Profile::CustomCursorColor);
|
||||
readStandardElement<int>(cursorOptions,"CursorShape",profile,Profile::CursorShape);
|
||||
|
||||
// interaction options
|
||||
KConfigGroup interactionOptions = config.group("Interaction Options");
|
||||
|
||||
readStandardElement<QString>(interactionOptions,"WordCharacters",profile,Profile::WordCharacters);
|
||||
|
||||
return true;
|
||||
}
|
||||
template <typename T>
|
||||
void KDE4ProfileReader::readStandardElement(const KConfigGroup& group ,
|
||||
char* name ,
|
||||
Profile* info ,
|
||||
Profile::Property property)
|
||||
{
|
||||
static T aDefault;
|
||||
|
||||
if ( group.hasKey(name) )
|
||||
info->setProperty(property,group.readEntry(name));
|
||||
info->setProperty(property,group.readEntry(name,aDefault));
|
||||
}
|
||||
|
||||
QStringList KDE3ProfileReader::findProfiles()
|
||||
|
||||
@@ -83,8 +83,15 @@ public:
|
||||
BlinkingTextEnabled, // bool
|
||||
FlowControlEnabled, // bool
|
||||
AllowProgramsToResizeWindow,// bool
|
||||
BlinkingCursorEnabled // bool
|
||||
|
||||
BlinkingCursorEnabled, // bool
|
||||
|
||||
// Cursor Options
|
||||
UseCustomCursorColor, // bool
|
||||
CursorShape, // CursorShapeEnum
|
||||
CustomCursorColor, // QColor
|
||||
|
||||
// Interaction options
|
||||
WordCharacters // QString
|
||||
};
|
||||
|
||||
enum TabBarModeEnum
|
||||
@@ -108,6 +115,13 @@ public:
|
||||
ScrollBarHidden
|
||||
};
|
||||
|
||||
enum CursorShapeEnum
|
||||
{
|
||||
BlockCursor,
|
||||
IBeamCursor,
|
||||
UnderlineCursor
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a new profile
|
||||
*/
|
||||
@@ -251,6 +265,7 @@ public:
|
||||
virtual QStringList findProfiles();
|
||||
virtual bool readProfile(const QString& path , Profile* profile);
|
||||
private:
|
||||
template <typename T>
|
||||
void readStandardElement(const KConfigGroup& group ,
|
||||
char* name ,
|
||||
Profile* info ,
|
||||
|
||||
@@ -531,7 +531,26 @@ void ViewManager::loadViewSettings(TerminalDisplay* view , Profile* info)
|
||||
//TODO - Add a method in TerminalDisplay to allow this to be turned on or off
|
||||
|
||||
bool blinkingCursor = info->property(Profile::BlinkingCursorEnabled).value<bool>();
|
||||
view->setBlinkingCursor(blinkingCursor);
|
||||
view->setBlinkingCursor(blinkingCursor);
|
||||
|
||||
// cursor shape
|
||||
int cursorShape = info->property(Profile::CursorShape).value<int>();
|
||||
|
||||
if ( cursorShape == Profile::BlockCursor )
|
||||
view->setKeyboardCursorShape(TerminalDisplay::BlockCursor);
|
||||
else if ( cursorShape == Profile::IBeamCursor )
|
||||
view->setKeyboardCursorShape(TerminalDisplay::IBeamCursor);
|
||||
else if ( cursorShape == Profile::UnderlineCursor )
|
||||
view->setKeyboardCursorShape(TerminalDisplay::UnderlineCursor);
|
||||
|
||||
// cursor color
|
||||
bool useCustomColor = info->property(Profile::UseCustomCursorColor).value<bool>();
|
||||
const QColor& cursorColor = info->property(Profile::CustomCursorColor).value<QColor>();
|
||||
|
||||
view->setKeyboardCursorColor(!useCustomColor,cursorColor);
|
||||
|
||||
// word characters
|
||||
view->setWordCharacters( info->property(Profile::WordCharacters).value<QString>() );
|
||||
}
|
||||
|
||||
void ViewManager::profileChanged(const QString& key)
|
||||
|
||||
Reference in New Issue
Block a user