summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-03-15 10:50:14 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-03-15 11:20:18 +0900
commit37c26178be0e54dc42908b1cc5d7ec4802aff85b (patch)
tree2dedbcc64a1110bd2bc08fabb45a9d5e4ee5cfe3
parent670268c0714ce4754cac757a4b13cc0fcdb71bd6 (diff)
downloadkvkbd-37c26178be0e54dc42908b1cc5d7ec4802aff85b.tar.gz
kvkbd-37c26178be0e54dc42908b1cc5d7ec4802aff85b.zip
Fixed behavior of caps for non-alpha characters, which was broken in
commit 1865767. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 48c1053fa1e5896a10e576b9eb35634fa789cff4)
-rw-r--r--src/MainWidget.cpp13
-rw-r--r--src/MainWidget.h2
-rw-r--r--src/VButton.cpp29
-rw-r--r--src/VButton.h11
-rw-r--r--src/numpadvbutton.cpp4
5 files changed, 38 insertions, 21 deletions
diff --git a/src/MainWidget.cpp b/src/MainWidget.cpp
index 8797085..ff10c27 100644
--- a/src/MainWidget.cpp
+++ b/src/MainWidget.cpp
@@ -858,16 +858,17 @@ void MainWidget::updateNumlock()
void MainWidget::toggleShift(unsigned int 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++)
{
VButton *v = btns[a];
- v->shiftPressed(state);
+ v->shiftCapsPressed(shiftState, capsState);
}
}
@@ -880,7 +881,7 @@ void MainWidget::keyPress ( unsigned int a )
mod->setOn(false);
}
// Make sure the key labels are correctly updated
- updateShift();
+ updateShiftCaps();
}
void MainWidget::send_key(unsigned int keycode)
@@ -935,7 +936,7 @@ void MainWidget::queryModState()
if (caps_state != caps->isOn())
{
caps->setOn(caps_state);
- updateShift();
+ updateShiftCaps();
}
bool numl_state = keyState(XK_Num_Lock);
diff --git a/src/MainWidget.h b/src/MainWidget.h
index 2c708cc..d7c7691 100644
--- a/src/MainWidget.h
+++ b/src/MainWidget.h
@@ -73,7 +73,7 @@ protected:
private:
void updateFont();
void updateNumlock();
- void updateShift();
+ void updateShiftCaps();
bool nresize;
diff --git a/src/VButton.cpp b/src/VButton.cpp
index cabedd1..c949612 100644
--- a/src/VButton.cpp
+++ b/src/VButton.cpp
@@ -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
{
- 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)
{
TQPushButton::setText(text);
- l=text;
+ lowerText = text;
+ isAlpha = text.length() == 1 && (text.upper() != text);
}
void VButton::setShiftText(const TQString& text)
{
- u=text;
+ shiftText=text;
}
void VButton::setColor(const TQColor &color)
diff --git a/src/VButton.h b/src/VButton.h
index cab13cd..349b403 100644
--- a/src/VButton.h
+++ b/src/VButton.h
@@ -24,22 +24,21 @@ public:
static double pw;
static double ph;
-private:
+protected:
bool press;
bool inrpt;
bool inside;
-
-protected:
+ bool isAlpha;
unsigned int keycode;
- TQString u;
- TQString l;
+ TQString lowerText;
+ TQString shiftText;
TQRect orig_size;
void timerEvent ( TQTimerEvent * );
public slots:
void sendKey();
- void shiftPressed(bool press);
+ void shiftCapsPressed(bool shift, bool caps);
protected slots:
void enterEvent(TQEvent *e);
diff --git a/src/numpadvbutton.cpp b/src/numpadvbutton.cpp
index 722d90f..2cb1773 100644
--- a/src/numpadvbutton.cpp
+++ b/src/numpadvbutton.cpp
@@ -33,10 +33,10 @@ NumpadVButton::~NumpadVButton()
void NumpadVButton::numlockPressed(bool press)
{
if (press==true){
- TQPushButton::setText(u);
+ TQPushButton::setText(shiftText);
}
else{
- TQPushButton::setText(l);
+ TQPushButton::setText(lowerText);
}
}