Summary: | The background color of input fields of type "file" is wrong | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Simon Ejsing <simon> |
Component: | khtml | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | minor | ||
Priority: | NOR | ||
Version: | 3.1 | ||
Target Milestone: | --- | ||
Platform: | Slackware | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
A screenshot showing the bug
Patch, plus testing how it works on the upload form here |
Description
Simon Ejsing
2003-04-04 11:45:10 UTC
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); |