diff --git a/gb.qt4/src/CTextArea.cpp b/gb.qt4/src/CTextArea.cpp index d6ebffe6f..dec0ce401 100644 --- a/gb.qt4/src/CTextArea.cpp +++ b/gb.qt4/src/CTextArea.cpp @@ -23,9 +23,8 @@ #define __CTEXTAREA_CPP -#include -#include -#include +#include +#include #include #include @@ -59,6 +58,12 @@ static int get_length(void *_object) return THIS->length; } +static bool is_empty(void *_object) +{ + QTextBlock block = WIDGET->document()->begin(); + return !block.isValid(); +} + static void to_pos(QTextEdit *wid, int par, int car, int *pos) { QTextCursor cursor; @@ -147,16 +152,27 @@ void CTEXTAREA_set_foreground(void *_object) { THIS->no_change = TRUE; - QTextCursor oldCursor = WIDGET->textCursor(); - - WIDGET->selectAll(); - - WIDGET->setTextColor(Qt::black); - set_text_color(THIS); - - WIDGET->setTextCursor(oldCursor); - - set_text_color(THIS); + if (is_empty(THIS)) + { + WIDGET->setPlainText(" "); + WIDGET->selectAll(); + WIDGET->setTextColor(Qt::black); + set_text_color(THIS); + WIDGET->textCursor().insertText(""); + } + else + { + QTextCursor oldCursor = WIDGET->textCursor(); + + WIDGET->selectAll(); + + WIDGET->setTextColor(Qt::black); + set_text_color(THIS); + + WIDGET->setTextCursor(oldCursor); + + set_text_color(THIS); + } THIS->no_change = FALSE; } diff --git a/gb.qt4/src/CWidget.cpp b/gb.qt4/src/CWidget.cpp index 6bfa2cac3..26b100254 100644 --- a/gb.qt4/src/CWidget.cpp +++ b/gb.qt4/src/CWidget.cpp @@ -1308,7 +1308,7 @@ void CWIDGET_reset_color(CWIDGET *_object) bg = THIS_EXT->bg; fg = THIS_EXT->fg; - if (qobject_cast(w)) + if (GB.Is(THIS, CLASS_ComboBox)) { //QComboBox *cb = (QComboBox *)w; palette = QPalette(); @@ -1333,18 +1333,28 @@ void CWIDGET_reset_color(CWIDGET *_object) w->setPalette(palette); } - /*else if (qobject_cast(w)) + else if (GB.Is(THIS, CLASS_TextArea)) { palette = QPalette(); if (bg != COLOR_DEFAULT) + { palette.setColor(QPalette::Base, TO_QCOLOR(bg)); + palette.setColor(QPalette::Window, TO_QCOLOR(bg)); + palette.setColor(QPalette::Button, TO_QCOLOR(bg)); + } if (fg != COLOR_DEFAULT) + { palette.setColor(QPalette::Text, TO_QCOLOR(fg)); + palette.setColor(QPalette::WindowText, TO_QCOLOR(fg)); + palette.setColor(QPalette::ButtonText, TO_QCOLOR(fg)); + } w->setPalette(palette); - }*/ + + CTEXTAREA_set_foreground(THIS); + } else { palette = QPalette(); @@ -1383,8 +1393,6 @@ void CWIDGET_reset_color(CWIDGET *_object) //w->setAutoFillBackground(THIS->bg != COLOR_DEFAULT); - if (GB.Is(THIS, CLASS_TextArea)) - CTEXTAREA_set_foreground(THIS); if (_after_set_color) (*_after_set_color)(THIS); diff --git a/gb.qt4/src/main.cpp b/gb.qt4/src/main.cpp index 21a3215f0..1f0dc3b35 100644 --- a/gb.qt4/src/main.cpp +++ b/gb.qt4/src/main.cpp @@ -144,6 +144,7 @@ GB_CLASS CLASS_Printer; GB_CLASS CLASS_Image; GB_CLASS CLASS_SvgImage; GB_CLASS CLASS_TextArea; +GB_CLASS CLASS_ComboBox; static bool in_event_loop = false; static int _no_destroy = 0; @@ -1459,6 +1460,7 @@ int EXPORT GB_INIT(void) CLASS_Image = GB.FindClass("Image"); CLASS_SvgImage = GB.FindClass("SvgImage"); CLASS_TextArea = GB.FindClass("TextArea"); + CLASS_ComboBox = GB.FindClass("ComboBox"); QT_InitEventLoop(); diff --git a/gb.qt4/src/main.h b/gb.qt4/src/main.h index 33854adf6..6e3ce12a2 100644 --- a/gb.qt4/src/main.h +++ b/gb.qt4/src/main.h @@ -76,6 +76,7 @@ extern GB_CLASS CLASS_Printer; extern GB_CLASS CLASS_Image; extern GB_CLASS CLASS_SvgImage; extern GB_CLASS CLASS_TextArea; +extern GB_CLASS CLASS_ComboBox; #endif