Added functionality to select keyboard background and keys colors.

A restart of the application is required if the keys color is changed.

Signed-off-by: Ray-V <ray-v@inbox.lv>
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/10/head
Ray-V 4 years ago committed by Michele Calgaro
parent 2b6b682830
commit dd8d527084
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -38,7 +38,7 @@
#include <tqfontdialog.h> #include <tqfontdialog.h>
#include <tdeconfig.h> #include <tdeconfig.h>
#include <tdeapplication.h> #include <tdeapplication.h>
#include <tqcolordialog.h>
#define R1LEN 13 #define R1LEN 13
@ -73,15 +73,15 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
int stx=15; int stx=15;
int sty=15; int sty=15;
extent_visible=false; extent_visible=false;
TDEConfig *cfg = TDEApplication::kApplication()->config(); TDEConfig *cfg = TDEApplication::kApplication()->config();
if (cfg) if (cfg)
{ {
extent_visible = cfg->readBoolEntry("numpad_visible", false); extent_visible = cfg->readBoolEntry("numpad_visible", false);
TQString backgroundC = cfg->readEntry("keyboardBackgroundColor", "#cdc0b0");
setPaletteBackgroundColor(TQColor(backgroundC));
} }
// resize ( 550,235 );
// move(0,0);
VButton *esc = new VButton ( this,"" ); VButton *esc = new VButton ( this,"" );
esc->setKeyCode ( 9 ); esc->setKeyCode ( 9 );
esc->move ( stx,sty ); esc->move ( stx,sty );
@ -409,7 +409,6 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
connect ( t, TQT_SIGNAL ( timeout() ), this, TQT_SLOT ( queryModState() ) ); connect ( t, TQT_SIGNAL ( timeout() ), this, TQT_SLOT ( queryModState() ) );
t->start ( 500, FALSE ); t->start ( 500, FALSE );
setPaletteBackgroundColor ( TQt::black );
setFocusPolicy ( TQ_NoFocus ); setFocusPolicy ( TQ_NoFocus );
int padx= 550; int padx= 550;
@ -525,6 +524,10 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
bool fnt_autores = cfg->readBoolEntry("autoresfont",true); bool fnt_autores = cfg->readBoolEntry("autoresfont",true);
m->setItemChecked(mnu_autores, fnt_autores); 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->insertSeparator();
mnu_dock = m->insertItem ( "Dock widget", this, TQT_SLOT ( showDock() ) ); mnu_dock = m->insertItem ( "Dock widget", this, TQT_SLOT ( showDock() ) );
bool show_dock = cfg->readBoolEntry("showdock",false); bool show_dock = cfg->readBoolEntry("showdock",false);
m->setItemChecked(mnu_dock, show_dock); m->setItemChecked(mnu_dock, show_dock);
@ -572,6 +575,32 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
} }
} }
void MainWidget::chooseBackgroundColor()
{
TDEConfig *cfg = TDEApplication::kApplication()->config();
TQString backgroundC = cfg->readEntry("keyboardBackgroundColor", "#cdc0b0");
TQColor newBackgroundC = TQColorDialog::getColor(TQColor(backgroundC));
if (newBackgroundC.isValid())
{
cfg->writeEntry("keyboardBackgroundColor", newBackgroundC.name()); // save as #rrbbgg
cfg->sync();
setPaletteBackgroundColor(newBackgroundC);
}
}
void MainWidget::chooseKeysColor()
{
TDEConfig *cfg = TDEApplication::kApplication()->config();
TQString keysC = cfg->readEntry("keysColor", "#f0f0f0");
TQColor newkeysC = TQColorDialog::getColor(TQColor(keysC));
if (newkeysC.isValid())
{
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
}
}
void MainWidget::finishInit() void MainWidget::finishInit()
{ {
TDEConfig *cfg = TDEApplication::kApplication()->config(); TDEConfig *cfg = TDEApplication::kApplication()->config();

@ -61,12 +61,13 @@ public slots:
void quitClicked(); void quitClicked();
void chooseFont(); void chooseFont();
void chooseBackgroundColor();
void chooseKeysColor();
void toggleNumericPad(); void toggleNumericPad();
void toggleFontAutoRes(); void toggleFontAutoRes();
void toggleLock(); void toggleLock();
void restorePosition(); void restorePosition();
void showConfigMenu(); void showConfigMenu();
// void shutDown();
void saveState(); void saveState();
protected: protected:

@ -1,18 +1,21 @@
#include "VButton.h" #include "VButton.h"
#include <tqvbox.h> #include <tqvbox.h>
#include <tqfont.h> #include <tqfont.h>
#include <tdeconfig.h>
#include <tdeapplication.h>
double VButton::pw=550.0; double VButton::pw=550.0;
double VButton::ph=235.0; double VButton::ph=235.0;
VButton::VButton(TQWidget *parent, const char *name): TQPushButton (parent,name) VButton::VButton(TQWidget *parent, const char *name): TQPushButton (parent,name)
{ {
TDEConfig *cfg = TDEApplication::kApplication()->config();
//connect(this,TQT_SIGNAL(clicked()),this,TQT_SLOT(sendKey())); TQString keysC = cfg->readEntry("keysColor", "#f0f0f0");
setPaletteBackgroundColor(TQColor(keysC));
setFocusPolicy(TQ_NoFocus); setFocusPolicy(TQ_NoFocus);
resize(30,30); resize(30,30);
press=false; press=false;
} }
VButton::~VButton() VButton::~VButton()
{ {

Loading…
Cancel
Save