//====================================
// setArrangement
//------------------------------------
void SCCMonitorArrange::setArrangement (
	int devices,QList<SCCMonitorDisplay> displays
) {
	//=====================================
	// get translation pointer
	//-------------------------------------
	SCCWrapPointer< QDict<QString> > mText (mTextPtr);
	mMatrix -> clear();

	//====================================
	// create manipulators
	//------------------------------------
	SaXManipulateLayout saxLayout (
		mSection["Layout"],mSection["Card"]
	);
	//====================================
	// obtain enabled device ID's
	//------------------------------------
	setDeviceMap ( devices,displays );

	//====================================
	// setup layout
	//------------------------------------
	for (int count=0;count < devices; count++) {
		QString key; QTextOStream (&key)
			<< "Screen:Screen[" << mCardID[count] << "]";
		QList<QString> neighbours = saxLayout.getXOrgLayout ( mCardID[count] );
		if (neighbours.isEmpty()) {
			continue;
		}
		QListIterator<QString> at (neighbours);
		int indexList [4];
		int index = 0;
		for (; at.current(); ++at) {
			QString* item = at.current();
			if (item->contains("none")) {
				indexList[ index ] = -1; index++;
				continue;
			}
			item->replace (QRegExp("Screen\\["),"");
			item->replace (QRegExp("\\]"),"");
			indexList[ index ] = item->toInt();
			index++;
		}
		SCCMonitorDisplay* displayInfo = displays.at ( mCardID[count] );
		SCCMonitorModel* monitorData = displayInfo -> getMonitorData();
		QString vendor = monitorData->getVendorName();
		QString model  = monitorData->getModelName();
		QString monitorInfo;
		if ( vendor != model ) {
			QTextOStream (&monitorInfo) << "<b>[" << count << "]</b> " << 
				mText["PrimaryMonitor"] << " " << vendor << " " << model;
		} else {
			QTextOStream (&monitorInfo) << "<b>[" << count << "]</b> " <<
				mText["UnknownMonitor"];
		}
		QString toolTip;
		QTextOStream (&toolTip)
			<< "<table border=0 cellspacing=0>"
			<< "<tr>"
			<< "<th rowspan=2><img src=\"" << TIP_PIXMAP << "\"></th>"
			<< "<td><nobr>" << monitorInfo << "</nobr></td>"
			<< "</tr>"
			<< "<tr>"
			<< "<td><nobr><hr>" << mText["ConnectedTo"] << " "
			<< displayInfo->getCardName() << "</nobr></td>"
			<< "</tr>"
			<< "</table>";
		mMatrix->setWidget(
			mCardID[count],indexList[0],indexList[1],indexList[2],indexList[3],
			toolTip,displayInfo->isDualModeEnabled()
		);
	}
	mMatrix->setLayout();
	//====================================
	// update figure pixmaps
	//------------------------------------
	for (int count=0;count < devices; count++) {
		if ( mCardID[count] == -1 ) {
			continue;
		}
		SCCMonitorDisplay* displayInfo = displays.at ( mCardID[count] );
		setFigurePixmap (
			displayInfo->getDisplay(),
			displayInfo->getDualPixmap()
		);
	}
}
//====================================
// import
//------------------------------------
void SCCTouchSelection::import ( void ) {
	//=====================================
	// search touchscreen ID's
	//-------------------------------------
	int n = 0;
	int x = 0;
	int touchID[mSection["Pointers"]->getCount()];
	for (int i=SAX_CORE_POINTER;i<mSection["Pointers"]->getCount();i+=2) {
		touchID[x] = 0;
		if (mSaxToucher->selectPointer (i)) {
		if (mSaxToucher->isTouchpanel()) {
			touchID[n] = i;
			n++;
		}
		}
		x++;
	}
	//=====================================
	// no touchers found... return
	//-------------------------------------
	if (touchID[mDisplay] == 0) {
		return;
	}
	//=====================================
	// select touchscreen
	//-------------------------------------
	mSaxToucher -> selectPointer ( touchID[mDisplay] );

	//=====================================
	// select vendor and name
	//-------------------------------------
	QString vendorName = mSaxToucher -> getVendor();
	QString modelName  = mSaxToucher -> getName(); 
	if ((! vendorName.isEmpty()) && (! modelName.isEmpty())) {
		QListBoxItem* vendor = mVendorList -> findItem ( vendorName );
		if ( vendor ) {
			mVendorList -> setSelected ( vendor, true );
			slotVendor ( vendor );
			QListBoxItem* name = mModelList -> findItem ( modelName );
			if ( name ) {
				mModelList -> setSelected ( name, true );
				slotName ( name );
			}
		}
	}
	//=====================================
	// setup port
	//-------------------------------------
	QString device = mSaxToucher -> getDevice();
	QRegExp identifier ("/dev/input/mice");
	if (identifier.search (device) >= 0) {
		mPortBox -> setCurrentItem ( 0 );
		mPortBox -> setCurrentText (device);
	}
	if (device == "/dev/ttyS0") {
		mPortBox -> setCurrentItem ( 1 );
	}
	if (device == "/dev/ttyS1") {
		mPortBox -> setCurrentItem ( 2 );
	}

	//=====================================
	// setup touchscreen display state
	//-------------------------------------
	SaXManipulateLayout saxLayout ( mSection["Layout"],mSection["Card"] );
	QList<QString> inputLayout = saxLayout.getInputLayout();
	QListIterator<QString> it (inputLayout);
	bool foundID = false;
	for (; it.current();++it) {
		if (touchID[mDisplay] == it.current()->toInt()) {
			foundID = true;
			break;
		}
	}
	if ( foundID ) {
		mCheckEnable -> setChecked ( true );
		slotActivateToucher();
	}
}
Example #3
0
//====================================
// remove and reorganize section ID...
//------------------------------------
bool SaXStorage::delID ( int id ) {
	// .../
	//! remove a data record and adapt the Identifier strings
	//! to provide consistency
	// ----
	if ((! mData.at (id)) || (mData.at(id)->isEmpty())) {
		return false;
	}
	int step = 1;
	int type = SAX_DESKTOP_TYPE;
	QString ident = *mData.at(id)->find ("Identifier");
	if (ident.contains ("Mouse")) {
		type = SAX_POINTER_TYPE;
		step = 2;
	}
	if (ident.contains ("Keyboard")) {
		type = SAX_KEYBOARD_TYPE;
		step = 2;
	}
	int index = -1;
	QListIterator < QDict<QString> > in (mData);
	for (; in.current(); ++in) {
		index++;
		QDict<QString>* data = in.current();
		QString* ident = data->find ("Identifier");
		if (! ident) {
			continue;
		}
		int curType = SAX_DESKTOP_TYPE;
		if (ident->contains("Mouse")) {
			curType = SAX_POINTER_TYPE;
		}
		if (ident->contains("Keyboard")) {
			curType = SAX_KEYBOARD_TYPE;
		}
		if ((data->isEmpty()) || (index <= id) || (curType != type)) {
			continue;
		}
		QString oIDstr;
		QString nIDstr;
		oIDstr.sprintf ("%d",index);
		nIDstr.sprintf ("%d",index - step);
		QString mouseIDstr    ("Mouse["   + oIDstr +"]");
		QString keyboardIDstr ("Keyboard["+ oIDstr +"]");
		QString deviceIDstr   ("Device["  + oIDstr +"]");
		QString monitorIDstr  ("Monitor[" + oIDstr +"]");
		QString screenIDstr   ("Screen["  + oIDstr +"]");
		QDictIterator<QString> it (*data);
		for (; it.current(); ++it) {
			QString val = *it.current();
			QString key = it.currentKey();
			if (val == mouseIDstr) {
				QString* nMouseIDstr = new QString ("Mouse["+nIDstr+"]");
				data -> replace (key,nMouseIDstr);
			}
			if (val == keyboardIDstr) {
				QString* nKbdIDstr = new QString ("Keyboard["+nIDstr+"]");
				data -> replace (key,nKbdIDstr);
			}
			if (val == deviceIDstr) {
				QString* nDeviceIDstr = new QString ("Device["+nIDstr+"]");
				data -> replace (key,nDeviceIDstr);
			}
			if (val == monitorIDstr) {
				QString* nMonitorIDstr = new QString ("Monitor["+nIDstr+"]");
				data -> replace (key,nMonitorIDstr);
			}
			if (val == screenIDstr) {
				QString* nScreenIDstr = new QString ("Screen["+nIDstr+"]");
				data -> replace (key,nScreenIDstr);
			}
			if ((key == "Screen") && (val == oIDstr)) {
				QString* nScreenIDstr = new QString (nIDstr);
				data -> replace (key,nScreenIDstr);
			}
		}
	}
	mData.remove (id);
	if ((mData.at(id)) && (mData.at(id)->isEmpty())) {
		mData.remove (id);
	}
	return true;
}
//=====================================
// XKeyboard init function for toplevel
//-------------------------------------
void XKeyboard::setupTop ( void ) {
	// log (L_INFO,"XKeyboard::setupTop() called\n");
	// ...
	// this function is called if the setup toplevel window
	// is created to configure options for the selected
	// keyboard type
	// ---
	// lookup AutoRepeat value to init slider
	// values within the options dialog
	// ---
	if (mKeyboardOptions["AutoRepeat"]) {
		XStringList valList;
		valList.setText (mKeyboardOptions["AutoRepeat"]);
		valList.setSeperator (" ");
		QList<char> kbd = valList.getList();
		mCurrentDelay = atoi(kbd.at(0));
		mCurrentKrate = atoi(kbd.at(1));
		mDelay  -> setValue (
			mCurrentDelay
		);
		mRepeat -> setValue (
			mCurrentKrate
		);
	}
	// ...
	// init all XKB values in the key-mapping dialog
	// overwrite the default setup with it
	// ---
	for (int i=0;i<=6;i++) {
		mXkbOption[i]->setCurrentItem (0);
	}
	if (mKeyboardOptions["XkbOptions"]) {
		XStringList optList;
		optList.setText (mKeyboardOptions["XkbOptions"]);
		optList.setSeperator (",");
		QList<char> opt = optList.getList();
		QListIterator<char> it (opt);
		for (; it.current(); ++it) {
			QDictIterator<char> itOption (mOptionHash);
			for (; itOption.current(); ++itOption) {
			if (itOption.currentKey() == QString(it.current())) {
				QString optionText = QString::fromLocal8Bit (
					itOption.current()
				);
				int index0 = getItem ( mXkbOption[0],optionText );
				int index1 = getItem ( mXkbOption[1],optionText );
				int index2 = getItem ( mXkbOption[6],optionText );
				if (index0 != 0) {
					mXkbOption[0] -> setCurrentItem ( index0 );
				}
				if (index1 != 0) {
					mXkbOption[1] -> setCurrentItem ( index1 );
				}
				if (index2 != 0) {
					mXkbOption[6] -> setCurrentItem ( index2 );
				}
			}
			}
		}
	}
	if (mKeyboardOptions["LeftAlt"]) {
		mXkbOption[2]->setCurrentItem (
		getItem (mXkbOption[2],mKeyboardOptions["LeftAlt"])
		);
	}
	if (mKeyboardOptions["RightAlt"]) {
		mXkbOption[3]->setCurrentItem (
		getItem (mXkbOption[3],mKeyboardOptions["RightAlt"])
		);
	}
	if (mKeyboardOptions["ScrollLock"]) {
		mXkbOption[4]->setCurrentItem (
		getItem (mXkbOption[3],mKeyboardOptions["ScrollLock"])
		);
	}
	if (mKeyboardOptions["RightCtl"]) {
		mXkbOption[5]->setCurrentItem (
		getItem (mXkbOption[3],mKeyboardOptions["RightCtl"])
		);
	}
}
//=====================================
// XKeyboard virtual slots...
//-------------------------------------
bool XKeyboard::slotRun (int index) {
	if (XTemplate::slotRun (index)) {
	// log(L_INFO,"XKeyboard::slotRun() called: %d\n",index);
	// ...
	// this function is called if the keyboard page is activated.
	// use this function to init the dialog with the current
	// setup of the keyboard
	// ---
	XWrapPointer< QDict<char> > mText (mTextPtr);
	mStatus -> message (mText["RunXKeyboard"]);
	mFrame  -> nextButton() -> setText (mText["finish"]);
	// ...
	// get the mFiles pointer wrapper from the Intro
	// object which has read all the data files. Than
	// lookup the keyboard XData object
	// ---
	QDict<XFile>* mFilePtr = mIntro->getFiles();
	XWrapFile < QDict<XFile> > mFiles (mFilePtr);
	XData* sysData = mFiles["sys_KEYBOARD"] -> getDevice(0);
	if (! sysData) {
		return (FALSE);
	}
	QDict<char> keyboardInfo = sysData -> getData();
	QString XKBLayouts  = keyboardInfo["XkbLayout"];
	QString XKBVariants = keyboardInfo["XkbVariant"];
	QString XKBModel    = keyboardInfo["XkbModel"];

	//=====================================
	// clean QListView data fields
	//-------------------------------------
	mAddView -> clearSelection();
	QListViewItemIterator itAdd (mAddView);
	for ( ; itAdd.current(); ++itAdd ) {
		QCheckListItem* item = (QCheckListItem*)itAdd.current();
		item -> setOn   ( false );
		item -> setText ( 3 , "" );
	}

	//=====================================
	// select base keyboard model
	//-------------------------------------
	QDictIterator<char> itModel (mModelHash);
	for (; itModel.current(); ++itModel) {
	if (itModel.currentKey() == XKBModel) {
		mType -> setCurrentText (QString::fromLocal8Bit (itModel.current()));
	}
	}
	
	//=====================================
	// get layout/variant lists
	//-------------------------------------
	XStringList completeLayout (XKBLayouts);
	completeLayout.setSeperator (",");
	QList<char> layoutList = completeLayout.getList();
	QString baseLayout = layoutList.getFirst();
	layoutList.removeFirst();

	QStringList completeVariant = QStringList::split (",", XKBVariants,True);
	QList<char> variantList;
	QStringList::Iterator in;
	for (in = completeVariant.begin(); in != completeVariant.end(); ++in) {
		if (QString (*in).isEmpty()) {
			variantList.append ("!");
		} else {
			variantList.append (*in);
		}
	}
	QString baseVariant = variantList.getFirst();
	variantList.removeFirst();
	int varCount = 0;

	//=====================================
	// select base/secondary layout(s)
	//-------------------------------------
	// 1)
	QDictIterator<char> itLayout (mLayoutHash);
	for (; itLayout.current(); ++itLayout) {
	if (itLayout.currentKey() == baseLayout) {
		mLayout -> setCurrentText (QString::fromLocal8Bit (itLayout.current()));
	}
	}
	// 2)
	QListIterator<char> it (layoutList);
	for (; it.current(); ++it) {
	QListViewItemIterator itAdd (mAddView);
	for ( ; itAdd.current(); ++itAdd ) {
		QCheckListItem* item = (QCheckListItem*)itAdd.current();
		QString layout = itAdd.current()->text(2);
		if (layout == it.current()) {
			item -> setOn (true);
			if (QString(variantList.at(varCount)) != "!") {
				item -> setText ( 3 , variantList.at(varCount) );
			}
			mAddView -> setSelected (itAdd.current(), true);
			mAddView -> ensureItemVisible (item);
			varCount++;
		}
	}
	}
	updateVariants();

	//=====================================
	// select base/secondary variant(s)
	//-------------------------------------
	for (int n=0;n<mVariant->count();n++) {
		QString item = mVariant->text (n);
		if (item == baseVariant) {
			mVariant -> setCurrentText (baseVariant);
		}
	}
	}
	return (TRUE);
}
Example #6
0
Expert::Expert( QWidget *parent ) : QTabDialog( parent )
{

  m_dependencies = new QDict< QList<IInput> >(257);
  m_dependencies->setAutoDelete(TRUE);
  m_inputWidgets = new QDict< IInput >;
  m_switches = new QDict< QObject >;
  m_changed = FALSE;

  setHelpButton();
  
  QListIterator<ConfigOption> options = Config::instance()->iterator();
  QVBoxLayout *pageLayout = 0;
  QFrame *page = 0;
  ConfigOption *option = 0;
  for (options.toFirst();(option=options.current());++options)
  {
    switch(option->kind())
    {
      case ConfigOption::O_Info:
        {
          if (pageLayout) pageLayout->addStretch(1);
          QScrollView *view = new QScrollView(this);
          view->setVScrollBarMode(QScrollView::Auto);
          view->setHScrollBarMode(QScrollView::AlwaysOff);
          view->setResizePolicy(QScrollView::AutoOneFit);
          page = new QFrame( view->viewport(), option->name() );
          pageLayout = new QVBoxLayout(page);
          pageLayout->setMargin(10);
          view->addChild(page);
          addTab(view,option->name());
          QWhatsThis::add(page, option->docs().simplifyWhiteSpace() );
          QToolTip::add(page, option->docs() );
        }
        break;
      case ConfigOption::O_String:
        {
          ASSERT(page!=0);
          InputString::StringMode sm=InputString::StringFree;
          switch(((ConfigString *)option)->widgetType())
          {
            case ConfigString::String: sm=InputString::StringFree; break;
            case ConfigString::File:   sm=InputString::StringFile; break;
            case ConfigString::Dir:    sm=InputString::StringDir;  break;
          }
          InputString *inputString = new InputString( 
                         option->name(),                        // name
                         page,                                  // widget
                         *((ConfigString *)option)->valueRef(), // variable 
                         sm                                     // type
                       ); 
          pageLayout->addWidget(inputString);
          QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() );
          QToolTip::add(inputString,option->docs());
          connect(inputString,SIGNAL(changed()),SLOT(changed()));
          m_inputWidgets->insert(option->name(),inputString);
          addDependency(m_switches,option->dependsOn(),option->name());
        }
        break;
      case ConfigOption::O_Enum:
        {
          ASSERT(page!=0);
          InputString *inputString = new InputString( 
                         option->name(),                        // name
                         page,                                  // widget
                         *((ConfigEnum *)option)->valueRef(),   // variable 
                         InputString::StringFixed               // type
                       ); 
          pageLayout->addWidget(inputString);
          QStrListIterator sli=((ConfigEnum *)option)->iterator();
          for (sli.toFirst();sli.current();++sli)
          {
            inputString->addValue(sli.current());
          }
          inputString->init();
          QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() );
          QToolTip::add(inputString, option->docs());
          connect(inputString,SIGNAL(changed()),SLOT(changed()));
          m_inputWidgets->insert(option->name(),inputString);
          addDependency(m_switches,option->dependsOn(),option->name());
        }
        break;
      case ConfigOption::O_List:
        {
          ASSERT(page!=0);
          InputStrList::ListMode lm=InputStrList::ListString;
          switch(((ConfigList *)option)->widgetType())
          {
            case ConfigList::String:     lm=InputStrList::ListString;  break;
            case ConfigList::File:       lm=InputStrList::ListFile;    break;
            case ConfigList::Dir:        lm=InputStrList::ListDir;     break;
            case ConfigList::FileAndDir: lm=InputStrList::ListFileDir; break;
          }
          InputStrList *inputStrList = new InputStrList(
                          option->name(),                         // name
                          page,                                   // widget
                          *((ConfigList *)option)->valueRef(),    // variable
                          lm                                      // type
                        );
          pageLayout->addWidget(inputStrList);
          QWhatsThis::add(inputStrList, option->docs().simplifyWhiteSpace() );
          QToolTip::add(inputStrList, option->docs());
          connect(inputStrList,SIGNAL(changed()),SLOT(changed()));
          m_inputWidgets->insert(option->name(),inputStrList);
          addDependency(m_switches,option->dependsOn(),option->name());
        }
        break;
        break;
      case ConfigOption::O_Bool:
        {
          ASSERT(page!=0);
          InputBool *inputBool = new InputBool(
                          option->name(),                         // name
                          page,                                   // widget
                          *((ConfigBool *)option)->valueRef()     // variable
                        );
          pageLayout->addWidget(inputBool);
          QWhatsThis::add(inputBool, option->docs().simplifyWhiteSpace() );
          QToolTip::add(inputBool, option->docs() );
          connect(inputBool,SIGNAL(changed()),SLOT(changed()));
          m_inputWidgets->insert(option->name(),inputBool);
          addDependency(m_switches,option->dependsOn(),option->name());
        }
        break;
      case ConfigOption::O_Int:
        {
          ASSERT(page!=0);
          InputInt *inputInt = new InputInt(
                          option->name(),                         // name
                          page,                                   // widget
                          *((ConfigInt *)option)->valueRef(),     // variable
                          ((ConfigInt *)option)->minVal(),        // min value
                          ((ConfigInt *)option)->maxVal()         // max value
                        );
          pageLayout->addWidget(inputInt);
          QWhatsThis::add(inputInt, option->docs().simplifyWhiteSpace() );
          QToolTip::add(inputInt, option->docs() );
          connect(inputInt,SIGNAL(changed()),SLOT(changed()));
          m_inputWidgets->insert(option->name(),inputInt);
          addDependency(m_switches,option->dependsOn(),option->name());
        }
        break;
      case ConfigOption::O_Obsolete:
        break;
    } 
  }
  if (pageLayout) pageLayout->addStretch(1);

  QDictIterator<QObject> di(*m_switches);
  QObject *obj = 0;
  for (di.toFirst();(obj=di.current());++di)
  {
    connect(obj,SIGNAL(toggle(const char *,bool)),SLOT(toggle(const char *,bool)));
    // UGLY HACK: assumes each item depends on a boolean without checking!
    emit toggle(di.currentKey(),((InputBool *)obj)->getState());
  }

  connect(this,SIGNAL(helpButtonPressed()),this,SLOT(handleHelp()));
  
}