[Settings] add new menu, store and restore settings from previous session
This commit is contained in:
parent
3ca0b4c671
commit
a87070e43f
@ -17,7 +17,6 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <QSettings>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
@ -109,8 +108,10 @@ PylonRecorder::PylonRecorder(QWidget *parent)
|
||||
statusBar()->addWidget(fileHeader);
|
||||
statusBar()->addWidget(fileLabel);
|
||||
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
|
||||
applySettings();
|
||||
}
|
||||
|
||||
|
||||
PylonRecorder::~PylonRecorder(){
|
||||
if (grabber->isRunning()) {
|
||||
grabber->requestStop();
|
||||
@ -120,10 +121,38 @@ PylonRecorder::~PylonRecorder(){
|
||||
writer->forceStop();
|
||||
writer->wait(1000);
|
||||
}
|
||||
storeSettings();
|
||||
|
||||
delete pylon;
|
||||
delete buffer;
|
||||
delete grabber;
|
||||
delete writer;
|
||||
delete settings;
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::applySettings() {
|
||||
int bufferSize = settings->value("recorder/buffersize", defaultBufferSize).toInt();
|
||||
int exposureTime = settings->value("camera/exposure", defaultExposureTime).toInt();
|
||||
int frameRate = settings->value("camera/framerate", defaultFrameRate).toInt();
|
||||
int gain = settings->value("camera/gain", defaultGain).toInt();
|
||||
storageLocation = settings->value("recorder/storagelocation", "").toString();
|
||||
if (!storageLocation.isEmpty()) {
|
||||
selectStorageAction->setStatusTip(tr("Default storage location: ") + storageLocation);
|
||||
}
|
||||
buffersizeSpinner->setValue(bufferSize);
|
||||
exposureSpinner->setValue(exposureTime);
|
||||
gainSpinner->setValue(gain);
|
||||
framerateSpinner->setValue(frameRate);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::storeSettings() {
|
||||
settings->setValue("camera/exposure", exposureSpinner->value());
|
||||
settings->setValue("camera/framerate", framerateSpinner->value());
|
||||
settings->setValue("camera/gain", gainSpinner->value());
|
||||
settings->setValue("recorder/buffersize", buffersizeSpinner->value());
|
||||
settings->setValue("recorder/storagelocation", storageLocation);
|
||||
}
|
||||
|
||||
|
||||
@ -384,8 +413,19 @@ void PylonRecorder::createActions() {
|
||||
grab_stop_action = camera_menu->addAction(stop_icon, tr("&stop grabbing"), this, &PylonRecorder::stopRecording);
|
||||
grab_stop_action->setShortcut(tr("Ctrl+Shift+Enter"));
|
||||
|
||||
selectStorageAction = new QAction(tr("storage location"), this);
|
||||
selectStorageAction->setStatusTip(tr("Select a storage location for the recorded videos"));
|
||||
selectStorageAction->setToolTip(tr("Select a storage location for the recorded videos"));
|
||||
connect(selectStorageAction, &QAction::triggered, this, &PylonRecorder::selectStorageLocation);
|
||||
|
||||
storeSettingsAction = new QAction(tr("store settings"), this);
|
||||
storeSettingsAction->setStatusTip(tr("store current settings as defaults"));
|
||||
connect(storeSettingsAction, &QAction::triggered, this, &PylonRecorder::storeSettings);
|
||||
|
||||
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
||||
settingsMenu->addAction(tr("Storage location"), this, &PylonRecorder::selectStorageLocation);
|
||||
settingsMenu->addAction(selectStorageAction);
|
||||
settingsMenu->addAction(storeSettingsAction);
|
||||
settingsMenu->setToolTipsVisible(true);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(tr("&About"), this, &PylonRecorder::about);
|
||||
@ -674,5 +714,13 @@ void PylonRecorder::grabStillFromPylon() {
|
||||
}
|
||||
|
||||
void PylonRecorder::selectStorageLocation() {
|
||||
std::cerr << "Select folder!!! " << std::endl;
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
|
||||
"/home",
|
||||
QFileDialog::ShowDirsOnly
|
||||
| QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!dir.isEmpty()) {
|
||||
this->storageLocation = dir;
|
||||
selectStorageAction->setStatusTip(tr("Storage location: ") + storageLocation);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QTimer>
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QSettings>
|
||||
|
||||
#include "pylonwrapper.h"
|
||||
#include "imagebuffer.h"
|
||||
@ -66,6 +67,8 @@ private slots:
|
||||
private:
|
||||
void createActions();
|
||||
void updateActions();
|
||||
void applySettings();
|
||||
void storeSettings();
|
||||
QColor progressColor(int value);
|
||||
std::string createFilename();
|
||||
|
||||
@ -76,6 +79,7 @@ private:
|
||||
void adjustScrollBar(QScrollBar *scrollBar, double factor);
|
||||
|
||||
int defaultBufferSize = 3000, defaultFrameRate = 30, movieCount = 0, defaultExposureTime = 6000, defaultGain=13;
|
||||
QSettings *settings = new QSettings;
|
||||
QImage image;
|
||||
QTimer *frameTimer, *preassureTimer, *labelTimer;
|
||||
QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel, *fileLabel;
|
||||
@ -94,7 +98,8 @@ private:
|
||||
QString activeLabelStyleLow = "QLabel { font-size: 10px;font-family: Arial; color : cmyk(0, 255, 255, 0, 50); }";
|
||||
QString inactiveLabelStyle = ("QLabel { font-size: 10px;font-family: Arial; color :gray; }");
|
||||
QSpinBox *framerateSpinner, *buffersizeSpinner, *exposureSpinner, *gainSpinner;
|
||||
|
||||
QAction *selectStorageAction, *storeSettingsAction;
|
||||
QString storageLocation = "";
|
||||
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
QPrinter printer;
|
||||
|
Loading…
Reference in New Issue
Block a user