From 0eb1af1add19c8ffb8f5ab11f74810366f1beed1 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 9 Mar 2006 11:03:35 +0000 Subject: *** empty log message *** --- client/historyframe.cc | 42 ++++++++++++++++++++++++++---------------- client/historyframe.h | 11 ++++++++--- client/historywidget.cc | 48 +++++++++++------------------------------------- client/historywidget.h | 14 +++++--------- client/mainwindow.cc | 40 ++++++++++++++++++++++++++++++---------- client/mainwindow.h | 7 ++++--- client/splashscreen.cc | 34 ++++++++++++++++++---------------- client/splashscreen.h | 12 +++++------- client/videowidget.cc | 6 +++--- client/videowidget.h | 4 ++-- 10 files changed, 112 insertions(+), 106 deletions(-) (limited to 'client') diff --git a/client/historyframe.cc b/client/historyframe.cc index ad9154b..8c67c66 100644 --- a/client/historyframe.cc +++ b/client/historyframe.cc @@ -29,40 +29,50 @@ #include #include +#include HistoryFrame::HistoryFrame() { - QVBoxLayout *layout = new QVBoxLayout(); - setLayout(layout); } HistoryFrame::~HistoryFrame() { } +void HistoryFrame::clearHistory() +{ + while(!widgets.empty()) delete widgets.takeLast(); +} + void HistoryFrame::addHistoryItem(HistoryWidget *item) { - widgets.append(item); + item->setParent(this); + + if(widgets.size() == MAX_HISTORY) delete widgets.takeLast(); + widgets.prepend(item); + + doLayoutHistoryWidgets(); } void HistoryFrame::resizeEvent(QResizeEvent *event) { - int w = event->size().width(); - int h = event->size().height(); - - int widget_height = h / 10; + doLayoutHistoryWidgets(); +} - int num_widgets = h / widget_height; - int top = num_widgetscount()) { - layout()->removeItem(layout()->itemAt(0)); // Remove all widgets - } + int num_widgets = height() / h; + int hspace = widgets.size();// - clear_button->height(); + int top = num_widgetsresize(w, widget_height); - layout()->addWidget(history); + history->resize(w, h); + history->move(0, i * h); + if(i < top) history->show(); + else history->hide(); } - } diff --git a/client/historyframe.h b/client/historyframe.h index 39366a9..696b8fc 100644 --- a/client/historyframe.h +++ b/client/historyframe.h @@ -28,22 +28,27 @@ #ifndef __MIAV_HISTORYFRAME_H__ #define __MIAV_HISTORYFRAME_H__ -#include -#include +#include #include "historywidget.h" -class HistoryFrame : public QFrame +// How many history items should be held in memory? +#define MAX_HISTORY 20 + +class HistoryFrame : public QGroupBox { public: HistoryFrame(); ~HistoryFrame(); void addHistoryItem(HistoryWidget *item); + void clearHistory(); protected: void resizeEvent(QResizeEvent *event); private: + void doLayoutHistoryWidgets(); + QList widgets; }; diff --git a/client/historywidget.cc b/client/historywidget.cc index ba768eb..aff783a 100644 --- a/client/historywidget.cc +++ b/client/historywidget.cc @@ -28,43 +28,21 @@ #include "miav_config.h" -#include #include -#define PIXMAP_DUMMY PIXMAPS"/dummy.png" -HistoryWidget::HistoryWidget() : QLabel() +HistoryWidget::HistoryWidget(QPixmap *pixmap) { - image = NULL; - // set_image(new QImage(PIXMAP_DUMMY)); - setLineWidth(1); - setFrameStyle(QFrame::Plain); + this->pixmap = pixmap; + setFrameStyle(QFrame::Panel | QFrame::Raised); + // setScaledContents(true); + setAlignment(Qt::AlignCenter); } HistoryWidget::~HistoryWidget() { - if(image) delete image; + delete pixmap; } -void HistoryWidget::set_image(QImage *i) -{/* - if(image) delete image; - - image = new QImage(*i); - - QImage resized = image->scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - QPixmap pixmap; - pixmap.fromImage(resized); - setPixmap(pixmap); - */ -} - -QImage * HistoryWidget::get_image() -{ - return image; -} - -//static HistoryWidget *fs = NULL; - void HistoryWidget::mouseReleaseEvent(QMouseEvent *event) { /* @@ -85,13 +63,9 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *event) void HistoryWidget::resizeEvent(QResizeEvent *event) { - /* - QImage resized = image->scaled(event->size().width(), - event->size().height(), - Qt::KeepAspectRatio, - Qt::SmoothTransformation); - QPixmap pixmap; - pixmap.fromImage(resized); - setPixmap(pixmap); - */ + QPixmap resized = pixmap->scaled(event->size().width(), + event->size().height(), + Qt::KeepAspectRatio, + Qt::SmoothTransformation); + setPixmap(resized); } diff --git a/client/historywidget.h b/client/historywidget.h index dd2345d..734935b 100644 --- a/client/historywidget.h +++ b/client/historywidget.h @@ -29,25 +29,21 @@ #define __MIAV_HISTORYWIDGET_H__ #include -#include +#include -class HistoryWidget : public QLabel { -Q_OBJECT +class HistoryWidget : public QLabel +{ public: - HistoryWidget(); + HistoryWidget(QPixmap *pixmap); ~HistoryWidget(); - void set_image(QImage *image); - QImage *get_image(); - void mouseReleaseEvent(QMouseEvent *event); protected: void resizeEvent(QResizeEvent *event); private: - QImage *image; - QWidget *parent; + QPixmap *pixmap; }; #endif/*__MIAV_HISTORYWIDGET_H__*/ diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 3a0eeab..9970568 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -35,7 +35,6 @@ #include #include "videowidget.h" -#include "historyframe.h" #include "historywidget.h" // Macro for creating buttons @@ -54,12 +53,20 @@ static QPushButton *createButton(char* icon) return btn; } +#include MainWindow::MainWindow(): QWidget() { MIaV::info->log("Starting MIaV v. %s.", VERSION); // Create the overlaying splashscreen - // SplashScreen splash; + SplashScreen splash(this); + /* + sleep(3); + splash.setProgress("Loading some items", 10); + sleep(3); + splash.setProgress("Established connections",50); + sleep(3); + */ // Create layout QGridLayout *layout = new QGridLayout(this); @@ -92,16 +99,27 @@ MainWindow::MainWindow(): QWidget() layout->addWidget(button, 2,3, 1,1); connect(button, 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())); + // Create history bar - HistoryFrame *frame = new HistoryFrame(); - layout->addWidget(frame, 0,4, 3,1); - frame->addHistoryItem(new HistoryWidget()); - frame->addHistoryItem(new HistoryWidget()); - frame->addHistoryItem(new HistoryWidget()); + history = new HistoryFrame(); + layout->addWidget(history, 0,4, 2,1); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_MUTE))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_UNMUTE))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_STOP))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_RECORD))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_FREEZE))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_UNFREEZE))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_CPR))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_CLEAR))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_DUMMY))); + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_LOGO_SMALL))); // Create statusbar - + show(); // setWindowState(Qt::WindowFullScreen); @@ -123,18 +141,20 @@ void MainWindow::about_clicked() void MainWindow::clear_clicked() { + printf("clear\n"); } void MainWindow::cpr_clicked() { } -void MainWindow::rec_clicked() +void MainWindow::record_clicked() { } -void MainWindow::shoot_clicked() +void MainWindow::snapshot_clicked() { + history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_LOGO_SMALL))); } void MainWindow::freeze_clicked() diff --git a/client/mainwindow.h b/client/mainwindow.h index acba62c..4222b3d 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -29,6 +29,7 @@ #define __MIAV_MAINWINDOW_H__ #include +#include "historyframe.h" /** * Images @@ -59,14 +60,14 @@ public: public slots: void cpr_clicked(); void clear_clicked(); - void rec_clicked(); - void shoot_clicked(); + void record_clicked(); + void snapshot_clicked(); void freeze_clicked(); void about_clicked(); void mute_clicked(); private: - + HistoryFrame *history; }; #endif/*__MIAV_MAINWINDOW_H__*/ diff --git a/client/splashscreen.cc b/client/splashscreen.cc index c4acb25..7b23609 100644 --- a/client/splashscreen.cc +++ b/client/splashscreen.cc @@ -27,9 +27,22 @@ #include "config.h" #include "splashscreen.h" -SplashScreen::SplashScreen() +#include +#include + +SplashScreen::SplashScreen(QWidget *mainwindow) { - start(); + setPixmap(QPixmap(PIXMAP_SPLASH)); + finish(mainwindow); + + progbar = new QProgressBar(this); + progbar->setRange(0,100); + progbar->setValue(0); + progbar->move(100,100); + progbar->resize(100,20); + progbar->show(); + + show(); } SplashScreen::~SplashScreen() @@ -38,18 +51,7 @@ SplashScreen::~SplashScreen() void SplashScreen::setProgress(QString text, unsigned int pct) { - // progbartext->text = text; - // progbar->setValue(pct); -} - -void SplashScreen::run() -{ - /* - QDialog splash; - splash.setModal(true); - progbar = new QProgressBar(&splash); - progbar->setRange(0, 100); - progbar->setTextVisible(true); - splash.exec(); - */ + showMessage(text); + qApp->processEvents(); + progbar->setValue(pct); } diff --git a/client/splashscreen.h b/client/splashscreen.h index 95de335..529f8cb 100644 --- a/client/splashscreen.h +++ b/client/splashscreen.h @@ -28,23 +28,21 @@ #ifndef __MIAV_SPLASHSCREEN_H__ #define __MIAV_SPLASHSCREEN_H__ -#include -#include +#include #include #include -class SplashScreen : public QThread +#define PIXMAP_SPLASH PIXMAPS"/dummy.png" + +class SplashScreen : public QSplashScreen { public: - SplashScreen(); + SplashScreen(QWidget *mainwindow); ~SplashScreen(); void setProgress(QString text, unsigned int pct); - void run(); - private: - QDialog *splash; QProgressBar *progbar; }; diff --git a/client/videowidget.cc b/client/videowidget.cc index 6ff062d..cc81ead 100644 --- a/client/videowidget.cc +++ b/client/videowidget.cc @@ -27,7 +27,7 @@ #include "videowidget.h" #include "miav_config.h" -VideoWidget::VideoWidget() : QFrame() +VideoWidget::VideoWidget() { // A welltested hack to force SDL to draw in the QWidget @@ -39,8 +39,8 @@ VideoWidget::VideoWidget() : QFrame() palette.setColor(backgroundRole(), Qt::blue); setPalette(palette); - setLineWidth(1); - setFrameStyle(QFrame::Plain); + setLineWidth(10); + setFrameStyle(QFrame::Raised); } diff --git a/client/videowidget.h b/client/videowidget.h index 25f5bed..e2b597a 100644 --- a/client/videowidget.h +++ b/client/videowidget.h @@ -28,10 +28,10 @@ #ifndef __VIDEOWIDGET_H__ #define __VIDEOWIDGET_H__ -#include +#include #include -class VideoWidget : public QFrame +class VideoWidget : public QTextEdit { Q_OBJECT public: -- cgit v1.2.3