summaryrefslogtreecommitdiffstats
path: root/src/VButton.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2021-02-27 15:28:40 +0900
committerMichele Calgaro <[email protected]>2021-02-27 15:28:40 +0900
commit64d40d992ecb290a7d395b14e5d3b81e4ed074d2 (patch)
tree620066cb47066d1919c7fdfba8dba5f544c97f0b /src/VButton.cpp
parent43425b84f70794eeb975f6811b7dacc3cec01cd2 (diff)
downloadkvkbd-64d40d992ecb290a7d395b14e5d3b81e4ed074d2.tar.gz
kvkbd-64d40d992ecb290a7d395b14e5d3b81e4ed074d2.zip
Keys color can now be changed without the need to restart the
application. Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src/VButton.cpp')
-rw-r--r--src/VButton.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/VButton.cpp b/src/VButton.cpp
index 58b2a1b..c5763ab 100644
--- a/src/VButton.cpp
+++ b/src/VButton.cpp
@@ -11,16 +11,16 @@ VButton::VButton(TQWidget *parent, const char *name): TQPushButton (parent,name)
{
TDEConfig *cfg = TDEApplication::kApplication()->config();
TQString keysC = cfg->readEntry("keysColor", "#f0f0f0");
- setPaletteBackgroundColor(TQColor(keysC));
-
+ setColor(TQColor(keysC));
setFocusPolicy(TQ_NoFocus);
resize(30,30);
press=false;
}
+
VButton::~VButton()
{
-
}
+
void VButton::shiftPressed(bool press)
{
if (press==true){
@@ -32,12 +32,12 @@ void VButton::shiftPressed(bool press)
else{
TQPushButton::setText(tu);
}
-
}
else{
TQPushButton::setText(l);
}
}
+
void VButton::capsPressed(bool press)
{
if (press==true){
@@ -59,20 +59,40 @@ void VButton::setText(const TQString& text)
TQPushButton::setText(text);
l=text;
}
+
void VButton::setShiftText(const TQString& text)
{
u=text;
}
+void VButton::setColor(const TQColor &color)
+{
+ setPaletteBackgroundColor(color);
+ // Need to set TQColorGroup::Button color as well, otherwise the actual
+ // color of the key does not change until the next restart of the application.
+ TQPalette plt = palette();
+ TQColorGroup cg = plt.active();
+ cg.setColor(TQColorGroup::Button, color);
+ plt.setActive(cg);
+ cg = plt.inactive();
+ cg.setColor(TQColorGroup::Button, color);
+ plt.setInactive(cg);
+ cg = plt.disabled();
+ cg.setColor(TQColorGroup::Button, color);
+ plt.setDisabled(cg);
+ setPalette(plt);
+}
+
void VButton::setKeyCode(unsigned int keycode)
{
this->keycode=keycode;
-
}
+
unsigned int VButton::getKeyCode()
{
return this->keycode;
}
+
void VButton::sendKey()
{
emit keyClick(keycode);
@@ -86,8 +106,8 @@ void VButton::reposition(int width, int height)
double sdy=ph/orig_size.height();
move((int)(width/dx),(int)(height/dy));
resize((int)(width/sdx), (int)(height/sdy));
-
}
+
void VButton::res()
{
orig_size=geometry();