diff --git a/src/main.cpp b/src/main.cpp index 1e07718..e36c38d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,8 +21,8 @@ #include int main( int argc, char *argv[] ) { - QApplication a( argc, argv ); - lcMainWindow w; + QApplication a{ argc, argv }; + lc::MainWindow w; w.show(); return a.exec(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3b59e19..a664fa5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -22,7 +22,7 @@ #include #include -lcMainWindow::lcMainWindow( QWidget *argParent ) : +lc::MainWindow::MainWindow( QWidget *argParent ) : QMainWindow{ argParent }, icons{ new QPixmap[ icons_t::ICON_QUANTITY ] }, ui{ new Ui::MainWindow } @@ -35,18 +35,19 @@ lcMainWindow::lcMainWindow( QWidget *argParent ) : SetupWidgets(); if ( valid_items ) { gui_update_timer = new QTimer{ this }; - connect(gui_update_timer, &QTimer::timeout, this, &lcMainWindow::UpdateClientsTableView ); + connect( gui_update_timer, &QTimer::timeout, + this, &MainWindow::UpdateClientsTableView ); gui_update_timer->start( 500 ); } } -lcMainWindow::~lcMainWindow() { +lc::MainWindow::~MainWindow() { delete ui; delete valid_items; delete[] icons; } -bool lcMainWindow::CheckIfUserIsAdmin() { +bool lc::MainWindow::CheckIfUserIsAdmin() { // Query the current user's name or give an error if this fails QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString userName{ "" }; @@ -81,7 +82,7 @@ bool lcMainWindow::CheckIfUserIsAdmin() { return false; } -void lcMainWindow::DisableDisfunctionalWidgets() { +void lc::MainWindow::DisableDisfunctionalWidgets() { // Disable all functions relying on the labcontrol installation directory if it is not available if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) { ui->CBClientNames->setEnabled( false ); @@ -192,7 +193,7 @@ void lcMainWindow::DisableDisfunctionalWidgets() { } } -void lcMainWindow::LoadIconPixmaps() { +void lc::MainWindow::LoadIconPixmaps() { if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) { return; } @@ -214,7 +215,7 @@ void lcMainWindow::LoadIconPixmaps() { } } -void lcMainWindow::on_CBWebcamChooser_activated( int index ) { +void lc::MainWindow::on_CBWebcamChooser_activated( int index ) { if ( !( index == 0 ) ) { QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/webcam_display" }; QStringList arguments; @@ -227,7 +228,7 @@ void lcMainWindow::on_CBWebcamChooser_activated( int index ) { } } -void lcMainWindow::on_PBBeamFile_clicked() { +void lc::MainWindow::on_PBBeamFile_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); const QString fileToBeam{ ui->LEFilePath->text() }; @@ -239,7 +240,7 @@ void lcMainWindow::on_PBBeamFile_clicked() { } } -void lcMainWindow::on_PBBoot_clicked() { +void lc::MainWindow::on_PBBoot_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { @@ -249,7 +250,7 @@ void lcMainWindow::on_PBBoot_clicked() { } } -void lcMainWindow::on_PBChooseFile_clicked() { +void lc::MainWindow::on_PBChooseFile_clicked() { QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() }; file_dialog->setFileMode( QFileDialog::Directory ); file_dialog->setOption( QFileDialog::DontUseNativeDialog, true ); @@ -267,7 +268,7 @@ void lcMainWindow::on_PBChooseFile_clicked() { delete file_dialog; } -void lcMainWindow::on_PBDeactivateScreensaver_clicked() { +void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { const QString * const publickey_path_user = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const user_name_on_clients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); QVector< lcClient* > *clients = lablib->GetClients(); for ( auto s : *clients ) { @@ -276,7 +277,7 @@ void lcMainWindow::on_PBDeactivateScreensaver_clicked() { } } -void lcMainWindow::on_PBExecute_clicked() { +void lc::MainWindow::on_PBExecute_clicked() { // This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up) bool executeOnEveryClient = true; @@ -334,7 +335,7 @@ void lcMainWindow::on_PBExecute_clicked() { clients = nullptr; } -void lcMainWindow::on_PBKillLocalzLeaf_clicked() { +void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/scripts/kill_zLeaf_labcontrol2.sh" }; // Start the process @@ -349,7 +350,7 @@ void lcMainWindow::on_PBKillLocalzLeaf_clicked() { ui->PTEDebugMessages->appendPlainText( "[DEBUG] " + program ); } -void lcMainWindow::on_PBKillzLeaf_clicked() { +void lc::MainWindow::on_PBKillzLeaf_clicked() { QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { @@ -360,7 +361,7 @@ void lcMainWindow::on_PBKillzLeaf_clicked() { } } -void lcMainWindow::on_PBOpenFilesystem_clicked() { +void lc::MainWindow::on_PBOpenFilesystem_clicked() { // Determine the correct user to be used QString * userToBeUsed = nullptr; if ( ui->RBUseUserRoot->isChecked() ) { @@ -379,7 +380,7 @@ void lcMainWindow::on_PBOpenFilesystem_clicked() { delete userToBeUsed; } -void lcMainWindow::on_PBOpenTerminal_clicked() { +void lc::MainWindow::on_PBOpenTerminal_clicked() { QString *tempPublickeyPathUser = nullptr; if ( ui->RBUseUserRoot->isChecked() ) { tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ); @@ -397,7 +398,7 @@ void lcMainWindow::on_PBOpenTerminal_clicked() { } } -void lcMainWindow::on_PBPrintPaymentFileManually_clicked() { +void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() { QFileDialog *fileDialog = new QFileDialog{ this, tr( "Please choose a payment file to print." ), QDir::homePath(), "*.pay" }; fileDialog->setFileMode( QFileDialog::ExistingFile ); @@ -416,7 +417,7 @@ void lcMainWindow::on_PBPrintPaymentFileManually_clicked() { delete fileDialog; } -void lcMainWindow::on_PBRunzLeaf_clicked() { +void lc::MainWindow::on_PBRunzLeaf_clicked() { // Show an error message, if no zTree version was chosen yet if ( ui->CBzLeafVersion->currentIndex() == 0 ) { QMessageBox messageBox{ QMessageBox::Warning, tr( "Unset z-Leaf version" ), tr( "There is no z-Leaf version chosen yet. Please choose one." ), QMessageBox::Ok, this }; @@ -451,22 +452,23 @@ void lcMainWindow::on_PBRunzLeaf_clicked() { } } -void lcMainWindow::on_PBShowORSEE_clicked() { +void lc::MainWindow::on_PBShowORSEE_clicked() { lablib->ShowOrsee(); } -void lcMainWindow::on_PBShowPreprints_clicked() { +void lc::MainWindow::on_PBShowPreprints_clicked() { lablib->ShowPreprints(); } -void lcMainWindow::on_PBShowSessions_clicked() { - QWidget *sessionDisplay = new lcSessionDisplay{ lablib->GetSessionsModel(), this }; +void lc::MainWindow::on_PBShowSessions_clicked() { + QWidget *sessionDisplay = new SessionDisplay{ lablib->GetSessionsModel(), this }; sessionDisplay->setWindowFlags( Qt::Window ); sessionDisplay->show(); - connect( sessionDisplay, &lcSessionDisplay::destroyed, sessionDisplay, &lcSessionDisplay::deleteLater ); + connect( sessionDisplay, &SessionDisplay::destroyed, + sessionDisplay, &SessionDisplay::deleteLater ); } -void lcMainWindow::on_PBShutdown_clicked() { +void lc::MainWindow::on_PBShutdown_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); @@ -478,7 +480,7 @@ void lcMainWindow::on_PBShutdown_clicked() { } } -void lcMainWindow::on_PBStartLocalzLeaf_clicked() { +void lc::MainWindow::on_PBStartLocalzLeaf_clicked() { // Show an error message, if no z-Leaf version was chosen yet if ( ui->CBzLeafVersion->currentIndex() == 0 ) { QMessageBox::information( this, tr( "Unset z-Leaf version" ), tr( "There is no z-Leaf version chosen yet. Please choose one." ), QMessageBox::Ok ); @@ -518,7 +520,7 @@ void lcMainWindow::on_PBStartLocalzLeaf_clicked() { delete messageBox; } -void lcMainWindow::on_PBStartzLeaf_clicked() { +void lc::MainWindow::on_PBStartzLeaf_clicked() { // Show an error message, if no z-Leaf version was chosen yet if ( ui->CBzLeafVersion->currentIndex() == 0 ) { QMessageBox messageBox{ QMessageBox::Warning, tr( "Unset z-Leaf version" ), tr( "There is no z-Leaf version chosen yet. Please choose one." ), QMessageBox::Ok, this }; @@ -540,11 +542,12 @@ void lcMainWindow::on_PBStartzLeaf_clicked() { delete zLeafVersion; } -void lcMainWindow::on_PBStartzTree_clicked() { - lcSessionStarter *sessionStarter = new lcSessionStarter{ lablib, ui->PTEDebugMessages, this }; +void lc::MainWindow::on_PBStartzTree_clicked() { + SessionStarter *sessionStarter = new SessionStarter{ lablib, ui->PTEDebugMessages, this }; sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->show(); - connect( sessionStarter, &lcSessionStarter::destroyed, sessionStarter, &lcSessionStarter::deleteLater ); + connect( sessionStarter, &SessionStarter::destroyed, + sessionStarter, &SessionStarter::deleteLater ); // // Show an error message, if no zTree version was chosen yet // if (ui->CBzTreeVersion->currentIndex() == 0) { // QMessageBox messageBox{ QMessageBox::Warning, tr("Unset zTree version"), tr("There is no zTree version chosen yet. Please choose one."), QMessageBox::Ok, this }; @@ -586,7 +589,7 @@ void lcMainWindow::on_PBStartzTree_clicked() { // lablib->StartNewZTreeInstance(); } -void lcMainWindow::on_PBViewDesktop_clicked() { +void lc::MainWindow::on_PBViewDesktop_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { @@ -596,13 +599,13 @@ void lcMainWindow::on_PBViewDesktop_clicked() { } } -void lcMainWindow::on_RBUseLocalUser_toggled(bool checked) { +void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) { if ( checked ) { ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] RBUseLocalUser got toggled." ) ); } } -void lcMainWindow::SetupWidgets() { +void lc::MainWindow::SetupWidgets() { // Fill the 'CBClientNames' with possible client names and the 'TVClients' with the clients const QVector< lcClient* > *clients = lablib->GetClients(); if ( !( clients == nullptr ) ) { @@ -732,7 +735,7 @@ void lcMainWindow::SetupWidgets() { "This version of Labcontrol was compiled on " + date + " at " + time + "." ); } -void lcMainWindow::UpdateClientsTableView() { +void lc::MainWindow::UpdateClientsTableView() { for ( auto s : *valid_items ) { state_t state = static_cast< lcClient * >( s->data( Qt::UserRole ).value() )->GetClientState(); switch ( state ) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 37d1116..e5ba8e7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -39,6 +39,8 @@ enum class icons_t : unsigned short int { UNKNOWN, OFF, DOWN, BOOT, ON, ZLEAF, I #include #include +namespace lc { + namespace Ui { class MainWindow; } @@ -47,13 +49,12 @@ class MainWindow; /*! This class represents the graphical user interface and all connected functionality. */ -class lcMainWindow : public QMainWindow -{ +class MainWindow : public QMainWindow { Q_OBJECT public: - explicit lcMainWindow( QWidget *argParent = 0 ); - ~lcMainWindow(); + explicit MainWindow( QWidget *argParent = 0 ); + ~MainWindow(); private slots: void on_CBWebcamChooser_activated(int index); @@ -109,4 +110,6 @@ private: QVector *valid_items = nullptr; //! Stores all valid Client instances displayed by the table view, its main use is as iterable object for 'update_clients_table_view()' }; +} + #endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 5e6d54d..84c2ee3 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1,7 +1,7 @@ - MainWindow - + lc::MainWindow + 0 diff --git a/src/sessiondisplay.cpp b/src/sessiondisplay.cpp index 9922fd4..77a9ff2 100644 --- a/src/sessiondisplay.cpp +++ b/src/sessiondisplay.cpp @@ -20,7 +20,8 @@ #include "sessiondisplay.h" #include "ui_sessiondisplay.h" -lcSessionDisplay::lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidget *argParent ) : +lc::SessionDisplay::SessionDisplay( QAbstractTableModel *argSessionsModel, + QWidget *argParent ) : QWidget{ argParent }, ui{ new Ui::SessionDisplay } { @@ -28,6 +29,6 @@ lcSessionDisplay::lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidg ui->TVSessions->setModel( argSessionsModel ); } -lcSessionDisplay::~lcSessionDisplay() { +lc::SessionDisplay::~SessionDisplay() { delete ui; } diff --git a/src/sessiondisplay.h b/src/sessiondisplay.h index 1e5aef4..a8e72af 100644 --- a/src/sessiondisplay.h +++ b/src/sessiondisplay.h @@ -23,20 +23,24 @@ #include #include +namespace lc { + namespace Ui { class SessionDisplay; } -class lcSessionDisplay : public QWidget -{ +class SessionDisplay : public QWidget { Q_OBJECT public: - explicit lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidget *argParent = nullptr ); - ~lcSessionDisplay(); + explicit SessionDisplay( QAbstractTableModel *argSessionsModel, + QWidget *argParent = nullptr ); + ~SessionDisplay(); private: Ui::SessionDisplay *ui = nullptr; }; +} + #endif // SESSIONDISPLAY_H diff --git a/src/sessiondisplay.ui b/src/sessiondisplay.ui index d619783..aa796c1 100644 --- a/src/sessiondisplay.ui +++ b/src/sessiondisplay.ui @@ -1,7 +1,7 @@ - SessionDisplay - + lc::SessionDisplay + 0 diff --git a/src/sessionstarter.cpp b/src/sessionstarter.cpp index 2ffefdc..cfce1eb 100644 --- a/src/sessionstarter.cpp +++ b/src/sessionstarter.cpp @@ -20,21 +20,21 @@ #include "sessionstarter.h" #include "ui_sessionstarter.h" -lcSessionStarter::lcSessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent ) : +lc::SessionStarter::SessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent ) : QWidget{ parent }, debugMessagesTextEdit { argDebugMessagesTextEdit }, lablib{ argLablib }, - ui{ new Ui::lcSessionStarter } + ui{ new Ui::SessionStarter } { ui->setupUi( this ); this->SetupWidgets(); } -lcSessionStarter::~lcSessionStarter() { +lc::SessionStarter::~SessionStarter() { delete ui; } -void lcSessionStarter::GetNewDataTargetPath() { +void lc::SessionStarter::GetNewDataTargetPath() { QFileDialog *file_dialog = new QFileDialog{ this }; file_dialog->setFileMode( QFileDialog::Directory ); file_dialog->setDirectory( QDir::homePath() ); @@ -49,7 +49,7 @@ void lcSessionStarter::GetNewDataTargetPath() { delete file_dialog; } -void lcSessionStarter::on_CBDataTargetPath_activated(const QString &arg1) { +void lc::SessionStarter::on_CBDataTargetPath_activated(const QString &arg1) { if ( ui->CBDataTargetPath->currentIndex() == 0 ) { emit NewDataTargetPathRequested(); return; @@ -58,21 +58,21 @@ void lcSessionStarter::on_CBDataTargetPath_activated(const QString &arg1) { lablib->SetChosenZTreeDataTargetPath( arg1 ); } -void lcSessionStarter::on_CBReceiptsHeader_activated(const QString &arg1) { +void lc::SessionStarter::on_CBReceiptsHeader_activated(const QString &arg1) { ui->CBReceiptsHeader->setStyleSheet( "" ); lablib->SetChosenLaTeXHeader( arg1 ); } -void lcSessionStarter::on_CBReplaceParticipantName_currentTextChanged(const QString &arg1) { +void lc::SessionStarter::on_CBReplaceParticipantName_currentTextChanged(const QString &arg1) { lablib->SetAnonymousReceiptsPlaceholder( arg1 ); } -void lcSessionStarter::on_CBzTreeVersion_activated(const QString &arg1) { +void lc::SessionStarter::on_CBzTreeVersion_activated(const QString &arg1) { ui->CBzTreeVersion->setStyleSheet( "" ); lablib->SetChosenZTreeVersion( arg1 ); } -void lcSessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) { +void lc::SessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) { // Enable or disable the corresponding widgets if ( checked ) { ui->LReplaceParticipantName->setEnabled( true ); @@ -90,17 +90,17 @@ void lcSessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) { ui->ChBPrintanonymousreceipts->setStyleSheet( "" ); } -void lcSessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) { +void lc::SessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) { ui->ChBReceiptsforLocalClients->setStyleSheet( "" ); lablib->SetPrintReceiptsForLocalClients( checked ); } -void lcSessionStarter::on_SBPort_editingFinished() { +void lc::SessionStarter::on_SBPort_editingFinished() { ui->SBPort->setStyleSheet( "" ); lablib->SetChosenZTreePort( ui->SBPort->value() ); } -void lcSessionStarter::SetupWidgets() { +void lc::SessionStarter::SetupWidgets() { ui->SBPort->setValue( lablib->GetChosenZTreePort() ); // Fill the 'CBzTreeVersion' combobox with known entries from the lablib class @@ -138,7 +138,8 @@ void lcSessionStarter::SetupWidgets() { ui->CBDataTargetPath->addItem( QDir::homePath() ); ui->CBDataTargetPath->addItem( QString{ QDir::homePath() + "/zTreeData" } ); ui->CBDataTargetPath->setCurrentIndex( 2 ); - connect( this, &lcSessionStarter::NewDataTargetPathRequested, this, &lcSessionStarter::GetNewDataTargetPath ); + connect( this, &SessionStarter::NewDataTargetPathRequested, + this, &SessionStarter::GetNewDataTargetPath ); // Since filling a QComboBox does not emit the 'activated' signal, initially set some variables manually lablib->SetChosenLaTeXHeader( ui->CBReceiptsHeader->currentText() ); diff --git a/src/sessionstarter.h b/src/sessionstarter.h index 0b1f5cf..f464842 100644 --- a/src/sessionstarter.h +++ b/src/sessionstarter.h @@ -25,17 +25,18 @@ #include #include +namespace lc { + namespace Ui { -class lcSessionStarter; +class SessionStarter; } -class lcSessionStarter : public QWidget -{ +class SessionStarter : public QWidget { Q_OBJECT public: - explicit lcSessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent = nullptr ); - ~lcSessionStarter(); + explicit SessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent = nullptr ); + ~SessionStarter(); //! This gets thrown as an exception if this class is created even if it shouldn't //! (because no installed z-Tree instances could be detected). @@ -44,7 +45,7 @@ public: private: QPlainTextEdit * const debugMessagesTextEdit = nullptr; lcLablib * const lablib = nullptr; - Ui::lcSessionStarter *ui; + Ui::SessionStarter *ui = nullptr; void SetupWidgets(); @@ -64,4 +65,6 @@ signals: void NewDataTargetPathRequested(); }; +} + #endif // SESSIONSTARTER_H diff --git a/src/sessionstarter.ui b/src/sessionstarter.ui index fc5d115..521723d 100644 --- a/src/sessionstarter.ui +++ b/src/sessionstarter.ui @@ -1,7 +1,7 @@ - lcSessionStarter - + lc::SessionStarter + 0