1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
# 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/
# -----------------------------------------------------------------------------
# profileDialog.cpp
# - GUI to define the profile.
# -----------------------------------------------------------------------------
*/
#include "profileDialog.h"
profileDialog::profileDialog(QWidget * parent) :
QDialog(parent)
{
setupUi(this);
_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()
{
}
void profileDialog::add()
{
_current = "";
save();
}
void profileDialog::remove()
{
if (listWidget->currentItem())
{
_profiles->remove(listWidget->currentItem()->text());
listWidget->clear();
listWidget->addItems(_profiles->childGroups());
}
}
void profileDialog::save()
{
if (_current == "")
{
QString profile = QInputDialog::getText(this, tr("New Profile"), tr("Save profile as:"));
if (!profile.isEmpty())
{
_current = profile;
_profiles->setValue("current", _current);
}
else
return;
}
QList<ConnectionFrame*> clients = MainWindow::getConnectionWindow()->getAllFrameOnWindow();
_profiles->beginGroup(_current);
foreach (ConnectionFrame *client, clients)
{
QString key = client->getTaskbarTitle();
QPoint value = client->pos();
_profiles->setValue(key, value);
}
_profiles->endGroup();
listWidget->clear();
listWidget->addItems(_profiles->childGroups());
}
void profileDialog::load()
{
if (listWidget->currentItem())
_current = listWidget->currentItem()->text();
QList<ConnectionFrame*> clients = MainWindow::getConnectionWindow()->getAllFrameOnWindow();
_profiles->beginGroup(_current);
QPoint shift(0,0);
foreach (ConnectionFrame *client, clients)
{
QString key = client->getTaskbarTitle();
QPoint position = _profiles->value(key).toPoint();
if (position != QPoint(0,0))
client->move(position);
else
{
client->move(shift);
shift += QPoint(10,10);
}
}
_profiles->endGroup();
_profiles->setValue("current", _current);
}
|