More welcome screen layout updates. Instantiate the welcome screen

automatically. Try to make the sparklines resolution independent.

svn path=/trunk/; revision=44555
This commit is contained in:
Gerald Combs 2012-08-17 19:37:18 +00:00
parent 409f711889
commit c12c712d9c
8 changed files with 98 additions and 87 deletions

View File

@ -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);
}

View File

@ -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;"

View File

@ -37,79 +37,61 @@
</item>
<item row="1" column="1">
<widget class="QStackedWidget" name="taskStack">
<property name="currentIndex">
<number>2</number>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</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>
</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>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</column>
</widget>
</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>
<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="currentIndex">
<number>0</number>
</property>
<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>&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>
<string notr="true">1</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</widget>
</column>
</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="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>

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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"/>

View File

@ -33,7 +33,6 @@
#include <glib.h>
#include <epan/timestamp.h>
//#include <packet_list.h>
#ifdef __cplusplus
extern "C" {

View File

@ -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());
}