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/Makefile.am | 2 + client/control.cc | 29 ++++++---- client/control.h | 5 ++ client/decoder.cc | 2 +- client/icons.cc | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ client/icons.h | 48 +++++++++++++++++ client/mainwindow.cc | 140 ++++++++++++++++++++++-------------------------- client/mainwindow.h | 30 ++++------- client/yuv_draw.cc | 29 +++------- pixmaps/freeze.svg | 28 +++++----- pixmaps/record.svg | 26 ++++----- pixmaps/snapshot.svg | 22 ++++---- pixmaps/stop.svg | 122 ++++++++++++++++++++++-------------------- pixmaps/unfreeze.svg | 22 ++++---- 14 files changed, 412 insertions(+), 240 deletions(-) create mode 100644 client/icons.cc create mode 100644 client/icons.h diff --git a/client/Makefile.am b/client/Makefile.am index b7d3a74..4a49d35 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -15,6 +15,7 @@ miav_client_SOURCES = $(shell ../tools/MocList cc ) \ decoder.cc \ dv1394.cc \ dvfile.cc \ + icons.cc \ networksender.cc \ historyframe.cc \ historywidget.cc \ @@ -37,6 +38,7 @@ EXTRA_DIST = \ decoder.h \ dv1394.h \ dvfile.h \ + icons.h \ networksender.h \ historyframe.h \ historywidget.h \ diff --git a/client/control.cc b/client/control.cc index 6dd4b4b..b6495d2 100644 --- a/client/control.cc +++ b/client/control.cc @@ -31,6 +31,7 @@ Control::Control() // Initialize control state frozen = false; recording = false; + muted = false; cpr = ""; } @@ -86,14 +87,21 @@ void Control::stop() recording = false; mutex.unlock(); } -/* -void Control::takeScreenshot() + +void Control::mute() { mutex.lock(); - screenshot = true; + muted = true; mutex.unlock(); } -*/ + +void Control::unmute() +{ + mutex.lock(); + muted = false; + mutex.unlock(); +} + bool Control::isFrozen() { bool isfrozen; @@ -111,17 +119,16 @@ bool Control::isRecording() mutex.unlock(); return isrecording; } -/* -bool Control::isScreenshot() + +bool Control::isMuted() { - bool isscreenshot; + bool ismuted; mutex.lock(); - isscreenshot = screenshot; - screenshot = false; + ismuted = muted; mutex.unlock(); - return isscreenshot; + return ismuted; } -*/ + // Global control object Control MIaV::control; diff --git a/client/control.h b/client/control.h index 1563f3d..f6b4599 100644 --- a/client/control.h +++ b/client/control.h @@ -48,8 +48,12 @@ public: void record(); void stop(); + void mute(); + void unmute(); + bool isFrozen(); bool isRecording(); + bool isMuted(); // bool isScreenshot(); // void takeScreenshot(); @@ -57,6 +61,7 @@ public: private: bool frozen; bool recording; + bool muted; // bool screenshot; QMutex mutex; diff --git a/client/decoder.cc b/client/decoder.cc index 1a85db7..5421e16 100644 --- a/client/decoder.cc +++ b/client/decoder.cc @@ -28,7 +28,7 @@ #include "info.h" -//#define READ_DV_FROM_FILE +#define READ_DV_FROM_FILE #include "dv.h" #ifdef READ_DV_FROM_FILE 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; diff --git a/client/icons.h b/client/icons.h new file mode 100644 index 0000000..33bc5ef --- /dev/null +++ b/client/icons.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * icons.h + * + * 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. + */ +#ifndef __MIAV_ICONS_H__ +#define __MIAV_ICONS_H__ + +#include + +namespace Icons { + bool loadIcons(); + bool unloadIcons(); + + // Pixmaps + extern QPixmap *cpr; + extern QPixmap *record; + extern QPixmap *stop; + extern QPixmap *snapshot; + extern QPixmap *freeze; + extern QPixmap *unfreeze; + extern QPixmap *mute; + extern QPixmap *unmute; + extern QPixmap *clear; +}; + +#endif/*__MIAV_ICONS_H__*/ diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 645fef4..3680afc 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -34,69 +34,23 @@ #include "historywidget.h" -#include -#include +#include #include "control.h" -#include -#include -#include "svgloader.h" +#include "icons.h" -//#define CAIRO_SVG - -QPixmap MainWindow::loadIcon(char* fname) +QPushButton *MainWindow::createButton(QPixmap *pixmap) { - QSvgRenderer svgrenderer; - QPainter painter; - - int dpix = x11Info().appDpiX(); - int dpiy = x11Info().appDpiY(); - - printf("DpiX: %d DpiY: %d\n", dpix, dpiy); - -#ifdef CAIRO_SVG - QPixmap pixmap; - SVGLoader svg; - QString filename = fname; - filename.append(".svg"); - double dpi = (double)(dpix + dpiy) / 2.0; - pixmap = QPixmap::fromImage(svg.load(filename, 0, 0, 12.0 / dpi, 12.0 / dpi)); - return pixmap; -#else/*CAIRO_SVG*/ -#ifdef QT_SVG - QPixmap pixmap(w, h); - painter.begin(&pixmap); - QString filename = fname; - svgrenderer.load(filename . ".svg"); - svgrenderer.render(&painter); - painter.end(); - return pixmap; -#else/*QT_SVG*/ - // Load as png - QString filename = fname; - filename.append(".png"); - QPixmap pixmap(filename); - Qt::AspectRatioMode aspect = pixmap.width()setIconSize(QSize(p.width(), p.height())); - btn->setIcon(p); + btn->setIconSize(QSize(pixmap->width(), pixmap->height())); + btn->setIcon(*pixmap); return btn; } -#include -MainWindow::MainWindow(Decoder *d): QWidget() +MainWindow::MainWindow(Decoder *d) { decoder = d; MIaV::info->log("Starting MIaV v. %s.", VERSION); @@ -112,48 +66,57 @@ MainWindow::MainWindow(Decoder *d): QWidget() */ // Create layout - QGridLayout *layout = new QGridLayout(this); - setLayout(layout); + QGridLayout *outerlayout = new QGridLayout(this); + outerlayout->setMargin(0); + setLayout(outerlayout); + QGridLayout *layout = new QGridLayout(); + outerlayout->addLayout(layout, 0,0,1,1); + outerlayout->setRowStretch(0, 100); + outerlayout->setRowStretch(1, 1); // Create the videoarea video = new VideoWidget(); layout->addWidget(video, 0,0, 1,4); - // Create the control buttons - QPushButton *button; + // Load the icons + Icons::loadIcons(); - button = createButton(PIXMAP_CPR); - layout->addWidget(button, 1,3, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(cpr_clicked())); + // Create the control buttons + btn_cpr = createButton(Icons::cpr); + layout->addWidget(btn_cpr, 1,3, 1,1); + connect(btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked())); - button = createButton(PIXMAP_RECORD); - layout->addWidget(button, 2,0, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(record_clicked())); + btn_record = createButton(Icons::record); + layout->addWidget(btn_record, 2,0, 1,1); + connect(btn_record, SIGNAL(clicked()), this, SLOT(record_clicked())); - button = createButton(PIXMAP_SNAPSHOT); - layout->addWidget(button, 2,1, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(snapshot_clicked())); + btn_snapshot = createButton(Icons::snapshot); + layout->addWidget(btn_snapshot, 2,1, 1,1); + connect(btn_snapshot, SIGNAL(clicked()), this, SLOT(snapshot_clicked())); - button = createButton(PIXMAP_FREEZE); - layout->addWidget(button, 2,2, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(freeze_clicked())); + btn_freeze = createButton(Icons::freeze); + layout->addWidget(btn_freeze, 2,2, 1,1); + connect(btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked())); - button = createButton(PIXMAP_MUTE); - layout->addWidget(button, 2,3, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(mute_clicked())); + btn_mute = createButton(Icons::mute); + layout->addWidget(btn_mute, 2,3, 1,1); + connect(btn_mute, SIGNAL(clicked()), this, SLOT(mute_clicked())); - button = createButton(PIXMAP_CLEAR); - layout->addWidget(button, 2,4, 1,1); - connect(button, SIGNAL(clicked()), this, SLOT(clear_clicked())); + btn_clear = createButton(Icons::clear); + layout->addWidget(btn_clear, 2,4, 1,1); + connect(btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked())); // Create history bar history = new HistoryFrame(); layout->addWidget(history, 0,4, 2,1); // Create statusbar - + QStatusBar *statusbar = new QStatusBar(this); + outerlayout->addWidget(statusbar, 1,0, 1,1); + statusbar->showMessage("Ready!"); + show(); - // setWindowState(Qt::WindowFullScreen); + // setWindowState(Qt::WindowFullScreen); resize(800, 600); MIaV::info->log("MIaV is ready."); @@ -163,6 +126,8 @@ MainWindow::~MainWindow() { MIaV::info->log("MIaV is shutting down."); + Icons::unloadIcons(); + MIaV::info->log("MIaV is shut down."); } @@ -183,10 +148,22 @@ void MainWindow::cpr_clicked() void MainWindow::record_clicked() { + if(MIaV::control.isRecording()) { + MIaV::control.stop(); + btn_record->setIcon(*Icons::record); + } else { + MIaV::control.record(); + btn_record->setIcon(*Icons::stop); + } + } void MainWindow::snapshot_clicked() { + if(MIaV::control.isFrozen()) { + btn_freeze->setIcon(*Icons::freeze); + } + MIaV::control.shoot(); QImage screenshot(720, 576, QImage::Format_RGB32); @@ -202,12 +179,21 @@ void MainWindow::freeze_clicked() { if(MIaV::control.isFrozen()) { MIaV::control.unfreeze(); + btn_freeze->setIcon(*Icons::freeze); } else { MIaV::control.freeze(); + btn_freeze->setIcon(*Icons::unfreeze); } } void MainWindow::mute_clicked() { + if(MIaV::control.isMuted()) { + MIaV::control.unmute(); + btn_mute->setIcon(*Icons::mute); + } else { + MIaV::control.mute(); + btn_mute->setIcon(*Icons::unmute); + } } diff --git a/client/mainwindow.h b/client/mainwindow.h index 762b7f3..742351d 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -35,25 +35,6 @@ #include "decoder.h" -/** - * Images - */ -#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" - class MainWindow : public QWidget { Q_OBJECT @@ -78,8 +59,15 @@ private: HistoryFrame *history; VideoWidget *video; - QPushButton *createButton(char* icon); - QPixmap loadIcon(char* fname); + QPushButton *createButton(QPixmap *pixmap); + + // Buttons + QPushButton *btn_cpr; + QPushButton *btn_record; + QPushButton *btn_snapshot; + QPushButton *btn_freeze; + QPushButton *btn_mute; + QPushButton *btn_clear; }; #endif/*__MIAV_MAINWINDOW_H__*/ diff --git a/client/yuv_draw.cc b/client/yuv_draw.cc index 7cc2f4c..a4ffc60 100644 --- a/client/yuv_draw.cc +++ b/client/yuv_draw.cc @@ -27,29 +27,9 @@ #include "yuv_draw.h" #include - +#include "icons.h" #define TEXT_MARGIN 10 -#include "mainwindow.h" -static QImage *loadIcon( char *name, int height ) -{ - QImage scaled; - QImage *img; - - img = new QImage(); - img->load( name ); - - int h = height; - int w = (int)((float)img->width() / (float)(img->height() / (float)h)); - - scaled = img->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation); - delete img; - img = new QImage(scaled); - - return img; -} - - YUVDraw::YUVDraw() { overlay = NULL; @@ -70,12 +50,15 @@ YUVDraw::YUVDraw() } } - img_muted = loadIcon(PIXMAP_MUTE, ICON_HEIGHT); - img_unmuted = loadIcon(PIXMAP_UNMUTE, ICON_HEIGHT); + img_muted = new QImage(Icons::mute->toImage()); + img_unmuted = new QImage(Icons::unmute->toImage()); } YUVDraw::~YUVDraw() { + delete img_muted; + delete img_unmuted; + delete top_pixmap; delete bottom_pixmap; } diff --git a/pixmaps/freeze.svg b/pixmaps/freeze.svg index 9c5a854..79990c1 100644 --- a/pixmaps/freeze.svg +++ b/pixmaps/freeze.svg @@ -11,7 +11,7 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:version="0.43" sodipodi:docname="freeze.svg" - sodipodi:docbase="/home/deva/docs/c/miav/pixmaps" + sodipodi:docbase="/home/deva/docs/miav/pixmaps" xml:space="preserve" height="400pt" width="400pt" @@ -437,7 +437,7 @@ cx="241.86195" id="radialGradient617" xlink:href="#linearGradient3280" - gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-149.6426)" + gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-119.6426)" gradientUnits="userSpaceOnUse" /> @@ -780,7 +780,7 @@ x2="369.22589" y1="348.19913" x1="114.63815" - gradientTransform="matrix(1.264328,0,0,0.790934,-51.04607,-149.6426)" + gradientTransform="matrix(1.264328,0,0,0.790934,-51.04607,-119.6426)" id="linearGradient2518" xlink:href="#linearGradient2512" inkscape:collect="always" /> @@ -860,7 +860,7 @@ \ No newline at end of file diff --git a/pixmaps/record.svg b/pixmaps/record.svg index 0498f99..7cb26bc 100644 --- a/pixmaps/record.svg +++ b/pixmaps/record.svg @@ -14,7 +14,7 @@ width="400pt" height="400pt" xml:space="preserve" - sodipodi:docbase="/home/deva/docs/c/miav/pixmaps" + sodipodi:docbase="/home/deva/docs/miav/pixmaps" sodipodi:docname="record.svg" inkscape:version="0.43" version="1.0"> \ No newline at end of file + transform="matrix(1.0597,0,0,1.058628,-149.4829,-249.8624)" /> \ No newline at end of file diff --git a/pixmaps/snapshot.svg b/pixmaps/snapshot.svg index 2b751d6..6773caa 100644 --- a/pixmaps/snapshot.svg +++ b/pixmaps/snapshot.svg @@ -17,7 +17,7 @@ width="400pt" height="400pt" xml:space="preserve" - sodipodi:docbase="/home/deva/docs/c/miav/pixmaps" + sodipodi:docbase="/home/deva/docs/miav/pixmaps" sodipodi:docname="snapshot.svg" inkscape:version="0.43" version="1.0"> @@ -254,7 +254,7 @@ r="255.9723" fx="245.05766" fy="492.77755" - gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-141.6747)" + gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-126.6747)" gradientUnits="userSpaceOnUse" /> @@ -430,7 +430,7 @@ width="447.5" height="297.5" x="26.8125" - y="105.6875" + y="120.6875" ry="20" rx="20" /> @@ -440,13 +440,13 @@ width="397.50003" height="247.5" x="51.812508" - y="130.68747" + y="145.68747" ry="16.638657" rx="16.638657" /> + transform="translate(-231.0247,-321.4489)"> + transform="matrix(1.436363,0,0,1.436363,-93.42323,-312.5481)"> + transform="matrix(1.3045,0,0,1.304498,-127.1808,-218.2587)"> + transform="matrix(1.200678,0,0,1.200677,-103.3567,173.5649)"> image/svg+xml \ No newline at end of file + width="256.42938" + height="257.55328" + x="122.11414" + y="124.14508" /> \ No newline at end of file diff --git a/pixmaps/unfreeze.svg b/pixmaps/unfreeze.svg index 37d02d9..9aa71e5 100644 --- a/pixmaps/unfreeze.svg +++ b/pixmaps/unfreeze.svg @@ -11,7 +11,7 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:version="0.43" sodipodi:docname="unfreeze.svg" - sodipodi:docbase="/home/deva/docs/c/miav/pixmaps" + sodipodi:docbase="/home/deva/docs/miav/pixmaps" xml:space="preserve" height="400pt" width="400pt" @@ -454,7 +454,7 @@ cx="240.79671" id="radialGradient617" xlink:href="#linearGradient618" - gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-143.5183)" + gradientTransform="matrix(1.223982,0,0,0.817005,-50.6875,-113.5183)" gradientUnits="userSpaceOnUse" /> @@ -638,7 +638,7 @@ x2="391.20468" y1="342.38516" x1="87.164658" - gradientTransform="matrix(1.264328,0,0,0.790934,-50.6875,-143.5183)" + gradientTransform="matrix(1.264328,0,0,0.790934,-50.6875,-113.5183)" id="linearGradient3948" xlink:href="#linearGradient3950" inkscape:collect="always" /> @@ -649,7 +649,7 @@ -- cgit v1.2.3