diff --git a/VimbaC/Include/VmbCommonTypes.h b/VimbaC/Include/VmbCommonTypes.h index c635ad706808f69d3286569b44c94ad9381b9f67..a0f1c314efcf5bc71f0552b6259a32cc920a8672 100644 --- a/VimbaC/Include/VmbCommonTypes.h +++ b/VimbaC/Include/VmbCommonTypes.h @@ -105,6 +105,7 @@ extern "C" { // typedef enum VmbErrorType { + VmbErrorNothing = 27, // No error. No Success. Nothing really! VmbErrorSuccess = 0, // No error VmbErrorInternalFault = -1, // Unexpected fault in VimbaC or driver VmbErrorApiNotStarted = -2, // VmbStartup() was not called before the current command diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/binary/x86_64bit/AsynchronousOpenCVRecorder b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/binary/x86_64bit/AsynchronousOpenCVRecorder index dfa3e9df22861ec741c5ba53ae8112ef6701a1f0..4bb665099cef4a9b6aeae0a51489baf503e8dba8 100755 Binary files a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/binary/x86_64bit/AsynchronousOpenCVRecorder and b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/binary/x86_64bit/AsynchronousOpenCVRecorder differ diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/AsynchronousOpenCVRecorder.o b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/AsynchronousOpenCVRecorder.o index d1129011baa2f9826116d75a10da9353a1f94e66..c96cfdb535b5a2f5649fbcb610517b14f5bf0b30 100644 Binary files a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/AsynchronousOpenCVRecorder.o and b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/AsynchronousOpenCVRecorder.o differ diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/moc_AsynchronousOpenCVRecorder.o b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/moc_AsynchronousOpenCVRecorder.o index 82d4e4be4a2557ed7972617f7e224024f2212e42..0de13c04305377ca7583ced82d120adfad603c9e 100644 Binary files a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/moc_AsynchronousOpenCVRecorder.o and b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Build/Make/object/x86_64bit/moc_AsynchronousOpenCVRecorder.o differ diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/ApiController.cpp b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/ApiController.cpp index 76db9d68f238f3a15d64df5b60acc1d05d8c726f..ce18c52300abc126ff9ac1f2d945d980ef69718b 100644 --- a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/ApiController.cpp +++ b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/ApiController.cpp @@ -313,6 +313,9 @@ VmbErrorType ApiController::QueueFrame( FramePtr pFrame ) QObject* ApiController::GetCameraObserver() { return SP_DYN_CAST( m_pCameraObserver, CameraObserver ).get(); + // so same as + // return SP_ACCESS(SP_DYN_CAST( m_pCameraObserver, CameraObserver ); + // ?? } // diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/FrameObserver.h b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/FrameObserver.h index f714cfb9db78c8894c761cbd1c756cafbbca3d8a..a0440f11374a87b0dd28c979ee30d49697cd703a 100644 --- a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/FrameObserver.h +++ b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/FrameObserver.h @@ -40,6 +40,8 @@ namespace AVT { namespace VmbAPI { namespace Examples { +//Why VIRTUAL inheritance?? https://www.sandordargo.com/blog/2020/12/23/virtual-inheritance + class FrameObserver : public QObject, virtual public IFrameObserver { Q_OBJECT diff --git a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/OpenCVVideoRecorder.h b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/OpenCVVideoRecorder.h index ba0520e9a1f3ab0de8b3a9a5119c1651ec665d51..8166854d07b793f12e3872c77a31c6c770d84d69 100644 --- a/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/OpenCVVideoRecorder.h +++ b/VimbaCPP/Examples/AsynchronousOpenCVRecorder/Qt/Source/OpenCVVideoRecorder.h @@ -255,7 +255,7 @@ class OpenCVRecorder: public QThread // Details: main thread processing function that will run while the object is alife. // // - void run() + void run() override { while( ! m_StopThread ) { diff --git a/recorder/obj/moc_mainwindow.cpp b/recorder/obj/moc_mainwindow.cpp index d61dda207042797b02c480b38cad425b83eb5de4..871145ef700a8f9b2603397e1bed1cbed13b7bae 100644 --- a/recorder/obj/moc_mainwindow.cpp +++ b/recorder/obj/moc_mainwindow.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - const uint offsetsAndSize[14]; - char stringdata0[55]; + const uint offsetsAndSize[16]; + char stringdata0[65]; }; #define QT_MOC_LITERAL(ofs, len) \ uint(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs), len @@ -35,11 +35,12 @@ QT_MOC_LITERAL(15, 0), // "" QT_MOC_LITERAL(16, 10), // "VmbError_t" QT_MOC_LITERAL(27, 3), // "err" QT_MOC_LITERAL(31, 10), // "updateCams" -QT_MOC_LITERAL(42, 12) // "opencloseCam" +QT_MOC_LITERAL(42, 12), // "openCloseCam" +QT_MOC_LITERAL(55, 9) // "selectCam" }, "MainWindow\0log\0\0VmbError_t\0err\0" - "updateCams\0opencloseCam" + "updateCams\0openCloseCam\0selectCam" }; #undef QT_MOC_LITERAL @@ -49,7 +50,7 @@ static const uint qt_meta_data_MainWindow[] = { 10, // revision 0, // classname 0, 0, // classinfo - 4, 14, // methods + 5, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -57,15 +58,17 @@ static const uint qt_meta_data_MainWindow[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags, initial metatype offsets - 1, 2, 38, 2, 0x0a, 1 /* Public */, - 1, 1, 43, 2, 0x2a, 4 /* Public | MethodCloned */, - 5, 0, 46, 2, 0x08, 6 /* Private */, - 6, 2, 47, 2, 0x08, 7 /* Private */, + 1, 2, 44, 2, 0x0a, 1 /* Public */, + 1, 1, 49, 2, 0x2a, 4 /* Public | MethodCloned */, + 5, 0, 52, 2, 0x08, 6 /* Private */, + 6, 0, 53, 2, 0x08, 7 /* Private */, + 7, 2, 54, 2, 0x08, 8 /* Private */, // slots: parameters QMetaType::Void, QMetaType::QString, 0x80000000 | 3, 2, 4, QMetaType::Void, QMetaType::QString, 2, QMetaType::Void, + QMetaType::Void, QMetaType::Void, QMetaType::Int, QMetaType::Int, 2, 2, 0 // eod @@ -80,7 +83,8 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, case 0: _t->log((*reinterpret_cast< std::add_pointer_t<QString>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<VmbError_t>>(_a[2]))); break; case 1: _t->log((*reinterpret_cast< std::add_pointer_t<QString>>(_a[1]))); break; case 2: _t->updateCams(); break; - case 3: _t->opencloseCam((*reinterpret_cast< std::add_pointer_t<int>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<int>>(_a[2]))); break; + case 3: _t->openCloseCam(); break; + case 4: _t->selectCam((*reinterpret_cast< std::add_pointer_t<int>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<int>>(_a[2]))); break; default: ; } } @@ -94,7 +98,7 @@ const QMetaObject MainWindow::staticMetaObject = { { nullptr, qt_incomplete_metaTypeArray<qt_meta_stringdata_MainWindow_t , QtPrivate::TypeAndForceComplete<MainWindow, std::true_type> -, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QString, std::false_type>, QtPrivate::TypeAndForceComplete<VmbError_t, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QString, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<int, std::false_type>, QtPrivate::TypeAndForceComplete<int, std::false_type> +, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QString, std::false_type>, QtPrivate::TypeAndForceComplete<VmbError_t, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QString, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<int, std::false_type>, QtPrivate::TypeAndForceComplete<int, std::false_type> >, @@ -121,13 +125,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 4) + if (_id < 5) qt_static_metacall(this, _c, _id, _a); - _id -= 4; + _id -= 5; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 4) + if (_id < 5) *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); - _id -= 4; + _id -= 5; } return _id; } diff --git a/recorder/src/mainwindow.cpp b/recorder/src/mainwindow.cpp index dc9b11898da3840f45602b54dec61ca19b3b6604..1f18ef56ef14781db3e2b47bdf4992633b724d50 100644 --- a/recorder/src/mainwindow.cpp +++ b/recorder/src/mainwindow.cpp @@ -15,11 +15,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , sys(VimbaSystem::GetInstance()) // Create and get Vimba singleton +, curCam(CameraPtr()) , cameras(CameraPtrVector()) +, camInfoNames({"name","model","id","serial","interface","state"}) { ui->setupUi(this); + ui->tw_cams->setColumnCount(camInfoNames.size()); + ui->tw_cams->setHorizontalHeaderLabels(camInfoNames); + QObject::connect(ui->b_update, SIGNAL(clicked()), this, SLOT(updateCams())); - QObject::connect(ui->tw_cams, SIGNAL(cellClicked(int,int)), this, SLOT(openCloseCam(int,int))); + QObject::connect(ui->b_openclose, SIGNAL(clicked()), this, SLOT(openCloseCam())); + QObject::connect(ui->tw_cams, SIGNAL(cellClicked(int,int)), this, SLOT(selectCam(int,int))); log(getVersionString()); @@ -57,45 +63,56 @@ void MainWindow::keyPressEvent(QKeyEvent *e) return QWidget::keyPressEvent(e); } -void MainWindow::opencloseCam(int row,int col) +void MainWindow::selectCam(int row,int ) { - log(QString("%1,%2").arg(row).arg(col)); - auto cam = cameras.at(row); - auto item = ui->tw_cams->itemAt(row,col); - if( item->text() == "opened" ) + curCam = cameras.at(row); + //display Stream on label (stackedWidget) + //display options in dockwidget-right + +} + +void MainWindow::openCloseCam() +{ + + QPushButton* b = ui->b_openclose; + if( b->text() == "open" ) { - //close - auto ret = cam->Close(); - log( QString("Close camera %1").arg(row), ret ); + auto ret = curCam->Open(VmbAccessModeFull); + if( ret == VmbErrorSuccess ) + b->setText("close"); + log( QString("Open camera"), ret ); } - else + else if( b->text() == "close" ) { - //open - auto ret = cam->Open(VmbAccessModeFull); - log( QString("Open camera %1").arg(row), ret ); + auto ret = curCam->Close(); + if( ret == VmbErrorSuccess ) + b->setText("open"); + log( QString("Close camera"), ret ); } } void MainWindow::updateCams() { - - ui->tw_cams->clear(); - - VmbErrorType err = sys.GetCameras( cameras ); // Fetch all cameras known to Vimba + // clear + ui->tw_cams->setRowCount(0); + ui->tw_cams->clearContents(); //dont remove headers + curCam = CameraPtr(); + cameras = CameraPtrVector(); + + // get new + VmbErrorType err = sys.GetCameras( cameras ); // fetch all cameras known to Vimba if( VmbErrorSuccess == err ) { // query and print all _static_ details of all known cams [without opening cams] auto ncam = cameras.size(); log( QString("Found %1 Camera%2!").arg(ncam).arg(ncam>1?"s":"")); - auto mf = std::bind(&MainWindow::printCamInfo, this, std::placeholders::_1); //weird syntax for calling non-static memberfunction in for_each... + auto mf = std::bind(&MainWindow::getCamInfo, this, std::placeholders::_1); //weird syntax for calling non-static memberfunction in for_each... - ui->tw_cams->setRowCount(ncam); + // ui->tw_cams->setRowCount(ncam); std::for_each( cameras.begin(), cameras.end(), mf ); if( cameras.size() ) - { - ui->tw_cams->setCurrentCell(0,0); //XXX select row? - } + ui->tw_cams->setCurrentCell(0,0); //select row } else { @@ -103,49 +120,66 @@ void MainWindow::updateCams() } } -/// get static cam info and add to listwidget -void MainWindow::printCamInfo( const CameraPtr &camera ) +/// get static cam info +void MainWindow::getCamInfo( const CameraPtr &camera ) { - std::string strID, strName, strModelName, strSerialNumber, strInterfaceID, strCaminfo; + std::string str; + QStringList infos; - VmbErrorType err = camera->GetID( strID ); + VmbErrorType err = camera->GetID( str ); if( VmbErrorSuccess != err ) - strID = errorCodeToMessage(err).toStdString(); + str = errorCodeToMessage(err).toStdString(); + infos << QString::fromStdString(str); - err = camera->GetName( strName ); + err = camera->GetName( str ); if( VmbErrorSuccess != err ) - strName = errorCodeToMessage(err).toStdString(); + str = errorCodeToMessage(err).toStdString(); + infos << QString::fromStdString(str); - err = camera->GetModel( strModelName ); + err = camera->GetModel( str ); if( VmbErrorSuccess != err ) - strModelName = errorCodeToMessage(err).toStdString(); + str = errorCodeToMessage(err).toStdString(); + infos << QString::fromStdString(str); - err = camera->GetSerialNumber( strSerialNumber ); + err = camera->GetSerialNumber( str ); if( VmbErrorSuccess != err ) - strSerialNumber = errorCodeToMessage(err).toStdString(); + str = errorCodeToMessage(err).toStdString(); + infos << QString::fromStdString(str); - err = camera->GetInterfaceID( strInterfaceID ); + err = camera->GetInterfaceID( str ); if( VmbErrorSuccess != err ) - strInterfaceID = errorCodeToMessage(err).toStdString(); + str = errorCodeToMessage(err).toStdString(); + infos << QString::fromStdString(str); - strCaminfo = \ - "Name : " + strName + - "\nModel : " + strModelName + - "\nID : " + strID + - "\nSerial : " + strSerialNumber + - "\n@Interface : " + strInterfaceID + "\n\n"; - QString caminfo = QString::fromStdString(strCaminfo); + infos << "closed"; //initially cams are closed, right? + //XXX use sth like isClosed() instead?? - auto row = ui->tw_cams->rowCount()-1; + //XXX use icon instead of text + //QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type) - ui->tw_cams->setItem( row, 0, new QTableWidgetItem( caminfo ) ); - ui->tw_cams->setItem( row, 1, new QTableWidgetItem("closed") ); //XXX setIcon ?? + addRow(infos); + QStringList sl= {randomString(),randomString(),randomString(),randomString(),randomString(),randomString()}; + addRow(sl); } +///add row to listwidget +void MainWindow::addRow( QStringList& camInfos ) +{ + auto row = ui->tw_cams->rowCount(); + ui->tw_cams->setRowCount(row+1); + for( auto col=0; col < ui->tw_cams->columnCount(); col++) + { + auto item = new QTableWidgetItem( camInfos.at(col) ); + item->setTextAlignment(Qt::AlignCenter); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); //but not editable! + + ui->tw_cams->setItem( row, col, item ); + } +} void MainWindow::log(QString msg, VmbError_t err ) { - msg.append(QString("%1" ).arg(errorCodeToMessage(err))); + msg.append(QString("%1").arg(errorCodeToMessage(err))); //for std::string, use: log(QString::fromStdString(msg)) auto idx = ui->lw_log->count()-1; diff --git a/recorder/src/mainwindow.h b/recorder/src/mainwindow.h index f1edef926562ab47dfd69a35abea491e555fec5c..2aad2d37c35684d5a68432018481262adf3a6f21 100644 --- a/recorder/src/mainwindow.h +++ b/recorder/src/mainwindow.h @@ -18,20 +18,25 @@ public: ~MainWindow(); public slots: - void log(QString,VmbError_t err = VmbErrorSuccess); + void log(QString,VmbError_t err = VmbErrorNothing); private slots: void updateCams(); - void opencloseCam(int,int); + void openCloseCam(); + void selectCam(int,int); protected: void keyPressEvent(QKeyEvent *); private: - void printCamInfo( const AVT::VmbAPI::CameraPtr &camera ); + void getCamInfo( const AVT::VmbAPI::CameraPtr &camera ); + void addRow( QStringList& ); Ui::MainWindow *ui; AVT::VmbAPI::VimbaSystem &sys; + + AVT::VmbAPI::CameraPtr curCam; AVT::VmbAPI::CameraPtrVector cameras; + QStringList camInfoNames; }; #endif // MAINWINDOW_H diff --git a/recorder/src/mainwindow.ui b/recorder/src/mainwindow.ui index 150c8ec79ebc597afd1aeb27928d43598ce21ae8..661313598bf6a1c3c53cca827d68bc4f23eda57b 100644 --- a/recorder/src/mainwindow.ui +++ b/recorder/src/mainwindow.ui @@ -6,63 +6,36 @@ <rect> <x>0</x> <y>0</y> - <width>800</width> - <height>600</height> + <width>984</width> + <height>622</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> - <widget class="QTableWidget" name="tw_cams_2"> - <property name="geometry"> - <rect> - <x>50</x> - <y>30</y> - <width>311</width> - <height>241</height> - </rect> - </property> - <property name="sizeAdjustPolicy"> - <enum>QAbstractScrollArea::AdjustToContents</enum> - </property> - <property name="rowCount"> - <number>3</number> - </property> - <property name="columnCount"> - <number>2</number> - </property> - <attribute name="horizontalHeaderVisible"> - <bool>false</bool> - </attribute> - <attribute name="horizontalHeaderCascadingSectionResizes"> - <bool>true</bool> - </attribute> - <attribute name="horizontalHeaderStretchLastSection"> - <bool>false</bool> - </attribute> - <attribute name="verticalHeaderCascadingSectionResizes"> - <bool>true</bool> - </attribute> - <row/> - <row/> - <row/> - <column/> - <column/> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="l_vid"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>800</width> + <width>984</width> <height>22</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> - <widget class="QDockWidget" name="dockWidget"> + <widget class="QDockWidget" name="dockWidget_down"> <attribute name="dockWidgetArea"> <number>8</number> </attribute> @@ -74,7 +47,7 @@ </layout> </widget> </widget> - <widget class="QDockWidget" name="dockWidget_2"> + <widget class="QDockWidget" name="dockWidget_left"> <attribute name="dockWidgetArea"> <number>1</number> </attribute> @@ -83,20 +56,43 @@ <item> <widget class="QPushButton" name="b_update"> <property name="text"> - <string>update</string> + <string>update (search Cams)</string> </property> </widget> </item> <item> <widget class="QTableWidget" name="tw_cams"> - <property name="columnCount"> - <number>2</number> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="textElideMode"> + <enum>Qt::ElideNone</enum> </property> <attribute name="horizontalHeaderVisible"> - <bool>false</bool> + <bool>true</bool> + </attribute> + <attribute name="verticalHeaderVisible"> + <bool>true</bool> + </attribute> + <attribute name="verticalHeaderStretchLastSection"> + <bool>true</bool> </attribute> - <column/> - <column/> + </widget> + </item> + </layout> + </widget> + </widget> + <widget class="QDockWidget" name="dockWidget_right"> + <attribute name="dockWidgetArea"> + <number>2</number> + </attribute> + <widget class="QWidget" name="dockWidgetContents_3"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QPushButton" name="b_openclose"> + <property name="text"> + <string>open</string> + </property> </widget> </item> </layout> diff --git a/recorder/src/utils.cpp b/recorder/src/utils.cpp index 62aec564a525fb9fbcbe82522561e85f323c86ac..eaa904fd4b84bac1cfb9b99755a0e0b36e5fcd78 100644 --- a/recorder/src/utils.cpp +++ b/recorder/src/utils.cpp @@ -1,8 +1,11 @@ #include "opencv2/core/version.hpp" +#include <random> + #include "mainwindow.h" #include "VimbaCPP/Include/VimbaCPP.h" #include <QString> +#include <QDebug> const int APP_VERSION_MAJOR = 0; @@ -32,7 +35,8 @@ const QString errorCodeToMessage( VmbError_t err ) switch( err ) { default: msg += "Unknown"; break; - case VmbErrorSuccess: msg = ""; break; + case VmbErrorNothing: msg = ""; break; + case VmbErrorSuccess: msg = "Success"; break; case VmbErrorInternalFault: msg += "Unexpected fault in VmbApi or driver."; break; case VmbErrorApiNotStarted: msg += "API not started."; break; case VmbErrorNotFound: msg += "Not found."; break; @@ -55,3 +59,14 @@ const QString errorCodeToMessage( VmbError_t err ) return msg; } +QString randomString() +{ + QStringList list{"a", "b", "c", "d", "e", "f", "g"}; + //, "h", "i", "j", "k", "l", "m"}; + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(list.begin(), list.end(), g); + QString randomString = list.join(""); + qDebug() << "Random string:" << randomString; + return randomString; +} diff --git a/recorder/src/utils.h b/recorder/src/utils.h index 5df483302929bbc66fff9b89d8dbbded9e329179..1efdd380a03808edcb2cd80246ebf0d4eaef8155 100644 --- a/recorder/src/utils.h +++ b/recorder/src/utils.h @@ -7,5 +7,6 @@ const QString getVersionString(); const QString errorCodeToMessage( VmbError_t ); +QString randomString(); #endif