summaryrefslogblamecommitdiffstats
path: root/src/server/sessionnamewindow/sessionnamewindow.cpp
blob: 01ac910be329e41b7ba26cda8fd021030e893814 (plain) (tree)





























                                                                                          
                                






















                                                  
  













                                                                     
/*
 # 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/
 # -----------------------------------------------------------------------------
 # mainWindow.cpp
 This is the Main class for the pvsManager. The GUI is contructed here.
 # -----------------------------------------------------------------------------
 */

#include <QtGui>
#include "sessionnamewindow.h"
#include "../util/global.h"

#include "ui_sessionname.h"

SessionNameWindow::SessionNameWindow(QWidget *parent) :
	QDialog(parent), ui(new Ui::SessionName)

{
	ui->setupUi(this);
	connect(ui->bboxOkCancel, SIGNAL(accepted()),  this, SLOT(onOkClicked()));
	connect(ui->bboxOkCancel, SIGNAL(rejected()), this, SLOT(close()));
	connect(ui->cmdRandom, SIGNAL(clicked(bool)), this, SLOT(onGenerateRandomName()));
	ui->txtName->setFocus();
}

SessionNameWindow::~SessionNameWindow()
{
	delete ui;
}

void SessionNameWindow::show(const QString& name)
{
	ui->txtName->setText(name);
	this->showNormal();
}

/*
 * Overridden methods
 */

void SessionNameWindow::closeEvent(QCloseEvent *e)
{
	e->ignore();
	this->hide();
}

/*
 * Slots
 */

void SessionNameWindow::onOkClicked()
{
	Global::setSessionName(ui->txtName->text());
	emit updateSessionName();
	this->hide();
}

void SessionNameWindow::onGenerateRandomName()
{
	ui->txtName->setText(QString::number(qrand() % 9000 + 1000));
}