summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/Makefile.am2
-rw-r--r--client/control.cc29
-rw-r--r--client/control.h5
-rw-r--r--client/decoder.cc2
-rw-r--r--client/icons.cc147
-rw-r--r--client/icons.h48
-rw-r--r--client/mainwindow.cc140
-rw-r--r--client/mainwindow.h30
-rw-r--r--client/yuv_draw.cc29
9 files changed, 299 insertions, 133 deletions
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 <QSvgRenderer>
+#include <QPainter>
+#endif /*QT_SVG*/
+
+#ifdef CAIRO_SVG
+#include "svgloader.h"
+#endif /*CAIRO_SVG*/
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QX11Info>
+
+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()<pixmap.height()?
+ Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding;
+ double dpi = (double)(dpix + dpiy) / 2.0;
+ *pixmap = pixmap->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 <QPixmap>
+
+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 <QX11Info>
-#include <QMoveEvent>
+#include <QStatusBar>
#include "control.h"
-#include <QSvgRenderer>
-#include <QPainter>
-#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()<pixmap.height()?
- Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding;
- pixmap = pixmap.scaled((int)((double)dpix / 1.5),(int)((double)dpix / 1.5), aspect, Qt::SmoothTransformation);
- return pixmap;
-#endif/*QT_SVG*/
-#endif/*CAIRO_SVG*/
-}
-
-QPushButton *MainWindow::createButton(char* icon)
-{
- QPixmap p = loadIcon(icon);
+ // QPixmap p = loadIcon(icon);
QPushButton *btn = new QPushButton();
- btn->setIconSize(QSize(p.width(), p.height()));
- btn->setIcon(p);
+ btn->setIconSize(QSize(pixmap->width(), pixmap->height()));
+ btn->setIcon(*pixmap);
return btn;
}
-#include <QApplication>
-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 <string.h>
-
+#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;
}