summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay-V <[email protected]>2021-03-22 12:56:28 +0900
committerMichele Calgaro <[email protected]>2021-03-22 13:10:44 +0900
commitb1c1fd93a72134d2e450301926d0121a8f73529b (patch)
treeaa9b89842487bcb8a72a5f45b9c3889d95308fee
parent54fd5c4cb114b87671e750430a4d0b1b67a43d58 (diff)
downloadkvkbd-b1c1fd93a72134d2e450301926d0121a8f73529b.tar.gz
kvkbd-b1c1fd93a72134d2e450301926d0121a8f73529b.zip
Fixed algorithm for CAPS text key visualization.
Signed-off-by: Ray-V <[email protected]> Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r--src/VButton.cpp32
-rw-r--r--src/VButton.h4
-rw-r--r--src/numpadvbutton.cpp2
3 files changed, 30 insertions, 8 deletions
diff --git a/src/VButton.cpp b/src/VButton.cpp
index e44feba..41871cd 100644
--- a/src/VButton.cpp
+++ b/src/VButton.cpp
@@ -26,13 +26,21 @@ void VButton::shiftCapsPressed(bool shift, bool caps)
if (isAlpha)
{
// Alpha button, both shift and caps affect its state
- if (shift ^ caps)
+ if (caps && shift)
+ {
+ TQPushButton::setText(capsShiftText);
+ }
+ else if (caps)
+ {
+ TQPushButton::setText(capsText);
+ }
+ else if (shift)
{
TQPushButton::setText(shiftText);
}
else
{
- TQPushButton::setText(lowerText);
+ TQPushButton::setText(normalText);
}
}
else
@@ -44,7 +52,7 @@ void VButton::shiftCapsPressed(bool shift, bool caps)
}
else
{
- TQPushButton::setText(lowerText);
+ TQPushButton::setText(normalText);
}
}
}
@@ -54,13 +62,25 @@ void VButton::setText(const TQString& text)
// Need to set the pushbutton text to correctly handle those buttons which usually
// don't change (tab, shift, caps, Fn, ...)
TQPushButton::setText(text);
- lowerText = text;
- isAlpha = text.length() == 1 && (text.upper() != text);
+ normalText = text;
+ capsText = text.upper();
+ isAlpha = text.length() == 1 && capsText != normalText;
}
void VButton::setShiftText(const TQString& text)
{
- shiftText=text;
+ shiftText = text;
+ // 'text' is normally uppercase here, so in most cases we need to set capsShiftText
+ // to text.lower() to handle caps+shift correctly. Special cases like ç and Ç are
+ // handled by using text.upper()
+ if (text.lower() != text)
+ {
+ capsShiftText = text.lower();
+ }
+ else
+ {
+ capsShiftText = text.upper();
+ }
}
void VButton::setColor(const TQColor &color)
diff --git a/src/VButton.h b/src/VButton.h
index 349b403..481c077 100644
--- a/src/VButton.h
+++ b/src/VButton.h
@@ -30,8 +30,10 @@ protected:
bool inside;
bool isAlpha;
unsigned int keycode;
- TQString lowerText;
+ TQString normalText;
+ TQString capsText;
TQString shiftText;
+ TQString capsShiftText;
TQRect orig_size;
void timerEvent ( TQTimerEvent * );
diff --git a/src/numpadvbutton.cpp b/src/numpadvbutton.cpp
index 2cb1773..b6b2a25 100644
--- a/src/numpadvbutton.cpp
+++ b/src/numpadvbutton.cpp
@@ -36,7 +36,7 @@ void NumpadVButton::numlockPressed(bool press)
TQPushButton::setText(shiftText);
}
else{
- TQPushButton::setText(lowerText);
+ TQPushButton::setText(normalText);
}
}