From 85c9c2ee911c956caceb360e6048fb4c99bd8381 Mon Sep 17 00:00:00 2001 From: gerald Date: Fri, 17 Aug 2012 19:37:18 +0000 Subject: 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 --- ui/qt/interface_tree.cpp | 4 +- ui/qt/main_welcome.cpp | 24 +++++++++- ui/qt/main_welcome.ui | 109 +++++++++++++++++++------------------------ ui/qt/main_window.cpp | 9 ++-- ui/qt/main_window.h | 2 +- ui/qt/main_window.ui | 8 +++- ui/qt/qt_ui_utils.h | 1 - ui/qt/sparkline_delegate.cpp | 24 +++++----- 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 @@ + + + 0 + 1 + + - 2 + 0 - - - - - 0 - 0 - 521 - 421 - - - - Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + 2 + + + false + + + + 1 - - 2 + + + + 2 - - false - - - - 1 - - - - - 2 - - - + - - - - - 0 - 0 - 521 - 431 - - - - Qt::ScrollBarAlwaysOff - - + + + + 1 + 1 + + + + Qt::ScrollBarAlwaysOff + - - - - - 0 - 0 - 321 - 391 - - - - <html><head/><body><p>User's Guide</p><p><br/></p><p>Wiki</p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - + + + <html><head/><body><p>User's Guide</p><p><br/></p><p>Wiki</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + - + 0 5 @@ -123,6 +105,9 @@ false + + Qt::ElideNone + Capture @@ -132,7 +117,7 @@ live packets from the network Open -recent capture files +a recent capture file 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 @@ - + @@ -449,6 +449,12 @@ QStatusBar
main_status_bar.h
+ + MainWelcome + QFrame +
main_welcome.h
+ 1 +
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 #include -//#include #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 #include -#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 *points = qvariant_cast *>(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 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()); } -- cgit v1.2.3