summaryrefslogtreecommitdiff
path: root/client/mainwindow.cc
diff options
context:
space:
mode:
authordeva <deva>2006-05-04 14:19:37 +0000
committerdeva <deva>2006-05-04 14:19:37 +0000
commit60c43b0a065175a49ae0aa2b10280e893479889b (patch)
treeed007e88dbc34d03b016f19a164bc0126af6f76a /client/mainwindow.cc
parentd5da69b6ed984df4c60c3a7abfa8119db34eab2b (diff)
*** empty log message ***
Diffstat (limited to 'client/mainwindow.cc')
-rw-r--r--client/mainwindow.cc140
1 files changed, 63 insertions, 77 deletions
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);
+ }
}