From 0d97a7378ffe5f6be408201cd1f5595607ed5f87 Mon Sep 17 00:00:00 2001 From: Fabian Schillinger Date: Mon, 1 Nov 2010 16:53:24 +0100 Subject: Process start/stop/view functionality processWidget - shows a list of processes on one client, allows to start ans stop processes processesDialog - shows every processWidget as a tab processesStartDialog - starts process entered in messageEdit added handling of new pvscommands --- src/gui/connectionWindow.cpp | 29 +++++ src/gui/connectionWindow.h | 1 + src/gui/dialog.cpp | 2 +- src/gui/mainWindow.cpp | 51 ++++++++- src/gui/mainWindow.h | 9 +- src/gui/processWidget.cpp | 98 ++++++++++++++++ src/gui/processWidget.h | 35 ++++++ src/gui/processesDialog.cpp | 62 ++++++++++ src/gui/processesDialog.h | 37 ++++++ src/gui/processesStartDialog.cpp | 75 ++++++++++++ src/gui/processesStartDialog.h | 31 +++++ src/gui/ui/mainwindow.ui | 10 ++ src/gui/ui/mainwindowtouch.ui | 10 ++ src/gui/ui/processWidget.ui | 227 +++++++++++++++++++++++++++++++++++++ src/gui/ui/processesDialog.ui | 92 +++++++++++++++ src/gui/ui/processesStartDialog.ui | 69 +++++++++++ 16 files changed, 831 insertions(+), 7 deletions(-) create mode 100644 src/gui/processWidget.cpp create mode 100644 src/gui/processWidget.h create mode 100644 src/gui/processesDialog.cpp create mode 100644 src/gui/processesDialog.h create mode 100644 src/gui/processesStartDialog.cpp create mode 100644 src/gui/processesStartDialog.h create mode 100644 src/gui/ui/processWidget.ui create mode 100644 src/gui/ui/processesDialog.ui create mode 100644 src/gui/ui/processesStartDialog.ui (limited to 'src/gui') diff --git a/src/gui/connectionWindow.cpp b/src/gui/connectionWindow.cpp index cf51051..df31562 100644 --- a/src/gui/connectionWindow.cpp +++ b/src/gui/connectionWindow.cpp @@ -472,6 +472,35 @@ void ConnectionWindow::messageStation(QString ident, QString message, pvsCon->sendMessage(PVSMESSAGE, ident, message); } +/* + * to send COMMAND instead of PVSMESSaGE + */ +bool ConnectionWindow::commandStations(QString ident, QString message) { + if (std::list* messageList = MainWindow::getConnectionList()->getSelectedClients()) { + if (!messageList->empty()) { + for (std::list::iterator tmpIt = messageList->begin(); tmpIt + != messageList->end(); tmpIt++) { + PVSClient + * tmpConnection = + PVSConnectionManager::getManager()->getClientFromIp( + (*tmpIt).toUtf8().data()); + // we don't want to lock the dozent machine + if (tmpConnection && tmpConnection->getConnectionFrame()->getFrame() && + !tmpConnection->getConnectionFrame()->getFrame()->isDozent()) + { + //messageStation(ident, message, tmpConnection); + tmpConnection->sendMessage(PVSCOMMAND, ident, message); + } else { + // scream in agony + } + } + } + delete messageList; + } + return true; +} + + bool ConnectionWindow::lockStationsWithMessage(QString message) { if (!hasDozent) diff --git a/src/gui/connectionWindow.h b/src/gui/connectionWindow.h index 81b5033..e7d0177 100644 --- a/src/gui/connectionWindow.h +++ b/src/gui/connectionWindow.h @@ -83,6 +83,7 @@ public: bool lockInvertStations(); void lockInvertStation(PVSClient* pvsCon); bool messageStations(QString ident, QString message); + bool commandStations(QString ident, QString message); void messageStation(QString ident, QString message, PVSClient* pvsCon); bool lockStationsWithMessage(QString message); void lockStationsWithMessage(QString message, PVSClient* pvsCon); diff --git a/src/gui/dialog.cpp b/src/gui/dialog.cpp index 3c9b7a2..5f24009 100644 --- a/src/gui/dialog.cpp +++ b/src/gui/dialog.cpp @@ -30,7 +30,7 @@ Dialog::Dialog(QWidget *parent) : connect( dui->send, SIGNAL( clicked()), this, SLOT( send())); connect( dui->cancel, SIGNAL( clicked()), this, SLOT( NotSend())); - connect(dui->message, SIGNAL(textChanged()), this, SLOT(textchange())); + connect( dui->message, SIGNAL(textChanged()), this, SLOT(textchange())); } Dialog::~Dialog() diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 10c64d6..815f001 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -32,6 +32,7 @@ using namespace std; #include #include #include +#include //#include #include #include @@ -108,6 +109,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionUnprojection, SIGNAL(triggered()), this, SLOT(unprojecttoolbar())); connect(ui->actionDozent, SIGNAL(triggered()), this, SLOT(setdozenttoolbar())); connect(ui->actionShowProcesses, SIGNAL(triggered()), this, SLOT(showProcesses())); + connect(ui->actionStartProcess, SIGNAL(triggered()), this, SLOT(startProcess())); // Ui specific settings @@ -133,6 +135,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionCreate_profile, SIGNAL(triggered()), this, SLOT(createProfile())); connect(ui->actionShowProcesses, SIGNAL(triggered()), this, SLOT(showProcesses())); ui->actionShowProcesses->setStatusTip(tr("Show Processes of the selected Client")); + connect(ui->actionStartProcess, SIGNAL(triggered()), this, SLOT(startProcess())); + ui->actionStartProcess->setStatusTip(tr("Starts Process on the selected Client(s)")); connect(ui->actionShow_Username, SIGNAL(triggered()), this, SLOT(showusername())); connect(ui->actionShow_Hostname_IP, SIGNAL(triggered()), this, SLOT(showip())); @@ -769,13 +773,50 @@ void MainWindow::showProcesses() { std::list* selectedClients = MainWindow::getConnectionList()->getSelectedClients(); - if (selectedClients->size() == 1) + if (selectedClients->size() >= 1) + { + ProcessDialog procDialog; + procDialog.exec(); + + } + else + { + QString + message = + QString( + tr( + "This operation can only be performed if you have selected at least one Client!")); + QMessageBox::information(this, "PVS", message); + } + +} + + +/* Perform some action if actionStartProcess button was pressed + * + */ +void MainWindow::startProcess() +{ + std::list* selectedClients = + MainWindow::getConnectionList()->getSelectedClients(); + if (selectedClients->size() >= 1) { // do stuff - PVSClient * pvsClient = + /*PVSClient * pvsClient = PVSConnectionManager::getManager()->getClientFromIp( - selectedClients->front().toStdString().c_str()); - pvsClient->sendMessage(PVSCOMMAND, "SHOWPROCESSES", ""); + selectedClients->front().toStdString().c_str());*/ + + ProcessesStartDialog procD; + QString myString = NULL; + int result = procD.exec(); + + if (result == 1) + { + myString = MainWindow::getWindow()->getProcessesDialog(); + if(!myString.isEmpty()) + MainWindow::getConnectionWindow()->commandStations("STARTPROCESS",myString); + } + } else { @@ -783,7 +824,7 @@ void MainWindow::showProcesses() message = QString( tr( - "This operation can only be performed if you have selected a Client!")); + "This operation can only be performed if you have selected at least one Client!")); QMessageBox::information(this, "PVS", message); } } diff --git a/src/gui/mainWindow.h b/src/gui/mainWindow.h index 574be7e..2ab62f8 100644 --- a/src/gui/mainWindow.h +++ b/src/gui/mainWindow.h @@ -10,9 +10,11 @@ #include #include //#include +#include #include #include #include "src/gui/aboutDialog.h" +#include "src/gui/processesDialog.h" #include "src/gui/serverChatDialog.h" #include @@ -94,6 +96,9 @@ public: void setMsgDialog(QString msgd){msgDialog = msgd;}; QString getMsgDialog(){return msgDialog;}; + void setProcessesDialog(QString procd){procDialog = procd;}; + QString getProcessesDialog(){return procDialog;}; + bool isLockAllStatus() { return _isLockAll; @@ -131,9 +136,10 @@ private: ConnectionDialog* pwDiag; ConnectionDialog* messageDiag;*/ - AboutDialog *_aboutDialog; + AboutDialog *_aboutDialog; QString msgDialog; + QString procDialog; bool bgimage; bool locked, locked1; bool force_square; @@ -179,6 +185,7 @@ public slots: void setdozenttoolbar(); void startChatDialog(); void showProcesses(); + void startProcess(); private slots: void onToggleLog(bool showtime); diff --git a/src/gui/processWidget.cpp b/src/gui/processWidget.cpp new file mode 100644 index 0000000..9b59b2a --- /dev/null +++ b/src/gui/processWidget.cpp @@ -0,0 +1,98 @@ +/* +# Copyright (c) 2010 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# processWidget.cpp + Widget to start/stop processes on a client. This widget is used in + processesDialog.cpp as a tab in the QTabWidget +# ----------------------------------------------------------------------------- +*/ + +#include "processesDialog.h" +#include "processWidget.h" +#include "ui_processWidget.h" + +ProcessWidget::ProcessWidget(QWidget *parent, PVSClient *cl): + QWidget(parent), + prowui(new Ui::ProcessWidget) +{ + prowui->setupUi(this); + + client = cl; + + connect( prowui->startButton, SIGNAL( clicked()), this, SLOT( startProcess())); + connect( prowui->refreshButton, SIGNAL( clicked()), this, SLOT( refrProcessList())); + connect( prowui->stopButton, SIGNAL( clicked()), this, SLOT( stopProcess())); + connect( client, SIGNAL( processVectorReady(bool)), this, SLOT( refrProcessList())); + + sendCommand("SHOWPROCESSES", ""); +} + +void ProcessWidget::startProcess() +{ + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to start the process: ") + prowui->processLineEdit->text() + + tr(" on User '") + client->getDesktopName() + tr("' ?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (start == QMessageBox::Ok) + { + sendCommand("STARTPROCESS", prowui->processLineEdit->text()); + sendCommand("SHOWPROCESSES", ""); + } + prowui->processLineEdit->clear(); +} + +void ProcessWidget::refrProcessList() +{ + for(int i=prowui->processTable->rowCount(); i == 0; i--) + { + prowui->processTable->removeRow(i); + } + prowui->processTable->setRowCount(0); + QVector processes = client->getProcessesVector(); + + for (int i=0; iprocessTable->setRowCount(i+1); + QStringList processesList = processes.at(i).split(QRegExp("<#>")); + for (int j=0; jprocessTable->setItem(i,j,new QTableWidgetItem(processesList.at(j),0)); + } + } + prowui->processTable->selectRow(0); +} + +void ProcessWidget::stopProcess() +{ + if (prowui->processTable->rowCount() > 0) + { + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to stop the process: ") + prowui->processTable->item(prowui->processTable->currentRow(),1)->text() + + tr(" on User '") + client->getDesktopName() + tr("' ?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + if (start == QMessageBox::Ok) + { + sendCommand("KILLPROCESS", prowui->processTable->item(prowui->processTable->currentRow(),0)->text()); + sendCommand("SHOWPROCESSES", ""); + } + } +} + +void ProcessWidget::sendCommand(QString ident, QString message) +{ + client->sendMessage(PVSCOMMAND, ident, message); +} + +ProcessWidget::~ProcessWidget() +{ + delete prowui; +} diff --git a/src/gui/processWidget.h b/src/gui/processWidget.h new file mode 100644 index 0000000..7e7eb72 --- /dev/null +++ b/src/gui/processWidget.h @@ -0,0 +1,35 @@ +#ifndef PROCESSWIDGET_H_ +#define PROCESSWIDGET_H_ + +#include +#include +#include + +namespace Ui { + class ProcessWidget; +} + +class PVSClient; +class ProcessWidget: public QWidget +{ + Q_OBJECT + +public: + ProcessWidget(QWidget *parent, PVSClient *client); + ~ ProcessWidget(); + QAbstractItemModel *model; +public slots: + void refrProcessList(); + +private: + Ui::ProcessWidget *prowui; + PVSClient *client; + QVector *processes; + +private slots: + void startProcess(); + void stopProcess(); + void sendCommand(QString ident, QString message); +}; + +#endif diff --git a/src/gui/processesDialog.cpp b/src/gui/processesDialog.cpp new file mode 100644 index 0000000..d2ef7dc --- /dev/null +++ b/src/gui/processesDialog.cpp @@ -0,0 +1,62 @@ +/* +# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# processesDialog.cpp + Dialog where a tab with running processes for every client is shown +# ----------------------------------------------------------------------------- +*/ + +#include "processesDialog.h" +#include "ui_processesDialog.h" +#include +//#include + +ProcessDialog::ProcessDialog(QDialog *parent) : + QDialog(parent), + procui(new Ui::ProcessesDialog) +{ + procui->setupUi(this); + + tWidget = new QTabWidget; + procui->grLayout->addWidget(tWidget); + + connect( tWidget, SIGNAL( currentChanged(int)), this, SLOT( currChanged())); + + std::list listAll = + PVSConnectionManager::getManager()->getConnections(); + for (std::list::iterator it = listAll.begin(); it + != listAll.end(); it++) + { + if (*it == NULL || (*it)->getConnectionFrame() == NULL) continue; + if ((*it)->getConnectionFrame()->getFrame() && + /*!(*it)->getConnectionFrame()->getFrame()->isDozent() &&*/ + (*it)->getVNCConnection()) + {tWidget->addTab(new ProcessWidget(0, *it), (*it)->getUserName()); + tWidget->addTab(new ProcessWidget(0, *it), (*it)->getUserName()); + tWidget->addTab(new ProcessWidget(0, *it), (*it)->getUserName());} + else if (!(*it)->getConnectionFrame()->getFrame()) + ConsoleLog writeError(QString("The Frame connection from client: "). + append((*it)->getConnectionFrame()->getTaskbarTitle()). + append(QString(" is corrupted. Reconnect the client it again."))); + } +} + +// if other Tab is activated we say our tab to refresh the processList +void ProcessDialog::currChanged() +{ + ProcessWidget *temp = static_cast(tWidget->currentWidget()); + temp->refrProcessList(); +} + +ProcessDialog::~ProcessDialog() +{ + delete procui; +} diff --git a/src/gui/processesDialog.h b/src/gui/processesDialog.h new file mode 100644 index 0000000..9d98136 --- /dev/null +++ b/src/gui/processesDialog.h @@ -0,0 +1,37 @@ +#ifndef PROCESSESDIALOG_H +#define PROCESSESDIALOG_H + +#include +#include +#include +#include +#include + + +namespace Ui { + class ProcessesDialog; +} + +class ConnectionList; +class PVSClient; +class PVSConnectionManager; +class ProcessesWidget; +class MainWindow; + +class ProcessDialog : public QDialog { + Q_OBJECT +public: + ProcessDialog(QDialog *parent = 0); + ~ProcessDialog(); + + +private: + Ui::ProcessesDialog *procui; + QTabWidget *tWidget; + QDialogButtonBox *buttonBox; + +private slots: + void currChanged(); +}; + +#endif // PROCESSESDIALOG_H diff --git a/src/gui/processesStartDialog.cpp b/src/gui/processesStartDialog.cpp new file mode 100644 index 0000000..b4c8c79 --- /dev/null +++ b/src/gui/processesStartDialog.cpp @@ -0,0 +1,75 @@ +/* +# Copyright (c) 2010 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# processesStartDialog.cpp + Dialog to get process to send to clients +# ----------------------------------------------------------------------------- +*/ + +#include "processesStartDialog.h" +#include "ui_processesStartDialog.h" +#include + +ProcessesStartDialog::ProcessesStartDialog(QWidget *parent) : + QDialog(parent) +{ + textLabel = new QLabel; + textLabel->setText("Process to start:"); + + messageEdit = new QLineEdit; + + layout = new QGridLayout; + + sendButton = new QPushButton(tr("Start")); + cancelButton = new QPushButton(tr("Cancel")); + + connect( sendButton, SIGNAL( clicked()), this, SLOT( send())); + connect( cancelButton, SIGNAL( clicked()), this, SLOT( NotSend())); + + layout->addWidget(textLabel,0,0); + layout->addWidget(messageEdit,1,0); + layout->addWidget(cancelButton,2,0); + layout->addWidget(sendButton,2,0); + + setLayout(layout); + setWindowTitle(tr("PVS start Process")); +} + +ProcessesStartDialog::~ProcessesStartDialog() +{ + //delete procstartui; +} + +void ProcessesStartDialog::send() +{ + QString procd = messageEdit->text(); + MainWindow::getWindow()->setProcessesDialog(procd); + messageEdit->clear(); + emit accept(); +} + +void ProcessesStartDialog::NotSend() +{ + messageEdit->clear(); + emit reject(); +} + +/*void ProcessesStartDialog::changeEvent(QEvent *e) +{ + //QDialog::changeEvent(e); + //switch (e->type()) { + //case QEvent::LanguageChange: + // procstartui->retranslateUi(this); + // break; + //default: + // break; + //} +}*/ diff --git a/src/gui/processesStartDialog.h b/src/gui/processesStartDialog.h new file mode 100644 index 0000000..61aee4f --- /dev/null +++ b/src/gui/processesStartDialog.h @@ -0,0 +1,31 @@ +#ifndef PROCESSESSTARTDIALOG_H +#define PROCESSESSTARTDIALOG_H + +#include +#include + + +class MainWindow; + +class ProcessesStartDialog : public QDialog { + Q_OBJECT +public: + ProcessesStartDialog(QWidget *parent = 0); + ~ProcessesStartDialog(); + +/*protected: + void changeEvent(QEvent *e);*/ + +private: + QGridLayout *layout; + QLabel *textLabel; + QLineEdit *messageEdit; + QPushButton *sendButton; + QPushButton *cancelButton; + +private slots: + void send(); + void NotSend(); +}; + +#endif // PROCESSESSTARTDIALOG_H diff --git a/src/gui/ui/mainwindow.ui b/src/gui/ui/mainwindow.ui index 374177a..285d0f2 100644 --- a/src/gui/ui/mainwindow.ui +++ b/src/gui/ui/mainwindow.ui @@ -287,6 +287,7 @@ + @@ -544,6 +545,15 @@ Show Processes of the selected Client + + + + :/icons/gearsgo.png:/icons/gearsgo.png + + + Start Process + + diff --git a/src/gui/ui/mainwindowtouch.ui b/src/gui/ui/mainwindowtouch.ui index 8b76101..ae1d0cf 100644 --- a/src/gui/ui/mainwindowtouch.ui +++ b/src/gui/ui/mainwindowtouch.ui @@ -366,6 +366,7 @@ + @@ -649,6 +650,15 @@ Show Processes of the selected Client + + + + :/icons/gearsgo.png:/icons/gearsgo.png + + + Start Process + + diff --git a/src/gui/ui/processWidget.ui b/src/gui/ui/processWidget.ui new file mode 100644 index 0000000..3e7f55e --- /dev/null +++ b/src/gui/ui/processWidget.ui @@ -0,0 +1,227 @@ + + + ProcessWidget + + + + 0 + 0 + 646 + 504 + + + + Form + + + + + 10 + 10 + 631 + 481 + + + + + + + Prozessliste + + + + + 10 + 24 + 611 + 361 + + + + + + + QFrame::Sunken + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + Qt::DotLine + + + true + + + false + + + false + + + 0 + + + true + + + false + + + false + + + true + + + true + + + true + + + true + + + true + + + false + + + true + + + false + + + true + + + + ID + + + + + Name + + + + + Commandline + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Aktualisieren + + + + + + + Prozess beenden + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + 16777215 + 80 + + + + Prozess starten + + + + + 10 + 20 + 611 + 51 + + + + + + + + + + Prozess starten + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + diff --git a/src/gui/ui/processesDialog.ui b/src/gui/ui/processesDialog.ui new file mode 100644 index 0000000..4ac4859 --- /dev/null +++ b/src/gui/ui/processesDialog.ui @@ -0,0 +1,92 @@ + + + ProcessesDialog + + + + 0 + 0 + 654 + 562 + + + + Prozesse + + + + + 310 + 530 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + false + + + + + + 0 + 0 + 651 + 531 + + + + + + 0 + 0 + 651 + 521 + + + + + + + + + + buttonBox + accepted() + ProcessesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProcessesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/ui/processesStartDialog.ui b/src/gui/ui/processesStartDialog.ui new file mode 100644 index 0000000..5d8c7ee --- /dev/null +++ b/src/gui/ui/processesStartDialog.ui @@ -0,0 +1,69 @@ + + + ProcessesStartDialog + + + + 0 + 0 + 393 + 109 + + + + Start Process + + + + + 20 + 20 + 351 + 71 + + + + + + + + + + 5 + + + + + Qt::Horizontal + + + + 108 + 20 + + + + + + + + Cancel + + + + + + + Send + + + + + + + + + + + + -- cgit v1.2.3-55-g7522