diff options
author | Ray-V <ray-v@inbox.lv> | 2021-02-26 13:02:18 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-02-26 13:04:57 +0900 |
commit | dd8d52708461bcd9d5fd11f62fc59f18fcfc542e (patch) | |
tree | 26a64e4909a269bdf947f7886be78f892193edb1 /src/MainWidget.cpp | |
parent | 2b6b682830d718edf4f2bc4f660239857f6a6fca (diff) | |
download | kvkbd-dd8d52708461bcd9d5fd11f62fc59f18fcfc542e.tar.gz kvkbd-dd8d52708461bcd9d5fd11f62fc59f18fcfc542e.zip |
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>
Diffstat (limited to 'src/MainWidget.cpp')
-rw-r--r-- | src/MainWidget.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/MainWidget.cpp b/src/MainWidget.cpp index e57ff39..ff7dc62 100644 --- a/src/MainWidget.cpp +++ b/src/MainWidget.cpp @@ -38,7 +38,7 @@ #include <tqfontdialog.h> #include <tdeconfig.h> #include <tdeapplication.h> - +#include <tqcolordialog.h> #define R1LEN 13 @@ -73,15 +73,15 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const int stx=15; int sty=15; extent_visible=false; + TDEConfig *cfg = TDEApplication::kApplication()->config(); if (cfg) { 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,"" ); esc->setKeyCode ( 9 ); 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() ) ); t->start ( 500, FALSE ); - setPaletteBackgroundColor ( TQt::black ); setFocusPolicy ( TQ_NoFocus ); int padx= 550; @@ -525,6 +524,10 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const 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->insertSeparator(); mnu_dock = m->insertItem ( "Dock widget", this, TQT_SLOT ( showDock() ) ); bool show_dock = cfg->readBoolEntry("showdock",false); 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() { TDEConfig *cfg = TDEApplication::kApplication()->config(); |