aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-17 19:37:18 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-17 19:37:18 +0000
commit85c9c2ee911c956caceb360e6048fb4c99bd8381 (patch)
treece57313db1193d33c2d1d250cd3b9d56dca3bab9
parent7a6ee19f2fd8e40d0fbe1fb45421da8ad0492348 (diff)
More welcome screen layout updates. Instantiate the welcome screen
automatically. Try to make the sparklines resolution independent. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@44555 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--ui/qt/interface_tree.cpp4
-rw-r--r--ui/qt/main_welcome.cpp24
-rw-r--r--ui/qt/main_welcome.ui109
-rw-r--r--ui/qt/main_window.cpp9
-rw-r--r--ui/qt/main_window.h2
-rw-r--r--ui/qt/main_window.ui8
-rw-r--r--ui/qt/qt_ui_utils.h1
-rw-r--r--ui/qt/sparkline_delegate.cpp24
8 files changed, 96 insertions, 85 deletions
diff --git a/ui/qt/interface_tree.cpp b/ui/qt/interface_tree.cpp
index c321173855..5eac19eeec 100644
--- a/ui/qt/interface_tree.cpp
+++ b/ui/qt/interface_tree.cpp
@@ -94,6 +94,7 @@ InterfaceTree::InterfaceTree(QWidget *parent) :
v.setValue(points);
ti->setData(1, Qt::UserRole, v);
addTopLevelItem(ti);
+ resizeColumnToContents(1);
}
}
@@ -131,9 +132,6 @@ void InterfaceTree::hideEvent(QHideEvent *evt) {
void InterfaceTree::showEvent(QShowEvent *evt) {
Q_UNUSED(evt);
- // XXX The column disappears otherwise.
- setColumnWidth(1, 10);
-
m_statTimer->start(1000);
}
diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp
index 782b05deeb..b468db5f8b 100644
--- a/ui/qt/main_welcome.cpp
+++ b/ui/qt/main_welcome.cpp
@@ -83,11 +83,13 @@ MainWelcome::MainWelcome(QWidget *parent) :
recent_files_ = welcome_ui_->recentList;
setStyleSheet(
- "QFrame {"
+ "MainWelcome {"
" background: palette(base);"
+ " padding: 2em;"
" }"
"QListWidget {"
" border: 0;"
+// " border: 1px dotted blue;"
"}"
// "QListWidget::focus {"
// " border: 1px dotted palette(mid);"
@@ -99,6 +101,7 @@ MainWelcome::MainWelcome(QWidget *parent) :
"}"
"QTreeWidget {"
" border: 0;"
+// " border: 1px dotted green;"
"}"
// "QTreeWidget::focus {"
// " border: 1px dotted palette(mid);"
@@ -112,6 +115,25 @@ MainWelcome::MainWelcome(QWidget *parent) :
iface_tree->setAttribute(Qt::WA_MacShowFocusRect, false);
#endif
+ task_list_->setStyleSheet(
+ "QListWidget {"
+ " margin-right: 2em;"
+ "}"
+ "QListWidget::item {"
+ " padding: 1.5em;"
+ " margin-bottom: 1em;"
+ " border-radius: 0.5em;"
+ "}"
+// "QListWidget::item:hover {"
+// " background-color: palette(midlight);"
+// " background-color: palette(midlight);"
+// "}"
+ "QListWidget::item:selected {"
+ " background-color: palette(window);"
+ " color: palette(window-text);"
+ "}"
+ );
+
recent_files_->setStyleSheet(
"QListWidget::item {"
" padding-top: 0.1em;"
diff --git a/ui/qt/main_welcome.ui b/ui/qt/main_welcome.ui
index c3a3671f47..d648e8000e 100644
--- a/ui/qt/main_welcome.ui
+++ b/ui/qt/main_welcome.ui
@@ -37,79 +37,61 @@
</item>
<item row="1" column="1">
<widget class="QStackedWidget" name="taskStack">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
- <widget class="QWidget" name="capturePage">
- <widget class="InterfaceTree" name="interfaceTree">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>521</width>
- <height>421</height>
- </rect>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
+ <widget class="InterfaceTree" name="interfaceTree">
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
</property>
- <property name="columnCount">
- <number>2</number>
+ </column>
+ <column>
+ <property name="text">
+ <string notr="true">2</string>
</property>
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string notr="true">2</string>
- </property>
- </column>
- </widget>
+ </column>
</widget>
- <widget class="QWidget" name="recentPage">
- <widget class="QListWidget" name="recentList">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>521</width>
- <height>431</height>
- </rect>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- </widget>
+ <widget class="QListWidget" name="recentList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
</widget>
- <widget class="QWidget" name="helpPage">
- <widget class="QLabel" name="helpLinks">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>321</width>
- <height>391</height>
- </rect>
- </property>
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;User's Guide&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Wiki&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- </widget>
+ <widget class="QLabel" name="helpLinks">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;User's Guide&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Wiki&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QListWidget" name="taskList">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
@@ -123,6 +105,9 @@
<property name="autoScroll">
<bool>false</bool>
</property>
+ <property name="textElideMode">
+ <enum>Qt::ElideNone</enum>
+ </property>
<item>
<property name="text">
<string>Capture
@@ -132,7 +117,7 @@ live packets from the network</string>
<item>
<property name="text">
<string>Open
-recent capture files</string>
+a recent capture file</string>
</property>
</item>
<item>
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index e320c1a866..f85b99d6fc 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -104,10 +104,9 @@ MainWindow::MainWindow(QWidget *parent) :
main_ui_->mainStack->addWidget(splitter_v_);
- main_welcome_ = new MainWelcome(main_ui_->mainStack);
- main_ui_->mainStack->addWidget(main_welcome_);
+ main_welcome_ = main_ui_->welcomePage;
connect(main_welcome_, SIGNAL(recentFileActivated(QString&)),
- this, SLOT(on_actionFileOpen_triggered(QString&)));
+ this, SLOT(openRecentCaptureFile(QString&)));
connect(wsApp, SIGNAL(captureFileReadStarted(const capture_file*)),
this, SLOT(captureFileReadStarted(const capture_file*)));
@@ -329,7 +328,7 @@ void MainWindow::updateRecentFiles() {
}
}
-void MainWindow::on_actionFileOpen_triggered(QString &cfPath)
+void MainWindow::openRecentCaptureFile(QString &cfPath)
{
QString fileName = "";
QString displayFilter = "";
@@ -415,6 +414,6 @@ void MainWindow::recentActionTriggered() {
if (ra) {
QString cfPath = ra->data().toString();
- on_actionFileOpen_triggered(cfPath);
+ openRecentCaptureFile(cfPath);
}
}
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index e65cba8796..e8e8449ec8 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -76,7 +76,7 @@ public slots:
private slots:
void updateRecentFiles();
- void on_actionFileOpen_triggered(QString& cfPath = *new QString());
+ void openRecentCaptureFile(QString& cfPath = *new QString());
void on_actionFileClose_triggered();
void recentActionTriggered();
void on_actionHelpWebsite_triggered();
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index 61de368137..f0e019cb31 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -35,7 +35,7 @@
</property>
<item row="0" column="0">
<widget class="QStackedWidget" name="mainStack">
- <widget class="QWidget" name="welcomePage"/>
+ <widget class="MainWelcome" name="welcomePage"/>
<widget class="QWidget" name="packetPage"/>
</widget>
</item>
@@ -449,6 +449,12 @@
<extends>QStatusBar</extends>
<header>main_status_bar.h</header>
</customwidget>
+ <customwidget>
+ <class>MainWelcome</class>
+ <extends>QFrame</extends>
+ <header>main_welcome.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources>
<include location="../../image/toolbar.qrc"/>
diff --git a/ui/qt/qt_ui_utils.h b/ui/qt/qt_ui_utils.h
index fc469dd9cd..6b85529b41 100644
--- a/ui/qt/qt_ui_utils.h
+++ b/ui/qt/qt_ui_utils.h
@@ -33,7 +33,6 @@
#include <glib.h>
#include <epan/timestamp.h>
-//#include <packet_list.h>
#ifdef __cplusplus
extern "C" {
diff --git a/ui/qt/sparkline_delegate.cpp b/ui/qt/sparkline_delegate.cpp
index 7c126787b9..532edd190d 100644
--- a/ui/qt/sparkline_delegate.cpp
+++ b/ui/qt/sparkline_delegate.cpp
@@ -26,29 +26,29 @@
#include <QPainter>
#include <QApplication>
-#define MIN_WIDTH 10
-
-// XXX - Should we use a style sheet for this?
-#define SL_MARGIN 2
+#define SPARKLINE_MIN_EM_WIDTH 10
void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QList<int> *points = qvariant_cast<QList<int> *>(index.data(Qt::UserRole));
int max = 1;
- int content_w = option.rect.width() - (SL_MARGIN * 2);
- int content_h = option.rect.height() - (SL_MARGIN * 2);
+ int em_w = option.fontMetrics.height();
+ int content_w = option.rect.width() - (em_w / 4);
+ int content_h = option.fontMetrics.ascent() - 1;
int val;
qreal idx = 0.0;
+ qreal step_w = em_w / 10.0;
+ qreal steps = content_w / step_w;
QVector<QPointF> fpoints;
QStyledItemDelegate::paint(painter, option, index);
- if (!points || points->isEmpty() || content_w <= 0 || content_h <= 0) {
+ if (!points || points->isEmpty() || steps < 1.0 || content_h <= 0) {
return;
}
- while(points->length() > content_w) {
+ while((qreal) points->length() > steps) {
points->removeFirst();
}
@@ -58,7 +58,7 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
foreach (val, *points) {
fpoints.append(QPointF(idx, (qreal) content_h - (val * content_h / max) ));
- idx = idx + 1;
+ idx = idx + step_w;
}
QStyleOptionViewItemV4 optv4 = option;
@@ -83,7 +83,9 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
}
painter->setRenderHint(QPainter::Antialiasing, true);
- painter->translate(option.rect.x() + SL_MARGIN + 0.5, option.rect.y() + SL_MARGIN + 0.5);
+ painter->translate(
+ option.rect.x() + (em_w / 8) + 0.5,
+ option.rect.y() + ((option.rect.height() - option.fontMetrics.height()) / 2) + 1 + 0.5);
painter->drawPolyline(QPolygonF(fpoints));
// painter->setPen(Qt::NoPen);
@@ -98,5 +100,5 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
QSize SparkLineDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const {
- return QSize(MIN_WIDTH, QStyledItemDelegate::sizeHint(option, index).height());
+ return QSize(option.fontMetrics.height() * SPARKLINE_MIN_EM_WIDTH, QStyledItemDelegate::sizeHint(option, index).height());
}