⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kapp.cpp

📁 一种效率高
💻 CPP
📖 第 1 页 / 共 4 页
字号:
  // at which child process are being killed). So we first mark  // the controller deleted (so that the SIGCHLD handler thinks it  // is already gone) before we actually delete it.  KProcessController* ctrl = theKProcessController;  theKProcessController = 0;  delete ctrl; // Stephan: "there can be only one" ;)  KApp = 0;}bool KApplication::x11EventFilter( XEvent *_event ){  // You can get root drop events twice.  // This is to avoid this.  static int rootDropEventID = -1;  if ( _event->type == ClientMessage )    {	  XClientMessageEvent *cme = ( XClientMessageEvent * ) _event;	  // session management	  if( cme->message_type == WM_PROTOCOLS )		{		  if( (Atom)(cme->data.l[0]) == WM_SAVE_YOURSELF )			{			    //we want a new session config!			    if (bIsRestored && pSessionConfig) {				delete pSessionConfig;				pSessionConfig = 0;				bIsRestored = false;			    }										  if (!topWidget() ||			      cme->window != topWidget()->winId()){			    KWM::setWmCommand(cme->window, "");			    return true;			  }						  emit saveYourself(); // give applications a chance to			  // save their data			  if (bSessionManagementUserDefined)			    KWM::setWmCommand( topWidget()->winId(), aWmCommand);			  else {						    if (pSessionConfig && !aSessionName.isEmpty()){			      QString aCommand = aAppName.copy();			      if (aAppName != argv()[0]){					if (argv()[0][0]=='/')					  aCommand = argv()[0];					else {					  char* s = new char[1024];					  aCommand=(getcwd(s, 1024));					  aCommand+="/";					  delete [] s;					  aCommand+=aAppName;					}			      }			      aCommand+=" -restore ";			      aCommand+=aSessionName;			      aCommand+=aDummyString2;			      KWM::setWmCommand( topWidget()->winId(),									 aCommand);			      pSessionConfig->sync();			    } else {			      QString aCommand = argv()[0];			      aCommand+=aDummyString2;			      KWM::setWmCommand( topWidget()->winId(),									 aCommand);			    }			  }						  return true;			}		}	  // stuff for reconfiguring	  if ( cme->message_type == KDEChangeStyle )		{		  QString str;				  getConfig()->setGroup("KDE");		  str = getConfig()->readEntry("widgetStyle");		  if(!str.isNull())		    if(str == "Motif")		      applyGUIStyle(MotifStyle);		    else		      if(str == "Windows 95")			applyGUIStyle(WindowsStyle);		  return TRUE;		}	  if ( cme->message_type == KDEChangePalette )		{		  readSettings();		  kdisplaySetPalette();				  return True;		}	  if ( cme->message_type == KDEChangeGeneral )		{		  readSettings();		  kdisplaySetStyleAndFont();		  kdisplaySetPalette();				  return True;		}		  if ( cme->message_type == DndLeaveProtocol )		{		  if ( lastEnteredDropZone != 0L )			lastEnteredDropZone->leave();			  lastEnteredDropZone = 0L;		  return TRUE;		}	  else if ( cme->message_type != DndProtocol && cme->message_type != DndEnterProtocol &&				cme->message_type != DndRootProtocol )	    return FALSE;		  Window root = DefaultRootWindow(display);		  unsigned char *Data;	  unsigned long Size;	  Atom    ActualType;	  int     ActualFormat;	  unsigned long RemainingBytes;	  XGetWindowProperty(display,root,DndSelection,						 0L,1000000L,						 FALSE,AnyPropertyType,						 &ActualType,&ActualFormat,						 &Size,&RemainingBytes,						 &Data);	  QPoint p( (int)cme->data.l[3], (int)cme->data.l[4] );	  if ( cme->message_type == DndRootProtocol )		{		  if ( rootDropEventID == (int)cme->data.l[1] )			return FALSE;			  rootDropEventID = (int)cme->data.l[1];		  if ( rootDropZone != 0L )			rootDropZone->drop( (char*)Data, Size, (int)cme->data.l[0], p.x(), p.y() );		  return TRUE;		}		  KDNDDropZone *dz;	  KDNDDropZone *result = 0L;		  /*		for ( dz = dropZones.first(); dz != 0L; dz = dropZones.next() )		{		QPoint p2 = dz->getWidget()->mapFromGlobal( p );		if ( dz->getWidget()->rect().contains( p2 ) )		result = dz;		}	  */	  QWidget *w = widgetAt( p.x(), p.y(), TRUE );	  while ( result == 0L && w != 0L )		{	      for ( dz = dropZones.first(); dz != 0L; dz = dropZones.next() )			{			  if ( dz->getWidget() == w )				result = dz;			}		      if ( result == 0L )			w = w->parentWidget();		}	  // KFM hack. Find not decorated windows ( root icons )	  if ( result == 0L )		for ( dz = dropZones.first(); dz != 0L; dz = dropZones.next() )	      {			QPoint p2 = dz->getWidget()->mapFromGlobal( p );			if ( dz->getWidget()->rect().contains( p2 ) )		      result = dz;	      }		  if ( result != 0L )		{	      if ( cme->message_type == DndProtocol )			{			  result->drop( (char*)Data, Size, (int)cme->data.l[0], p.x(), p.y() );			}	      else if ( cme->message_type == DndEnterProtocol )			{			  // If we entered another drop zone, tell the drop zone we left about it			  if ( lastEnteredDropZone != 0L && lastEnteredDropZone != result )				lastEnteredDropZone->leave();					  // Notify the drop zone over which the pointer is right now.			  result->enter( (char*)Data, Size, (int)cme->data.l[0], p.x(), p.y() );			  lastEnteredDropZone = result;			}		}	  else		{		  // Notify the last DropZone that the pointer has left the drop zone.		  if ( lastEnteredDropZone != 0L )			lastEnteredDropZone->leave();		  lastEnteredDropZone = 0L;		}	  return TRUE;    }  return FALSE;}void KApplication::applyGUIStyle(GUIStyle newstyle) {  QApplication::setStyle( applicationStyle );  // get list of toplevels  QWidgetList *wl = QApplication::topLevelWidgets();  QWidgetListIt wl_it( *wl );  // foreach toplevel ...  while(wl_it.current()) {    QWidget *w = wl_it.current();    // set new style    w->setStyle(newstyle);    QObjectList *ol = w->queryList("QWidget", 0, 0, TRUE);    QObjectListIt ol_it( *ol );    // set style to child widgets    while ( ol_it.current() ) {      QWidget *child = (QWidget *)(ol_it.current());      child->setStyle(newstyle);      ++ol_it;    }    delete ol;    ++wl_it;  }  delete wl;}QString KApplication::findFile( const char *file ){  QString fullPath;  QStrListIterator it( *pSearchPaths );  while ( it.current() )    {	  fullPath = it.current();	  fullPath += '/';	  fullPath += file;	  if ( !access( fullPath, 0 ) )		return fullPath;	  ++it;    }  fullPath.resize( 0 );  return fullPath;}const char* KApplication::getCaption() const{  if( !aCaption.isNull() )	return aCaption;  else	return aAppName;}void KApplication::buildSearchPaths(){  // Torben  // We want to search the local files with highest priority  QString tmp = KApplication::localkdedir();  appendSearchPath( tmp );  // add paths from "[KDE Setup]:Path=" config file entry  getConfig()->setGroup( "KDE Setup" );  QString kdePathRc = getConfig()->readEntry( "Path" );  if ( !kdePathRc.isNull() )    {      char *start, *end, *workPath = new char [ kdePathRc.length() + 1 ];	  strcpy( workPath, kdePathRc );	  start = workPath;	  while ( start )		{	  	  end = strchr( start, ':' );		  if ( end )		    *end = '\0';		  appendSearchPath( start );		  start = end ? end + 1 : end;		}	  delete [] workPath;    }  // add paths in the KDEPATH environment variable  const char *kdePathEnv = getenv( "KDEPATH" );  if ( kdePathEnv )    {	  char *start, *end, *workPath = new char [ strlen( kdePathEnv ) + 1 ];	  strcpy( workPath, kdePathEnv );	  start = workPath;	  while ( start )		{	  	  end = strchr( start, ':' );		  if ( end )		    *end = '\0';		  appendSearchPath( start );		  start = end ? end + 1 : end;		}	  delete [] workPath;    }  appendSearchPath( kdedir().data() );}void KApplication::appendSearchPath( const char *path ){  QStrListIterator it( *pSearchPaths );  // return if this path has already been added  while ( it.current() )    {	  if ( !strcmp( it.current(), path ) )		return;	  ++it;    }  pSearchPaths->append( path );}void KApplication::readSettings(){  // use the global config files  KConfig* config = getConfig();  config->reparseConfiguration();  QString str;	  // Read the color scheme group from config file  // If unavailable set color scheme to KDE default  config->setGroup( "General");  // this default is Qt black  textColor = config->readColorEntry( "foreground", &black );  // this default is the Qt lightGray  backgroundColor = config->readColorEntry( "background", &lightGray  );  // this default is Qt darkBlue  selectColor = config->readColorEntry( "selectBackground", &darkBlue );  // this default is Qt white  selectTextColor = config->readColorEntry( "selectForeground", &white);  // this default is Qt white  windowColor = config->readColorEntry( "windowBackground", &white );  // this default is Qt black  windowTextColor = config->readColorEntry( "windowForeground", &black );	  config->setGroup( "WM");  // this default is Qt lightGray  inactiveTitleColor = config->readColorEntry( "inactiveBackground", &lightGray );  // this default is Qt darkGrey  inactiveTextColor = config->readColorEntry( "inactiveForeground", &darkGray );  // this default is Qt darkBlue  activeTitleColor = config->readColorEntry( "activeBackground", &darkBlue );  // this default is Qt white  activeTextColor = config->readColorEntry( "activeForeground", &white );  config->setGroup( "KDE");  contrast = config->readNumEntry( "contrast", 7 );  //  Read the font specification from config.  //  Initialize fonts to default first or it won't work !!		  pCharsets->setDefault(klocale->charset());  generalFont = QFont("helvetica", 12, QFont::Normal);  pCharsets->setQFont(generalFont);  fixedFont = QFont("fixed", 12, QFont::Normal);  pCharsets->setQFont(fixedFont);  config->setGroup( "General" );  generalFont = config->readFontEntry( "font", &generalFont );  fixedFont = config->readFontEntry( "fixedFont", &fixedFont );  // Finally, read GUI style from config.	  config->setGroup( "KDE" );  if ( config->readEntry( "widgetStyle", "Windows 95" ) == "Windows 95" )    applicationStyle=WindowsStyle;  else    applicationStyle=MotifStyle;	}void KApplication::kdisplaySetPalette(){  // WARNING : QApplication::setPalette() produces inconsistent results.  // There are 3 problems :-  // 1) You can't change select colors  // 2) You need different palettes to apply the same color scheme to  //		different widgets !!  // 3) Motif style needs a different palette to Windows style.	  int highlightVal, lowlightVal;	  highlightVal=100+(2*contrast+4)*16/10;  lowlightVal=100+(2*contrast+4)*10;	  // printf("contrast = %d\n", contrast);	  if ( applicationStyle==MotifStyle ) {	QColorGroup disabledgrp( textColor, backgroundColor,							 backgroundColor.light(highlightVal),							 backgroundColor.dark(lowlightVal),							 backgroundColor.dark(120),							 backgroundColor.dark(120), windowColor );	QColorGroup colgrp( textColor, backgroundColor,						backgroundColor.light(highlightVal),						backgroundColor.dark(lowlightVal),						backgroundColor.dark(120),						textColor, windowColor );	QApplication::setPalette( QPalette(colgrp,disabledgrp,colgrp), TRUE );	emit kdisplayPaletteChanged();	emit appearanceChanged();  } else {	QColorGroup disabledgrp( textColor, backgroundColor,							 backgroundColor.light(150),							 backgroundColor.dark(),							 backgroundColor.dark(120),							 backgroundColor.dark(120), windowColor );	QColorGroup colgrp( textColor, backgroundColor,						backgroundColor.light(150),						backgroundColor.dark(),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -