Browse Source

Improve checkbox look and feel

Antialize 14 years ago
parent
commit
683e7f1e0e
3 changed files with 67 additions and 23 deletions
  1. 63 19
      src/lib/utilities.cc
  2. 0 4
      static_qt_conf_base
  3. 4 0
      static_qt_conf_linux

+ 63 - 19
src/lib/utilities.cc

@@ -25,23 +25,73 @@
 #endif
 
 #include "utilities.hh"
+#include <QTextStream>
 
-void loadSvg(QSvgRenderer * & ptr, const QString & path) {
-	delete ptr;
-	if (path != "") {
-		ptr = new QSvgRenderer(path);
-		if (ptr->isValid()) return;
-		delete ptr;
-	}
-	ptr = 0;
+void loadSvg(QSvgRenderer * & ptr, const QString & path, const char * def, int w, int h) {
+	 delete ptr;
+	 if (path != "") {
+	 	ptr = new QSvgRenderer(path);
+	 } else {
+		 QByteArray a;
+		 QTextStream s(&a, QIODevice::WriteOnly );
+		 s << "<?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\"\n"
+		   << "  baseProfile=\"full\"\n"
+		   << "  width=\"" << w << "px\"\n"
+		   << "  height=\"" << h << "px\"\n"
+		   << "  viewBox=\"0 0 " << w << "px " << h << "px\">\n"
+		   << def
+		   << "</svg>\n";
+		 s.flush();
+		 ptr = new QSvgRenderer(a);
+	 }
+	 if (ptr->isValid()) return;
+	 delete ptr;
+	 ptr = 0;
 }
 
-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);}
+#define RB \
+"<path d=\"M0,0 h-1 a1,1 0 0,0 2,0 z\" fill=\"#808080\" stroke=\"\" stroke-width=\"0\" transform=\"translate(5.5,5.5)rotate(-225)scale(5.5,5.5)\"/>\n" \
+"<path d=\"M0,0 h-1 a1,1 0 0,0 2,0 z\" fill=\"#ffffff\" stroke=\"\" stroke-width=\"0\" transform=\"translate(5.5,5.5)rotate(-45)scale(5.5,5.5)\"/>\n" \
+"<path d=\"M0,0 h-1 a1,1 0 0,0 2,0 z\" fill=\"#404040\" stroke=\"\" stroke-width=\"0\" transform=\"translate(5.5,5.5)rotate(-225)scale(4.5,4.5)\"/>\n" \
+ "<path d=\"M0,0 h-1 a1,1 0 0,0 2,0 z\" fill=\"#d4d0c8\" stroke=\"\" stroke-width=\"0\" transform=\"translate(5.5,5.5)rotate(-45)scale(4.5,4.5)\"/>\n" \
+"<circle id=\"c1\" cx=\"5.5\" cy=\"5.5\" r=\"3.5\" fill=\"white\" stroke=\"\" stroke-width=\"0\"/>\n"
 
-MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false) {}
+#define CB \
+"<rect x=\"0\" y=\"0\" width=\"1\" height=\"12\" fill=\"#808080\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"1\" y=\"0\" width=\"11\" height=\"1\" fill=\"#808080\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"1\" y=\"11\" width=\"11\" height=\"1\" fill=\"#d4d0c8\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"11\" y=\"1\" width=\"1\" height=\"11\" fill=\"#d4d0c8\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"1\" y=\"1\" width=\"1\" height=\"10\" fill=\"#404040\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"2\" y=\"1\" width=\"9\" height=\"1\" fill=\"#404040\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"2\" y=\"10\" width=\"9\" height=\"1\" fill=\"#ffffff\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"10\" y=\"2\" width=\"1\" height=\"9\" fill=\"#ffffff\" stroke=\"\" stroke-width=\"0\" />\n" \
+"<rect x=\"2\" y=\"2\" width=\"8\" height=\"8\" fill=\"#ffffff\" stroke=\"\" stroke-width=\"0\" />\n"
+
+void MyLooksStyle::setCheckboxSvg(const QString & path) {
+	loadSvg(checkbox, path,
+			CB, 12, 12);
+}
+void MyLooksStyle::setCheckboxCheckedSvg(const QString & path) {
+	loadSvg(checkbox_checked, path,
+			CB
+			"<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",
+			12, 12);
+}
+void MyLooksStyle::setRadioButtonSvg(const QString & path) {
+	loadSvg(radiobutton, path, RB, 11, 11);
+}
+void MyLooksStyle::setRadioButtonCheckedSvg(const QString & path) {
+	loadSvg(radiobutton_checked, path,
+			RB
+			"<circle id=\"c2\" cx=\"5.5\" cy=\"5.5\" r=\"1.5\" fill=\"black\" stroke=\"\" stroke-width=\"0\"/>\n", 11, 11);
+}
+
+MyLooksStyle::MyLooksStyle(): weAreDrawingForms(false) {
+}
 
 void MyLooksStyle::producingForms(bool f) {weAreDrawingForms=f;}
 
@@ -114,9 +164,3 @@ QSvgRenderer * MyLooksStyle::checkbox = 0;
 QSvgRenderer * MyLooksStyle::checkbox_checked = 0;
 QSvgRenderer * MyLooksStyle::radiobutton = 0;
 QSvgRenderer * MyLooksStyle::radiobutton_checked = 0;
-
-// void printSupportedWriteformats() {
-//   QList<QByteArray> formats = QImageWriter::supportedImageFormats();
-//   for ( QList<QByteArray>::Iterator f = formats.begin(); f != formats.end(); ++ f )
-//     printf("%s , ", f->constData() );
-// }

+ 0 - 4
static_qt_conf_base

@@ -34,10 +34,6 @@
 -no-3dnow
 -no-sse
 -no-sse2 
--no-sse3
--no-ssse3
--no-sse4.1
--no-sse4.2
 -qt-zlib
 -qt-gif
 -qt-libtiff

+ 4 - 0
static_qt_conf_linux

@@ -34,3 +34,7 @@
 # -no-opengl
 -no-xsync
 -no-audio-backend
+-no-sse3
+-no-ssse3
+-no-sse4.1
+-no-sse4.2