summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/aboutwindow.cc12
-rw-r--r--client/aboutwindow.h10
-rw-r--r--client/camera.h2
-rw-r--r--client/cprquerydialog.cc86
-rw-r--r--client/cprquerydialog.h45
-rw-r--r--client/encoder.h2
-rw-r--r--client/historywidget.cc8
-rw-r--r--client/historywidget.h4
-rw-r--r--client/info_gui.h13
-rw-r--r--client/mainwindow.cc174
-rw-r--r--client/mainwindow.h16
-rw-r--r--client/messagebox.cc18
-rw-r--r--client/messagebox.h14
-rw-r--r--client/miav_client.cc4
-rw-r--r--client/miav_client.h2
-rw-r--r--client/player.h2
-rw-r--r--client/videowidget.cc6
-rw-r--r--client/videowidget.h4
-rw-r--r--client/yuv_draw.cc8
-rw-r--r--client/yuv_draw.h6
20 files changed, 236 insertions, 200 deletions
diff --git a/client/aboutwindow.cc b/client/aboutwindow.cc
index 8743ed8..849608d 100644
--- a/client/aboutwindow.cc
+++ b/client/aboutwindow.cc
@@ -29,14 +29,14 @@
#include "aboutwindow.h"
-#include <qpainter.h>
-#include <qfont.h>
+#include <QPainter>
+#include <QFont>
#include <config.h>
#define MARGIN 12
-AboutWindow::AboutWindow( QWidget* parent, const char* name )
- : QDialog( parent, name )
+AboutWindow::AboutWindow( QWidget* parent)
+ : QDialog( parent )
{
setModal(true);
pix_about = new QPixmap();
@@ -44,7 +44,7 @@ AboutWindow::AboutWindow( QWidget* parent, const char* name )
resize(pix_about->width(), pix_about->height());
- setBackgroundColor(QColor(200,200,200));
+ // setBackgroundColor(QColor(200,200,200));
btn_ok = new QPushButton(this);
btn_ok->setText("OK");
@@ -79,7 +79,7 @@ void AboutWindow::paintEvent( QPaintEvent *event )
painter.drawPixmap(0,0, *pix_about);
// Draw title and version
- painter.setBrush( SolidPattern );
+ painter.setBrush( Qt::SolidPattern );
painter.setFont( QFont( "Arial", 18, QFont::Bold ) );
painter.setPen( Qt::black );
painter.drawText(version_x, version_y, "MIAV-Grab v" VERSION);
diff --git a/client/aboutwindow.h b/client/aboutwindow.h
index f87a10e..25fb6f0 100644
--- a/client/aboutwindow.h
+++ b/client/aboutwindow.h
@@ -30,11 +30,9 @@
#ifndef __ABOUTWINDOW_H__
#define __ABOUTWINDOW_H__
-#include <qdialog.h>
-//#include <qlabel.h>
-#include <qpixmap.h>
-//#include <qtextedit.h>
-#include <qpushbutton.h>
+#include <QDialog>
+#include <QPixmap>
+#include <QPushButton>
#define PIXMAP_ABOUT PIXMAPS"/about.png"
/*
@@ -68,7 +66,7 @@ class AboutWindow : public QDialog
{
Q_OBJECT
public:
- AboutWindow(QWidget* parent = 0, const char* name = 0);
+ AboutWindow(QWidget* parent = 0);
~AboutWindow();
virtual void paintEvent( QPaintEvent *event );
void mouseReleaseEvent(QMouseEvent *event);
diff --git a/client/camera.h b/client/camera.h
index a0b849a..410b9f5 100644
--- a/client/camera.h
+++ b/client/camera.h
@@ -50,7 +50,7 @@ using namespace std;
#include "thread.h"
#include "frame.h"
-#include <qwidget.h>
+#include <QWidget>
/**
* This class represents the symbolic representation of the camera and
diff --git a/client/cprquerydialog.cc b/client/cprquerydialog.cc
index 19337a4..15e00d1 100644
--- a/client/cprquerydialog.cc
+++ b/client/cprquerydialog.cc
@@ -27,7 +27,7 @@
#include <config.h>
#ifdef USE_GUI
-#include <qframe.h>
+#include <QFrame>
#include "messagebox.h"
#include "cprquerydialog.h"
@@ -39,10 +39,11 @@ CPRQueryDialog::CPRQueryDialog(Info *info,
QWidget *parent,
const char *name,
QStatusBar *status)
- : QDialog(parent, name, TRUE)
+ : QDialog(parent)
{
+ setModal(true);
this->info = info;
- setCaption(name);
+ setWindowTitle(name);
// Load image
QPixmap pix_backspace;
@@ -60,7 +61,7 @@ CPRQueryDialog::CPRQueryDialog(Info *info,
cpr[0] = '\0';
internalCpr[0] = '\0';
- cprSocket = new QSocket(this);
+ cprSocket = new QTcpSocket(this);
connect(cprSocket, SIGNAL(readyRead()), SLOT(cprSocket_readyRead()));
connect(cprSocket, SIGNAL(connected()), SLOT(cprSocket_connected()));
connect(cprSocket, SIGNAL(error(int)), SLOT(cprSocket_error(int)));
@@ -72,21 +73,21 @@ CPRQueryDialog::CPRQueryDialog(Info *info,
connect(timer, SIGNAL(timeout()), SLOT(cprSocket_timeout()));
// Generate input buttons
- QGridLayout *gl = new QGridLayout(this, 4, 3, 10, 2);
-
- QButton *b1 = createButton(this, "1", 1);
- QButton *b2 = createButton(this, "2", 2);
- QButton *b3 = createButton(this, "3", 3);
- QButton *b4 = createButton(this, "4", 4);
- QButton *b5 = createButton(this, "5", 5);
- QButton *b6 = createButton(this, "6", 6);
- QButton *b7 = createButton(this, "7", 7);
- QButton *b8 = createButton(this, "8", 8);
- QButton *b9 = createButton(this, "9", 9);
- QButton *b0 = createButton(this, "0", 0);
- QButton *bbs = createButton(this, "", 10);
- bbs->setPixmap(pix_backspace);
- QButton *bca = createButton(this, "CA", 11);
+ QGridLayout *gl = new QGridLayout(this);//, 4, 3, 10, 2);
+
+ QPushButton *b1 = createButton(this, "1", 1);
+ QPushButton *b2 = createButton(this, "2", 2);
+ QPushButton *b3 = createButton(this, "3", 3);
+ QPushButton *b4 = createButton(this, "4", 4);
+ QPushButton *b5 = createButton(this, "5", 5);
+ QPushButton *b6 = createButton(this, "6", 6);
+ QPushButton *b7 = createButton(this, "7", 7);
+ QPushButton *b8 = createButton(this, "8", 8);
+ QPushButton *b9 = createButton(this, "9", 9);
+ QPushButton *b0 = createButton(this, "0", 0);
+ QPushButton *bbs = createButton(this, "", 10);
+ bbs->setIcon(pix_backspace);
+ QPushButton *bca = createButton(this, "CA", 11);
gl->addWidget(b1, 0,0);
gl->addWidget(b2, 0,1);
@@ -160,7 +161,8 @@ QPushButton *CPRQueryDialog::createButton(QWidget *parent, const char *text, int
{
char buf[32];
sprintf(buf, "%d", value);
- QPushButton *q = new QPushButton(this, buf);
+ QPushButton *q = new QPushButton(this);
+ q->setText(buf);
QFont f("Lucida", 48);
q->setFixedSize(150, 100);
@@ -366,19 +368,19 @@ void CPRQueryDialog::cprSocket_error(int errnum)
// Print error message
switch(errnum) {
- case QSocket::ErrConnectionRefused: // if the connection was refused
+ case QAbstractSocket::ConnectionRefusedError: // if the connection was refused
msg.append("ErrConnectionRefused");
break;
- case QSocket::ErrHostNotFound: // if the host was not found
+ case QAbstractSocket::HostNotFoundError: // if the host was not found
msg.append("ErrHostNotFound");
break;
- case QSocket::ErrSocketRead: // if a read from the socket failed
+ case QAbstractSocket::SocketAccessError: // if a read from the socket failed
msg.append("ErrSocketRead");
break;
}
- if(statusbar) statusbar->message(msg, 5000);
- MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec();
+ if(statusbar) statusbar->showMessage(msg, 5000);
+ MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec();
//info->error(msg.c_str());
accept();
}
@@ -399,7 +401,7 @@ void CPRQueryDialog::cprSocket_readyRead()
if (!cprSocket->canReadLine()) return;
QString msg = QString("Recieving name from cpr database...");
- if(statusbar) statusbar->message(msg, 5000);
+ if(statusbar) statusbar->showMessage(msg, 5000);
timer->stop();
while(cprSocket->canReadLine()) {
@@ -407,13 +409,13 @@ void CPRQueryDialog::cprSocket_readyRead()
if (s.startsWith("0001")) {
name.append(s.right(s.length()-4));
lastname.append(s.right(s.length()-4));
- name.setLength(name.length()-1);
+ name.resize(name.length()-1);
if (name.length()) name += QString(", ");
}
if (s.startsWith("0002")) {
name.append(s.right(s.length()-4));
firstname.append(s.right(s.length()-4));
- name.setLength(name.length()-1);
+ name.resize(name.length()-1);
cprSocket->close();
lbl_name->setText(name);
accept();
@@ -440,11 +442,11 @@ void CPRQueryDialog::cprSocket_readyRead()
void CPRQueryDialog::cprSocket_connected()
{
QString msg = QString("Connected to cpr database, sending cpr number...");
- if(statusbar) statusbar->message(msg, 5000);
+ if(statusbar) statusbar->showMessage(msg, 5000);
timer->stop();
- cprSocket->writeBlock(internalCpr, 10);
- cprSocket->writeBlock("\n", 1);
+ cprSocket->write(internalCpr, 10);
+ cprSocket->write("\n", 1);
}
/**
@@ -461,25 +463,31 @@ void CPRQueryDialog::cprSocket_timeout()
// Print connection status
switch(cprSocket->state()) {
- case QSocket::Idle: // if there is no connection
- msg.append("Idle");
+ case QAbstractSocket::UnconnectedState: // if there is no connection
+ msg.append("Unconnected");
break;
- case QSocket::HostLookup: // during a DNS lookup
+ case QAbstractSocket::HostLookupState: // during a DNS lookup
msg.append("HostLookup");
break;
- case QSocket::Connecting: // during TCP connection establishment
+ case QAbstractSocket::ConnectingState: // during TCP connection establishment
msg.append("Connecting");
break;
- case QSocket::Connected: // when there is an operational connection
+ case QAbstractSocket::ConnectedState: // when there is an operational connection
msg.append("Conected");
break;
- case QSocket::Closing: // if the socket is closing down, but is not yet closed.
+ case QAbstractSocket::ClosingState: // if the socket is closing down, but is not yet closed.
msg.append("Closing");
break;
+ case QAbstractSocket::BoundState: //
+ msg.append("Bound");
+ break;
+ case QAbstractSocket::ListeningState: //
+ msg.append("Listening");
+ break;
}
- if(statusbar) statusbar->message(msg, 5000);
- MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec();
+ if(statusbar) statusbar->showMessage(msg, 5000);
+ MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec();
accept();
}
diff --git a/client/cprquerydialog.h b/client/cprquerydialog.h
index 85b2659..c70206e 100644
--- a/client/cprquerydialog.h
+++ b/client/cprquerydialog.h
@@ -49,40 +49,23 @@
/**
* Includes
*/
-#include <qdialog.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qfont.h>
-
-#include <qwidget.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qdialog.h>
-#include <qlabel.h>
-#include <qpixmap.h>
-
-#include <qsocket.h>
-#include <qtextedit.h>
-#include <qstring.h>
-#include <qwidget.h>
-
-#include <qevent.h>
-
-#include <qpushbutton.h>
-
-#include <qwidget.h>
-#include <qlayout.h>
-#include <qdialog.h>
+#include <QDialog>
+#include <QPushButton>
+#include <QLayout>
+#include <QLabel>
+#include <QFont>
+#include <QWidget>
+#include <QPixmap>
+#include <QTcpSocket>
+#include <QTextEdit>
+#include <QString>
+#include <QEvent>
+#include <QTimer>
+#include <QStatusBar>
#include <string>
using namespace std;
-#include <qdialog.h>
-#include <qlabel.h>
-#include <qsocket.h>
-#include <qtimer.h>
-#include <qstatusbar.h>
#include "messagebox.h"
@@ -125,7 +108,7 @@ private:
QLabel *lbl_cpr;
QLabel *lbl_name;
- QSocket *cprSocket;
+ QTcpSocket *cprSocket;
char cpr[12];
char internalCpr[11];
diff --git a/client/encoder.h b/client/encoder.h
index 0fada07..de29646 100644
--- a/client/encoder.h
+++ b/client/encoder.h
@@ -46,7 +46,7 @@
#include <string.h>
//#include <avformat.h>
-#include "miav.h"
+#include "miav_client.h"
#include "util.h"
#include "package.h"
#include "frame.h"
diff --git a/client/historywidget.cc b/client/historywidget.cc
index bdeb880..55fb178 100644
--- a/client/historywidget.cc
+++ b/client/historywidget.cc
@@ -30,6 +30,8 @@
#include "miav_config.h"
+#include <QPixmap>
+
HistoryWidget::HistoryWidget(QWidget *p) : QLabel(p)
{
parent = p;
@@ -47,8 +49,10 @@ void HistoryWidget::set_image(QImage *i)
image = new QImage(*i);
- QImage resized = image->smoothScale(width(), height());
- setPixmap(resized);
+ QImage resized = image->scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ QPixmap pixmap;
+ pixmap.fromImage(resized);
+ setPixmap(pixmap);
}
QImage * HistoryWidget::get_image()
diff --git a/client/historywidget.h b/client/historywidget.h
index d464d59..b798ddb 100644
--- a/client/historywidget.h
+++ b/client/historywidget.h
@@ -29,8 +29,8 @@
#ifndef __MIAV_HISTORYWIDGET_H__
#define __MIAV_HISTORYWIDGET_H__
-#include <qlabel.h>
-#include <qimage.h>
+#include <QLabel>
+#include <QImage>
class HistoryWidget : public QLabel {
Q_OBJECT
diff --git a/client/info_gui.h b/client/info_gui.h
index a4f5135..a607c0f 100644
--- a/client/info_gui.h
+++ b/client/info_gui.h
@@ -38,8 +38,9 @@
#include "miav_config.h"
-#include <qwidget.h>
-#include <qapplication.h>
+#include <QWidget>
+#include <QApplication>
+#include <QEvent>
#include <pthread.h>
#include <semaphore.h>
@@ -48,11 +49,13 @@
#define TYPE_SHOW_MESSAGEBOX 65432
-class ShowMessageEvent : public QCustomEvent {
+class ShowMessageEvent : public QEvent {
public:
- ShowMessageEvent( MessageBox* msgbox )
- : QCustomEvent( TYPE_SHOW_MESSAGEBOX ), m( msgbox ) {}
+ ShowMessageEvent( MessageBox* msgbox ) :
+ QEvent((QEvent::Type)TYPE_SHOW_MESSAGEBOX),
+ m( msgbox ) {}
MessageBox *messagebox() const { return m; }
+ // Type type() const { return TYPE_SHOW_MESSAGEBOX; }
private:
MessageBox *m;;
};
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index ce3d9bb..0978120 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -29,18 +29,16 @@
#include "mainwindow.h"
-#include <qpainter.h>
-#include <qpicture.h>
-
-#include <qpushbutton.h>
-#include <qfont.h>
-#include <qpixmap.h>
-#include <qbitmap.h>
-#include <qimage.h>
-#include <qlayout.h>
-#include <qgroupbox.h>
-
-#include <qstatusbar.h>
+#include <QPainter>
+#include <QPicture>
+#include <QPushButton>
+#include <QFont>
+#include <QPixmap>
+#include <QBitmap>
+#include <QImage>
+#include <QLayout>
+#include <QGroupBox>
+#include <QStatusBar>
#include <math.h>
@@ -53,8 +51,8 @@
//"miav-grab.h"
//#define WITH_DV
-MainWindow::MainWindow(QApplication *qApp, QWidget* parent, const char* name )
- : QWidget( parent, name, WStyle_Customize | WStyle_NoBorder )
+MainWindow::MainWindow(QWidget* parent )
+ : QWidget( parent, Qt::FramelessWindowHint )
{
info = new InfoGui(qApp, this, config);
@@ -140,7 +138,7 @@ QImage *MainWindow::loadButtonIcon( char *name, int height )
int h = (int)(height * unit);
int w = (int)((float)img->width() / (float)(img->height() / (float)h));
- scaled = img->smoothScale(w, h);
+ scaled = img->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
delete img;
img = new QImage(scaled);
@@ -182,29 +180,27 @@ void MainWindow::createGui()
* |_______________________________|__________________|
*/
- QGridLayout *g0 = new QGridLayout(this, 2, 2, 0, -1);
- QGridLayout *g1 = new QGridLayout(4, 4, -1);
+ QPixmap pixmap;
+
+ QGridLayout *g0 = new QGridLayout(this);
+ QGridLayout *g1 = new QGridLayout();
g0->addLayout(g1, 0, 0);
QGroupBox *gb = new QGroupBox(this);
- // gb->setRows(NUM_HISTORY);
+ /*
gb->setColumns(1);
- // gb->setTitle("fisk");
- // QGridLayout *g2 = new QGridLayout(1, NUM_HISTORY, -1);
- // QVBoxLayout *g2 = new QVBoxLayout(this);
- // g0->addLayout(g2, 0, 1);
-
gb->setInsideMargin(HISTORY_LIST_MARGIN);
gb->setInsideSpacing(HISTORY_LIST_SPACING);
gb->setFlat(true);
g0->addWidget(gb, 0, 1);
+ */
int resolution_w = config->readInt("pixel_width");
int resolution_h = config->readInt("pixel_height");
int output_width = resolution_w - // this->width() -
(int)(BUTTON_WIDTH * unit) -
- (gb->insideMargin() * 2) -
+ /* (gb->insideMargin() * 2) - */
g1->margin() * 2 -
g0->margin() * 2;
@@ -214,28 +210,30 @@ void MainWindow::createGui()
g0->margin() * 3;
img_recedge = new QLabel(this);
- img_recedge->setBackgroundColor(QColor(160,160,160));
+ QPalette palette;
+ palette.setColor(img_recedge->backgroundRole(), QColor(160,160,160));
+ img_recedge->setPalette(palette);
img_recedge->setFixedSize(output_width, output_height);
img_live = new VideoWidget(img_recedge, camera);
img_live->setFixedSize(output_width - 20, output_height - 20);
img_live->move(10,10);
- g1->addMultiCellWidget ( img_recedge, 0, 0, 0, 3, Qt::AlignHCenter);
- // QObject::connect( img_live, SIGNAL(clicked()), this, SLOT(live_clicked()) );
+ g1->addWidget( img_recedge, 0, 0, 0, 3, Qt::AlignHCenter);
// CPR/NAME LABEL + CPR button
lbl_cpr = createLabel("", output_width - (int)(BUTTON_WIDTH * unit), BUTTON_HEIGHT);
- g1->addMultiCellWidget ( lbl_cpr, 1, 1, 0, 2);
+ g1->addWidget( lbl_cpr, 1, 1, 0, 2);
btn_cpr = createButton("");
btn_cpr->setFocus();
- btn_cpr->setPixmap(*img_cpr);
+ pixmap.fromImage(*img_cpr);
+ btn_cpr->setIcon(pixmap);
QObject::connect( btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked()) );
// Will also be connected in the MGUI code
g1->addWidget(btn_cpr, 1, 3);
lbl_name = createLabel("", output_width, (int)(BUTTON_HEIGHT * 0.8f));
- g1->addMultiCellWidget ( lbl_name, 2, 2, 0, 3);
+ g1->addWidget( lbl_name, 2, 2, 0, 3);
/*
btn_clear = createButton("");
btn_clear->setPixmap(*img_clear);
@@ -245,22 +243,26 @@ void MainWindow::createGui()
*/
// Rec + Shot + Freeze buttons
btn_rec = createButton("");
- btn_rec->setPixmap(*img_record);
+ pixmap.fromImage(*img_record);
+ btn_rec->setIcon(pixmap);
QObject::connect( btn_rec, SIGNAL(clicked()), this, SLOT(rec_clicked()) );
g1->addWidget(btn_rec, 3, 0);
btn_shoot = createButton("");
- btn_shoot->setPixmap(*img_snapshot);
+ pixmap.fromImage(*img_snapshot);
+ btn_shoot->setIcon(pixmap);
QObject::connect( btn_shoot, SIGNAL(clicked()), this, SLOT(shoot_clicked()) );
g1->addWidget(btn_shoot, 3, 1);
btn_freeze = createButton("");
- btn_freeze->setPixmap(*img_freeze);
+ pixmap.fromImage(*img_freeze);
+ btn_freeze->setIcon(pixmap);
QObject::connect( btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked()) );
g1->addWidget(btn_freeze, 3, 2);
btn_mute = createButton("");
- btn_mute->setPixmap(*img_unmute);
+ pixmap.fromImage(*img_unmute);
+ btn_mute->setIcon(pixmap);
QObject::connect( btn_mute, SIGNAL(clicked()), this, SLOT(mute_clicked()) );
g1->addWidget(btn_mute, 3, 3);
@@ -282,38 +284,40 @@ void MainWindow::createGui()
// Clear button
btn_clear = createButton("", gb);
- btn_clear->setPixmap(*img_clear);
+ pixmap.fromImage(*img_clear);
+ btn_clear->setIcon(pixmap);
QObject::connect( btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked()) );
// Statusbar
status = new QStatusBar(this);
status->setSizeGripEnabled(FALSE);
// status->setFont(QFont( "Sans Serif", (int)(unit * height / 3), QFont::Normal ));
- g0->addMultiCellWidget(status, 4, 4, 0, 1);
+ g0->addWidget(status, 4, 4, 0, 1);
lbl_recordtime = createLabel("", BUTTON_WIDTH, 1);
lbl_recordtime->setFixedWidth((int)(BUTTON_WIDTH * unit) +
- (gb->insideMargin() * 2) +
+ /* (gb->insideMargin() * 2) + */
g1->margin() * 2 +
g0->margin() * 2);
- status->addWidget(lbl_recordtime, 0, TRUE);
+ status->addWidget(lbl_recordtime, 0);
// About button
btn_about = new QPushButton("", this);
btn_about->setFixedHeight((int)unit);
- btn_about->setPixmap(*img_logo);
+ pixmap.fromImage(*img_logo);
+ btn_about->setIcon(pixmap);
QObject::connect( btn_about, SIGNAL(clicked()), this, SLOT(about_clicked()) );
- status->addWidget(btn_about, 0, TRUE);
+ status->addWidget(btn_about, 0);
// Version label
lbl_version = createLabel("MIaV-Grab v" VERSION, BUTTON_WIDTH, 1);
lbl_version->setFixedWidth((int)(BUTTON_WIDTH * unit) +
- (gb->insideMargin() * 2) +
+ /* (gb->insideMargin() * 2) + */
g1->margin() * 2 +
g0->margin() * 2);
- status->addWidget(lbl_version, 0, TRUE);
+ status->addWidget(lbl_version, 0);
- status->message( TXT_READY );
+ status->showMessage( TXT_READY );
}
@@ -387,14 +391,17 @@ void MainWindow::redraw_edge()
{
rec_edge_counter += SPEED;
float val = fabs(sin(rec_edge_counter));
- img_recedge->setBackgroundColor(QColor((int) ((255 - GREY) * val + GREY),
- (int) (GREY - (GREY * val)),
- (int) (GREY - (GREY * val))));
+
+ QPalette palette;
+ palette.setColor(img_recedge->backgroundRole(), QColor((int) ((255 - GREY) * val + GREY),
+ (int) (GREY - (GREY * val)),
+ (int) (GREY - (GREY * val))));
+ img_recedge->setPalette(palette);
}
void MainWindow::message(char *msg)
{
- status->message(msg);
+ status->showMessage(msg);
info->log("Message: %s", msg);
}
@@ -447,8 +454,8 @@ void MainWindow::cpr_clicked()
info->log("Activated CPR chooser.");
// Save CPR and name, from the labels.
- strcpy(oldname, lbl_name->text().ascii());
- strcpy(oldcpr, lbl_cpr->text().ascii());
+ strcpy(oldname, lbl_name->text().toStdString().c_str());
+ strcpy(oldcpr, lbl_cpr->text().toStdString().c_str());
clear();
@@ -462,25 +469,29 @@ void MainWindow::cpr_clicked()
info->log("Cancelled CPR chooser.");
} else {
// Change CPR camera.
- info->log("New CPR %s (old %s).", (char*)lbl_cpr->text().ascii(), oldcpr);
- strcpy(oldname, lbl_name->text().ascii());
- strcpy(oldcpr, lbl_cpr->text().ascii());
+ info->log("New CPR %s (old %s).", (char*)lbl_cpr->text().toStdString().c_str(), oldcpr);
+ strcpy(oldname, lbl_name->text().toStdString().c_str());
+ strcpy(oldcpr, lbl_cpr->text().toStdString().c_str());
clear();
lbl_name->setText(oldname);
lbl_cpr->setText(oldcpr);
- camera->setCpr((char*)lbl_cpr->text().ascii(), (char*)lbl_name->text().ascii());
+ camera->setCpr((char*)lbl_cpr->text().toStdString().c_str(), (char*)lbl_name->text().toStdString().c_str());
}
}
void MainWindow::rec_clicked()
{
+ QPalette palette;
+ QPixmap pixmap;
+
if(!recording) {
info->log("Start recording.");
recording = 1;
// Start flashing the edge
rec_edge_counter = 0.0f;
timer->start(100);
- btn_rec->setPixmap(*img_stop);
+ pixmap.fromImage(*img_stop);
+ btn_rec->setIcon(pixmap);
camera->start();
} else {
switch(MessageBox(this,
@@ -493,8 +504,10 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(SAVE);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ palette.setColor(img_recedge->backgroundRole(), QColor(160,160,160));
+ img_recedge->setPalette(palette);
+ pixmap.fromImage(*img_record);
+ btn_rec->setIcon(pixmap);
break;
case MSG_NO:
@@ -502,8 +515,10 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(DELETE);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ palette.setColor(img_recedge->backgroundRole(), QColor(160,160,160));
+ img_recedge->setPalette(palette);
+ pixmap.fromImage(*img_record);
+ btn_rec->setIcon(pixmap);
break;
case MSG_MAYBE:
@@ -511,8 +526,10 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(LATER);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ palette.setColor(img_recedge->backgroundRole(), QColor(160,160,160));
+ img_recedge->setPalette(palette);
+ pixmap.fromImage(*img_record);
+ btn_rec->setIcon(pixmap);
break;
case MSG_CANCEL:
@@ -527,7 +544,7 @@ void MainWindow::shoot_clicked()
// unsigned char pixels[720*576*3];
info->log("Snapshot (%s).", frozen?"frozen":"unfrozen");
- QImage screenshot(720, 576, 32);
+ QImage screenshot(720, 576, QImage::Format_RGB32);
camera->snapshot(screenshot.bits());
@@ -540,8 +557,12 @@ void MainWindow::shoot_clicked()
if(frozen) {
camera->unfreeze();
- btn_freeze->setPixmap(*img_freeze);
- btn_freeze->setOn(false);
+
+ QPixmap pixmap;
+ pixmap.fromImage(*img_freeze);
+ btn_freeze->setIcon(pixmap);
+
+ btn_freeze->setDown(false);
frozen = false;
}
}
@@ -551,23 +572,38 @@ void MainWindow::freeze_clicked()
if(frozen) {
info->log("Unfreeze.");
camera->unfreeze();
- btn_freeze->setPixmap(*img_freeze);
- btn_freeze->setOn(false);
+
+ QPixmap pixmap;
+ pixmap.fromImage(*img_freeze);
+ btn_freeze->setIcon(pixmap);
+
+ btn_freeze->setDown(false);
frozen = false;
} else {
info->log("Freeze.");
camera->freeze();
- btn_freeze->setPixmap(*img_unfreeze);
- btn_freeze->setOn(true);
+
+ QPixmap pixmap;
+ pixmap.fromImage(*img_freeze);
+ btn_freeze->setIcon(pixmap);
+
+ btn_freeze->setDown(true);
frozen = true;
}
}
void MainWindow::mute_clicked()
{
+ QPixmap pixmap;
+
muted = !muted;
- if(muted) btn_mute->setPixmap(*img_mute);
- else btn_mute->setPixmap(*img_unmute);
+ if(muted) {
+ pixmap.fromImage(*img_mute);
+ btn_mute->setIcon(pixmap);
+ } else {
+ pixmap.fromImage(*img_unmute);
+ btn_mute->setIcon(pixmap);
+ }
camera->setMute(muted);
}
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 2ac7d82..435d20d 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -33,13 +33,13 @@
#include <string>
using namespace std;
-#include <qwidget.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qstatusbar.h>
-#include <qtimer.h>
-#include <qpixmap.h>
-#include <qimage.h>
+#include <QWidget>
+#include <QLabel>
+#include <QPushButton>
+#include <QStatusBar>
+#include <QTimer>
+#include <QPixmap>
+#include <QImage>
#include "videowidget.h"
#include "camera.h"
@@ -100,7 +100,7 @@ class MainWindow : public QWidget
{
Q_OBJECT
public:
- MainWindow(QApplication *qApp, QWidget* parent = 0, const char* name = 0);
+ MainWindow(QWidget* parent = 0);
~MainWindow();
void message(char* msg);
diff --git a/client/messagebox.cc b/client/messagebox.cc
index fd812eb..abd7479 100644
--- a/client/messagebox.cc
+++ b/client/messagebox.cc
@@ -43,14 +43,14 @@ MessageBox::MessageBox(QWidget* parent,
const char* text,
msg_type type,
msg_icon icon)
- : QDialog(parent, name, TRUE)
+ : QDialog(parent)
{
int resolution_w = config->readInt("pixel_width");
//int resolution_h = config->readInt("pixel_height");
unit = ((float)resolution_w / config->readFloat("screensize")) / INCH_IN_CM;
- setCaption(name);
+ setWindowTitle(name);
QFrame *topf = new QFrame(this);
topf->setFrameStyle(QFrame::Box | QFrame::Raised);
topf->setLineWidth(3);
@@ -116,7 +116,7 @@ MessageBox::MessageBox(QWidget* parent,
// lbl_text->setFont(QFont("Arial", 18));
QFrame *f = new QFrame(topf);
- QVBoxLayout *blayout = new QVBoxLayout(topf, 20, 20);
+ QVBoxLayout *blayout = new QVBoxLayout(topf);
blayout->addWidget(lbl_icon);
blayout->addWidget(lbl_text);
@@ -127,7 +127,7 @@ MessageBox::MessageBox(QWidget* parent,
case TYPE_OK:
{
QPushButton *bok = createButton(f, TXT_OK );
- QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bok, 0, 0);
connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
break;
@@ -136,7 +136,7 @@ MessageBox::MessageBox(QWidget* parent,
{
QPushButton *bok = createButton(f, TXT_OK );
QPushButton *bcancel = createButton(f, TXT_CANCEL );
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(bok, 0, 2);
connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
@@ -147,7 +147,7 @@ MessageBox::MessageBox(QWidget* parent,
{
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(byes, 0, 1);
connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
@@ -159,7 +159,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bmaybe = createButton(f, TXT_MAYBE );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(byes, 0, 1);
glayout->addWidget(bmaybe, 0, 2);
@@ -173,7 +173,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(byes, 0, 2);
@@ -188,7 +188,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 4, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(byes, 0, 2);
diff --git a/client/messagebox.h b/client/messagebox.h
index 30a8307..e2c576c 100644
--- a/client/messagebox.h
+++ b/client/messagebox.h
@@ -30,13 +30,13 @@
#ifndef __MIAV_MESSAGEBOX_H__
#define __MIAV_MESSAGEBOX_H__
-#include <qdialog.h>
-#include <qwidget.h>
-#include <qframe.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qlabel.h>
-#include <qpixmap.h>
+#include <QDialog>
+#include <QWidget>
+#include <QFrame>
+#include <QLayout>
+#include <QPushButton>
+#include <QLabel>
+#include <QPixmap>
typedef enum {
ICON_NONE, // No icon is used
diff --git a/client/miav_client.cc b/client/miav_client.cc
index a8e9f7c..f8ea6d2 100644
--- a/client/miav_client.cc
+++ b/client/miav_client.cc
@@ -42,6 +42,7 @@ QApplication *miav_app;
* This function starts the MIaV gui.
*/
int main(int argc, char *argv[])
+{
QApplication miav_grab( argc, argv );
miav_app = &miav_grab;
@@ -52,8 +53,7 @@ int main(int argc, char *argv[])
InfoEventHandler *eventhandler = new InfoEventHandler( );
miav_grab.installEventFilter( eventhandler );
- MainWindow mainwindow( &miav_grab );
- miav_grab.setMainWidget( &mainwindow );
+ MainWindow mainwindow;
info.setParent(&mainwindow);
return miav_grab.exec();
diff --git a/client/miav_client.h b/client/miav_client.h
index ce7842a..7b14912 100644
--- a/client/miav_client.h
+++ b/client/miav_client.h
@@ -35,7 +35,7 @@
#include "queue.h"
#ifdef USE_GUI
-#include <qapplication.h>
+#include <QApplication>
extern QApplication *miav_app;
#endif/*USE_GUI*/
diff --git a/client/player.h b/client/player.h
index 0f5ca51..4e826ad 100644
--- a/client/player.h
+++ b/client/player.h
@@ -51,7 +51,7 @@
#include "thread.h"
#include "frame.h"
-#include <qwidget.h>
+#include <QWidget>
#include "yuv_draw.h"
diff --git a/client/videowidget.cc b/client/videowidget.cc
index 61b5c8e..a2d5a14 100644
--- a/client/videowidget.cc
+++ b/client/videowidget.cc
@@ -32,7 +32,7 @@
#include "miav_config.h"
-VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p, "")
+VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p)
{
camera = c;
parent = p;
@@ -41,7 +41,7 @@ VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p, "")
// A welltested hack to force SDL to draw in the QWidget
QString ids;
- setenv("SDL_WINDOWID", ids.setNum(winId()), 1);
+ setenv("SDL_WINDOWID", ids.setNum(winId()).toStdString().c_str(), 1);
}
VideoWidget::~VideoWidget()
@@ -59,7 +59,7 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
{
if(!parent) { // We are a fullscreen window
QString ids;
- setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()), 1);
+ setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()).toStdString().c_str(), 1);
camera->resize(oldWindow->width(), oldWindow->height(), false);
destroy();
} else { // We are a nested window
diff --git a/client/videowidget.h b/client/videowidget.h
index b9ac9d6..f088bfc 100644
--- a/client/videowidget.h
+++ b/client/videowidget.h
@@ -30,8 +30,8 @@
#ifndef __VIDEOWIDGET_H__
#define __VIDEOWIDGET_H__
-#include <qwidget.h>
-#include <qpixmap.h>
+#include <QWidget>
+#include <QPixmap>
#include "camera.h"
diff --git a/client/yuv_draw.cc b/client/yuv_draw.cc
index 21e5c28..156c705 100644
--- a/client/yuv_draw.cc
+++ b/client/yuv_draw.cc
@@ -29,7 +29,7 @@
#include "yuv_draw.h"
// for miav_app
-#include "miav.h"
+#include "miav_client.h"
#include <string.h>
@@ -47,7 +47,7 @@ static QImage *loadIcon( char *name, int height )
int h = height;
int w = (int)((float)img->width() / (float)(img->height() / (float)h));
- scaled = img->smoothScale(w, h);
+ scaled = img->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
delete img;
img = new QImage(scaled);
@@ -107,6 +107,7 @@ void YUVDraw::addPixel(int x, int y, int val)
void YUVDraw::setTopText(char* text)
{
+ /*
miav_app->lock();
top_pixmap->fill();
@@ -125,10 +126,12 @@ void YUVDraw::setTopText(char* text)
}
}
miav_app->unlock();
+ */
}
void YUVDraw::setBottomText(char* text)
{
+ /*
miav_app->lock();
bottom_pixmap->fill();
@@ -147,6 +150,7 @@ void YUVDraw::setBottomText(char* text)
}
}
miav_app->unlock();
+ */
}
void YUVDraw::draw()
diff --git a/client/yuv_draw.h b/client/yuv_draw.h
index 62f7d02..9f70798 100644
--- a/client/yuv_draw.h
+++ b/client/yuv_draw.h
@@ -31,9 +31,9 @@
#include <SDL/SDL.h>
-#include <qpixmap.h>
-#include <qimage.h>
-#include <qpainter.h>
+#include <QPixmap>
+#include <QImage>
+#include <QPainter>
#define ICON_HEIGHT 48
#define ICON_WIDTH 48