1 //===========================================
2 // Lumina Desktop Source Code
3 // Copyright (c) 2016, Ken Moore & JT Pennington
4 // Available under the 3-clause BSD license
5 // See the LICENSE file for full details
6 //===========================================
7 #include "page_mouse_trueos.h"
8 #include "ui_page_mouse_trueos.h"
9
10 #include <QDebug>
11 #include <QProcess>
12
13
14 //==========
15 // PUBLIC
16 //==========
page_mouse_trueos(QWidget * parent)17 page_mouse_trueos::page_mouse_trueos(QWidget *parent) : PageWidget(parent), ui(new Ui::page_mouse_trueos()){
18 ui->setupUi(this);
19 QString program = "/usr/sbin/moused";
20
21 ui->slider_mouseAcceleration->setRange(1,200);
22 ui->slider_mouseAcceleration->setValue(100);
23 connect( ui->slider_mouseAcceleration, SIGNAL(valueChanged(int)), this, SLOT(setValue(double)));
24 realAccelValue = ( ui->slider_mouseAcceleration->value() / divisor);
25 realAccelValueString = QString::number(ui->slider_mouseAcceleration->value() / divisor, 'f', 2);
26
27 ui->slider_doubleClickThreshold->setRange(1,1000);
28 ui->slider_doubleClickThreshold->setValue(500);
29 connect( ui->slider_doubleClickThreshold, SIGNAL(valueChanged(int)), this, SLOT(setValue(double)));
30 realDoubleClickValue = (ui->slider_doubleClickThreshold->value());
31 realDoubleClickValueString = QString::number(ui->slider_doubleClickThreshold->value());
32
33 ui->combobox_resolutionBox->setCurrentIndex(1);
34 connect(ui->combobox_resolutionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseResolution()) );
35
36 connect(ui->checkBoxHandedness, SIGNAL(toggled(bool)), this, SLOT(swapHandedness()) );
37 connect(ui->checkBoxTerminateDrift, SIGNAL(toggled(bool)), this, SLOT(terminateDrift()) );
38
39 connect( ui->button_apply, SIGNAL(clicked()), this, SLOT(updateMoused()));
40 }
41
~page_mouse_trueos()42 page_mouse_trueos::~page_mouse_trueos(){
43 }
44
45 //================
46 // PUBLIC SLOTS
47 //================
SaveSettings()48 void page_mouse_trueos::SaveSettings(){
49
50 emit HasPendingChanges(false);
51 }
52
LoadSettings(int)53 void page_mouse_trueos::LoadSettings(int){
54 emit HasPendingChanges(false);
55 emit ChangePageTitle( tr("Mouse Settings") );
56 }
57
58 //=================
59 // PRIVATE
60 //=================
61
swapHandedness()62 void page_mouse_trueos::swapHandedness(){
63 if(ui->checkBoxHandedness->isChecked()){
64 handString = "-m 1=3 -m 3=1";
65 }
66 else{
67 handString = "-m 1=1 -m 3=3";
68 }
69 }
70
setMouseResolution()71 void page_mouse_trueos::setMouseResolution(){
72 resolutionValue = ui->combobox_resolutionBox->itemText(ui->combobox_resolutionBox->currentIndex());
73 resString = "-r " + resolutionValue;
74 }
75
setMouseAcceleration()76 void page_mouse_trueos::setMouseAcceleration(){
77 realAccelValue = ( ui->slider_mouseAcceleration->value() / divisor);
78 realAccelValueString = QString::number( ui->slider_mouseAcceleration->value() / divisor, 'f', 2);
79 accelString = "-a " + realAccelValueString;
80 }
81
setDoubleClickThreshold()82 void page_mouse_trueos::setDoubleClickThreshold(){
83 realDoubleClickValueString = QString::number( ui->slider_doubleClickThreshold->value());
84 dclickString = "-C " + realDoubleClickValueString;
85 }
86
terminateDrift()87 void page_mouse_trueos::terminateDrift(){
88 if(ui->checkBoxTerminateDrift->isChecked()){
89 driftString = "-T 4[,500[,4000]]";
90 }
91 else{
92 driftString = "";
93 }
94 }
95
updateMoused()96 void page_mouse_trueos::updateMoused(){
97 setMouseAcceleration(); setDoubleClickThreshold();
98 qDebug() << "handString" << handString;
99 qDebug() << "resString" << resString;
100 qDebug() << "accelString" << accelString;
101 qDebug() << "dclickString" << dclickString;
102 qDebug() << "driftstring" << driftString;
103 deviceString = "-p /dev/sysmouse";
104 mousedargs << deviceString << handString << resString << accelString << dclickString << driftString;
105 qDebug() << "mousedargs" << mousedargs;
106 QProcess *moused = new QProcess(this);
107 moused->start(program, mousedargs);
108 }
109