Properly utilized namespaces for the GUI related classes

remotes/origin/HEAD
markuspg 10 years ago
parent 5e695a67d7
commit b514858e96

@ -21,8 +21,8 @@
#include <QApplication> #include <QApplication>
int main( int argc, char *argv[] ) { int main( int argc, char *argv[] ) {
QApplication a( argc, argv ); QApplication a{ argc, argv };
lcMainWindow w; lc::MainWindow w;
w.show(); w.show();
return a.exec(); return a.exec();

@ -22,7 +22,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <QInputDialog> #include <QInputDialog>
lcMainWindow::lcMainWindow( QWidget *argParent ) : lc::MainWindow::MainWindow( QWidget *argParent ) :
QMainWindow{ argParent }, QMainWindow{ argParent },
icons{ new QPixmap[ icons_t::ICON_QUANTITY ] }, icons{ new QPixmap[ icons_t::ICON_QUANTITY ] },
ui{ new Ui::MainWindow } ui{ new Ui::MainWindow }
@ -35,18 +35,19 @@ lcMainWindow::lcMainWindow( QWidget *argParent ) :
SetupWidgets(); SetupWidgets();
if ( valid_items ) { if ( valid_items ) {
gui_update_timer = new QTimer{ this }; 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 ); gui_update_timer->start( 500 );
} }
} }
lcMainWindow::~lcMainWindow() { lc::MainWindow::~MainWindow() {
delete ui; delete ui;
delete valid_items; delete valid_items;
delete[] icons; delete[] icons;
} }
bool lcMainWindow::CheckIfUserIsAdmin() { bool lc::MainWindow::CheckIfUserIsAdmin() {
// Query the current user's name or give an error if this fails // Query the current user's name or give an error if this fails
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString userName{ "" }; QString userName{ "" };
@ -81,7 +82,7 @@ bool lcMainWindow::CheckIfUserIsAdmin() {
return false; return false;
} }
void lcMainWindow::DisableDisfunctionalWidgets() { void lc::MainWindow::DisableDisfunctionalWidgets() {
// Disable all functions relying on the labcontrol installation directory if it is not available // Disable all functions relying on the labcontrol installation directory if it is not available
if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) { if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) {
ui->CBClientNames->setEnabled( false ); 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 ) ) { if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) {
return; 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 ) ) { if ( !( index == 0 ) ) {
QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/webcam_display" }; QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/webcam_display" };
QStringList arguments; 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(); 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 * 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() }; 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(); QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { 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() }; QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() };
file_dialog->setFileMode( QFileDialog::Directory ); file_dialog->setFileMode( QFileDialog::Directory );
file_dialog->setOption( QFileDialog::DontUseNativeDialog, true ); file_dialog->setOption( QFileDialog::DontUseNativeDialog, true );
@ -267,7 +268,7 @@ void lcMainWindow::on_PBChooseFile_clicked() {
delete file_dialog; 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 ); 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(); QVector< lcClient* > *clients = lablib->GetClients();
for ( auto s : *clients ) { 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) // 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; bool executeOnEveryClient = true;
@ -334,7 +335,7 @@ void lcMainWindow::on_PBExecute_clicked() {
clients = nullptr; 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" }; QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/scripts/kill_zLeaf_labcontrol2.sh" };
// Start the process // Start the process
@ -349,7 +350,7 @@ void lcMainWindow::on_PBKillLocalzLeaf_clicked() {
ui->PTEDebugMessages->appendPlainText( "[DEBUG] " + program ); ui->PTEDebugMessages->appendPlainText( "[DEBUG] " + program );
} }
void lcMainWindow::on_PBKillzLeaf_clicked() { void lc::MainWindow::on_PBKillzLeaf_clicked() {
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); 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 ); 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 ) { 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 // Determine the correct user to be used
QString * userToBeUsed = nullptr; QString * userToBeUsed = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) { if ( ui->RBUseUserRoot->isChecked() ) {
@ -379,7 +380,7 @@ void lcMainWindow::on_PBOpenFilesystem_clicked() {
delete userToBeUsed; delete userToBeUsed;
} }
void lcMainWindow::on_PBOpenTerminal_clicked() { void lc::MainWindow::on_PBOpenTerminal_clicked() {
QString *tempPublickeyPathUser = nullptr; QString *tempPublickeyPathUser = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) { if ( ui->RBUseUserRoot->isChecked() ) {
tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ); 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." ), QFileDialog *fileDialog = new QFileDialog{ this, tr( "Please choose a payment file to print." ),
QDir::homePath(), "*.pay" }; QDir::homePath(), "*.pay" };
fileDialog->setFileMode( QFileDialog::ExistingFile ); fileDialog->setFileMode( QFileDialog::ExistingFile );
@ -416,7 +417,7 @@ void lcMainWindow::on_PBPrintPaymentFileManually_clicked() {
delete fileDialog; delete fileDialog;
} }
void lcMainWindow::on_PBRunzLeaf_clicked() { void lc::MainWindow::on_PBRunzLeaf_clicked() {
// Show an error message, if no zTree version was chosen yet // Show an error message, if no zTree version was chosen yet
if ( ui->CBzLeafVersion->currentIndex() == 0 ) { 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 }; 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(); lablib->ShowOrsee();
} }
void lcMainWindow::on_PBShowPreprints_clicked() { void lc::MainWindow::on_PBShowPreprints_clicked() {
lablib->ShowPreprints(); lablib->ShowPreprints();
} }
void lcMainWindow::on_PBShowSessions_clicked() { void lc::MainWindow::on_PBShowSessions_clicked() {
QWidget *sessionDisplay = new lcSessionDisplay{ lablib->GetSessionsModel(), this }; QWidget *sessionDisplay = new SessionDisplay{ lablib->GetSessionsModel(), this };
sessionDisplay->setWindowFlags( Qt::Window ); sessionDisplay->setWindowFlags( Qt::Window );
sessionDisplay->show(); 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(); QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ),
* const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); * 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 // Show an error message, if no z-Leaf version was chosen yet
if ( ui->CBzLeafVersion->currentIndex() == 0 ) { 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 ); 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; 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 // Show an error message, if no z-Leaf version was chosen yet
if ( ui->CBzLeafVersion->currentIndex() == 0 ) { 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 }; 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; delete zLeafVersion;
} }
void lcMainWindow::on_PBStartzTree_clicked() { void lc::MainWindow::on_PBStartzTree_clicked() {
lcSessionStarter *sessionStarter = new lcSessionStarter{ lablib, ui->PTEDebugMessages, this }; SessionStarter *sessionStarter = new SessionStarter{ lablib, ui->PTEDebugMessages, this };
sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->setWindowFlags( Qt::Window );
sessionStarter->show(); 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 // // Show an error message, if no zTree version was chosen yet
// if (ui->CBzTreeVersion->currentIndex() == 0) { // 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 }; // 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(); // lablib->StartNewZTreeInstance();
} }
void lcMainWindow::on_PBViewDesktop_clicked() { void lc::MainWindow::on_PBViewDesktop_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { 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 ) { if ( checked ) {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] RBUseLocalUser got toggled." ) ); 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 // Fill the 'CBClientNames' with possible client names and the 'TVClients' with the clients
const QVector< lcClient* > *clients = lablib->GetClients(); const QVector< lcClient* > *clients = lablib->GetClients();
if ( !( clients == nullptr ) ) { if ( !( clients == nullptr ) ) {
@ -732,7 +735,7 @@ void lcMainWindow::SetupWidgets() {
"This version of Labcontrol was compiled on " + date + " at " + time + "." ); "This version of Labcontrol was compiled on " + date + " at " + time + "." );
} }
void lcMainWindow::UpdateClientsTableView() { void lc::MainWindow::UpdateClientsTableView() {
for ( auto s : *valid_items ) { for ( auto s : *valid_items ) {
state_t state = static_cast< lcClient * >( s->data( Qt::UserRole ).value<void *>() )->GetClientState(); state_t state = static_cast< lcClient * >( s->data( Qt::UserRole ).value<void *>() )->GetClientState();
switch ( state ) { switch ( state ) {

@ -39,6 +39,8 @@ enum class icons_t : unsigned short int { UNKNOWN, OFF, DOWN, BOOT, ON, ZLEAF, I
#include <QTimer> #include <QTimer>
#include <QVector> #include <QVector>
namespace lc {
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
@ -47,13 +49,12 @@ class MainWindow;
/*! /*!
This class represents the graphical user interface and all connected functionality. This class represents the graphical user interface and all connected functionality.
*/ */
class lcMainWindow : public QMainWindow class MainWindow : public QMainWindow {
{
Q_OBJECT Q_OBJECT
public: public:
explicit lcMainWindow( QWidget *argParent = 0 ); explicit MainWindow( QWidget *argParent = 0 );
~lcMainWindow(); ~MainWindow();
private slots: private slots:
void on_CBWebcamChooser_activated(int index); void on_CBWebcamChooser_activated(int index);
@ -109,4 +110,6 @@ private:
QVector<QStandardItem *> *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()' QVector<QStandardItem *> *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 #endif // MAINWINDOW_H

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>lc::MainWindow</class>
<widget class="QMainWindow" name="MainWindow"> <widget class="QMainWindow" name="lc::MainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

@ -20,7 +20,8 @@
#include "sessiondisplay.h" #include "sessiondisplay.h"
#include "ui_sessiondisplay.h" #include "ui_sessiondisplay.h"
lcSessionDisplay::lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidget *argParent ) : lc::SessionDisplay::SessionDisplay( QAbstractTableModel *argSessionsModel,
QWidget *argParent ) :
QWidget{ argParent }, QWidget{ argParent },
ui{ new Ui::SessionDisplay } ui{ new Ui::SessionDisplay }
{ {
@ -28,6 +29,6 @@ lcSessionDisplay::lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidg
ui->TVSessions->setModel( argSessionsModel ); ui->TVSessions->setModel( argSessionsModel );
} }
lcSessionDisplay::~lcSessionDisplay() { lc::SessionDisplay::~SessionDisplay() {
delete ui; delete ui;
} }

@ -23,20 +23,24 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QWidget> #include <QWidget>
namespace lc {
namespace Ui { namespace Ui {
class SessionDisplay; class SessionDisplay;
} }
class lcSessionDisplay : public QWidget class SessionDisplay : public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit lcSessionDisplay( QAbstractTableModel *argSessionsModel, QWidget *argParent = nullptr ); explicit SessionDisplay( QAbstractTableModel *argSessionsModel,
~lcSessionDisplay(); QWidget *argParent = nullptr );
~SessionDisplay();
private: private:
Ui::SessionDisplay *ui = nullptr; Ui::SessionDisplay *ui = nullptr;
}; };
}
#endif // SESSIONDISPLAY_H #endif // SESSIONDISPLAY_H

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>SessionDisplay</class> <class>lc::SessionDisplay</class>
<widget class="QWidget" name="SessionDisplay"> <widget class="QWidget" name="lc::SessionDisplay">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

@ -20,21 +20,21 @@
#include "sessionstarter.h" #include "sessionstarter.h"
#include "ui_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 }, QWidget{ parent },
debugMessagesTextEdit { argDebugMessagesTextEdit }, debugMessagesTextEdit { argDebugMessagesTextEdit },
lablib{ argLablib }, lablib{ argLablib },
ui{ new Ui::lcSessionStarter } ui{ new Ui::SessionStarter }
{ {
ui->setupUi( this ); ui->setupUi( this );
this->SetupWidgets(); this->SetupWidgets();
} }
lcSessionStarter::~lcSessionStarter() { lc::SessionStarter::~SessionStarter() {
delete ui; delete ui;
} }
void lcSessionStarter::GetNewDataTargetPath() { void lc::SessionStarter::GetNewDataTargetPath() {
QFileDialog *file_dialog = new QFileDialog{ this }; QFileDialog *file_dialog = new QFileDialog{ this };
file_dialog->setFileMode( QFileDialog::Directory ); file_dialog->setFileMode( QFileDialog::Directory );
file_dialog->setDirectory( QDir::homePath() ); file_dialog->setDirectory( QDir::homePath() );
@ -49,7 +49,7 @@ void lcSessionStarter::GetNewDataTargetPath() {
delete file_dialog; 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 ) { if ( ui->CBDataTargetPath->currentIndex() == 0 ) {
emit NewDataTargetPathRequested(); emit NewDataTargetPathRequested();
return; return;
@ -58,21 +58,21 @@ void lcSessionStarter::on_CBDataTargetPath_activated(const QString &arg1) {
lablib->SetChosenZTreeDataTargetPath( arg1 ); lablib->SetChosenZTreeDataTargetPath( arg1 );
} }
void lcSessionStarter::on_CBReceiptsHeader_activated(const QString &arg1) { void lc::SessionStarter::on_CBReceiptsHeader_activated(const QString &arg1) {
ui->CBReceiptsHeader->setStyleSheet( "" ); ui->CBReceiptsHeader->setStyleSheet( "" );
lablib->SetChosenLaTeXHeader( arg1 ); lablib->SetChosenLaTeXHeader( arg1 );
} }
void lcSessionStarter::on_CBReplaceParticipantName_currentTextChanged(const QString &arg1) { void lc::SessionStarter::on_CBReplaceParticipantName_currentTextChanged(const QString &arg1) {
lablib->SetAnonymousReceiptsPlaceholder( arg1 ); lablib->SetAnonymousReceiptsPlaceholder( arg1 );
} }
void lcSessionStarter::on_CBzTreeVersion_activated(const QString &arg1) { void lc::SessionStarter::on_CBzTreeVersion_activated(const QString &arg1) {
ui->CBzTreeVersion->setStyleSheet( "" ); ui->CBzTreeVersion->setStyleSheet( "" );
lablib->SetChosenZTreeVersion( arg1 ); lablib->SetChosenZTreeVersion( arg1 );
} }
void lcSessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) { void lc::SessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) {
// Enable or disable the corresponding widgets // Enable or disable the corresponding widgets
if ( checked ) { if ( checked ) {
ui->LReplaceParticipantName->setEnabled( true ); ui->LReplaceParticipantName->setEnabled( true );
@ -90,17 +90,17 @@ void lcSessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) {
ui->ChBPrintanonymousreceipts->setStyleSheet( "" ); ui->ChBPrintanonymousreceipts->setStyleSheet( "" );
} }
void lcSessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) { void lc::SessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) {
ui->ChBReceiptsforLocalClients->setStyleSheet( "" ); ui->ChBReceiptsforLocalClients->setStyleSheet( "" );
lablib->SetPrintReceiptsForLocalClients( checked ); lablib->SetPrintReceiptsForLocalClients( checked );
} }
void lcSessionStarter::on_SBPort_editingFinished() { void lc::SessionStarter::on_SBPort_editingFinished() {
ui->SBPort->setStyleSheet( "" ); ui->SBPort->setStyleSheet( "" );
lablib->SetChosenZTreePort( ui->SBPort->value() ); lablib->SetChosenZTreePort( ui->SBPort->value() );
} }
void lcSessionStarter::SetupWidgets() { void lc::SessionStarter::SetupWidgets() {
ui->SBPort->setValue( lablib->GetChosenZTreePort() ); ui->SBPort->setValue( lablib->GetChosenZTreePort() );
// Fill the 'CBzTreeVersion' combobox with known entries from the lablib class // 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( QDir::homePath() );
ui->CBDataTargetPath->addItem( QString{ QDir::homePath() + "/zTreeData" } ); ui->CBDataTargetPath->addItem( QString{ QDir::homePath() + "/zTreeData" } );
ui->CBDataTargetPath->setCurrentIndex( 2 ); 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 // Since filling a QComboBox does not emit the 'activated' signal, initially set some variables manually
lablib->SetChosenLaTeXHeader( ui->CBReceiptsHeader->currentText() ); lablib->SetChosenLaTeXHeader( ui->CBReceiptsHeader->currentText() );

@ -25,17 +25,18 @@
#include <QFileDialog> #include <QFileDialog>
#include <QWidget> #include <QWidget>
namespace lc {
namespace Ui { namespace Ui {
class lcSessionStarter; class SessionStarter;
} }
class lcSessionStarter : public QWidget class SessionStarter : public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit lcSessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent = nullptr ); explicit SessionStarter( lcLablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent = nullptr );
~lcSessionStarter(); ~SessionStarter();
//! This gets thrown as an exception if this class is created even if it shouldn't //! 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). //! (because no installed z-Tree instances could be detected).
@ -44,7 +45,7 @@ public:
private: private:
QPlainTextEdit * const debugMessagesTextEdit = nullptr; QPlainTextEdit * const debugMessagesTextEdit = nullptr;
lcLablib * const lablib = nullptr; lcLablib * const lablib = nullptr;
Ui::lcSessionStarter *ui; Ui::SessionStarter *ui = nullptr;
void SetupWidgets(); void SetupWidgets();
@ -64,4 +65,6 @@ signals:
void NewDataTargetPathRequested(); void NewDataTargetPathRequested();
}; };
}
#endif // SESSIONSTARTER_H #endif // SESSIONSTARTER_H

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>lcSessionStarter</class> <class>lc::SessionStarter</class>
<widget class="QWidget" name="lcSessionStarter"> <widget class="QWidget" name="lc::SessionStarter">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

Loading…
Cancel
Save