From 46c42fb0bdd3adee0f5d5901915ab76bc79d7cc4 Mon Sep 17 00:00:00 2001 From: JT Pennington Date: Wed, 7 Dec 2016 21:58:39 -0800 Subject: code cleanup --- .../lumina-config/pages/page_mouse_trueos.cpp | 160 +-------------------- 1 file changed, 7 insertions(+), 153 deletions(-) diff --git a/src-qt5/core-utils/lumina-config/pages/page_mouse_trueos.cpp b/src-qt5/core-utils/lumina-config/pages/page_mouse_trueos.cpp index 63c0838e..60bc2872 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_mouse_trueos.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_mouse_trueos.cpp @@ -8,8 +8,6 @@ #include "ui_page_mouse_trueos.h" #include "getPage.h" -#include -#include #include #include @@ -19,48 +17,30 @@ //========== page_mouse_trueos::page_mouse_trueos(QWidget *parent) : PageWidget(parent), ui(new Ui::page_mouse_trueos()){ ui->setupUi(this); -// devices = LInput::listDevices(); - //DEBUG Code - /*qDebug() << "List Devices:"; - for(int i=0; iisPointer()){ - ::free( devices.takeAt(i)); - i--; - }else{ - qDebug() << "Found Pointer:" << devices[i]->devNumber(); - qDebug() << " - isExtension:" << devices[i]->isExtension(); - QList props = devices[i]->listProperties(); - qDebug() << " - Properties:"; - for(int j=0; jpropertyName(props[j])+" ("+QString::number(props[j])+")" <<" = " << devices[i]->getPropertyValue(props[j]); - } - } - }*/ QString program = "/usr/sbin/moused"; + ui->slider_mouseAcceleration->setRange(1,200); ui->slider_mouseAcceleration->setValue(100); - ui->slider_doubleClickThreshold->setRange(1,1000); - ui->slider_doubleClickThreshold->setValue(500); - connect( ui->slider_mouseAcceleration, SIGNAL(valueChanged(int)), this, SLOT(setValue(double))); realAccelValue = ( ui->slider_mouseAcceleration->value() / divisor); realAccelValueString = QString::number(ui->slider_mouseAcceleration->value() / divisor, 'f', 2); + + ui->slider_doubleClickThreshold->setRange(1,1000); + ui->slider_doubleClickThreshold->setValue(500); connect( ui->slider_doubleClickThreshold, SIGNAL(valueChanged(int)), this, SLOT(setValue(double))); realDoubleClickValue = (ui->slider_doubleClickThreshold->value()); realDoubleClickValueString = QString::number(ui->slider_doubleClickThreshold->value()); - connect( ui->button_apply, SIGNAL(clicked()), this, SLOT(updateMoused())); + ui->combobox_resolutionBox->setCurrentIndex(1); + connect(ui->combobox_resolutionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseResolution()) ); connect(ui->checkBoxHandedness, SIGNAL(toggled(bool)), this, SLOT(swapHandedness()) ); connect(ui->checkBoxTerminateDrift, SIGNAL(toggled(bool)), this, SLOT(terminateDrift()) ); - ui->combobox_resolutionBox->setCurrentIndex(1); - connect(ui->combobox_resolutionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseResolution()) ); - + connect( ui->button_apply, SIGNAL(clicked()), this, SLOT(updateMoused())); } page_mouse_trueos::~page_mouse_trueos(){ -// for(int i=0; itabWidget->count(); i++){ - ui->tabWidget->setTabIcon( i, LXDG::findIcon( "input-"+ui->tabWidget->tabWhatsThis(i).section(":",0,0), "" ) ); - } } -*/ //================= // PRIVATE @@ -134,123 +106,5 @@ void page_mouse_trueos::updateMoused(){ qDebug() << "mousedargs" << mousedargs; QProcess *moused = new QProcess(this); moused->start(program, mousedargs); - -} - -/* -void page_mouse_trueos::populateDeviceTree(QTreeWidget *tree, LInputDevice *device){ - QTreeWidgetItem *top = new QTreeWidgetItem(tree); - if(device->isExtension()){ - top->setText( 0, QString(tr("Extension Device #%1")).arg(QString::number(tree->topLevelItemCount())) ); - }else{ top->setText(0, tr("Master Device")); } - top->setWhatsThis(0, QString(device->isPointer() ? "mouse" : "keyboard")+":"+QString::number(device->devNumber()) ); //save this for later - top->setFirstColumnSpanned(true); - top->setExpanded(true); - tree->addTopLevelItem(top); - //Now add all the child properties to this item - QList props = device->listProperties(); - for(int i=0; ipropertyName(props[i]).toLower().contains("matrix")){ continue; } //skip this one - can not change from UI and most people will never want to anyway - QTreeWidgetItem *tmp = new QTreeWidgetItem(top); - tmp->setWhatsThis(0, QString::number(props[i]) ); - tmp->setText(0, device->propertyName(props[i])); - top->addChild(tmp); - populateDeviceItemValue(tree, tmp, device->getPropertyValue(props[i]), QString::number(device->devNumber())+":"+QString::number(props[i]) ); - } - //Clean up the tree widget as needed - top->sortChildren(0, Qt::AscendingOrder); - tree->resizeColumnToContents(0); } -void page_mouse_trueos::populateDeviceItemValue(QTreeWidget *tree, QTreeWidgetItem *it, QVariant value, QString id){ - if(value.type()==QVariant::Int){ - //Could be a boolian - check the name for known "enable" states - if(value.toInt() < 2 && (it->text(0).toLower().contains("enable") || it->text(0).toLower().contains("emulation") || it->text(0)==("XTEST Device") ) ){ - //Just use a checkable column within the item - bool enabled = (value.toInt()==1); - it->setText(1,""); - it->setWhatsThis(1, "bool:"+id); - it->setCheckState(1, enabled ? Qt::Checked : Qt::Unchecked); - }else{ - //Use a QSpinBox - QSpinBox *box = new QSpinBox(); - box->setRange(0,100); - box->setValue( value.toInt() ); - box->setWhatsThis("int:"+id); - tree->setItemWidget(it, 1, box); - connect(box, SIGNAL(valueChanged(int)), this, SLOT(valueChanged()) ); - } - }else if(value.type()==QVariant::Double){ - //Use a QDoubleSpinBox - QDoubleSpinBox *box = new QDoubleSpinBox(); - box->setRange(0,1000); - box->setValue( value.toInt() ); - box->setWhatsThis("double:"+id); - tree->setItemWidget(it, 1, box); - connect(box, SIGNAL(valueChanged(double)), this, SLOT(valueChanged()) ); - - }else if(value.canConvert>()){ - //Not Modifiable - just use the label in the item - QList list = value.toList(); - QStringList txtList; - for(int i=0; isetText(1, txtList.join(", ") ); - it->setToolTip(1, txtList.join(", ")); - }else if( value.canConvert() ){ - //Not Modifiable - just use the label in the item - it->setText(1, value.toString()); - } -} -//================= -// PRIVATE SLOTS -//================= -void page_mouse_trueos::valueChanged(){ - //Now get the currently focused widget - QWidget *foc = this->focusWidget(); - if(foc==0){ return; } - //qDebug() << "Focus Widget:" << foc->whatsThis(); - //Now pull out the value and device/property numbers - unsigned int dev = foc->whatsThis().section(":",1,1).toInt(); - int prop = foc->whatsThis().section(":",2,2).toInt(); - QVariant value; - if(foc->whatsThis().startsWith("int:")){ value.setValue( static_cast(foc)->value() ); } - else if(foc->whatsThis().startsWith("double:")){ value.setValue( static_cast(foc)->value() ); } - //Now change the property for the device - qDebug() << " - Device:" <devNumber() == dev){ - bool ok = devices[i]->setPropertyValue(prop, value); - if(ok){ foc->setStyleSheet(""); } - else{ foc->setStyleSheet("background: red"); } - //qDebug() << " - Changed property:" << (ok ? "success" : "failure"); - break; - } - } -} - -void page_mouse_trueos::itemClicked(QTreeWidgetItem *it, int col){ - if(col!=1){ return; } //only care about value changes - if(it->whatsThis(1).isEmpty()){ return; }//not a checkable item - qDebug() << "item Clicked:" << it->whatsThis(1) << it->text(0); - //Now pull out the value and device/property numbers - unsigned int dev = it->whatsThis(1).section(":",1,1).toInt(); - int prop = it->whatsThis(1).section(":",2,2).toInt(); - QVariant value( (it->checkState(1)==Qt::Checked) ? 1 : 0 ); - //Now change the property for the device - qDebug() << " - Device:" <devNumber() == dev){ - //Since this "clicked" signal can get sent out even if the value has not changed, go ahead and make sure we have a different value first - QVariant current = devices[i]->getPropertyValue(prop); - //qDebug() << " - Current Value:" << current; - if(value.toInt()!=current.toInt()){ - bool ok = devices[i]->setPropertyValue(prop, value); - //if(ok){ foc->setStyleSheet(""); } - //else{ foc->setStyleSheet("background: red"); } - qDebug() << " - Changed property:" << (ok ? "success" : "failure"); - } - break; - } - } -} -*/ -- cgit