summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Schwabe2014-03-19 17:08:34 +0100
committerNils Schwabe2014-03-19 17:08:34 +0100
commit56a5cdd69ed50e809cdef1e368a41fd3c852db91 (patch)
treecba1a1746deab0c14e4ff39c498c36c2bbd1f023
parent- removed function to load icons locally (diff)
downloadvmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.tar.gz
vmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.tar.xz
vmchooser2-56a5cdd69ed50e809cdef1e368a41fd3c852db91.zip
- changed dialog desgin
- added details view
-rw-r--r--src/dialog.cpp38
-rw-r--r--src/dialog.h1
-rw-r--r--src/globals.h4
-rw-r--r--src/main.cpp6
-rw-r--r--src/sessionsiconholder.cpp2
-rw-r--r--src/sessiontreemodel.cpp24
-rw-r--r--src/ui/dialog.ui222
7 files changed, 243 insertions, 54 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index b48ff1b..b156231 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -28,6 +28,11 @@ Dialog::Dialog(QWidget *parent)
centerTimer_ = new QTimer(this);
connect(centerTimer_, SIGNAL(timeout()), this, SLOT(onCenterTimer()));
centerTimer_->start(1000);
+
+ ui->treeView->setModel(model_);
+
+ QObject::connect(ui->treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex&, const QModelIndex&)),
+ this, SLOT(treeView_selectionChanged(const QModelIndex&, const QModelIndex&)));
}
Dialog::~Dialog() {
@@ -80,19 +85,16 @@ void Dialog::on_treeView_activated(QModelIndex index) {
void Dialog::addItems(const QList<Session*>& entries, const QString& section) {
this->model_->addItems(entries, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
void Dialog::addLabelItem(const QString& label, const QString& section) {
this->model_->addLabelItem(label, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
void Dialog::removeItem(const QString& name, const QString& section) {
this->model_->removeItem(name, section);
- ui->treeView->setModel(model_);
ui->treeView->expandAll();
}
@@ -317,3 +319,33 @@ void Dialog::addSessionsAfterDownload(QNetworkReply* reply) {
}
}
+void Dialog::treeView_selectionChanged(const QModelIndex& current, const QModelIndex&) {
+ SessionTreeItem* item =
+ static_cast<SessionTreeItem*>(current.internalPointer());
+
+ const Session* s(item->session());
+ if (!s) {
+ // no valid session has been selected, do nothing
+ return;
+ }
+
+ if (s->type() == Session::VSESSION) {
+ const VSession* vs = (VSession*) s;
+ ui->label_name->setText(vs->getAttribute("short_description", "param"));
+ ui->label_name->setToolTip(vs->getAttribute("short_description", "param"));
+
+ ui->label_creator->setText(vs->getAttribute("creator", "param"));
+ ui->label_creator->setToolTip(vs->getAttribute("creator", "param"));
+
+ ui->label_os->setText(vs->getAttribute("os", "param"));
+ ui->label_os->setToolTip(vs->getAttribute("os", "param"));
+
+ ui->textBrowser->setText(vs->getAttribute("long_description", "param"));
+
+ } else {
+ ui->label_name->setText(s->shortDescription());
+ ui->label_creator->setText("");
+ ui->label_os->setText(QCoreApplication::instance()->translate("Dialog", "Native"));
+ ui->textBrowser->setPlainText(QCoreApplication::instance()->translate("Dialog", "Running on this machine."));
+ }
+}
diff --git a/src/dialog.h b/src/dialog.h
index 63f7c45..af795a9 100644
--- a/src/dialog.h
+++ b/src/dialog.h
@@ -47,6 +47,7 @@ class Dialog : public QDialog {
void on_pushButtonStart_clicked();
void on_pushButtonAbort_clicked();
void on_treeView_activated(QModelIndex index);
+ void treeView_selectionChanged(const QModelIndex& current, const QModelIndex&);
void onCenterTimer();
public slots:
diff --git a/src/globals.h b/src/globals.h
index 14374ad..c3a39ff 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -13,8 +13,8 @@
#define VMCHOOSER_SESSION_START_SCRIPT "/opt/openslx/vmchooser/sessionstart"
-#define VMCHOOSER_DEFAULT_WIDTH 500
-#define VMCHOOSER_DEFAULT_HEIGHT 580
+#define VMCHOOSER_DEFAULT_WIDTH 800
+#define VMCHOOSER_DEFAULT_HEIGHT 600
#define OPENSLXCONFIG "/opt/openslx/config"
diff --git a/src/main.cpp b/src/main.cpp
index a682a06..207f36e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -223,9 +223,11 @@ int main(int argc, char *argv[]) {
w.addItems(xsessions, a.translate("Dialog", "X Sessions"));
}
- if (vsessions.size()) {
+ if (!vSessionUrl.isEmpty()) {
w.addLabelItem(a.translate("Dialog", "Loading..."), a.translate("Dialog", "Virtual Sessions"));
- if (!(QFile::permissions(runVmScript) & QFile::ExeUser)) {
+ }
+ if (vsessions.size()) {
+ if (!(QFile::permissions(runVmScript) & QFile::ExeUser)) {
std::cerr << a.translate(
"Console",
"vmchooser: external script %1 is not executable")
diff --git a/src/sessionsiconholder.cpp b/src/sessionsiconholder.cpp
index 35be62c..a158773 100644
--- a/src/sessionsiconholder.cpp
+++ b/src/sessionsiconholder.cpp
@@ -65,7 +65,7 @@ QIcon SessionsIconHolder::getIcon(const QString& name) {
} else if (QResource(":" + name.toLower()).isValid()) {
icon = QIcon(":" + name.toLower());
} else {
- icon = QIcon(":none");
+ icon = QIcon();
}
// insert icon to hash table
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index 6208606..177049d 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -65,20 +65,22 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const {
if (!url_icon.isNull()) {
return url_icon;
}
-
- // fallback to os icon
- if (s->type() == Session::VSESSION) {
- const VSession* vs = (VSession*) s;
- if (vs->getAttribute("os", "param").toLower().startsWith("win")) {
- return iconHolder->getIcon("windows");
- } else {
- return iconHolder->getIcon("linux");
- }
- }
} else {
// try to load icon from QResource
- return iconHolder->getIcon(icon);
+ QIcon res_icon = iconHolder->getIcon(icon);
+ if (!res_icon.isNull()) {
+ return res_icon;
+ }
}
+ // fallback to os icon
+ if (s->type() == Session::VSESSION) {
+ const VSession* vs = (VSession*) s;
+ if (vs->getAttribute("os", "param").toLower().startsWith("win")) {
+ return iconHolder->getIcon("windows");
+ } else {
+ return iconHolder->getIcon("linux");
+ }
+ }
}
}
} else if (role == Qt::DisplayRole) {
diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui
index 16990b3..6f8ce05 100644
--- a/src/ui/dialog.ui
+++ b/src/ui/dialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>543</width>
- <height>655</height>
+ <width>653</width>
+ <height>684</height>
</rect>
</property>
<property name="windowTitle">
@@ -101,40 +101,192 @@ margin-bottom:0px;}</string>
</layout>
</item>
<item>
- <widget class="QTreeView" name="treeView">
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="styleSheet">
- <string notr="true">#treeView {border-top:1px solid #999;
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QTreeView" name="treeView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">#treeView {border-top:1px solid #999;
border-bottom:1px solid #999;}
</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::HLine</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
- <property name="lineWidth">
- <number>0</number>
- </property>
- <property name="iconSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <property name="headerHidden">
- <bool>true</bool>
- </property>
- <attribute name="headerMinimumSectionSize">
- <number>23</number>
- </attribute>
- </widget>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="indentation">
+ <number>12</number>
+ </property>
+ <property name="headerHidden">
+ <bool>true</bool>
+ </property>
+ <attribute name="headerMinimumSectionSize">
+ <number>23</number>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Details</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Description:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QTextBrowser" name="textBrowser">
+ <property name="html">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Click on an item on the left side for more infos.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Creator:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Operating System:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_name">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_creator">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_os">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</item>
<item>
<widget class="QGroupBox" name="PVSOptionsGroupBox">
@@ -149,7 +301,7 @@ border-bottom:1px solid #999;}
<number>9</number>
</property>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0,0,0,0">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">