diff --git a/konsole/EditProfileDialog.cpp b/konsole/EditProfileDialog.cpp index 69de4127..f1e97197 100644 --- a/konsole/EditProfileDialog.cpp +++ b/konsole/EditProfileDialog.cpp @@ -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() ); + + connect( _ui->wordCharacterEdit , SIGNAL(textChanged(const QString&)) , this , + SLOT(wordCharactersChanged(const QString&)) ); + + // cursor options + if ( profile->property(Profile::UseCustomCursorColor).value() ) + _ui->customCursorColorButton->setChecked(true); + else + _ui->autoCursorColorButton->setChecked(true); + + _ui->customColorSelectButton->setColor( profile->property(Profile::CustomCursorColor).value() ); + + 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(); + _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) { diff --git a/konsole/EditProfileDialog.h b/konsole/EditProfileDialog.h index 32c4943a..33233554 100644 --- a/konsole/EditProfileDialog.h +++ b/konsole/EditProfileDialog.h @@ -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); diff --git a/konsole/EditProfileDialog.ui b/konsole/EditProfileDialog.ui index 37e64e95..87796a3b 100644 --- a/konsole/EditProfileDialog.ui +++ b/konsole/EditProfileDialog.ui @@ -580,6 +580,44 @@ + + + + + + + Interaction options: + + + true + + + + + + + + Word characters for double-click selection: + + + + + + + + + + + + + + + Cursor Options: + + + true + + @@ -587,6 +625,61 @@ + + + + + + Cursor shape: + + + + + + + + Block + + + + + I-Beam + + + + + Underline + + + + + + + + + + Set cursor color to match current character + + + + + + + + + Custom cursor color: + + + + + + + + + + + + @@ -615,6 +708,11 @@ QLineEdit
klineedit.h
+ + KColorButton + QPushButton +
kcolorbutton.h
+
diff --git a/konsole/SessionManager.cpp b/konsole/SessionManager.cpp index ad2514f2..6cf63b79 100644 --- a/konsole/SessionManager.cpp +++ b/konsole/SessionManager.cpp @@ -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(general,"Icon",profile,Profile::Icon); + readStandardElement(general,"LocalTabTitleFormat",profile,Profile::LocalTabTitleFormat); + readStandardElement(general,"RemoteTabTitleFormat",profile,Profile::RemoteTabTitleFormat); - readStandardElement(general,"TabBarMode",profile,Profile::TabBarMode); - readStandardElement(general,"ShowMenuBar",profile,Profile::ShowMenuBar); + readStandardElement(general,"TabBarMode",profile,Profile::TabBarMode); + readStandardElement(general,"ShowMenuBar",profile,Profile::ShowMenuBar); // keyboard KConfigGroup keyboard = config.group("Keyboard"); - readStandardElement(keyboard,"KeyBindings",profile,Profile::KeyBindings); + readStandardElement(keyboard,"KeyBindings",profile,Profile::KeyBindings); // appearence KConfigGroup appearence = config.group("Appearence"); - readStandardElement(appearence,"ColorScheme",profile,Profile::ColorScheme); - readStandardElement(appearence,"Font",profile,Profile::Font); + readStandardElement(appearence,"ColorScheme",profile,Profile::ColorScheme); + readStandardElement(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(scrolling,"HistoryMode",profile,Profile::HistoryMode); + readStandardElement(scrolling,"HistorySize",profile,Profile::HistorySize); + readStandardElement(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(terminalFeatures,"FlowControl",profile,Profile::FlowControlEnabled); + readStandardElement(terminalFeatures,"BlinkingCursor",profile,Profile::BlinkingCursorEnabled); + + // cursor settings + KConfigGroup cursorOptions = config.group("Cursor Options"); + + readStandardElement(cursorOptions,"UseCustomCursorColor",profile,Profile::UseCustomCursorColor); + readStandardElement(cursorOptions,"CustomCursorColor",profile,Profile::CustomCursorColor); + readStandardElement(cursorOptions,"CursorShape",profile,Profile::CursorShape); + + // interaction options + KConfigGroup interactionOptions = config.group("Interaction Options"); + + readStandardElement(interactionOptions,"WordCharacters",profile,Profile::WordCharacters); return true; } +template 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() diff --git a/konsole/SessionManager.h b/konsole/SessionManager.h index 5498b428..6f0bc309 100644 --- a/konsole/SessionManager.h +++ b/konsole/SessionManager.h @@ -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 void readStandardElement(const KConfigGroup& group , char* name , Profile* info , diff --git a/konsole/ViewManager.cpp b/konsole/ViewManager.cpp index be0c34ab..41c858d1 100644 --- a/konsole/ViewManager.cpp +++ b/konsole/ViewManager.cpp @@ -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(); - view->setBlinkingCursor(blinkingCursor); + view->setBlinkingCursor(blinkingCursor); + + // cursor shape + int cursorShape = info->property(Profile::CursorShape).value(); + + 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(); + const QColor& cursorColor = info->property(Profile::CustomCursorColor).value(); + + view->setKeyboardCursorColor(!useCustomColor,cursorColor); + + // word characters + view->setWordCharacters( info->property(Profile::WordCharacters).value() ); } void ViewManager::profileChanged(const QString& key)