Version: 3.1 (using KDE KDE 3.1) Installed from: Slackware Packages OS: Linux The problem with the background color of input type "file" is that it uses my system colour instead of the bgcolor tag of the body, I'm using "Digital CDE" as colour sheme and a body tag as: <body bgcolor="#ffffff"> Everything else renders with the correct background colour (white), besides the file input field. By background colour I mean the color _around_ the input field, not the colour of the text area.
Created attachment 1301 [details] A screenshot showing the bug Look for the file browse input field
Created attachment 1567 [details] Patch, plus testing how it works on the upload form here The following is my attempt at fixing this. Note that the event filter stuff is really mostly correctness paranoia, and if it's omitted, no one will notice. That would only matter if a style were to shape buttons differently if they were pressed or focused (the former of which can't be done ATM due to Qt not updating the mask on mouse releases). No Qt or KDE style I know of does that. (Not sure about Aqua or XP styles, though)
Subject: kdelibs/khtml/rendering CVS commit by orlovich: Calculate a mask for <input type="file"> elements, so they don't get a grey or other such weird background CCMAIL: 56830-done@bugs.kde.org M +53 -4 render_form.cpp 1.228 M +3 -2 render_form.h 1.93 --- kdelibs/khtml/rendering/render_form.h #1.92:1.93 @@ -305,4 +305,5 @@ public: KLineEdit* lineEdit() const { return m_edit; } + const QPushButton* pushButton() const { return m_button; } public slots: --- kdelibs/khtml/rendering/render_form.cpp #1.227:1.228 @@ -47,4 +47,5 @@ #include <qpopupmenu.h> +#include <qbitmap.h> using namespace khtml; @@ -710,9 +711,55 @@ void RenderFieldset::paintBorderMinusLeg // ------------------------------------------------------------------------- +//A helper widget that generates a mask +class TransHBox:public QHBox +{ +public: + TransHBox(RenderFileButton* owner, QWidget* parent):QHBox(parent), m_owner(owner) + { + setAutoMask(true); + } + + virtual void updateMask() + { + QBitmap mask(size()); + QPainter p(&mask); + + const QPushButton* push = m_owner->pushButton(); + const QLineEdit* lineEdit = m_owner->lineEdit(); + + //If we have the button & line edit, make a proper mask + if (push && lineEdit) + { + //Mask everything off + p.fillRect(0, 0, width(), height(), Qt::color0); + + //Draw button mask + QRect buttonRect = QRect(push->pos(), push->size()); + parentWidget()->style().drawControlMask(QStyle::CE_PushButton, + &p, push, buttonRect); + + //Draw line edit mask + QRect lineEditRect = QRect(lineEdit->pos(), lineEdit->size()); + p.fillRect(lineEditRect, Qt::color1); + } + else //Fall back everything visible. + p.fillRect(0, 0, width(), height(), Qt::color1); + + p.end(); + setMask(mask); + } + +private: + RenderFileButton* m_owner; +}; + RenderFileButton::RenderFileButton(HTMLInputElementImpl *element) : RenderFormElement(element) { - // this sucks, it creates a grey background - QHBox *w = new QHBox(view()->viewport()); + m_edit = 0; //For the benefit of the transhbox. + m_button = 0; + + // this sucks, we need to use a custom widget to get a proper background + TransHBox *w = new TransHBox(this, view()->viewport()); m_edit = new LineEditWidget(element, view(), w); @@ -729,4 +776,6 @@ RenderFileButton::RenderFileButton(HTMLI w->setStretchFactor(m_edit, 2); w->setFocusProxy(m_edit); + + w->updateMask(); setQWidget(w);