From 60c43b0a065175a49ae0aa2b10280e893479889b Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 4 May 2006 14:19:37 +0000 Subject: *** empty log message *** --- client/icons.cc | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 client/icons.cc (limited to 'client/icons.cc') diff --git a/client/icons.cc b/client/icons.cc new file mode 100644 index 0000000..8d6f804 --- /dev/null +++ b/client/icons.cc @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * icons.cc + * + * Thu May 4 15:47:51 CEST 2006 + * Copyright 2006 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "icons.h" + +/** + * The image files + */ +#define PIXMAP_MUTE PIXMAPS"/mute" +#define PIXMAP_UNMUTE PIXMAPS"/unmute" + +#define PIXMAP_RECORD PIXMAPS"/record" +#define PIXMAP_STOP PIXMAPS"/stop" + +#define PIXMAP_FREEZE PIXMAPS"/freeze" +#define PIXMAP_UNFREEZE PIXMAPS"/unfreeze" + +#define PIXMAP_CPR PIXMAPS"/cpr" +#define PIXMAP_CLEAR PIXMAPS"/clear" + +#define PIXMAP_SNAPSHOT PIXMAPS"/snapshot" +#define PIXMAP_DUMMY PIXMAPS"/dummy" +#define PIXMAP_LOGO_SMALL PIXMAPS"/miav-logo" + +//#define QT_SVG +#define CAIRO_SVG + +#ifdef QT_SVG +#include +#include +#endif /*QT_SVG*/ + +#ifdef CAIRO_SVG +#include "svgloader.h" +#endif /*CAIRO_SVG*/ + +#include +#include +#include + +QPixmap *loadIcon(char* fname) +{ + QPixmap *pixmap; + + int dpix = qApp->desktop()->x11Info().appDpiX(); + int dpiy = qApp->desktop()->x11Info().appDpiY(); + + printf("DpiX: %d DpiY: %d\n", dpix, dpiy); + +#ifdef CAIRO_SVG + SVGLoader svg; + QString filename = fname; + filename.append(".svg"); + double dpi = (double)(dpix + dpiy) / 2.0; + pixmap = new QPixmap(QPixmap::fromImage(svg.load(filename, 0, 0, 14.0 / dpi, 14.0 / dpi))); +#endif/*CAIRO_SVG*/ + +#ifdef QT_SVG + QSvgRenderer svgrenderer; + QPainter painter; + + pixmap = new QPixmap(w, h); + painter.begin(pixmap); + QString filename = fname; + svgrenderer.load(filename . ".svg"); + svgrenderer.render(&painter); + painter.end(); +#endif/*QT_SVG*/ + +#ifndef QT_SVG +#ifndef CAIRO_SVG + // Load as png + QString filename = fname; + filename.append(".png"); + pixmap = new QPixmap(filename); + Qt::AspectRatioMode aspect = pixmap.width()scaled((int)(dpi / 1.5),(int)(dpi / 1.5), aspect, Qt::SmoothTransformation); +#endif/*CAIRO_SVG*/ +#endif/*QT_SVG*/ + + return pixmap; +} + + +bool Icons::loadIcons() +{ + cpr = loadIcon(PIXMAP_CPR); + record = loadIcon(PIXMAP_RECORD); + stop = loadIcon(PIXMAP_STOP); + snapshot = loadIcon(PIXMAP_SNAPSHOT); + freeze = loadIcon(PIXMAP_FREEZE); + unfreeze = loadIcon(PIXMAP_UNFREEZE); + mute = loadIcon(PIXMAP_MUTE); + unmute = loadIcon(PIXMAP_UNMUTE); + clear = loadIcon(PIXMAP_CLEAR); + return true; +} + +bool Icons::unloadIcons() +{ + delete cpr; + delete record; + delete stop; + delete snapshot; + delete freeze; + delete unfreeze; + delete mute; + delete unmute; + delete clear; + return true; +} + +// The pixmaps +QPixmap *Icons::cpr; +QPixmap *Icons::record; +QPixmap *Icons::stop; +QPixmap *Icons::snapshot; +QPixmap *Icons::freeze; +QPixmap *Icons::unfreeze; +QPixmap *Icons::mute; +QPixmap *Icons::unmute; +QPixmap *Icons::clear; -- cgit v1.2.3