diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1688bf22..e739f39ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,7 +125,13 @@ install(TARGETS kdeinit_konsole DESTINATION ${LIB_INSTALL_DIR} ) target_link_libraries( konsole kdeinit_konsole ) install(TARGETS konsole DESTINATION ${BIN_INSTALL_DIR}) - +install(FILES konsoleprofile PERMISSIONS OWNER_READ + OWNER_WRITE + OWNER_EXECUTE + GROUP_EXECUTE + GROUP_READ + WORLD_READ + WORLD_EXECUTE DESTINATION ${BIN_INSTALL_DIR}) ########### next target ############### set(konsolepart_PART_SRCS diff --git a/src/Emulation.h b/src/Emulation.h index bf2b1bc68..11c57892d 100644 --- a/src/Emulation.h +++ b/src/Emulation.h @@ -351,6 +351,14 @@ signals: */ void imageSizeChanged(int lineCount , int columnCount); + /** + * Emitted when the terminal program emits a profile change + * command sequence + * + * @param text The text of the command + */ + void profileChangeCommandReceived(const QString& text); + protected: virtual void setMode (int mode) = 0; virtual void resetMode(int mode) = 0; diff --git a/src/Profile.cpp b/src/Profile.cpp index 44641b2d3..02abcfd8b 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -185,7 +185,7 @@ Profile::Property Profile::lookupByName(const QString& name) // insert default names into table the first time this is called fillTableWithDefaultNames(); - return _propertyByName[name]; + return _propertyByName[name.toLower()]; } QString Profile::primaryNameForProperty(Property property) { @@ -203,7 +203,7 @@ QList Profile::namesForProperty(Property property) } void Profile::registerName(Property property , const QString& name) { - _propertyByName.insert(name,property); + _propertyByName.insert(name.toLower(),property); _nameByProperty.insert(property,name); } @@ -451,5 +451,36 @@ bool KDE3ProfileReader::readProfile(const QString& path , Profile* profile) return true; } +QHash ProfileCommandParser::parse(const QString& input) +{ + QHash changes; + + static QRegExp regExp("([a-z]+)=([^;]+)"); + + int offset = 0; + while ( regExp.indexIn(input,offset) != -1 ) + { + //qDebug() << "Captured texts: " << regExp.capturedTexts(); + + if ( regExp.capturedTexts().count() == 3 ) + { + Profile::Property property = Profile::lookupByName( + regExp.capturedTexts()[1]); + const QString value = regExp.capturedTexts()[2]; + + qDebug() << "property:" << property << "value:" << value; + + changes.insert(property,value); + } + + offset = input.indexOf(';',offset) + 1; + if ( offset == 0 ) + break; + } + + return changes; +} + + #include "Profile.moc" diff --git a/src/Profile.h b/src/Profile.h index ff96fa219..6e6a496fc 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -322,6 +322,8 @@ public: /** * Returns the element from the Property enum associated with the * specified @p name. + * + * @param The name of the property to look for, this is case insensitive. */ static Property lookupByName(const QString& name); /** @@ -440,6 +442,35 @@ private: Profile::Property property); }; +/** + * Parses an input string consisting of property names + * and assigned values and returns a table of properties + * and values. + * + * The input string will typically look like this: + * + * @code + * PropertyName=Value;PropertyName=Value ... + * @endcode + * + * For example: + * + * @code + * Icon=konsole;Directory=/home/bob + * @endcode + */ +class ProfileCommandParser +{ +public: + /** + * Parses an input string consisting of property names + * and assigned values and returns a table of + * properties and values. + */ + QHash parse(const QString& input); + +}; + } #endif // PROFILE_H diff --git a/src/Session.cpp b/src/Session.cpp index 49b2da51e..723ad6cd3 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -102,7 +102,8 @@ Session::Session() : SLOT( fireZModemDetected() ) ); connect( _emulation, SIGNAL( changeTabTextColorRequest( int ) ), this, SIGNAL( changeTabTextColorRequest( int ) ) ); - + connect( _emulation, SIGNAL(profileChangeCommandReceived(const QString&)), + this, SIGNAL( profileChangeCommandReceived(const QString&)) ); // TODO // connect( _emulation,SIGNAL(imageSizeChanged(int,int)) , this , // SLOT(onEmulationSizeChange(int,int)) ); @@ -358,6 +359,14 @@ void Session::setUserTitle( int what, const QString &caption ) } } + if (what == 50) { + + qDebug() << "Profile change command received"; + emit profileChangeCommandReceived(caption); + + return; + } + if ( modified ) emit titleChanged(); } diff --git a/src/Session.h b/src/Session.h index 3298da205..55f18bb7b 100644 --- a/src/Session.h +++ b/src/Session.h @@ -419,6 +419,14 @@ signals: */ void resizeRequest(const QSize& size); + /** + * Emitted when a profile change command is received from the terminal. + * + * @param text The text of the command. This is a string of the form + * "PropertyName=Value;PropertyName=Value ..." + */ + void profileChangeCommandReceived(const QString& text); + private slots: void done(int); diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index 1d8181d50..a695f9176 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -229,6 +229,9 @@ Session* SessionManager::createSession(const QString& key ) connect( session , SIGNAL(profileChanged(const QString&)) , this , SLOT(sessionProfileChanged()) ); + connect( session , SIGNAL(profileChangeCommandReceived(const QString&)) , this , + SLOT(sessionProfileCommandReceived(const QString&)) ); + //ask for notification when session dies _sessionMapper->setMapping(session,session); connect( session , SIGNAL(finished()) , _sessionMapper , @@ -658,12 +661,22 @@ QString SessionManager::findByShortcut(const QKeySequence& shortcut) void SessionManager::sessionProfileChanged() { Session* session = qobject_cast(sender()); - Q_ASSERT( session ); updateSession(session); } +void SessionManager::sessionProfileCommandReceived(const QString& text) +{ + Session* session = qobject_cast(sender()); + Q_ASSERT( session ); + + ProfileCommandParser parser; + QHash changes = parser.parse(text); + + changeProfile(session->profileKey(),changes,false); +} + QKeySequence SessionManager::shortcut(const QString& profileKey) const { Profile* info = profile(profileKey); diff --git a/src/SessionManager.h b/src/SessionManager.h index 034e14554..66fef4150 100644 --- a/src/SessionManager.h +++ b/src/SessionManager.h @@ -275,6 +275,7 @@ protected Q_SLOTS: private slots: void sessionProfileChanged(); + void sessionProfileCommandReceived(const QString& text); private: // loads the mappings between shortcut key sequences and diff --git a/src/konsoleprofile b/src/konsoleprofile new file mode 100755 index 000000000..60f82a763 --- /dev/null +++ b/src/konsoleprofile @@ -0,0 +1,3 @@ +#!/bin/sh + +/bin/echo -e "\033]50;$1\a"