|
@@ -34,77 +34,22 @@ Q_IMPORT_PLUGIN(qtiff)
|
|
|
Q_IMPORT_PLUGIN(qmng)
|
|
|
#endif
|
|
|
|
|
|
-MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false) {
|
|
|
- if (checkbox == 0)
|
|
|
- checkbox = new QSvgRenderer(QByteArray(
|
|
|
-"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
|
-"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
|
|
|
-"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
|
|
|
-" version=\"1.1\" baseProfile=\"full\" width=\"12px\" height=\"12px\" viewBox=\"0 0 12px 12px\">\n"
|
|
|
-" <rect x=\"0\" y=\"0\" width=\"1\" height=\"12\" fill=\"#808080\" />\n"
|
|
|
-" <rect x=\"1\" y=\"0\" width=\"11\" height=\"1\" fill=\"#808080\" />\n"
|
|
|
-" <rect x=\"1\" y=\"11\" width=\"11\" height=\"1\" fill=\"#d4d0c8\" />\n"
|
|
|
-" <rect x=\"11\" y=\"1\" width=\"1\" height=\"11\" fill=\"#d4d0c8\" />\n"
|
|
|
-" <rect x=\"1\" y=\"1\" width=\"1\" height=\"10\" fill=\"#404040\" />\n"
|
|
|
-" <rect x=\"2\" y=\"1\" width=\"9\" height=\"1\" fill=\"#404040\" />\n"
|
|
|
-" <rect x=\"2\" y=\"10\" width=\"9\" height=\"1\" fill=\"white\" />\n"
|
|
|
-" <rect x=\"10\" y=\"2\" width=\"1\" height=\"9\" fill=\"white\" />\n"
|
|
|
-" <rect x=\"2\" y=\"2\" width=\"8\" height=\"8\" fill=\"white\" />\n"
|
|
|
-"</svg>\n"));
|
|
|
- if (checkbox_checked == 0)
|
|
|
- checkbox_checked = new QSvgRenderer(QByteArray(
|
|
|
-"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
|
-"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
|
|
|
-"<svg xmlns=\"http://www.w3.org/2000/svg\"\n"
|
|
|
-" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
|
|
|
-" version=\"1.1\" baseProfile=\"full\" width=\"12px\" height=\"12px\" viewBox=\"0 0 12px 12px\">\n"
|
|
|
-" <rect x=\"0\" y=\"0\" width=\"1\" height=\"12\" fill=\"#808080\" />\n"
|
|
|
-" <rect x=\"1\" y=\"0\" width=\"11\" height=\"1\" fill=\"#808080\" />\n"
|
|
|
-" <rect x=\"1\" y=\"11\" width=\"11\" height=\"1\" fill=\"#d4d0c8\" />\n"
|
|
|
-" <rect x=\"11\" y=\"1\" width=\"1\" height=\"11\" fill=\"#d4d0c8\" />\n"
|
|
|
-" <rect x=\"1\" y=\"1\" width=\"1\" height=\"10\" fill=\"#404040\" />\n"
|
|
|
-" <rect x=\"2\" y=\"1\" width=\"9\" height=\"1\" fill=\"#404040\" />\n"
|
|
|
-" <rect x=\"2\" y=\"10\" width=\"9\" height=\"1\" fill=\"white\" />\n"
|
|
|
-" <rect x=\"10\" y=\"2\" width=\"1\" height=\"9\" fill=\"white\" />\n"
|
|
|
-" <rect x=\"2\" y=\"2\" width=\"8\" height=\"8\" fill=\"white\" />\n"
|
|
|
-" <path d=\"M 3 5.5 L 3 8 L 5.5 10.5 L 10 5.5 L 10 2.5 L 5.5 7.5\" fill=\"black\" />\n"
|
|
|
-"</svg>\n"));
|
|
|
- if (radiobutton == 0)
|
|
|
- radiobutton = new QSvgRenderer(QByteArray(
|
|
|
-"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
|
-"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
|
|
|
-"<svg xmlns=\"http://www.w3.org/2000/svg\"\n"
|
|
|
-" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
|
|
|
-" version=\"1.1\" baseProfile=\"full\" width=\"11px\" height=\"11px\" viewBox=\"0 0 11px 11px\">\n"
|
|
|
-" <clipPath id=\"upleftclip\"><path d=\"M 11 0 L 0 0 L 0 11\"/></clipPath>\n"
|
|
|
-" <clipPath id=\"downrightclip\"><path d=\"M 11 0 L 11 11 L 0 11\"/></clipPath>\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"5.5\" fill=\"#808080\" clip-path=\"url(#upleftclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"5.5\" fill=\"white\" clip-path=\"url(#downrightclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"4.5\" fill=\"#404040\" clip-path=\"url(#upleftclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"4.5\" fill=\"#d4d0c8\" clip-path=\"url(#downrightclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"3.5\" fill=\"white\"/>\n"
|
|
|
-"</svg>\n"));
|
|
|
- if (radiobutton_checked == 0)
|
|
|
- radiobutton_checked = new QSvgRenderer(QByteArray(
|
|
|
-"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
|
|
-"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
|
|
|
-"<svg xmlns=\"http://www.w3.org/2000/svg\"\n"
|
|
|
-" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
|
|
|
-" version=\"1.1\" baseProfile=\"full\" width=\"11px\" height=\"11px\" viewBox=\"0 0 11px 11px\">\n"
|
|
|
-" <clipPath id=\"upleftclip\"><path d=\"M 11 0 L 0 0 L 0 11\"/></clipPath>\n"
|
|
|
-" <clipPath id=\"downrightclip\"><path d=\"M 11 0 L 11 11 L 0 11\"/></clipPath>\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"5.5\" fill=\"#808080\" clip-path=\"url(#upleftclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"5.5\" fill=\"white\" clip-path=\"url(#downrightclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"4.5\" fill=\"#404040\" clip-path=\"url(#upleftclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"4.5\" fill=\"#d4d0c8\" clip-path=\"url(#downrightclip)\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"3.5\" fill=\"white\" />\n"
|
|
|
-" <circle cx=\"5.5\" cy=\"5.5\" r=\"1.5\" fill=\"black\" />\n"
|
|
|
-"</svg>\n"));
|
|
|
+void loadSvg(QSvgRenderer * & ptr, const QString & path) {
|
|
|
+ delete ptr;
|
|
|
+ ptr = new QSvgRenderer(path);
|
|
|
+ if (ptr->isValid()) return;
|
|
|
+ delete ptr;
|
|
|
+ ptr = 0;
|
|
|
}
|
|
|
|
|
|
-void MyLooksStyle::producingForms(bool f) {
|
|
|
- weAreDrawingForms=f;
|
|
|
-}
|
|
|
+void MyLooksStyle::setCheckboxSvg(const QString & path) {loadSvg(checkbox, path);}
|
|
|
+void MyLooksStyle::setCheckboxCheckedSvg(const QString & path) {loadSvg(checkbox_checked, path);}
|
|
|
+void MyLooksStyle::setRadioButtonSvg(const QString & path) {loadSvg(radiobutton, path);}
|
|
|
+void MyLooksStyle::setRadioButtonCheckedSvg(const QString & path) {loadSvg(radiobutton_checked, path);}
|
|
|
+
|
|
|
+MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false) {}
|
|
|
+
|
|
|
+void MyLooksStyle::producingForms(bool f) {weAreDrawingForms=f;}
|
|
|
|
|
|
void MyLooksStyle::drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget) const {
|
|
|
painter->setBrush(Qt::white);
|
|
@@ -115,16 +60,28 @@ void MyLooksStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *
|
|
|
if (element == QStyle::PE_PanelLineEdit) {
|
|
|
painter->drawRect(r);
|
|
|
} else if (element == QStyle::PE_IndicatorCheckBox) {
|
|
|
- if (weAreDrawingForms)
|
|
|
+ if (weAreDrawingForms || ((option->state & QStyle::State_On)? !checkbox_checked: !checkbox)) {
|
|
|
painter->drawRect(r);
|
|
|
- else if (option->state & QStyle::State_On)
|
|
|
+ if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
|
|
|
+ r.translate(int(r.width()*0.075), int(r.width()*0.075));
|
|
|
+ painter->drawLine(r.topLeft(), r.bottomRight());
|
|
|
+ painter->drawLine(r.topRight(), r.bottomLeft());
|
|
|
+ }
|
|
|
+ } else if (option->state & QStyle::State_On)
|
|
|
checkbox_checked->render(painter, r);
|
|
|
else
|
|
|
checkbox->render(painter, r);
|
|
|
} else if (element == QStyle::PE_IndicatorRadioButton) {
|
|
|
- if (weAreDrawingForms)
|
|
|
+ if (weAreDrawingForms || ((option->state & QStyle::State_On)? !radiobutton_checked: !radiobutton)) {
|
|
|
painter->drawEllipse(r);
|
|
|
- else if (option->state & QStyle::State_On)
|
|
|
+ if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
|
|
|
+ r.translate(int(r.width()*0.20), int(r.width()*0.20));
|
|
|
+ r.setWidth(int(r.width()*0.70));
|
|
|
+ r.setHeight(int(r.height()*0.70));
|
|
|
+ painter->setBrush(Qt::black);
|
|
|
+ painter->drawEllipse(r);
|
|
|
+ }
|
|
|
+ } else if (option->state & QStyle::State_On)
|
|
|
radiobutton_checked->render(painter, r);
|
|
|
else
|
|
|
radiobutton->render(painter, r);
|