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 64d40d992e)
r14.0.x
Michele Calgaro 4 years ago
parent 807c1ac53f
commit 4918c52f39
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -511,27 +511,27 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
{
tray = new KbdTray ( this );
tray->setPixmap ( UserIcon ( "tray" ) );
TDEConfig *cfg = TDEApplication::kApplication()->config();
TDEPopupMenu *m = tray->contextMenu();
m->setCheckable ( true );
KHelpMenu *h = new KHelpMenu ( tray, about );
m->insertItem ( "Font ...", this, TQT_SLOT ( chooseFont() ) );
mnu_autores = m->insertItem( "Auto resize font",this, TQT_SLOT ( toggleFontAutoRes() ) );
bool fnt_autores = cfg->readBoolEntry("autoresfont",true);
m->setItemChecked(mnu_autores, fnt_autores);
m->insertItem ( i18n ("Background color"), this, TQT_SLOT ( chooseBackgroundColor() ) );
m->insertItem ( i18n ("Keys color (requires restart)"), this, TQT_SLOT ( chooseKeysColor() ) );
m->insertItem ( i18n ("Keys color"), this, TQT_SLOT ( chooseKeysColor() ) );
m->insertSeparator();
mnu_dock = m->insertItem ( "Dock widget", this, TQT_SLOT ( showDock() ) );
bool show_dock = cfg->readBoolEntry("showdock",false);
m->setItemChecked(mnu_dock, show_dock);
mnu_lock = m->insertItem(i18n("Lock on screen"), this, TQT_SLOT(toggleLock()));
locked = cfg->readBoolEntry("locked", false);
m->setItemChecked(mnu_lock, locked);
@ -597,7 +597,23 @@ void MainWidget::chooseKeysColor()
{
cfg->writeEntry("keysColor", newkeysC.name()); // save as #rrbbgg
cfg->sync();
// can't set PaletteBackgroundColor because it's in VButton::VButton - needs restart to read configuration entry
for (unsigned idx = 0; idx < btns.size(); ++idx)
{
btns[idx]->setColor(newkeysC);
}
for (unsigned idx = 0; idx < mod_keys.size(); ++idx)
{
mod_keys[idx]->setColor(newkeysC);
}
for (unsigned idx = 0; idx < other_keys.size(); ++idx)
{
other_keys[idx]->setColor(newkeysC);
}
for (unsigned idx = 0; idx < numl_keys.size(); ++idx)
{
numl_keys[idx]->setColor(newkeysC);
}
}
}

@ -50,25 +50,21 @@ public:
public slots:
void keyPress(unsigned int keycode);
void toggleCaps();
void toggleNumlock();
void toggleShift();
void toggleNumericPad();
void toggleFontAutoRes();
void toggleLock();
void queryModState();
void showDock();
void quitClicked();
void chooseFont();
void chooseBackgroundColor();
void chooseKeysColor();
void toggleNumericPad();
void toggleFontAutoRes();
void toggleLock();
void restorePosition();
void showConfigMenu();
void saveState();
void quitClicked();
protected:
void resizeEvent(TQResizeEvent *e);

@ -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();

@ -11,15 +11,17 @@ Q_OBJECT
public:
VButton(TQWidget *parent=0, const char *name=0);
~VButton();
void setKeyCode(unsigned int keycode);
unsigned int getKeyCode();
void setText(const TQString& text);
void setShiftText(const TQString& text);
void setKeyCode(unsigned int keycode);
void setText(const TQString &text);
void setShiftText(const TQString &text);
void setColor(const TQColor &color);
void capsPressed(bool press);
void reposition(int width, int height);
void res();
static double pw;
static double ph;
@ -32,7 +34,8 @@ protected:
TQString u;
TQString l;
TQRect orig_size;
void timerEvent ( TQTimerEvent * );
void timerEvent ( TQTimerEvent * );
public slots:
void sendKey();
@ -44,7 +47,6 @@ protected slots:
signals:
void keyClick(unsigned int keycode);
};
#endif

Loading…
Cancel
Save