Simplified code for numpad buttons. This adds on to PR #9.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 47d89f2d15)
r14.0.x
Michele Calgaro 4 years ago
parent 543ee0948c
commit cf258cdbd6
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -20,6 +20,7 @@
#include "MainWidget.h"
#include "VButton.h"
#include "numpadvbutton.h"
#include <cstdlib>
@ -417,14 +418,13 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
"End", TQString::fromUtf8(""), "Pg\nDn" };
TQString nump[9] = {"7","8","9","4","5","6","1","2","3"};
int val=0;
int nval[9] = {79,80,81,83,84,85,87,88,89};
int cval[9] = {79,80,81,83,84,85,87,88,89};
for (int a=2;a<5;a++){
for (int b=0;b<3;b++){
NumpadVButton *v = new NumpadVButton(this,"");
v->move(padx+(b*35),sty+(a*35));
v->res();
v->setKeyCode(nval[val],cval[val]);
v->setKeyCode(cval[val]);
v->setText(txt[val]);
v->setShiftText(nump[val]);
numl_keys.append(v);
@ -437,7 +437,7 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
ins->move(padx,sty+(5*35));
ins->res();
ins->setText("Ins");
ins->setKeyCode(90,90);
ins->setKeyCode(90);
ins->setShiftText("0");
numl_keys.append(ins);
@ -449,7 +449,7 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
del->res();
del->setText("Del");
del->setShiftText(".");
del->setKeyCode(91,91);
del->setKeyCode(91);
numl_keys.append(del);
connect ( del, TQT_SIGNAL ( keyClick ( unsigned int ) ), this, TQT_SLOT ( keyPress ( unsigned int ) ) );
@ -485,7 +485,7 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
ent->resize(30,65);
ent->move(padx+70+35,sty+(4*35));
ent->res();
ent->setText("Ent");
ent->setText("En\nter");
ent->setKeyCode(104);
other_keys.append(ent);
connect ( ent, TQT_SIGNAL ( keyClick ( unsigned int ) ), this, TQT_SLOT ( keyPress ( unsigned int ) ) );

@ -34,19 +34,10 @@ void NumpadVButton::numlockPressed(bool press)
{
if (press==true){
TQPushButton::setText(u);
VButton::setKeyCode(numlock_code);
}
else{
TQPushButton::setText(l);
VButton::setKeyCode(cursor_code);
}
}
void NumpadVButton::setKeyCode(unsigned int numpad_keycode, unsigned int cursor_keycode)
{
cursor_code = cursor_keycode;
numlock_code = numpad_keycode;
VButton::setKeyCode(cursor_code);
}
#include "numpadvbutton.moc"

@ -30,15 +30,10 @@ class NumpadVButton : public VButton
Q_OBJECT
public:
NumpadVButton(TQWidget *parent = 0, const char *name = 0);
~NumpadVButton();
void numlockPressed(bool press);
void setKeyCode(unsigned int keycode, unsigned int n_keycode);
private:
unsigned int numlock_code;
unsigned int cursor_code;
NumpadVButton(TQWidget *parent = 0, const char *name = 0);
~NumpadVButton();
void numlockPressed(bool press);
};
#endif

Loading…
Cancel
Save