/* # 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/ # ----------------------------------------------------------------------------- # projectionDialog.cpp Dialog to select client for the projection # ----------------------------------------------------------------------------- */ #include "projectionDialog.h" #include "ui_projectionDialog.h" #include #include #include ProjectionDialog::ProjectionDialog(QWidget *parent) : QDialog(parent), pui(new Ui::projectionDialog) { pui->setupUi(this); this->setWindowTitle(tr("Target for Projection")); source = MainWindow::getConnectionList()->getSelectedClients()->front(); setupContent(MainWindow::getWindow()->getConnectionList()->getTargetToDisplay(source)); pui->send->setDisabled(true); connect( pui->send, SIGNAL( clicked() ), this, SLOT( sendListToProject() ) ); connect( pui->cancel, SIGNAL( clicked() ), this, SLOT( cancelProject() ) ); connect( pui->checkBox, SIGNAL( clicked() ), this, SLOT( selectAll() ) ); } ProjectionDialog::~ProjectionDialog() { delete pui; QCheckBox* cbox; foreach(cbox, checkList) { disconnect( cbox, SIGNAL( clicked() ), this, SLOT( sendState() ) ); } } void ProjectionDialog::setupContent(QList content) { if (!content.isEmpty()) { // get a list of all dozent machines QStringList dozentList; QList clients = MainWindow::getConnectionWindow()->getAllFrameOnWindow(); foreach (ConnectionFrame *client, clients) if (client->isDozent()) dozentList.append(client->getTaskbarTitle()); QString item; foreach(item, content) { // FIXME: Projection on tutor PC does not work bc. we change his name here... // if (dozentList.contains(item)) item.append(" (Tutor PC)"); QCheckBox *checkbox = new QCheckBox(item,this); pui->verticalLayout_2->addWidget(checkbox); checkList.push_back(checkbox); connect( checkbox, SIGNAL( clicked() ), this, SLOT( sendState() ) ); } } else { QLabel *textInfo = new QLabel(this); textInfo->setText("No Target available"); pui->verticalLayout_2->addWidget(textInfo); pui->checkBox->setDisabled(true); } } void ProjectionDialog::sendListToProject() { MainWindow::getConnectionList()->setProjectProporties(source); QCheckBox* cbox; foreach(cbox, checkList) { if (cbox->isChecked()) { MainWindow::getConnectionList()->addTargetToProjectList(cbox->text()); } } emit accept(); } void ProjectionDialog::cancelProject() { emit reject(); } void ProjectionDialog::sendState() { QCheckBox* cbox; bool set = false; foreach(cbox, checkList) { if (cbox->isChecked()) { pui->send->setDisabled(false); set = true; break; } } if (!set) pui->send->setDisabled(true); } void ProjectionDialog::selectAll() { if(pui->checkBox->isChecked()) { QCheckBox* cbox; foreach(cbox, checkList) cbox->setChecked(true); pui->send->setDisabled(false); } else { QCheckBox* cbox; foreach(cbox, checkList) cbox->setChecked(false); pui->send->setDisabled(true); } } void ProjectionDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: pui->retranslateUi(this); break; default: break; } }