renamed some fields, floating icon size from actual icon
This commit is contained in:
@ -23,93 +23,93 @@ AxisEdit::AxisEdit( Axis* ax )
|
|||||||
QVBoxLayout* v2 = new QVBoxLayout();
|
QVBoxLayout* v2 = new QVBoxLayout();
|
||||||
v2->setMargin(5);
|
v2->setMargin(5);
|
||||||
v2->setSpacing(5);
|
v2->setSpacing(5);
|
||||||
CGradient = new QCheckBox("&Gradient", this);
|
chkGradient = new QCheckBox("&Gradient", this);
|
||||||
CGradient->setChecked(axis->gradient);
|
chkGradient->setChecked(axis->gradient);
|
||||||
connect(CGradient, SIGNAL(toggled(bool)), this, SLOT( CGradientChanged( bool )));
|
connect(chkGradient, SIGNAL(toggled(bool)), this, SLOT( gradientChanged( bool )));
|
||||||
v2->addWidget(CGradient);
|
v2->addWidget(chkGradient);
|
||||||
|
|
||||||
CMode = new QComboBox(this);
|
cmbMode = new QComboBox(this);
|
||||||
CMode->insertItem((int) Axis::Keyboard, QString("Keyboard/Mouse Button"), Qt::DisplayRole);
|
cmbMode->insertItem((int) Axis::Keyboard, QString("Keyboard/Mouse Button"), Qt::DisplayRole);
|
||||||
CMode->insertItem((int) Axis::MousePosVert,QString("Mouse (Vert.)"),Qt::DisplayRole);
|
cmbMode->insertItem((int) Axis::MousePosVert,QString("Mouse (Vert.)"),Qt::DisplayRole);
|
||||||
CMode->insertItem((int) Axis::MouseNegVert, QString("Mouse (Vert. Rev.)"), Qt::DisplayRole);
|
cmbMode->insertItem((int) Axis::MouseNegVert, QString("Mouse (Vert. Rev.)"), Qt::DisplayRole);
|
||||||
CMode->insertItem((int) Axis::MousePosHor, "Mouse (Hor.)", Qt::DisplayRole);
|
cmbMode->insertItem((int) Axis::MousePosHor, "Mouse (Hor.)", Qt::DisplayRole);
|
||||||
CMode->insertItem((int) Axis::MouseNegHor, QString("Mouse (Hor. Rev.)"), Qt::DisplayRole);
|
cmbMode->insertItem((int) Axis::MouseNegHor, QString("Mouse (Hor. Rev.)"), Qt::DisplayRole);
|
||||||
CMode->setCurrentIndex( axis->mode );
|
cmbMode->setCurrentIndex( axis->mode );
|
||||||
connect(CMode, SIGNAL(activated(int)), this, SLOT( CModeChanged( int )));
|
connect(cmbMode, SIGNAL(activated(int)), this, SLOT( modeChanged( int )));
|
||||||
v2->addWidget(CMode);
|
v2->addWidget(cmbMode);
|
||||||
CTransferCurve = new QComboBox(this);
|
cmbTransferCurve = new QComboBox(this);
|
||||||
CTransferCurve->insertItem(Axis::Linear, QString("Linear"), Qt::DisplayRole);
|
cmbTransferCurve->insertItem(Axis::Linear, QString("Linear"), Qt::DisplayRole);
|
||||||
CTransferCurve->insertItem(Axis::Quadratic, QString("Quadratic"),Qt::DisplayRole );
|
cmbTransferCurve->insertItem(Axis::Quadratic, QString("Quadratic"),Qt::DisplayRole );
|
||||||
CTransferCurve->insertItem(Axis::Cubic, QString("Cubic"),Qt::DisplayRole );
|
cmbTransferCurve->insertItem(Axis::Cubic, QString("Cubic"),Qt::DisplayRole );
|
||||||
CTransferCurve->insertItem(Axis::QuadraticExtreme, QString("Quadratic Extreme"), Qt::DisplayRole);
|
cmbTransferCurve->insertItem(Axis::QuadraticExtreme, QString("Quadratic Extreme"), Qt::DisplayRole);
|
||||||
CTransferCurve->insertItem(Axis::PowerFunction, QString("Power Function"), Qt::DisplayRole);
|
cmbTransferCurve->insertItem(Axis::PowerFunction, QString("Power Function"), Qt::DisplayRole);
|
||||||
CTransferCurve->setCurrentIndex( axis->transferCurve );
|
cmbTransferCurve->setCurrentIndex( axis->transferCurve );
|
||||||
CTransferCurve->setEnabled(axis->gradient);
|
cmbTransferCurve->setEnabled(axis->gradient);
|
||||||
connect(CTransferCurve, SIGNAL(activated(int)), this, SLOT( CTransferCurveChanged( int )));
|
connect(cmbTransferCurve, SIGNAL(activated(int)), this, SLOT( transferCurveChanged( int )));
|
||||||
v2->addWidget(CTransferCurve);
|
v2->addWidget(cmbTransferCurve);
|
||||||
h->addLayout(v2);
|
h->addLayout(v2);
|
||||||
|
|
||||||
MouseBox = new QFrame(this);
|
mouseBox = new QFrame(this);
|
||||||
MouseBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
|
mouseBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
|
||||||
v2 = new QVBoxLayout(MouseBox);
|
v2 = new QVBoxLayout(mouseBox);
|
||||||
v2->setSpacing(5);
|
v2->setSpacing(5);
|
||||||
v2->setMargin(5);
|
v2->setMargin(5);
|
||||||
//v2->setAutoAdd(true);
|
//v2->setAutoAdd(true);
|
||||||
QLabel *mouseLabel = new QLabel("&Mouse Speed", MouseBox);
|
QLabel *mouseLabel = new QLabel("&Mouse Speed", mouseBox);
|
||||||
v2->addWidget(mouseLabel);
|
v2->addWidget(mouseLabel);
|
||||||
SSpeed = new QSpinBox(MouseBox);
|
spinSpeed = new QSpinBox(mouseBox);
|
||||||
SSpeed->setRange(0,MAXMOUSESPEED);
|
spinSpeed->setRange(0,MAXMOUSESPEED);
|
||||||
SSpeed->setSingleStep(1);
|
spinSpeed->setSingleStep(1);
|
||||||
SSpeed->setValue(axis->maxSpeed);
|
spinSpeed->setValue(axis->maxSpeed);
|
||||||
v2->addWidget(SSpeed);
|
v2->addWidget(spinSpeed);
|
||||||
LSensitivity = new QLabel("&Sensitivity", MouseBox);
|
lblSensitivity = new QLabel("&Sensitivity", mouseBox);
|
||||||
v2->addWidget(LSensitivity);
|
v2->addWidget(lblSensitivity);
|
||||||
SSensitivity = new QDoubleSpinBox(MouseBox);
|
spinSensitivity = new QDoubleSpinBox(mouseBox);
|
||||||
SSensitivity->setRange(1e-3F, 1e+3F);
|
spinSensitivity->setRange(1e-3F, 1e+3F);
|
||||||
SSensitivity->setSingleStep(0.10);
|
spinSensitivity->setSingleStep(0.10);
|
||||||
SSensitivity->setValue(axis->sensitivity);
|
spinSensitivity->setValue(axis->sensitivity);
|
||||||
v2->addWidget(SSensitivity);
|
v2->addWidget(spinSensitivity);
|
||||||
h->addWidget(MouseBox);
|
h->addWidget(mouseBox);
|
||||||
mouseLabel->setBuddy(SSpeed);
|
mouseLabel->setBuddy(spinSpeed);
|
||||||
LSensitivity->setBuddy(SSensitivity);
|
lblSensitivity->setBuddy(spinSensitivity);
|
||||||
v->addLayout(h);
|
v->addLayout(h);
|
||||||
|
|
||||||
Slider = new JoySlider(axis->dZone, axis->xZone, axis->state, this);
|
slider = new JoySlider(axis->dZone, axis->xZone, axis->state, this);
|
||||||
v->addWidget(Slider);
|
v->addWidget(slider);
|
||||||
|
|
||||||
KeyBox = new QFrame(this);
|
keyBox = new QFrame(this);
|
||||||
KeyBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
|
keyBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
|
||||||
h = new QHBoxLayout(KeyBox);
|
h = new QHBoxLayout(keyBox);
|
||||||
h->setSpacing(5);
|
h->setSpacing(5);
|
||||||
h->setMargin(5);
|
h->setMargin(5);
|
||||||
//h->setAutoAdd(true);
|
//h->setAutoAdd(true);
|
||||||
BNeg = new KeyButton(axis->getName(),axis->nkeycode,KeyBox,true,axis->nuseMouse);
|
btnNeg = new KeyButton(axis->getName(),axis->nkeycode,keyBox,true,axis->nuseMouse);
|
||||||
|
|
||||||
CThrottle = new QComboBox(KeyBox);
|
cmbThrottle = new QComboBox(keyBox);
|
||||||
CThrottle->insertItem(0,"Neg. Throttle",Qt::DisplayRole);
|
cmbThrottle->insertItem(0,"Neg. Throttle",Qt::DisplayRole);
|
||||||
CThrottle->insertItem(1,"No Throttle",Qt::DisplayRole);
|
cmbThrottle->insertItem(1,"No Throttle",Qt::DisplayRole);
|
||||||
CThrottle->insertItem(2,"Pos. Throttle",Qt::DisplayRole);
|
cmbThrottle->insertItem(2,"Pos. Throttle",Qt::DisplayRole);
|
||||||
CThrottle->setCurrentIndex(axis->throttle + 1);
|
cmbThrottle->setCurrentIndex(axis->throttle + 1);
|
||||||
connect( CThrottle, SIGNAL( activated( int )), this, SLOT( CThrottleChanged( int )));
|
connect( cmbThrottle, SIGNAL( activated( int )), this, SLOT( throttleChanged( int )));
|
||||||
|
|
||||||
BPos = new KeyButton(axis->getName(),axis->pkeycode,KeyBox,true,axis->puseMouse);
|
btnPos = new KeyButton(axis->getName(),axis->pkeycode,keyBox,true,axis->puseMouse);
|
||||||
h->addWidget(BNeg);
|
h->addWidget(btnNeg);
|
||||||
h->addWidget(CThrottle);
|
h->addWidget(cmbThrottle);
|
||||||
h->addWidget(BPos);
|
h->addWidget(btnPos);
|
||||||
v->addWidget( KeyBox );
|
v->addWidget( keyBox );
|
||||||
|
|
||||||
h = new QHBoxLayout();
|
h = new QHBoxLayout();
|
||||||
BOkay = new QPushButton("&Okay", this);
|
btnOkay = new QPushButton("&Okay", this);
|
||||||
connect(BOkay, SIGNAL( clicked() ), this, SLOT( accept()));
|
connect(btnOkay, SIGNAL( clicked() ), this, SLOT( accept()));
|
||||||
h->addWidget(BOkay);
|
h->addWidget(btnOkay);
|
||||||
BCancel = new QPushButton("&Cancel", this);
|
btnCancel = new QPushButton("&Cancel", this);
|
||||||
connect(BCancel, SIGNAL( clicked() ), this, SLOT( reject()));
|
connect(btnCancel, SIGNAL( clicked() ), this, SLOT( reject()));
|
||||||
h->addWidget(BCancel);
|
h->addWidget(btnCancel);
|
||||||
v->addLayout(h);
|
v->addLayout(h);
|
||||||
|
|
||||||
CModeChanged( axis->mode );
|
modeChanged( axis->mode );
|
||||||
CTransferCurveChanged( axis->transferCurve );
|
transferCurveChanged( axis->transferCurve );
|
||||||
CThrottleChanged( axis->throttle + 1 );
|
throttleChanged( axis->throttle + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::show() {
|
void AxisEdit::show() {
|
||||||
@ -118,76 +118,76 @@ void AxisEdit::show() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::setState( int val ) {
|
void AxisEdit::setState( int val ) {
|
||||||
Slider->setValue( val );
|
slider->setValue( val );
|
||||||
}
|
}
|
||||||
void AxisEdit::CGradientChanged( bool on ) {
|
void AxisEdit::gradientChanged( bool on ) {
|
||||||
CTransferCurve->setEnabled(on);
|
cmbTransferCurve->setEnabled(on);
|
||||||
if (on) {
|
if (on) {
|
||||||
CTransferCurveChanged( axis->transferCurve );
|
transferCurveChanged( axis->transferCurve );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSensitivity->setEnabled(false);
|
lblSensitivity->setEnabled(false);
|
||||||
SSensitivity->setEnabled(false);
|
spinSensitivity->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::CModeChanged( int index ) {
|
void AxisEdit::modeChanged( int index ) {
|
||||||
if (index == Axis::Keyboard) {
|
if (index == Axis::Keyboard) {
|
||||||
MouseBox->setEnabled(false);
|
mouseBox->setEnabled(false);
|
||||||
KeyBox->setEnabled(true);
|
keyBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MouseBox->setEnabled(true);
|
mouseBox->setEnabled(true);
|
||||||
KeyBox->setEnabled(false);
|
keyBox->setEnabled(false);
|
||||||
if (CGradient->isChecked()) {
|
if (chkGradient->isChecked()) {
|
||||||
CTransferCurve->setEnabled(true);
|
cmbTransferCurve->setEnabled(true);
|
||||||
CTransferCurveChanged( axis->transferCurve );
|
transferCurveChanged( axis->transferCurve );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::CTransferCurveChanged( int index ) {
|
void AxisEdit::transferCurveChanged( int index ) {
|
||||||
if (index == Axis::PowerFunction) {
|
if (index == Axis::PowerFunction) {
|
||||||
LSensitivity->setEnabled(true);
|
lblSensitivity->setEnabled(true);
|
||||||
SSensitivity->setEnabled(true);
|
spinSensitivity->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSensitivity->setEnabled(false);
|
lblSensitivity->setEnabled(false);
|
||||||
SSensitivity->setEnabled(false);
|
spinSensitivity->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::CThrottleChanged( int index ) {
|
void AxisEdit::throttleChanged( int index ) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
BNeg->setEnabled(true);
|
btnNeg->setEnabled(true);
|
||||||
BPos->setEnabled(false);
|
btnPos->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
BNeg->setEnabled(true);
|
btnNeg->setEnabled(true);
|
||||||
BPos->setEnabled(true);
|
btnPos->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
BNeg->setEnabled(false);
|
btnNeg->setEnabled(false);
|
||||||
BPos->setEnabled(true);
|
btnPos->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Slider->setThrottle( index - 1 );
|
slider->setThrottle( index - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisEdit::accept() {
|
void AxisEdit::accept() {
|
||||||
axis->gradient = CGradient->isChecked();
|
axis->gradient = chkGradient->isChecked();
|
||||||
axis->maxSpeed = SSpeed->value();
|
axis->maxSpeed = spinSpeed->value();
|
||||||
axis->transferCurve = (Axis::TransferCurve)CTransferCurve->currentIndex();
|
axis->transferCurve = (Axis::TransferCurve)cmbTransferCurve->currentIndex();
|
||||||
axis->sensitivity = SSensitivity->value();
|
axis->sensitivity = spinSensitivity->value();
|
||||||
axis->throttle = CThrottle->currentIndex() - 1;
|
axis->throttle = cmbThrottle->currentIndex() - 1;
|
||||||
axis->dZone = Slider->deadZone();
|
axis->dZone = slider->deadZone();
|
||||||
axis->xZone = Slider->xZone();
|
axis->xZone = slider->xZone();
|
||||||
axis->mode = (Axis::Mode) CMode->currentIndex();
|
axis->mode = (Axis::Mode) cmbMode->currentIndex();
|
||||||
axis->pkeycode = BPos->getValue();
|
axis->pkeycode = btnPos->getValue();
|
||||||
axis->nkeycode = BNeg->getValue();
|
axis->nkeycode = btnNeg->getValue();
|
||||||
axis->puseMouse = BPos->choseMouse();
|
axis->puseMouse = btnPos->choseMouse();
|
||||||
axis->nuseMouse = BNeg->choseMouse();
|
axis->nuseMouse = btnNeg->choseMouse();
|
||||||
axis->adjustGradient();
|
axis->adjustGradient();
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
@ -23,24 +23,24 @@ class AxisEdit : public QDialog {
|
|||||||
void setState( int val );
|
void setState( int val );
|
||||||
protected slots:
|
protected slots:
|
||||||
//slots for GUI events
|
//slots for GUI events
|
||||||
void CGradientChanged( bool on );
|
void gradientChanged( bool on );
|
||||||
void CModeChanged( int index );
|
void modeChanged( int index );
|
||||||
void CTransferCurveChanged( int index );
|
void transferCurveChanged( int index );
|
||||||
void CThrottleChanged( int index );
|
void throttleChanged( int index );
|
||||||
void accept();
|
void accept();
|
||||||
protected:
|
protected:
|
||||||
//the associated Axis that needs to be set.
|
//the associated Axis that needs to be set.
|
||||||
Axis *axis;
|
Axis *axis;
|
||||||
//the important parts of the dialog:
|
//the important parts of the dialog:
|
||||||
QCheckBox *CGradient;
|
QCheckBox *chkGradient;
|
||||||
QComboBox *CMode, *CThrottle, *CTransferCurve;
|
QComboBox *cmbMode, *cmbThrottle, *cmbTransferCurve;
|
||||||
QFrame *MouseBox, *KeyBox;
|
QFrame *mouseBox, *keyBox;
|
||||||
QSpinBox *SSpeed;
|
QSpinBox *spinSpeed;
|
||||||
QLabel *LSensitivity;
|
QLabel *lblSensitivity;
|
||||||
QDoubleSpinBox *SSensitivity;
|
QDoubleSpinBox *spinSensitivity;
|
||||||
KeyButton *BNeg, *BPos;
|
KeyButton *btnNeg, *btnPos;
|
||||||
JoySlider *Slider;
|
JoySlider *slider;
|
||||||
QPushButton *BOkay, *BCancel;
|
QPushButton *btnOkay, *btnCancel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,15 +13,15 @@ GetKey::GetKey( QString button, bool m )
|
|||||||
//I'd use a QLabel, but that steals x11Events!
|
//I'd use a QLabel, but that steals x11Events!
|
||||||
//So, I'll draw the text directly. That means
|
//So, I'll draw the text directly. That means
|
||||||
//I need to resolve the size of the dialog by hand:
|
//I need to resolve the size of the dialog by hand:
|
||||||
Text = "Choose a new key ";
|
text = "Choose a new key ";
|
||||||
if (mouse) Text += "or mouse button ";
|
if (mouse) text += "or mouse button ";
|
||||||
Text += "for " + button;
|
text += "for " + button;
|
||||||
QRect rect = fontMetrics().boundingRect( Text );
|
QRect rect = fontMetrics().boundingRect( text );
|
||||||
//I calculate the size based on the first line of text, which is longer.
|
//I calculate the size based on the first line of text, which is longer.
|
||||||
//The fontMetrics function is dumb and would treat the string with a
|
//The fontMetrics function is dumb and would treat the string with a
|
||||||
//newline in it as a continues flow of characters if I did the whole string
|
//newline in it as a continues flow of characters if I did the whole string
|
||||||
//at once.
|
//at once.
|
||||||
Text += "\n(Ctrl-X for no key)";
|
text += "\n(Ctrl-X for no key)";
|
||||||
//now I add 20 pixels of padding and double the height to make room for
|
//now I add 20 pixels of padding and double the height to make room for
|
||||||
//two lines.
|
//two lines.
|
||||||
setFixedSize( QSize( rect.width() + 20, rect.height()*2 + 20 ) );
|
setFixedSize( QSize( rect.width() + 20, rect.height()*2 + 20 ) );
|
||||||
@ -60,5 +60,5 @@ void GetKey::closeEvent(QCloseEvent *e) {
|
|||||||
void GetKey::paintEvent ( QPaintEvent * ) {
|
void GetKey::paintEvent ( QPaintEvent * ) {
|
||||||
//whenever we need to repaint, draw in our text.
|
//whenever we need to repaint, draw in our text.
|
||||||
QPainter paint( this );
|
QPainter paint( this );
|
||||||
paint.drawText( rect(), Qt::AlignCenter, Text );
|
paint.drawText( rect(), Qt::AlignCenter, text );
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class GetKey : public QDialog {
|
|||||||
void closeEvent (QCloseEvent *);
|
void closeEvent (QCloseEvent *);
|
||||||
private:
|
private:
|
||||||
//the dialog's message
|
//the dialog's message
|
||||||
QString Text;
|
QString text;
|
||||||
//does this dialog accept mouse clicks?
|
//does this dialog accept mouse clicks?
|
||||||
bool mouse;
|
bool mouse;
|
||||||
};
|
};
|
||||||
|
@ -9,10 +9,10 @@ FloatingIcon::FloatingIcon( const QString &icon, QMenu *popup, QWidget *parent,
|
|||||||
setAttribute(Qt::WA_QuitOnClose);
|
setAttribute(Qt::WA_QuitOnClose);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
setWindowTitle(QJOYPAD_NAME);
|
setWindowTitle(QJOYPAD_NAME " Floating Icon");
|
||||||
pop = popup;
|
pop = popup;
|
||||||
|
|
||||||
setFixedSize(64,64);
|
setFixedSize(this->icon.width(),this->icon.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FloatingIcon::mousePressEvent( QMouseEvent* event ) {
|
void FloatingIcon::mousePressEvent( QMouseEvent* event ) {
|
||||||
@ -28,8 +28,7 @@ void FloatingIcon::mousePressEvent( QMouseEvent* event ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FloatingIcon::paintEvent( QPaintEvent* event ) {
|
void FloatingIcon::paintEvent( QPaintEvent* ) {
|
||||||
Q_UNUSED(event);
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.drawPixmap(0, 0, icon);
|
painter.drawPixmap(0, 0, icon);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user