#include <QClipboard>
MainWindow::MainWindow(const string &tty)
- : QDialog(), m_commThread(tty), m_fileNum(0), m_image()
+ : QDialog(), m_commThread(tty), m_fileNum(0), m_lastSize(0), m_image()
{
ui.setupUi(this);
imageLabel = new QLabel;
ui.scrollArea->setWidget(imageLabel);
+ ui.scrollArea->setMinimumWidth(320);
ui.progressBar->setValue(0);
- ui.progressBar->setMaximum(15000);
+ ui.progressBar->hide();
ui.saveButton->setDisabled(true);
+
+ ui.statusBar->setText("Press \"hardcopy\" button on the scope...");
connect(ui.quitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(&m_commThread, SIGNAL(bytesReceived(int)), ui.progressBar, SLOT(setValue(int)));
+ connect(&m_commThread, SIGNAL(newImage()), this, SLOT(newImage()));
connect(&m_commThread, SIGNAL(imageAvailable(OscImage*)), this, SLOT(processImage(OscImage*)));
connect(ui.prefixLine, SIGNAL(textChanged(const QString&)), this, SLOT(generateFileName(const QString&)));
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(saveImage()));
}
+
MainWindow::~MainWindow()
{
}
{
bool ret;
ui.saveButton->setEnabled(true);
- ui.progressBar->setMaximum(img->size());
- ui.progressBar->setValue(img->size());
- ui.progressBar->update();
-
- m_fileNum++;
- generateFileName( ui.prefixLine->text());
+ m_lastSize = img->size();
+ ui.progressBar->setMaximum(m_lastSize);
+ ui.progressBar->setValue(m_lastSize);
+ ui.progressBar->hide();
if (m_image) delete m_image;
m_image = img;
QPixmap pixmap;
ret = pixmap.loadFromData(*m_image);
- if (!ret) cerr << "Can't display image!"<<endl;
+ if (!ret)
+ ui.statusBar->setText("Cannot display the image! Unsupported format?");
+ else
+ ui.statusBar->setText("Ready");
+
QApplication::clipboard()->setPixmap(pixmap);
imageLabel->setPixmap(pixmap);
imageLabel->adjustSize();
+
+ m_fileNum++;
+ generateFileName( ui.prefixLine->text());
+
}
ts.setFieldWidth(3);
ts.setPadChar('0') ;
- ts << prefix << m_fileNum << ".tif";
+
+ ts << prefix << m_fileNum << ".bmp";
ui.fileLine->setText(fname);
}
ds.writeRawData(m_image->data(), m_image->size());
file.close();
}
+
+void MainWindow::newImage()
+{
+ ui.progressBar->show();
+ ui.statusBar->setText("Transferring...");
+ if (m_lastSize == 0)
+ ui.progressBar->setMaximum(0);
+}