From 1db4bdcc019001c6bb8f72eb540d6ad29845623c Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Wed, 17 Nov 2010 20:21:30 +0100 Subject: [PVSMGR] New profile management --- misc/pvs.conf | 2 +- src/gui/mainWindow.cpp | 44 +++------ src/gui/mainWindow.h | 5 +- src/gui/profileDialog.cpp | 186 ++++++++++------------------------ src/gui/profileDialog.h | 44 +++------ src/gui/ui/mainwindow.ui | 40 ++++---- src/gui/ui/mainwindowtouch.ui | 18 +++- src/gui/ui/profileDialog.ui | 225 ++++++++++++++---------------------------- 8 files changed, 186 insertions(+), 378 deletions(-) diff --git a/misc/pvs.conf b/misc/pvs.conf index 0e71bc8..f3a7adc 100644 --- a/misc/pvs.conf +++ b/misc/pvs.conf @@ -2,7 +2,7 @@ script=/usr/local/bin/pvs-vncsrv [Permissions] -vnc_lecturer=no +vnc_lecturer=ro vnc_other=no allow_chat=T allow_filetransfer=T diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index beb80f4..260da89 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -168,6 +168,13 @@ MainWindow::MainWindow(QWidget *parent) : _serverSocket = new QTcpServer(); _serverSocket->listen(QHostAddress::Any, 29481); connect(_serverSocket, SIGNAL(newConnection()), this, SLOT(incomingFile())); + _profileDialog = new profileDialog(this); + +#ifdef MAINWINDOW_USE_TOUCHGUI + connect(ui->saveProfileButton, SIGNAL(clicked()), _profileDialog, SLOT(save())); +#else + connect(ui->actionSave_Profile, SIGNAL(triggered()), _profileDialog, SLOT(save())); +#endif } MainWindow::~MainWindow() @@ -242,27 +249,6 @@ QStringList MainWindow::getProfilList() // loads the profile list return profilList; } -#ifdef MAINWINDOW_USE_NORMALGUI -void MainWindow::addProfileInMenu(QString name) -{ - QAction* action = new QAction(name,this); - ui->menuLoad_profile->addAction(action); - connect(ui->menuLoad_profile, SIGNAL(triggered(QAction*)), this, SLOT(loadProfile(QAction*))); - _mapProfileToAction.insert(name, action); -} - -void MainWindow::removeProfileInMenu(QString name) -{ - if (_mapProfileToAction.contains(name)) - { - QAction* action = _mapProfileToAction.value(name); - ui->menuLoad_profile->removeAction(action); - _mapProfileToAction.take(name); - } - -} - -#endif void MainWindow::loadSettings() { QSettings settings("openslx", "pvsmgr"); @@ -319,10 +305,6 @@ void MainWindow::loadSettings() } MainWindow::getConnectionWindow()->showFrameFromSettings(); -#ifdef MAINWINDOW_USE_NORMALGUI - foreach (QString profile, getProfilList()) - addProfileInMenu(profile); -#endif } void MainWindow::loadProfile(QAction* actiontriggered) @@ -407,18 +389,12 @@ void MainWindow::saveSettings(QString profilname) profil.append(QString("%1").arg(i + 1)); settings.setValue(profil, current->pos()); } -#ifdef MAINWINDOW_USE_NORMALGUI - addProfileInMenu(profilname); -#endif } void MainWindow::removeProfil(QString profilname) { QSettings settings("openslx", "pvsmgr"); settings.remove(profilname); -#ifdef MAINWINDOW_USE_NORMALGUI - removeProfileInMenu(profilname); -#endif } void MainWindow::addConnection(PVSClient* newCon) @@ -431,6 +407,8 @@ void MainWindow::addConnection(PVSClient* newCon) sChatDialog.chat_nicklist_update(); } // sChatDialog->chat_nicklist_update(newCon->getUserName()); + + _profileDialog->load(); } void MainWindow::removeConnection(PVSClient* newCon) @@ -885,8 +863,8 @@ void MainWindow::foto() // makes a screenshot of the selected client void MainWindow::createProfile() { - profileDialog proDiag; - proDiag.exec(); + + _profileDialog->exec(); } void MainWindow::showusername() diff --git a/src/gui/mainWindow.h b/src/gui/mainWindow.h index 272d057..46b3b9a 100644 --- a/src/gui/mainWindow.h +++ b/src/gui/mainWindow.h @@ -60,8 +60,6 @@ public: QString test; QStringList profilList; QStringList getProfilList(); - void addProfileInMenu(QString name); - void removeProfileInMenu(QString name); QString currentProfi; QString getCurrentProfi() { @@ -136,7 +134,8 @@ private: ConnectionDialog* pwDiag; ConnectionDialog* messageDiag;*/ - AboutDialog *_aboutDialog; + AboutDialog *_aboutDialog; + profileDialog *_profileDialog; QString msgDialog; QString procToStart; diff --git a/src/gui/profileDialog.cpp b/src/gui/profileDialog.cpp index 2cbc155..07a97cf 100644 --- a/src/gui/profileDialog.cpp +++ b/src/gui/profileDialog.cpp @@ -15,165 +15,79 @@ */ #include "profileDialog.h" -#include "ui_profileDialog.h" -#include -#include -profileDialog::profileDialog(QWidget * parent): - QDialog(parent), - uidiag(new Ui::Dialog) +profileDialog::profileDialog(QWidget * parent) : + QDialog(parent) { - uidiag->setupUi(this); - content = new QTableView(uidiag->widget); - uidiag->gridLayout->addWidget(content); + setupUi(this); - /*Das Modelfestlegen, wo die Clientname angezeigt werden.*/ - model = new QStandardItemModel(0,1,content); //Leere Tabelle mit einer Spalte erstellen - model->setHeaderData(0, Qt::Horizontal, tr("Profile")); //Spalte name definieren - content->setModel(model); - - QItemSelectionModel *selectionModel = new QItemSelectionModel(model); - content->setSelectionModel(selectionModel); - QHeaderView *headerView = content->horizontalHeader(); - headerView->setStretchLastSection(true); - - content->setEditTriggers(QAbstractItemView::NoEditTriggers); //Die Einträge in der Tabelle werden nicht editierbar. - content->setSelectionMode(QAbstractItemView::ExtendedSelection); //Damit mehere Einträge selektierbar werden. - - content->resizeColumnToContents(0); - - - - uidiag->add->setDisabled(true); - uidiag->edit->setDisabled(true); - uidiag->edit->setVisible(false); - uidiag->remove->setDisabled(true); - uidiag->load->setDisabled(true); - uidiag->lineEdit->setDisabled(true); - - setUpProfile(); - - connect(uidiag->add, SIGNAL(clicked ()), this, SLOT(AddProfile())); - connect(uidiag->new_2, SIGNAL(clicked ()), this, SLOT(onNew())); - connect(uidiag->load, SIGNAL(clicked ()), this, SLOT(onLoad())); - connect(uidiag->remove, SIGNAL(clicked ()), this, SLOT(removeProfile())); - connect(uidiag->close, SIGNAL(clicked ()), this, SLOT(accept())); - connect(content, SIGNAL(clicked(const QModelIndex)), this, SLOT(selectionChange(const QModelIndex))); - //show(); + _profiles = new QSettings("openslx", "profiles", this); + _current = _profiles->value("current").toString(); + listWidget->addItems(_profiles->childGroups()); + connect(addButton, SIGNAL(clicked()), this, SLOT(add())); + connect(loadButton, SIGNAL(clicked()), this, SLOT(load())); + connect(removeButton, SIGNAL(clicked()), this, SLOT(remove())); } profileDialog::~profileDialog() { - // TODO Auto-generated destructor stub } -void profileDialog::setUpProfile() +void profileDialog::add() { - QStringList list = MainWindow::getWindow()->getProfilList(); - for (int i=0; iinsertRow(0, QModelIndex()); - model->setData(model->index(0, 0, QModelIndex()),list.at(i)); - } -} - -void profileDialog::AddProfile() -{ - QString name = QString(uidiag->lineEdit->text()); - if (!ProfilList.contains(name)) - { - if (!name.isEmpty()) - { - model->insertRow(0, QModelIndex()); - model->setData(model->index(0, 0, QModelIndex()),name); - ProfilList.append(name); - MainWindow::getWindow()->saveSettings(name); - uidiag->lineEdit->setText(""); - } - else - { - QString message = QString(tr("This field can't be empty.")); - QMessageBox::information(this, "PVS", message); - } - } - else - { - QString message = QString(tr("This name is already in the list.")); - QMessageBox::information(this, "PVS", message); - } + _current = ""; + save(); } -void profileDialog::removeProfile() +void profileDialog::remove() { - QTableView *temp = static_cast(content); - QItemSelectionModel *selectionModel = temp->selectionModel(); - - QModelIndexList indexes = selectionModel->selectedRows(); - QModelIndex index; - - foreach(index, indexes) - { - int row = content->currentIndex().row(); - QString current = model->index(content->currentIndex().row(), 0).data(Qt::DisplayRole).toString(); - model->removeRow(row, QModelIndex()); - ProfilList.removeOne(current); - MainWindow::getWindow()->removeProfil(current); - } - - - /* if (temp->model()->rowCount()<=0) - {*/ - uidiag->remove->setDisabled(true); - uidiag->edit->setDisabled(true); - uidiag->add->setDisabled(true); - uidiag->load->setDisabled(true); - //} -} - -void profileDialog::onNew() -{ - uidiag->add->setDisabled(false); - uidiag->lineEdit->setDisabled(false); - uidiag->lineEdit->setFocus(); + if (listWidget->currentItem()) + { + _profiles->remove(listWidget->currentItem()->text()); + listWidget->clear(); + listWidget->addItems(_profiles->childGroups()); + } } -void profileDialog::onLoad() +void profileDialog::save() { - QTableView *temp = static_cast(content); - QItemSelectionModel *selectionModel = temp->selectionModel(); - - QModelIndexList indexes = selectionModel->selectedRows(); - QModelIndex index; - if (indexes.size()>1) + if (_current == "") { - QMessageBox::information(this, "PVS", tr("You can only load one profile at time")); + QString profile = QInputDialog::getText(this, tr("New Profile"), tr("Save profile as:")); + if (!profile.isEmpty()) + { + _current = profile; + _profiles->setValue("current", _current); + } + else + return; } - else if(indexes.size() == 1) + QList clients = MainWindow::getConnectionWindow()->getAllFrameOnWindow(); + _profiles->beginGroup(_current); + foreach (ConnectionFrame *client, clients) { - foreach(index, indexes) - { - //int row = content->currentIndex().row(); - QString current = model->index(content->currentIndex().row(), 0).data(Qt::DisplayRole).toString(); - MainWindow::getWindow()->loadSettings(current); - } + QString key = client->getTaskbarTitle(); + QPoint value = client->pos(); + _profiles->setValue(key, value); } - - emit accept(); + _profiles->endGroup(); + listWidget->clear(); + listWidget->addItems(_profiles->childGroups()); } -void profileDialog::selectionChange(const QModelIndex & index) +void profileDialog::load() { - uidiag->remove->setDisabled(false); - uidiag->edit->setDisabled(false); - uidiag->add->setDisabled(false); - uidiag->load->setDisabled(false); + if (listWidget->currentItem()) + _current = listWidget->currentItem()->text(); + QList clients = MainWindow::getConnectionWindow()->getAllFrameOnWindow(); + _profiles->beginGroup(_current); + foreach (ConnectionFrame *client, clients) + { + QString key = client->getTaskbarTitle(); + client->move(_profiles->value(key).toPoint()); + } + _profiles->endGroup(); + _profiles->setValue("current", _current); } - -void profileDialog::close() -{ - close(); -} - - diff --git a/src/gui/profileDialog.h b/src/gui/profileDialog.h index 5caebfa..58a3de6 100644 --- a/src/gui/profileDialog.h +++ b/src/gui/profileDialog.h @@ -2,45 +2,27 @@ #define PROFILEDIALOG_H_ #include -#include -#include +#include "ui_profileDialog.h" +#include "mainWindow.h" -namespace Ui +class profileDialog: public QDialog, private Ui::ProfileDialogClass { -class Dialog; -} - -class MainWindow; - -class profileDialog : public QDialog -{ - Q_OBJECT +Q_OBJECT public: - profileDialog(QWidget * parent = 0); - virtual ~profileDialog(); - - void setUpProfile(); - - + profileDialog(QWidget * parent = 0); + ~profileDialog(); -signals: - void selectionChanged (const QItemSelection &selected); +public Q_SLOTS: + void add(); + void remove(); + void save(); + void load(); private: - Ui::Dialog *uidiag; - QTableView *content; - QAbstractItemModel *model; - QItemSelectionModel *selectionModel; - QList ProfilList; + QSettings *_profiles; + QString _current; -private Q_SLOTS: - void AddProfile(); - void removeProfile(); - void onNew(); - void onLoad(); - void selectionChange(const QModelIndex & index); - void close(); }; #endif /* PROFILEDIALOG_H_ */ diff --git a/src/gui/ui/mainwindow.ui b/src/gui/ui/mainwindow.ui index a9d5cad..0a6d0a6 100644 --- a/src/gui/ui/mainwindow.ui +++ b/src/gui/ui/mainwindow.ui @@ -28,8 +28,8 @@ 0 0 - 778 - 542 + 792 + 552 @@ -195,26 +195,9 @@ 0 0 838 - 23 + 21 - - - &File - - - - Load profile - - - - - - - - - - &Clients @@ -249,6 +232,18 @@ + + + &File + + + + + + + + + @@ -572,6 +567,11 @@ Start process on the selected client(s) + + + Save Profile + + diff --git a/src/gui/ui/mainwindowtouch.ui b/src/gui/ui/mainwindowtouch.ui index 12a2f2b..1f329d6 100644 --- a/src/gui/ui/mainwindowtouch.ui +++ b/src/gui/ui/mainwindowtouch.ui @@ -28,8 +28,8 @@ 0 0 - 1329 - 660 + 1431 + 655 @@ -133,6 +133,18 @@ + + + + + 15 + + + + Save Profile + + + @@ -141,7 +153,7 @@ - Profile + Manage Profiles diff --git a/src/gui/ui/profileDialog.ui b/src/gui/ui/profileDialog.ui index 3302a56..c102669 100644 --- a/src/gui/ui/profileDialog.ui +++ b/src/gui/ui/profileDialog.ui @@ -1,172 +1,78 @@ - Dialog - + ProfileDialogClass + 0 0 - 332 - 485 + 350 + 206 - ProfileDialog + Dialog - - - + + + + + + + + + + &Add + + + + + + + true + + + &Remove + + + - + - Qt::Horizontal + Qt::Vertical + + + + 20 + 40 + + + + + + + + &Load - - - - 1 - 0 - - - - background-color: rgb(255, 255, 255); - - - - - - - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 18 - - - - - - - - &Edit - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 18 - - - - - - - - &New - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &Load - - - - - - - Qt::Vertical - - - - 20 - 218 - - - - - - - - - - - - - - Add - - - - + + + Qt::Vertical + + + + 20 + 40 + + + - + - Close + &Close @@ -175,5 +81,22 @@ - + + + closeButton + clicked() + ProfileDialogClass + accept() + + + 291 + 185 + + + 324 + 133 + + + + -- cgit v1.2.3-55-g7522