diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-24 06:25:11 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-24 06:25:11 +0000 |
commit | 0dfb53e20e286167d0d38a347ee8911033d43fbb (patch) | |
tree | a399e58d36a1133d2f72f0d709447bb559a11bb2 /konqueror | |
parent | 6ade341229a0ce755b3e606d974b37c7d1609c8a (diff) | |
download | tdebase-0dfb53e20e286167d0d38a347ee8911033d43fbb.tar.gz tdebase-0dfb53e20e286167d0d38a347ee8911033d43fbb.zip |
Fix Documents shortcut in K Menu and system:/ folder
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1178867 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konqueror')
-rw-r--r-- | konqueror/konq_mainwindow.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/konqueror/konq_mainwindow.cc b/konqueror/konq_mainwindow.cc index c6a9bb742..18b638934 100644 --- a/konqueror/konq_mainwindow.cc +++ b/konqueror/konq_mainwindow.cc @@ -485,6 +485,69 @@ void KonqMainWindow::openURL( KonqView *_view, const KURL &_url, #endif KURL url( _url ); + if (url.url().startsWith("$(")) { + // check for environment variables and make necessary translations + TQString aValue = url.url(); + int nDollarPos = aValue.find( '$' ); + + while( nDollarPos != -1 && nDollarPos+1 < static_cast<int>(aValue.length())) { + // there is at least one $ + if( (aValue)[nDollarPos+1] == '(' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=')') ) + nEndPos++; + nEndPos++; + TQString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + + TQString result; + FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); + if (fs) + { + { + TQTextStream ts(fs, IO_ReadOnly); + result = ts.read().stripWhiteSpace(); + } + pclose(fs); + } + aValue.replace( nDollarPos, nEndPos-nDollarPos, result ); + } else if( (aValue)[nDollarPos+1] != '$' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + TQString aVarName; + if (aValue[nEndPos]=='{') + { + while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!='}') ) + nEndPos++; + nEndPos++; + aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + } + else + { + while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber() + || aValue[nEndPos].isLetter() || aValue[nEndPos]=='_' ) ) + nEndPos++; + aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); + } + const char* pEnv = 0; + if (!aVarName.isEmpty()) + pEnv = getenv( aVarName.ascii() ); + if( pEnv ) { + // !!! Sergey A. Sukiyazov <[email protected]> !!! + // A environment variables may contain values in 8bit + // locale cpecified encoding or in UTF8 encoding. + aValue.replace( nDollarPos, nEndPos-nDollarPos, KStringHandler::from8Bit( pEnv ) ); + } else + aValue.remove( nDollarPos, nEndPos-nDollarPos ); + } else { + // remove one of the dollar signs + aValue.remove( nDollarPos, 1 ); + nDollarPos++; + } + nDollarPos = aValue.find( '$', nDollarPos ); + } + url = KURL(aValue); + } TQString serviceType( _serviceType ); if ( url.url() == "about:blank" ) { |