/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** * mainwindow.cc * * Sat Aug 21 19:49:34 2004 * Copyright 2004 deva * 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 "mainwindow.h" #include "info.h" #include "miav_config.h" #include "splashscreen.h" #include "aboutwindow.h" #include #include "historywidget.h" #include "control.h" #include "icons.h" QPushButton *MainWindow::createButton(QPixmap *pixmap) { QPushButton *btn = new QPushButton(); btn->setIconSize(QSize(pixmap->width(), pixmap->height())); btn->setIcon(*pixmap); return btn; } MainWindow::MainWindow(Decoder *d) { decoder = d; MIaV::info->log("Starting MIaV v. %s.", VERSION); // Create the overlaying splashscreen SplashScreen splash(this); /* sleep(3); splash.setProgress("Loading some items", 10); sleep(3); splash.setProgress("Established connections",50); sleep(3); */ // Create 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); // Load the icons Icons::loadIcons(); // Create the control buttons btn_cpr = createButton(Icons::cpr); layout->addWidget(btn_cpr, 1,3, 2,1); connect(btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked())); btn_record = createButton(Icons::record); layout->addWidget(btn_record, 3,0, 1,1); connect(btn_record, SIGNAL(clicked()), this, SLOT(record_clicked())); btn_snapshot = createButton(Icons::snapshot); layout->addWidget(btn_snapshot, 3,1, 1,1); connect(btn_snapshot, SIGNAL(clicked()), this, SLOT(snapshot_clicked())); btn_freeze = createButton(Icons::freeze); layout->addWidget(btn_freeze, 3,2, 1,1); connect(btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked())); btn_mute = createButton(Icons::mute); layout->addWidget(btn_mute, 3,3, 1,1); connect(btn_mute, SIGNAL(clicked()), this, SLOT(mute_clicked())); btn_clear = createButton(Icons::clear); layout->addWidget(btn_clear, 3,4, 1,1); connect(btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked())); // Create the labels lbl_cpr = new QLabel(); QFont font = lbl_cpr->font(); font.setPointSize(font.pointSize() * 2); font.setBold(true); lbl_cpr->setFont(font); lbl_cpr->setText("CPR"); layout->addWidget(lbl_cpr, 1,0, 1,3); lbl_name = new QLabel(); font = lbl_name->font(); font.setPointSize(font.pointSize() * 3); font.setBold(true); lbl_name->setFont(font); lbl_name->setText("Name"); layout->addWidget(lbl_name, 2,0, 1,3); // Stretch the layout layout->setRowStretch(0, 100); layout->setRowStretch(1, 1); layout->setRowStretch(2, 1); layout->setRowStretch(3, 1); // Create history bar history = new HistoryFrame(); layout->addWidget(history, 0,4, 3,1); // Create statusbar statusbar = new QStatusBar(this); outerlayout->addWidget(statusbar, 1,0, 1,1); statusbar->showMessage("Ready!"); startTimer(100); show(); // setWindowState(Qt::WindowFullScreen); resize(800, 600); MIaV::info->log("MIaV is ready."); } MainWindow::~MainWindow() { MIaV::info->log("MIaV is shutting down."); Icons::unloadIcons(); MIaV::info->log("MIaV is shut down."); } void MainWindow::timerEvent(QTimerEvent *event) { Status s = decoder->status(); QString statusmsg; for(int cnt = 0; cnt < s.queue_sizes.size(); cnt++) { QString next; next.sprintf("(%d)", s.queue_sizes[cnt]); statusmsg.prepend(next); } statusbar->showMessage(statusmsg); } void MainWindow::about_clicked() { AboutWindow about; about.exec(); } void MainWindow::clear_clicked() { printf("clear\n"); } 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); decoder->snapshot((char*)screenshot.bits()); QPixmap *p = new QPixmap(); *p = QPixmap::fromImage(screenshot); history->addHistoryItem(new HistoryWidget(p)); } 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); } }