Moved 'installedZTreeVersions' into 'lc::Settings'

remotes/origin/HEAD
markuspg 10 years ago
parent 01855a637b
commit 6c46208033

@ -71,7 +71,6 @@ lc::Lablib::~Lablib () {
} }
} }
delete clients; delete clients;
delete InstalledZTreeVersions;
delete occupiedPorts; delete occupiedPorts;
} }
@ -106,28 +105,6 @@ void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] LaTeX headers: %1" ).arg( installedLaTeXHeaders->join( " / " ) ) ); debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] LaTeX headers: %1" ).arg( installedLaTeXHeaders->join( " / " ) ) );
} }
} }
// Detect the installed zTree versions
if ( !settings->zTreeInstDir.isEmpty() ) {
QDir zTreeDirectory{ settings->zTreeInstDir, "zTree*", QDir::Name,
QDir::NoDotAndDotDot | QDir::Dirs
| QDir::Readable | QDir::CaseSensitive };
if ( zTreeDirectory.entryList().isEmpty() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "zTree not found" ),
tr( "No zTree installation found in '%1'. Running zTree will not be possible." )
.arg( settings->zTreeInstDir ), QMessageBox::Ok };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No zTree versions could be found in '%1'." )
.arg( settings->zTreeInstDir ) );
}
else {
InstalledZTreeVersions = new QStringList{ zTreeDirectory.entryList() };
InstalledZTreeVersions->replaceInStrings( "zTree_", "" );
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] zTree versions: %1" ).arg( InstalledZTreeVersions->join( " / " ) ) ) ;
}
}
} }
void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections ) { void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections ) {

@ -112,11 +112,6 @@ public:
* @return A pointer to a QStringList containing all available LaTeX headers * @return A pointer to a QStringList containing all available LaTeX headers
*/ */
QStringList *GetInstalledLaTeXHeaders () const {return installedLaTeXHeaders; } QStringList *GetInstalledLaTeXHeaders () const {return installedLaTeXHeaders; }
/** Returns a QStringList containing all available zTree versions of this system
*
* @return A pointer to a QStringList containing all available zTree versions
*/
QStringList *GetInstalledZTreeVersions () const { return InstalledZTreeVersions; }
void SetChosenZTreeDataTargetPath( const QString &argZTreeDataTargetPath ); void SetChosenZTreeDataTargetPath( const QString &argZTreeDataTargetPath );
void SetChosenZTreePort( const int &argPort ); void SetChosenZTreePort( const int &argPort );
//! Sets the default name of local zLeaf instances //! Sets the default name of local zLeaf instances
@ -157,7 +152,6 @@ private:
QPlainTextEdit *debugMessagesTextEdit = nullptr; //! This stores a pointer to the text edit in the debug tab to be able to write to it QPlainTextEdit *debugMessagesTextEdit = nullptr; //! This stores a pointer to the text edit in the debug tab to be able to write to it
int defaultReceiptIndex = 0; //! Stores the index of the LaTeX header to be displayed by default int defaultReceiptIndex = 0; //! Stores the index of the LaTeX header to be displayed by default
QStringList *installedLaTeXHeaders = nullptr; QStringList *installedLaTeXHeaders = nullptr;
QStringList *InstalledZTreeVersions = nullptr;
QSettings labSettings; QSettings labSettings;
NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients
QThread netstatThread; QThread netstatThread;

@ -1,4 +1,5 @@
#include <QDebug> #include <QDebug>
#include <QDir>
#include <QFile> #include <QFile>
#include <QProcessEnvironment> #include <QProcessEnvironment>
@ -90,11 +91,13 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
zTreeInstDir{ ReadSettingsItem( "ztree_installation_directory", zTreeInstDir{ ReadSettingsItem( "ztree_installation_directory",
"zTree will not be available.", "zTree will not be available.",
argSettings, true ) }, argSettings, true ) },
installedZTreeVersions{ DetectInstalledzTreeVersions() },
localzLeafName{ ReadSettingsItem( "local_zLeaf_name", localzLeafName{ ReadSettingsItem( "local_zLeaf_name",
"The local zLeaf default name will default to 'local'.", "The local zLeaf default name will default to 'local'.",
argSettings, false ) } argSettings, false ) }
{ {
qDebug() << "The following webcams where loaded:" << webcams; qDebug() << "The following webcams where loaded:" << webcams;
qDebug() << "Detected z-Tree versions" << installedZTreeVersions;
} }
bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString &argVariableName, bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString &argVariableName,
@ -108,6 +111,22 @@ bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString &
return true; return true;
} }
QStringList lc::Settings::DetectInstalledzTreeVersions() const {
QStringList tempInstzTreeVersions;
if ( !zTreeInstDir.isEmpty() ) {
QDir zTreeDirectory{ zTreeInstDir, "zTree_*", QDir::Name,
QDir::NoDotAndDotDot | QDir::Dirs
| QDir::Readable | QDir::CaseSensitive };
if ( zTreeDirectory.entryList().isEmpty() ) {
qWarning() << "No zTree versions could be found in" << zTreeInstDir;
} else {
tempInstzTreeVersions = zTreeDirectory.entryList();
tempInstzTreeVersions.replaceInStrings( "zTree_", "" );
}
}
return tempInstzTreeVersions;
}
QString lc::Settings::GetLocalUserName() { QString lc::Settings::GetLocalUserName() {
const QProcessEnvironment env{ QProcessEnvironment::systemEnvironment() }; const QProcessEnvironment env{ QProcessEnvironment::systemEnvironment() };
QString userName; QString userName;

@ -49,10 +49,12 @@ public:
const QString wmctrlCmd; const QString wmctrlCmd;
const QString xsetCmd; const QString xsetCmd;
const QString zTreeInstDir; const QString zTreeInstDir;
const QStringList installedZTreeVersions;
private: private:
static bool CheckPathAndComplain( const QString &argPath, const QString &argVariableName, static bool CheckPathAndComplain( const QString &argPath, const QString &argVariableName,
const QString &argMessage ); const QString &argMessage );
QStringList DetectInstalledzTreeVersions() const;
static QString GetLocalUserName(); static QString GetLocalUserName();
static QString ReadSettingsItem( const QString &argVariableName, static QString ReadSettingsItem( const QString &argVariableName,
const QString &argMessage, const QString &argMessage,

@ -654,8 +654,8 @@ void lc::MainWindow::SetupWidgets() {
} }
clients = nullptr; clients = nullptr;
const QStringList *zTreeEntries = lablib->GetInstalledZTreeVersions(); const QStringList &zTreeEntries = settings->installedZTreeVersions;
if ( zTreeEntries == nullptr ) { if ( zTreeEntries.isEmpty() ) {
ui->CBClientNames->setEnabled( false ); ui->CBClientNames->setEnabled( false );
ui->GBzTree->setEnabled( false ); ui->GBzTree->setEnabled( false );
ui->GLzLeafSettings->setEnabled( false ); ui->GLzLeafSettings->setEnabled( false );
@ -665,7 +665,7 @@ void lc::MainWindow::SetupWidgets() {
ui->PBStartzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false );
} else { } else {
ui->CBzLeafVersion->addItem( "NONE" ); ui->CBzLeafVersion->addItem( "NONE" );
for ( auto zTreeVersionString : *zTreeEntries ) { for ( const auto &zTreeVersionString : zTreeEntries ) {
ui->CBzLeafVersion->addItem( zTreeVersionString ); ui->CBzLeafVersion->addItem( zTreeVersionString );
} }
ui->CBzLeafVersion->setCurrentIndex( 0 ); ui->CBzLeafVersion->setCurrentIndex( 0 );

@ -17,8 +17,13 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <memory>
#include "sessionstarter.h" #include "sessionstarter.h"
#include "ui_sessionstarter.h" #include "ui_sessionstarter.h"
#include "Lib/settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::SessionStarter::SessionStarter( Lablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent ) : lc::SessionStarter::SessionStarter( Lablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent ) :
QWidget{ parent }, QWidget{ parent },
@ -106,9 +111,9 @@ void lc::SessionStarter::SetupWidgets() {
// Fill the 'CBzTreeVersion' combobox with known entries from the lablib class // Fill the 'CBzTreeVersion' combobox with known entries from the lablib class
ui->CBzTreeVersion->addItem( "NONE" ); ui->CBzTreeVersion->addItem( "NONE" );
const QStringList * const zTreeEntries = lablib->GetInstalledZTreeVersions(); const QStringList &zTreeEntries = settings->installedZTreeVersions;
if ( !( zTreeEntries == nullptr ) ) { if ( !zTreeEntries.isEmpty() ) {
for ( auto zTreeVersionString : *zTreeEntries ) { for ( const auto &zTreeVersionString : zTreeEntries ) {
ui->CBzTreeVersion->addItem( zTreeVersionString ); ui->CBzTreeVersion->addItem( zTreeVersionString );
} }
ui->CBzTreeVersion->setCurrentIndex( 0 ); ui->CBzTreeVersion->setCurrentIndex( 0 );

Loading…
Cancel
Save