📄 kapp.cpp
字号:
backgroundColor.dark(120), textColor, windowColor ); QApplication::setWinStyleHighlightColor( selectColor ); QApplication::setPalette( QPalette(colgrp,disabledgrp,colgrp), TRUE ); emit kdisplayPaletteChanged(); emit appearanceChanged(); }}void KApplication::kdisplaySetFont(){ QApplication::setFont( generalFont, TRUE ); // setFont() works every time for me ! emit kdisplayFontChanged(); emit appearanceChanged(); resizeAll();} void KApplication::kdisplaySetStyle(){ // QApplication::setStyle( applicationStyle ); applyGUIStyle( applicationStyle ); emit kdisplayStyleChanged(); emit appearanceChanged(); resizeAll();} void KApplication::kdisplaySetStyleAndFont(){ // QApplication::setStyle( applicationStyle ); // setStyle() works pretty well but may not change the style of combo // boxes. QApplication::setFont( generalFont, TRUE ); applyGUIStyle(applicationStyle); emit kdisplayStyleChanged(); emit kdisplayFontChanged(); emit appearanceChanged(); resizeAll();} void KApplication::resizeAll(){ // send a resize event to all windows so that they can resize children QWidgetList *widgetList = QApplication::topLevelWidgets(); QWidgetListIt it( *widgetList ); while ( it.current() ) { it.current()->resize( it.current()->size() ); ++it; } delete widgetList;}void KApplication::invokeHTMLHelp( QString filename, QString topic ) const{ if ( fork() == 0 ) { if( filename.isEmpty() ) filename = aAppName + "/index.html"; QString path = KApplication::kde_htmldir().copy() + "/"; // first try the locale setting QString file = path + klocale->language() + '/' + filename; if( !QFileInfo( file ).exists() ) // not found: use the default file = path + "default/" + filename; if( !topic.isEmpty() ) { file.append( "#" ); file.append(topic); } /* Since this is a library, we must conside the possibilty that * we are being used by a suid root program. These next two * lines drop all privileges. */ setuid( getuid() ); setgid( getgid() ); const char* shell = "/bin/sh"; if (getenv("SHELL")) shell = getenv("SHELL"); file.prepend("kdehelp "); execl(shell, shell, "-c", file.data(), 0L); exit( 1 ); }}QString KApplication::kdedir(){ static QString kdedir; if (kdedir.isEmpty()) { kdedir = getenv("KDEDIR"); if (kdedir.isEmpty()) {#ifdef KDEDIR kdedir = KDEDIR;#else kdedir = "/usr/local/kde";#endif } } return kdedir;}/* maybe we could read it out of a config file, but this can be added later */const QString& KApplication::kde_htmldir(){ static QString dir; if (dir.isNull()) { dir = KDE_HTMLDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_appsdir(){ static QString dir; if (dir.isNull()) { dir = KDE_APPSDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_icondir(){ static QString dir; if (dir.isNull()) { dir = KDE_ICONDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_datadir(){ static QString dir; if (dir.isNull()) { dir = KDE_DATADIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_localedir(){ static QString dir; if (dir.isNull()) { dir = KDE_LOCALE; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_cgidir(){ static QString dir; if (dir.isNull()) { dir = KDE_CGIDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_sounddir(){ static QString dir; if (dir.isNull()) { dir = KDE_SOUNDDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_toolbardir(){ static QString dir; if (dir.isNull()) { dir = KDE_TOOLBARDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_wallpaperdir(){ static QString dir; if (dir.isNull()) { dir = KDE_WALLPAPERDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_bindir(){ static QString dir; if (dir.isNull()) { dir = KDE_BINDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_partsdir(){ static QString dir; if (dir.isNull()) { dir = KDE_PARTSDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_configdir(){ static QString dir; if (dir.isNull()) { dir = KDE_CONFIGDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}const QString& KApplication::kde_mimedir(){ static QString dir; if (dir.isNull()) { dir = KDE_MIMEDIR; if (!strncmp(dir.data(), "KDEDIR", 6)) dir = kdedir() + dir.right(dir.length() - 6); } return dir;}QString KApplication::localkdedir(){ return ( QDir::homeDirPath() + "/.kde" );}QString KApplication::localconfigdir(){ return ( localkdedir() + "/share/config" );}bool KApplication::getKDEFonts(QStrList *fontlist){ QString fontfilename; if(fontlist == 0L) return false; fontfilename = KApplication::localkdedir(); if(fontfilename.isEmpty()){ return false; } fontfilename = fontfilename + "/share/config/kdefonts"; QFile fontfile(fontfilename); if (!fontfile.exists()) return false; if(!fontfile.open(IO_ReadOnly)){ return false; } if (!fontfile.isReadable()) return false; QTextStream t(&fontfile); while ( !t.eof() ) { QString s = t.readLine(); if(!s.isEmpty()) fontlist->append( s ); } fontfile.close(); return true;}const char* KApplication::tempSaveName( const char* pFilename ){ QString aFilename; if( pFilename[0] != '/' ) { KDEBUG( KDEBUG_WARN, 101, "Relative filename passed to KApplication::tempSaveName" ); aFilename = QFileInfo( QDir( "." ), pFilename ).absFilePath(); } else aFilename = pFilename; QDir aAutosaveDir( QDir::homeDirPath() + "/autosave/" ); if( !aAutosaveDir.exists() ) { if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) { // Last chance: use _PATH_TMP aAutosaveDir.setPath( _PATH_TMP ); } } aFilename.replace( QRegExp( "/" ), "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); return qstrdup( aFilename.data() );}const char* KApplication::checkRecoverFile( const char* pFilename, bool& bRecover ){ QString aFilename; if( pFilename[0] != '/' ) { KDEBUG( KDEBUG_WARN, 101, "Relative filename passed to KApplication::tempSaveName" ); aFilename = QFileInfo( QDir( "." ), pFilename ).absFilePath(); } else aFilename = pFilename; QDir aAutosaveDir( QDir::homeDirPath() + "/autosave/" ); if( !aAutosaveDir.exists() ) { if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) { // Last chance: use _PATH_TMP aAutosaveDir.setPath( _PATH_TMP ); } } aFilename.replace( QRegExp( "/" ), "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); if( QFile( aFilename ).exists() ) { bRecover = true; return qstrdup( aFilename.data() ); } else { bRecover = false; return qstrdup( pFilename ); }}bool checkAccess(const char *pathname, int mode){ int accessOK = access( pathname, mode ); if ( accessOK == 0 ) return true; // OK, I can really access the file // else // if we want to write the file would be created. Check, if the // user may write to the directory to create the file. if ( mode & W_OK == 0 ) return false; // Check for write access is not part of mode => bail out //strip the filename (everything until '/' from the end QString dirName(pathname); int pos = dirName.findRev('/'); if ( pos == -1 ) return false; // No path in argument. This is evil, we won't allow this dirName.resize(pos+1); // strip everything starting from the last '/' accessOK = access( dirName, W_OK ); // -?- Can I write to the accessed diretory if ( accessOK == 0 ) return true; // Yes else return false; // No}void KApplication::setTopWidget( QWidget *topWidget ){ pTopWidget = topWidget; if (topWidget){ // set the specified icons KWM::setIcon(topWidget->winId(), getIcon()); KWM::setMiniIcon(topWidget->winId(), getMiniIcon()); // set a short icon text XSetIconName( qt_xdisplay(), topWidget->winId(), getCaption() ); if (bSessionManagement) enableSessionManagement(bSessionManagementUserDefined); if (!bSessionManagement) KWM::setWmCommand( topWidget->winId(), aWmCommand); }}void KApplication::registerTopWidget(){}void KApplication::unregisterTopWidget(){}#include "kapp.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -