Example #1
0
bool KAccel::setKeyDict( QDict<KKeyEntry> nKeyDict )
{

	kdebug(KDEBUG_INFO, 125, "Disconenct and remove");
	// Disconnect and remove all items in pAccel
	QDictIterator<KKeyEntry> *aKeyIt = new QDictIterator<KKeyEntry>( aKeyDict );
	aKeyIt->toFirst();
#define pE aKeyIt->current()
	while( pE ) {
		QString s;
		if ( pE->aAccelId && pE->aCurrentKeyCode ) {
			pAccel->disconnectItem( pE->aAccelId, pE->receiver,
						pE->member );
			pAccel->removeItem( pE->aAccelId );
		}
		++*aKeyIt;
	}
#undef pE
	
	kdebug(KDEBUG_INFO, 125, "Clear the dictionary");
	
	// Clear the dictionary
	aKeyDict.clear();
	
	kdebug(KDEBUG_INFO, 125, "Insert new items");
	
	// Insert the new items into the dictionary and reconnect if neccessary
	// Note also swap config and current key codes !!!!!!
	delete aKeyIt; // tanghus
	aKeyIt = new QDictIterator<KKeyEntry>( nKeyDict );
	aKeyIt->toFirst();
#define pE aKeyIt->current()
	KKeyEntry *pEntry;
	while( pE ) {
		pEntry = new KKeyEntry;
		aKeyDict.insert( aKeyIt->currentKey(), pEntry );
		pEntry->aDefaultKeyCode = pE->aDefaultKeyCode;
		// Note we write config key code to current key code !!
		pEntry->aCurrentKeyCode = pE->aConfigKeyCode;
		pEntry->aConfigKeyCode = pE->aConfigKeyCode;
		pEntry->bConfigurable = pE->bConfigurable;
		pEntry->aAccelId = pE->aAccelId;
		pEntry->receiver = pE->receiver;
		pEntry->member = pE->member;
		pEntry->descr = pE->descr; // tanghus
		
		if ( pEntry->aAccelId && pEntry->aCurrentKeyCode ) {
			pAccel->insertItem( pEntry->aCurrentKeyCode, pEntry->aAccelId );
			pAccel->connectItem( pEntry->aAccelId, pEntry->receiver,
					     pEntry->member);
		}
		++*aKeyIt;
	}
#undef pE
		
	delete aKeyIt; // tanghus
	return true;
}
Example #2
0
bool KGlobalAccel::setKeyDict( QDict<KKeyEntry> nKeyDict )
{
	// ungrab all connected and enabled keys
	QDictIterator<KKeyEntry> *aKeyIt = new QDictIterator<KKeyEntry>( aKeyDict );
	aKeyIt->toFirst();
#define pE aKeyIt->current()
	while( pE ) {
		QString s;
		if ( pE->bEnabled ) {
			uint keysym = keyToXSym( pE->aCurrentKeyCode );
			uint mod = keyToXMod( pE->aCurrentKeyCode );
			ungrabKey( keysym, mod );
		}
		++*aKeyIt;
	}
#undef pE
	
	// Clear the dictionary
	aKeyDict.clear();
	
	// Insert the new items into the dictionary and reconnect if neccessary
	// Note also swap config and current key codes !!!!!!
	aKeyIt = new QDictIterator<KKeyEntry>( nKeyDict );
	aKeyIt->toFirst();
#define pE aKeyIt->current()
	KKeyEntry *pEntry;
	while( pE ) {
		pEntry = new KKeyEntry;
		aKeyDict.insert( aKeyIt->currentKey(), pEntry );

		pEntry->aDefaultKeyCode = pE->aDefaultKeyCode;
		// Not we write config key code to current key code !!
		pEntry->aCurrentKeyCode = pE->aConfigKeyCode;
		pEntry->aConfigKeyCode = pE->aConfigKeyCode;
		pEntry->bConfigurable = pE->bConfigurable;
		pEntry->aAccelId = pE->aAccelId;
		pEntry->receiver = pE->receiver;
		pEntry->member = new QString( pE->member->data() );
		pEntry->bEnabled = pE->bEnabled;
		
		if ( pEntry->bEnabled ) {
			uint keysym = keyToXSym( pEntry->aCurrentKeyCode );
			uint mod = keyToXMod( pEntry->aCurrentKeyCode );
			grabKey( keysym, mod );
		}
		
		++*aKeyIt;
	}
#undef pE
		
	return true;
}
Example #3
0
bool KGlobalAccel::x11EventFilter( const XEvent *event_ ) {
	if ( aKeyDict.isEmpty() ) return false;
	if ( event_->type != KeyPress ) return false;
	
	uint mod=event_->xkey.state & (ControlMask | ShiftMask | Mod1Mask);
	uint keysym= XKeycodeToKeysym(qt_xdisplay(), event_->xkey.keycode, 0);
	
	debug("Key press event :: mod = %d, sym =%d", mod, keysym );
   
   KKeyEntry *pEntry =0;
   const char *action;
   
	QDictIterator<KKeyEntry> *aKeyIt = new QDictIterator<KKeyEntry>( aKeyDict );
	aKeyIt->toFirst();
#define pE aKeyIt->current()
	while( pE ) { //&& 
		//( mod != keyToXMod( pE->aCurrentKeyCode ) 
		//	|| keysym != keyToXSym( pE->aCurrentKeyCode ) ) ) {
		int kc = pE->aCurrentKeyCode;
		if( mod == keyToXMod( kc ) ) debug("That's the right modifier");
		if( keysym == keyToXSym( kc ) ) debug("That's the right symbol");
		if ( mod == keyToXMod( kc ) && keysym == keyToXSym( kc ) ) {
		//pEntry = pE;
		//action = aKeyIt->currentKey();
		//break;
		debug("Found key in dictionary for action %s", aKeyIt->currentKey());
		break;
		}
		++*aKeyIt;
	}
	
	if ( !pE ) {
		debug("Null KeyEntry object");
		return false; 
	}
	
	if ( !pE ) {
		debug("KeyEntry object not enabled");
		return false; 
	}

	debug("KGlobalAccel:: event action %s", aKeyIt->currentKey() );

	XAllowEvents(qt_xdisplay(), AsyncKeyboard, CurrentTime);
	
	connect( this, SIGNAL( activated() ), pE->receiver, pE->member->data() );
	emit activated();
	disconnect( this, SIGNAL( activated() ), pE->receiver, pE->member->data() );

//    warning("Signal has been sent!");
	return true;
}
Example #4
0
//====================================
// exportData
//------------------------------------
bool SCCMonitor::exportData ( void ) {
	int card = 0;
	//====================================
	// save particular monitor data
	//------------------------------------
	QListIterator<SCCMonitorDisplay> it (mMonitorDisplay);
	for (; it.current() ; ++it) {
		//====================================
		// remove current layout
		//------------------------------------
		if ( mMonitorArrange ) {
			QString screenID;
			QTextOStream (&screenID) << "Screen:Screen[" << card << "]";
			mSection["Layout"]->removeEntry( screenID );
		}
		//====================================
		// check for monitor display's
		//------------------------------------
		SCCMonitorDisplay* display = (SCCMonitorDisplay*)it.current();
		//if (display->isEnabled()) {
		//====================================
		// create manipulators...
		//------------------------------------
		SaXManipulateCard saxCard (
			mSection["Card"]
		);
		SaXManipulateDesktop saxDesktop ( 
			mSection["Desktop"],mSection["Card"],mSection["Path"]
		);
		//====================================
		// select card and desktop
		//------------------------------------
		saxDesktop.selectDesktop ( card );
		saxCard.selectCard ( card );

		//====================================
		// save resolution list
		//------------------------------------
		int colorDepths[4] = {8,15,16,24};
		for (int n=0;n<4;n++) {
			int color = colorDepths[n];
			QString modesKey;
			QTextOStream (&modesKey) << "Modes:" << color;
			mSection["Desktop"] -> removeEntry ( modesKey );
			QList<QString> resList = display->getResolution();
			QListIterator<QString> it ( resList );
			for (; it.current(); ++it) {
				QStringList tokens = QStringList::split ( "x",*it.current() );
				int xaxis = tokens.first().toInt();
				int yaxis = tokens.last().toInt();
				saxDesktop.addResolution (
					color,xaxis,yaxis
				);
			}
		}
		//====================================
		// save monitor settings
		//------------------------------------
		SCCMonitorModel* monitorData = display->getMonitorData();
		saxDesktop.setMonitorVendor (monitorData->getVendorName());
		saxDesktop.setMonitorName   (monitorData->getModelName());
		saxDesktop.setHsyncRange (
			(double)monitorData->getHSmin(),
			(double)monitorData->getHSmax()
		);
		saxDesktop.setVsyncRange (
			(double)monitorData->getVSmin(),
			(double)monitorData->getVSmax()
		);
		int sizeX = monitorData->getSizeX();
		int sizeY = monitorData->getSizeY();
		if ((sizeX > 0) && (sizeY > 0)) {
			saxDesktop.setDisplaySize ( sizeX,sizeY );
		}
		saxDesktop.disableDPMS();
		if (monitorData->isDPMSEnabled()) {
			saxDesktop.enableDPMS();
		}
		QString algorithm = saxDesktop.getModelineAlgorithm();
		if (algorithm != "XServerPool") {
			saxDesktop.calculateModelines ( true );
		}
		//====================================
		// save card options
		//------------------------------------
		SCCMonitorCard* cardData = display->getCardData();
		QDict<QString> optList = cardData->getOptions();
		mSection["Card"] -> removeEntry ("Option");
		mSection["Card"] -> removeEntry ("RawData");
		QDictIterator<QString> io (optList);
		for (; io.current(); ++io) {
			saxCard.addCardOption ( io.currentKey(),*io.current());
		}
		int rotateID = cardData->getRotate();
		mSection["Card"] -> removeEntry ("Rotate");
		saxCard.setRotate ( rotateID );

		//====================================
		// check for dual head mode
		//------------------------------------
		QString profile = saxDesktop.getDualHeadProfile();
		if ((! profile.isEmpty()) && (! saxDesktop.isXineramaMode())) {
			SaXImportProfile* pProfile = SaXWidgetProfile->getProfile (profile);
			SaXImport* mImport = pProfile -> getImport ( SAX_CARD );
			if ( mImport ) {
				//====================================
				// pick up card profile data
				//------------------------------------
				QString driver = saxCard.getCardDriver();
				QDict<QString> profileDriverOptions;
				SaXManipulateCard saxProfileCard ( mImport );
				profileDriverOptions = saxProfileCard.getOptions();
				QDictIterator<QString> it ( profileDriverOptions );

				//====================================
				// delete profile data keys
				//------------------------------------
				for (; it.current(); ++it) {
					saxCard.removeCardOption (it.currentKey());
				}
				#if 1 // to be removed as soon as possible
				//====================================               
				// fix broken cards                                     
				//------------------------------------
				fixBrokenCards (saxCard);
				#endif
				//====================================
				// init special modelines
				//------------------------------------
				//mSection["Desktop"] -> removeEntry ("SpecialModeline");
				saxDesktop.setExtraModelineString (
					monitorData->getExtraModeline()
				);
				//====================================
				// setup profile data
				//------------------------------------
				if (display->isDualModeEnabled()) {
					it.toFirst();
					SCCMonitorDual* dualData;
					SCCMonitorDualModel* dualModel;
					dualData  = display->getDualData();
					dualModel = dualData->getDualModelData();
					//====================================
					// call ok slot from dualhead setup
					//------------------------------------
					dualData->slotOk();
					//====================================
					// setup dualhead options
					//------------------------------------
					saxCard.addCardOption ("SaXDualHead",0);
					for (; it.current(); ++it) {
						QString key = it.currentKey();
						QString val = *it.current();
						//====================================
						// setup profile "off"-line data
						//------------------------------------
						if (val == "off") {
							saxCard.addCardOption ( key,val );
							continue;
						}
						//====================================
						// setup profile meta data
						//------------------------------------
						if (key == "SaXDualMonitorVendor") {
							QString vendor = dualModel ->getVendorName();
							saxCard.addCardOption ( key,vendor );
						}
						if (key == "SaXDualMonitorModel") {
							QString model = dualModel ->getModelName();
							saxCard.addCardOption ( key,model );
						}
						if (key == "SaXDualResolution") {
							QString resolution = dualData->getResolution();
							saxCard.addCardOption ( key,resolution );
						}
						if (key == "SaXDualOrientation") {
							int orientation  = dualData->getLayout();
							QString position = DUAL_LEFTOF_KEY;
							switch (orientation) {
								case DUAL_ABOVEOF:
									position = DUAL_ABOVEOF_KEY;
								break;
								case DUAL_RIGHTOF:
									position = DUAL_RIGHTOF_KEY;
								break;
								case DUAL_BELOWOF:
									position = DUAL_BELOWOF_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,position );
						}
						if (key == "SaXDualMode") {
							int mode = dualData->getMode();
							QString dualMode = DUAL_TRADITIONAL_KEY;
							switch (mode) {
								case DUAL_CLONE:
									dualMode = DUAL_CLONE_KEY;
								break;
								case DUAL_XINERAMA:
									dualMode = DUAL_XINERAMA_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,dualMode );
						}
						if (key == "SaXDualHSync") {
							QString hsync;
							int hsmax = dualModel->getHSmax();
							int hsmin = dualModel->getHSmin();
							QTextOStream (&hsync) << hsmin << "-" << hsmax;
							saxCard.addCardOption ( key,hsync );	
						}
						if (key == "SaXDualVSync") {
							QString vsync;
							int hsmax = dualModel->getHSmax();
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
							//====================================
							// calculate one modeline for each res
							//------------------------------------
							QString algorithm=saxDesktop.getModelineAlgorithm();
							if (algorithm != "XServerPool") {
								QList<QString> rList;
								rList=dualData->getResolutionList();
								QListIterator<QString> ir (rList);
								for (; ir.current(); ++ir) {
									QStringList xy = QStringList::split (
										"x",*ir.current()
									);
									int x = xy.first().toInt();
									int y = xy.last().toInt();
									log (L_INFO,
										"Add special mode: %dx%d@%d\n",x,y,vsmax
									);
									saxDesktop.addExtraModeline (
										x,y,vsmax,hsmax
									);
								}
							}
						}
						//====================================
						// setup profile NVidia data
						//------------------------------------
						if (key == "TwinView") {
							saxCard.addCardOption ( key,0 );
						}
						if (key == "ConnectedMonitor") {
							QStringList cs = QStringList::split (",",val);
							QString channelA = cs.first();
							QString channelB = cs.last();
							if ((channelA == "AUTO") || (channelB == "AUTO")) {
								saxCard.removeCardOption ( key );
							} else {
								saxCard.addCardOption ( key,val );
							}
						}
						if ((key== "MetaModes") && (driver == "nvidia")) {
							QString channelA = "AUTO:";
							QString channelB = "AUTO:";
							if (profileDriverOptions["ConnectedMonitor"]) {
								QStringList cs = QStringList::split (",",
									*profileDriverOptions["ConnectedMonitor"]
								);
								channelA = cs.first() + ":";
								channelB = cs.last()  + ":";
							}
							if ((channelA=="AUTO:") || (channelB=="AUTO:")) {
								channelA = "";
								channelB = "";
							}
							QList<QString> rList1=display->getResolution();
							QString resolution1 = *rList1.at(0);
							QList<QString> rList2=dualData->getResolutionList();
							QString resolution2 = *rList2.at(0);
							//====================================
							// add primary meta mode
							//------------------------------------
							QString metaItem;
							QString resolution;
							QTextOStream (&metaItem) <<
								channelA << resolution1 << "," <<
								channelB << resolution2;
							resolution.append (";"+metaItem);
							//====================================
							// add secondary meta modes
							//------------------------------------
							bool startMeta = false;
							QListIterator<QString> ir (rList1);
							for (; ir.current(); ++ir) {
								if (! startMeta) {
									startMeta = true; continue;
								}
								QString metaItem;
								int cmpr = compareResolution (
									*ir.current(),resolution2
								);
								if (cmpr >= 0) {
									QTextOStream (&metaItem) <<
										channelA << *ir.current() << "," <<
										channelB << resolution2;
								} else {
									QTextOStream (&metaItem) <<
										channelA << *ir.current() << "," <<
										channelB << *ir.current();
								}
								resolution.append (";"+metaItem);
							}
							resolution.replace(QRegExp("^;"),"");
							saxCard.addCardOption ( key,resolution );
						}
						if (key == "SecondMonitorHorizSync") {
							QString hsync;
							int hsmax = dualModel->getHSmax();
							int hsmin = dualModel->getHSmin();
							QTextOStream (&hsync) << hsmin << "-" << hsmax;
							saxCard.addCardOption ( key,hsync );
						}
						if (key == "SecondMonitorVertRefresh") {
							QString vsync;
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
						}
						if (key == "TwinViewOrientation") {
							int orientation  = dualData->getLayout();
							QString position = DUAL_LEFTOF_KEY;
							switch (orientation) {
								case DUAL_ABOVEOF:
									position = DUAL_ABOVEOF_KEY;
								break;
								case DUAL_RIGHTOF:
									position = DUAL_RIGHTOF_KEY;
								break;
								case DUAL_BELOWOF:
									position = DUAL_BELOWOF_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,position );
							int mode = dualData->getMode();
							if ( mode == DUAL_CLONE ) {
								saxCard.removeCardOption (key);
								saxCard.addCardOption (key,DUAL_CLONE_KEY);
							}
						}
						//====================================
                        // setup profile Matrox data
                        //------------------------------------
						if ((key == "MergedFB") && (driver == "mga")) {
							saxCard.addCardOption ( key,0 );
						}
						if (key == "Monitor2HSync") {
							QString hsync;
							int hsmax = dualModel->getHSmax();
							int hsmin = dualModel->getHSmin();
							QTextOStream (&hsync) << hsmin << "-" << hsmax;
							saxCard.addCardOption ( key,hsync );
						}
						if (key == "Monitor2VRefresh") {
							QString vsync;
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
						}
						if ((key== "MetaModes") && (driver == "mga")) {
							QList<QString> rList1=display->getResolution();
							QString resolution1 = *rList1.at(0);
							QList<QString> rList2=dualData->getResolutionList();
							QString resolution2 = *rList2.at(0);
							//====================================
							// add primary meta mode
							//------------------------------------
							QString metaItem;
							QTextOStream (&metaItem) <<
								resolution1 << "-" << resolution2;
							saxCard.addCardOption ( key,metaItem );
							//====================================
							// add virtual size
							//------------------------------------
							for (int color=8;color<=24;color+=8) {
								saxDesktop.removeVirtualResolution (color);
							}
							int mode = dualData->getMode();
							if ( mode != DUAL_CLONE ) {
								QStringList r1 = QStringList::split (
									"x",resolution1
								);
								QStringList r2 = QStringList::split (
									"x",resolution2
								);
								int x1 = r1.first().toInt();
								int y1 = r1.last().toInt();
								int x2 = r2.first().toInt();
								int y2 = r2.last().toInt();
								int orientation  = dualData->getLayout();
								int x = 0;
								int y = 0;
								switch (orientation) {
									case DUAL_ABOVEOF:
									case DUAL_BELOWOF:
										y = y1 + y2;
										if (x1 > x2) x = x1; else x = x2;
									break;
									case DUAL_RIGHTOF:
									case DUAL_LEFTOF:
										x = x1 + x2;
										if (y1 > y2) y = y1; else y = y2;
									break;
									default:
									break;
								}
								for (int color=8;color<=24;color+=8) {
									saxDesktop.setVirtualResolution (color,x,y);
								}
							}
						}
						if (key == "Monitor2Position") {
							int orientation  = dualData->getLayout();
							QString position = DUAL_LEFTOF_KEY;
							switch (orientation) {
								case DUAL_ABOVEOF:
									position = DUAL_ABOVEOF_KEY;
								break;
								case DUAL_RIGHTOF:
									position = DUAL_RIGHTOF_KEY;
								break;
								case DUAL_BELOWOF:
									position = DUAL_BELOWOF_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,position );
							int mode = dualData->getMode();
							if ( mode == DUAL_CLONE ) {
								saxCard.removeCardOption (key);
								saxCard.addCardOption (key,DUAL_CLONE_KEY);
							}
						}
						//====================================
						// setup profile Radeon data
						//------------------------------------
						if (key == "MergedFB") {
							saxCard.addCardOption ( key,0 );
						}
						if (key == "CRT2HSync") {
							QString hsync;
							int hsmax = dualModel->getHSmax();
							int hsmin = dualModel->getHSmin();
							QTextOStream (&hsync) << hsmin << "-" << hsmax;
							saxCard.addCardOption ( key,hsync );
						}
						if (key == "CRT2VRefresh") {
							QString vsync;
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
						}
						if (key == "IgnoreEDID") {
							saxCard.addCardOption ( key,0 );
						}
						if ((key== "MetaModes") && (driver == "radeon")) {
							QList<QString> rList1=display->getResolution();
							QString resolution1 = *rList1.at(0);
							QList<QString> rList2=dualData->getResolutionList();
							QString resolution2 = *rList2.at(0);
							//====================================
							// add primary meta mode
							//------------------------------------
							QString metaItem;
							QString resolution;
							QTextOStream (&metaItem) <<
								resolution1 << "," << resolution2;
							resolution.append (";"+metaItem);
							//====================================
							// add secondary meta modes
							//------------------------------------
							bool startMeta = false;
							QListIterator<QString> ir (rList1);
							for (; ir.current(); ++ir) {
								if (! startMeta) {
									startMeta = true; continue;
								}
								QString metaItem;
								int cmpr = compareResolution (
									*ir.current(),resolution2
								);
								if (cmpr >= 0) {
									QTextOStream (&metaItem) <<
										*ir.current() << "," << resolution2;
								} else {
									QTextOStream (&metaItem) <<
										*ir.current() << "," << *ir.current();
								}
								resolution.append (";"+metaItem);
							}
							resolution.replace(QRegExp("^;"),"");
							saxCard.addCardOption ( key,resolution );
						}
						if (key == "CRT2Position") {
							int orientation  = dualData->getLayout();
							QString position = DUAL_LEFTOF_KEY;
							switch (orientation) {
								case DUAL_ABOVEOF:
									position = DUAL_ABOVEOF_KEY;
								break;
								case DUAL_RIGHTOF:
									position = DUAL_RIGHTOF_KEY;
								break;
								case DUAL_BELOWOF:
									position = DUAL_BELOWOF_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,position );
							int mode = dualData->getMode();
							if ( mode == DUAL_CLONE ) {
								saxCard.removeCardOption (key);
								saxCard.addCardOption (key,DUAL_CLONE_KEY);
							}
						}
						//====================================
						// setup profile Intel data
						//------------------------------------
						if ((key== "MonitorLayout") && (driver == "i810")) {
							saxCard.addCardOption ( key,val );
						}
						if (key == "Clone") {
							saxCard.addCardOption ( key,0 );
						}
						if (key == "CloneRefresh") {
							QString vsync;
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
						}
						//====================================
						// setup profile FGLRX data
						//------------------------------------
						if (key== "ForceMonitors") {
							saxCard.addCardOption ( key,val );
						}
						if (key == "DesktopSetup") {
							int orientation  = dualData->getLayout();
							QString position = DUAL_FGLRX_LEFTOF_KEY;
							switch (orientation) {
								case DUAL_ABOVEOF:
									position = DUAL_FGLRX_ABOVEOF_KEY;
								break;
								case DUAL_RIGHTOF:
									position = DUAL_FGLRX_RIGHTOF_KEY;
								break;
								case DUAL_BELOWOF:
									position = DUAL_FGLRX_BELOWOF_KEY;
								break;
								default:
								break;
							}
							saxCard.addCardOption ( key,position );
							int mode = dualData->getMode();
							if ( mode == DUAL_CLONE ) {
								saxCard.removeCardOption (key);
								saxCard.addCardOption (key,DUAL_CLONE_KEY);
							}
						}
						if (key == "HSync2") {
							QString hsync;
							int hsmax = dualModel->getHSmax();
							int hsmin = dualModel->getHSmin();
							QTextOStream (&hsync) << hsmin << "-" << hsmax;
							saxCard.addCardOption ( key,hsync );
						}
						if (key == "VRefresh2") {
							QString vsync;
							int vsmax = dualModel->getVSmax();
							int vsmin = dualModel->getVSmin();
							QTextOStream (&vsync) << vsmin << "-" << vsmax;
							saxCard.addCardOption ( key,vsync );
						}
						if (key == "Mode2") {
							QString resolution;
							QList<QString> rList2=dualData->getResolutionList();
							QListIterator<QString> ir (rList2);
							for (; ir.current(); ++ir) {
								resolution.append(","+*ir.current());
							}
							resolution.replace(QRegExp("^,"),"");
							saxCard.addCardOption ( key,resolution );
						}
					}
				}
			}
		}
		//}
		card++;
	}
	//====================================
	// save arrangement
	//------------------------------------
	if ( mMonitorArrange ) {
		//====================================
		// create manipulators...
		//------------------------------------
		SaXManipulateLayout saxLayout (
			mSection["Layout"],mSection["Card"]
		);
		//====================================
		// save multihead state
		//------------------------------------
		int multiheadMode = mMonitorArrange->getMultiheadMode();
		switch (multiheadMode) {
			case 0:
				saxLayout.setXOrgMultiheadMode ( SAX_TRADITIONAL );
			break;
			case 1:
				saxLayout.setXOrgMultiheadMode ( SAX_CLONE );
			break;
			case 2:
				saxLayout.setXOrgMultiheadMode ( SAX_XINERAMA );
			break;
			default:
			break;
		};
		//====================================
		// save XOrg layout
		//------------------------------------
		QDict<QString> arrangeDict = mMonitorArrange->getArrangement();
		QDictIterator<QString> it (arrangeDict);
		for (; it.current(); ++it) {
			QString item (it.currentKey());
			item.replace (QRegExp("Screen:Screen\\["),"");
			item.replace (QRegExp("\\]"),"");
			int index = item.toInt();

			int count = 0;
			int left=-1,right=-1,above=-1,below=-1;
			QStringList tokens = QStringList::split (" ", *it.current());
			for (QStringList::Iterator it=tokens.begin();it!=tokens.end();++it){
				QString value (*it);
				int id = -1;
				if (value != "<none>") {
					value.replace (QRegExp("Screen\\["),"");
					value.replace (QRegExp("\\]"),"");
					id = value.toInt();
				}
				switch (count) {
					case 0: left  = id; break;
					case 1: right = id; break;
					case 2: above = id; break;
					case 3: below = id; break;
					default:
					break;
				}
				count++;
			}
			saxLayout.setXOrgLayout (
				index,left,right,above,below
			);
		}
	}
	//====================================
	// save 3D status
	//------------------------------------
	SaXManipulateDesktop saxDesktop (
		mSection["Desktop"],mSection["Card"],mSection["Path"]
	);
	saxDesktop.disable3D();
	if (mCheck3D->isChecked()) {
		saxDesktop.enable3D();
	}
	//====================================
	// save default color depth
	//------------------------------------
	it.toFirst(); card = 0;
	for (; it.current() ; ++it) {
		SCCMonitorDisplay* display = (SCCMonitorDisplay*)it.current();
		SaXManipulateDesktop saxDesktop (
			mSection["Desktop"],mSection["Card"],mSection["Path"]
		);
		SaXManipulateCard saxCard (
			mSection["Card"]
		);
		saxDesktop.selectDesktop ( card );
		saxCard.selectCard ( card );
		if (saxCard.getCardDriver() != "fbdev") {
			saxDesktop.setColorDepth ( display->getColorDepth() );
		}
		card++;
	}
	return true;
}