diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-02-27 15:28:40 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-02-27 15:29:41 +0900 |
commit | 4918c52f39ab6459d1c48e9456a7fbd01a4e91f6 (patch) | |
tree | 45027af97cb407006c2c09632566fbeeee1e3683 /src/VButton.cpp | |
parent | 807c1ac53f76fda7c4cafd58c5a2079a0a1961e5 (diff) | |
download | kvkbd-4918c52f39ab6459d1c48e9456a7fbd01a4e91f6.tar.gz kvkbd-4918c52f39ab6459d1c48e9456a7fbd01a4e91f6.zip |
Keys color can now be changed without the need to restart the
application.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 64d40d992ecb290a7d395b14e5d3b81e4ed074d2)
Diffstat (limited to 'src/VButton.cpp')
-rw-r--r-- | src/VButton.cpp | 32 |
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(); |