summaryrefslogtreecommitdiff
path: root/client/mainwindow.cc
diff options
context:
space:
mode:
authordeva <deva>2006-05-01 11:28:35 +0000
committerdeva <deva>2006-05-01 11:28:35 +0000
commit2bee772bed19a55f666d7106c02735f14c0084e4 (patch)
tree1b424406c33c43b0e4396eb4bb6fead19617b5ad /client/mainwindow.cc
parent7694d644af9f6058d31db5dc75ef6aa860276d25 (diff)
*** empty log message ***
Diffstat (limited to 'client/mainwindow.cc')
-rw-r--r--client/mainwindow.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index d2c9248..982388b 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -41,8 +41,9 @@
#include <QSvgRenderer>
#include <QPainter>
+#include "svgloader.h"
-#define SVG false
+#define CAIRO_SVG
QPixmap MainWindow::loadIcon(char* fname)
{
@@ -52,31 +53,40 @@ QPixmap MainWindow::loadIcon(char* fname)
int w = (int)((double)x11Info().appDpiX() / 1.5);
int h = (int)((double)x11Info().appDpiY() / 1.5);
- if(SVG) {
+#ifdef CAIRO_SVG
+ QPixmap pixmap;
+ SVGLoader cairo;
+ QString filename = fname;
+ filename.append(".svg");
+ w = h;
+ pixmap = QPixmap::fromImage(cairo.load(filename, 0, 0, 0.1, 0.1));
+ return pixmap;
+#else/*CAIRO_SVG*/
+#ifdef QT_SVG
QPixmap pixmap(w, h);
painter.begin(&pixmap);
QString filename = fname;
- svgrenderer.load(filename);
+ svgrenderer.load(filename . ".svg");
svgrenderer.render(&painter);
painter.end();
return pixmap;
- } else {
- QPixmap pixmap(fname);
+#else/*QT_SVG*/
+ // Load as png
+ QPixmap pixmap(fname".png");
Qt::AspectRatioMode aspect = pixmap.width()<pixmap.height()?
Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding;
pixmap = pixmap.scaled(w,h, aspect, Qt::SmoothTransformation);
return pixmap;
- }
+#endif/*QT_SVG*/
+#endif/*CAIRO_SVG*/
}
QPushButton *MainWindow::createButton(char* icon)
{
- int w = (int)((double)x11Info().appDpiX() / 1.5);
- int h = (int)((double)x11Info().appDpiY() / 1.5);
-
+ QPixmap p = loadIcon(icon);
QPushButton *btn = new QPushButton();
- btn->setIconSize(QSize(w,h));
- btn->setIcon(loadIcon(icon));
+ btn->setIconSize(QSize(p.width(), p.height()));
+ btn->setIcon(p);
return btn;
}