From c9bfc4db72b84292f541c795993abde98e22121f Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 6 Mar 2006 10:44:07 +0000 Subject: *** empty log message *** --- client/mainwindow.cc | 174 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 69 deletions(-) (limited to 'client/mainwindow.cc') 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 -#include - -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -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); } -- cgit v1.2.3