Fixed behavior of caps for non-alpha characters, which was broken in

commit 00e207e.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/10/head
Michele Calgaro 3 years ago
parent 568e7737c7
commit 48c1053fa1
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -858,16 +858,17 @@ void MainWidget::updateNumlock()
void MainWidget::toggleShift(unsigned int keycode) void MainWidget::toggleShift(unsigned int keycode)
{ {
send_key(keycode); send_key(keycode);
updateShift(); updateShiftCaps();
} }
void MainWidget::updateShift() void MainWidget::updateShiftCaps()
{ {
bool state = caps->isOn() ^ (lshift->isOn() || rshift->isOn()); bool shiftState = lshift->isOn() || rshift->isOn();
bool capsState = caps->isOn();
for (unsigned a = 0; a < btns.size(); a++) for (unsigned a = 0; a < btns.size(); a++)
{ {
VButton *v = btns[a]; VButton *v = btns[a];
v->shiftPressed(state); v->shiftCapsPressed(shiftState, capsState);
} }
} }
@ -880,7 +881,7 @@ void MainWidget::keyPress ( unsigned int a )
mod->setOn(false); mod->setOn(false);
} }
// Make sure the key labels are correctly updated // Make sure the key labels are correctly updated
updateShift(); updateShiftCaps();
} }
void MainWidget::send_key(unsigned int keycode) void MainWidget::send_key(unsigned int keycode)
@ -935,7 +936,7 @@ void MainWidget::queryModState()
if (caps_state != caps->isOn()) if (caps_state != caps->isOn())
{ {
caps->setOn(caps_state); caps->setOn(caps_state);
updateShift(); updateShiftCaps();
} }
bool numl_state = keyState(XK_Num_Lock); bool numl_state = keyState(XK_Num_Lock);

@ -73,7 +73,7 @@ protected:
private: private:
void updateFont(); void updateFont();
void updateNumlock(); void updateNumlock();
void updateShift(); void updateShiftCaps();
bool nresize; bool nresize;

@ -21,27 +21,44 @@ VButton::~VButton()
{ {
} }
void VButton::shiftPressed(bool press) void VButton::shiftCapsPressed(bool shift, bool caps)
{ {
if (press) if (isAlpha)
{ {
TQPushButton::setText(u); // Alpha button, both shift and caps affect its state
if (shift ^ caps)
{
TQPushButton::setText(shiftText);
}
else
{
TQPushButton::setText(lowerText);
}
} }
else else
{ {
TQPushButton::setText(l); // Non alpha button, only shift affects its state
if (shift)
{
TQPushButton::setText(shiftText);
}
else
{
TQPushButton::setText(lowerText);
}
} }
} }
void VButton::setText(const TQString& text) void VButton::setText(const TQString& text)
{ {
TQPushButton::setText(text); TQPushButton::setText(text);
l=text; lowerText = text;
isAlpha = text.length() == 1 && (text.upper() != text);
} }
void VButton::setShiftText(const TQString& text) void VButton::setShiftText(const TQString& text)
{ {
u=text; shiftText=text;
} }
void VButton::setColor(const TQColor &color) void VButton::setColor(const TQColor &color)

@ -24,22 +24,21 @@ public:
static double pw; static double pw;
static double ph; static double ph;
private: protected:
bool press; bool press;
bool inrpt; bool inrpt;
bool inside; bool inside;
bool isAlpha;
protected:
unsigned int keycode; unsigned int keycode;
TQString u; TQString lowerText;
TQString l; TQString shiftText;
TQRect orig_size; TQRect orig_size;
void timerEvent ( TQTimerEvent * ); void timerEvent ( TQTimerEvent * );
public slots: public slots:
void sendKey(); void sendKey();
void shiftPressed(bool press); void shiftCapsPressed(bool shift, bool caps);
protected slots: protected slots:
void enterEvent(TQEvent *e); void enterEvent(TQEvent *e);

@ -33,10 +33,10 @@ NumpadVButton::~NumpadVButton()
void NumpadVButton::numlockPressed(bool press) void NumpadVButton::numlockPressed(bool press)
{ {
if (press==true){ if (press==true){
TQPushButton::setText(u); TQPushButton::setText(shiftText);
} }
else{ else{
TQPushButton::setText(l); TQPushButton::setText(lowerText);
} }
} }

Loading…
Cancel
Save