diff options
| -rw-r--r-- | src/Makefile.am | 2 | ||||
| -rw-r--r-- | src/mainwindow.cc | 25 | ||||
| -rw-r--r-- | src/mainwindow.h | 3 | ||||
| -rw-r--r-- | src/recedge.cc | 141 | ||||
| -rw-r--r-- | src/recedge.h | 63 | 
5 files changed, 220 insertions, 14 deletions
| diff --git a/src/Makefile.am b/src/Makefile.am index 37b0f98..1afd35f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,7 @@ miav_SOURCES = \  	miav_config.cc \  	network.cc \  	player.cc \ +	recedge.cc \  	socket.cc \  	thread.cc \  	util.cc \ @@ -130,6 +131,7 @@ EXTRA_DIST = \  	package.h \  	player.h \  	queue.h \ +	recedge.h \  	semaphore.h \  	server.h \  	server_status.h \ diff --git a/src/mainwindow.cc b/src/mainwindow.cc index c8c427b..9d1c190 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -49,6 +49,9 @@  #include <config.h>  //"miav-grab.h" +// Control fade speed of record bar. +#define SPEED 0.07f +  //#define WITH_DV  MainWindow::MainWindow(QApplication *_qApp, QWidget* parent, const char* name )  	: QWidget( parent, Qt::FramelessWindowHint ) @@ -65,7 +68,7 @@ MainWindow::MainWindow(QApplication *_qApp, QWidget* parent, const char* name )    unit = ((float)resolution_w / config->readFloat("screensize")) / INCH_IN_CM; -  printf("Unit: %f\n", unit); +  //printf("Unit: %f\n", unit);    move(0,0);    resize(resolution_w, resolution_h); @@ -214,16 +217,18 @@ void MainWindow::createGui()      g1->margin() * 5 -      g0->margin() * 3; -  img_recedge = new QLabel(this); -  //img_recedge->setBackgroundColor(QColor(160,160,160)); +  img_recedge = new RecEdge();    img_recedge->setFixedSize(output_width, output_height);    img_live = new VideoWidget(img_recedge, camera); +  img_recedge->setInnerWidget(img_live); +    img_live->setFixedSize(output_width - 20, output_height - 20);    img_live->move(10,10);    //g1->addWidget ( img_recedge, 0, 0, 0, 3, Qt::AlignHCenter);    g1->addWidget ( img_recedge, 0, 0, 1, 4, Qt::AlignHCenter);    //  QObject::connect( img_live, SIGNAL(clicked()), this, SLOT(live_clicked()) ); +  img_recedge->setIdle(true);    // CPR/NAME LABEL + CPR button    lbl_cpr = createLabel("", output_width - (int)(BUTTON_WIDTH * unit), BUTTON_HEIGHT); @@ -393,17 +398,11 @@ void MainWindow::taskbar_update()    lbl_recordtime->setText(msg);  } -#define GREY 160 -#define SPEED 0.07f  void MainWindow::redraw_edge()  { -  /* // TODO    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)))); -  */ +  img_recedge->setLevel(val);  }  void MainWindow::message(char *msg) @@ -508,7 +507,7 @@ void MainWindow::rec_clicked()        recording = 0;        camera->stop(SAVE);        timer->stop(); -      //img_recedge->setBackgroundColor(QColor(160,160,160)); // TODO +      img_recedge->setIdle(true);        btn_rec->setIcon(QPixmap(PIXMAP_RECORD));        break; @@ -517,7 +516,7 @@ void MainWindow::rec_clicked()        recording = 0;        camera->stop(DELETE);        timer->stop(); -      //img_recedge->setBackgroundColor(QColor(160,160,160));// TODO +      img_recedge->setIdle(true);        btn_rec->setIcon(QPixmap(PIXMAP_RECORD));        break; @@ -526,7 +525,7 @@ void MainWindow::rec_clicked()        recording = 0;        camera->stop(LATER);        timer->stop(); -      //img_recedge->setBackgroundColor(QColor(160,160,160));// TODO +      img_recedge->setIdle(true);        btn_rec->setIcon(QPixmap(PIXMAP_RECORD));        break; diff --git a/src/mainwindow.h b/src/mainwindow.h index 3d47ffd..f683509 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,6 +43,7 @@ using namespace std;  #include "camera.h"  #include "cprquerydialog.h"  #include "historywidget.h" +#include "recedge.h"  #include "info_gui.h" @@ -155,7 +156,7 @@ private:    float rec_edge_counter;    QTimer *timer; -  QLabel *img_recedge; +  RecEdge *img_recedge;    HistoryWidget **img_history;    QPushButton *btn_logo; diff --git a/src/recedge.cc b/src/recedge.cc new file mode 100644 index 0000000..0d0543d --- /dev/null +++ b/src/recedge.cc @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            recedge.cc + * + *  Wed May 21 13:23:00 CEST 2014 + *  Copyright  2005 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 "recedge.h" + +#include <QPalette> +#include <QPaintEvent> +#include <QPainter> +#include <QGridLayout> + +#define GREY 160 +#define SIZE 10 + +RecEdge::RecEdge() +{ +  idle = true; +  level = 0.0; + +  QGridLayout *g = new QGridLayout(); + +  ul = new QLabel(); // upper left +  ul->setFixedSize(SIZE, SIZE); +  ul->setAutoFillBackground(true); + +  um = new QLabel(); // upper mid +  um->setFixedHeight(SIZE); +  um->setAutoFillBackground(true); + +  ur = new QLabel(); // upper right +  ur->setFixedSize(SIZE, SIZE); +  ur->setAutoFillBackground(true); + +  ml = new QLabel(); // left mid +  ml->setFixedWidth(SIZE); +  ml->setAutoFillBackground(true); + +  mr = new QLabel(); // right mid +  mr->setFixedWidth(SIZE); +  mr->setAutoFillBackground(true); + +  bl = new QLabel(); // bottom left +  bl->setFixedSize(SIZE, SIZE); +  bl->setAutoFillBackground(true); + +  bm = new QLabel(); // bottom mid +  bm->setFixedHeight(SIZE); +  bm->setAutoFillBackground(true); + +  br = new QLabel(); // bottom right +  br->setFixedSize(SIZE, SIZE); +  br->setAutoFillBackground(true); + +  g->addWidget(ul, 0,0, 1,1); +  g->addWidget(um, 0,1, 1,1); +  g->addWidget(ur, 0,2, 1,1); +  g->addWidget(ml, 1,0, 1,1); +  g->addWidget(mr, 1,2, 1,1); +  g->addWidget(bl, 2,0, 1,1); +  g->addWidget(bm, 2,1, 1,1); +  g->addWidget(br, 2,2, 1,1); + +  g->setContentsMargins(0,0,0,0); +  g->setSpacing(0); +  setContentsMargins(0,0,0,0); + +  setLayout(g); +} + +void RecEdge::updateEdge() +{ +  QLabel *lbls[] = {ul, um, ur, ml, mr, bl, bm, br, NULL}; +  int i = 0; +  while(lbls[i]) { +    QPalette pal = lbls[i]->palette(); +    +    if(idle) { +      pal.setColor(QPalette::Window, QColor(GREY, GREY, GREY)); +    } else { +      pal.setColor(QPalette::Window, +                   QColor((int) ((255 - GREY) * level + GREY), +                          (int) (GREY - (GREY * level)), +                          (int) (GREY - (GREY * level)))); +    } +    lbls[i]->setPalette(pal); +     +    i++; +  } +} + +void RecEdge::setInnerWidget(QWidget *inner) +{ +  QGridLayout *g = (QGridLayout*)layout(); +  g->addWidget(inner, 1, 1, 1, 1); +} + +void RecEdge::setLevel(float l) +{ +  idle = false; +  level = l; +  updateEdge(); +} + +void RecEdge::setIdle(bool i) +{ +  if(i) { +    QPalette pal = palette(); +    pal.setColor(QPalette::Window, QColor(GREY, GREY, GREY)); +    setPalette(pal); +  } + +  idle = i; + +  updateEdge(); +} + +void RecEdge::paintEvent(QPaintEvent *event) +{ +} diff --git a/src/recedge.h b/src/recedge.h new file mode 100644 index 0000000..ecbc37a --- /dev/null +++ b/src/recedge.h @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            recedge.h + * + *  Wed May 21 13:23:00 CEST 2014 + *  Copyright  2005 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 "config.h" +#ifndef __MIAV_RECEDGE_H__ +#define __MIAV_RECEDGE_H__ + +#include <QWidget> +#include <QLabel> + +class RecEdge : public QWidget { +Q_OBJECT +public: +  RecEdge(); + +  void setInnerWidget(QWidget *inner); + +  void setLevel(float level); +  void setIdle(bool idle); + +protected: +  void paintEvent(QPaintEvent *event); + +private: +  void updateEdge(); + +  float level; +  bool idle; + +  QLabel *ul; +  QLabel *um; +  QLabel *ur; +  QLabel *ml; +  QLabel *mr; +  QLabel *bl; +  QLabel *bm; +  QLabel *br; +}; + +#endif/*__MIAV_RECEDGE_H__*/ | 
