From b4a4de78d8f78f0cea54b9ae846a120c2a68d893 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 14 Oct 2015 15:29:04 -0700 Subject: Use buttons to display the main status bar icons. Use QToolButtons to display the expert indicator and comment icons in the main status bar. Use the same style sheet hack we use in ProgressFrame to un-style the buttons. Make sure we specify the @2x comment icon in our .qrc file so that it's loaded and used on retina displays. Move the comment and expert .pngs to the stock icon directory and use StockIcon to load them. Remove status.qrc since it's no longer used. Change-Id: I84485b22656f8f9af29ad3c02446ffefb6657ed5 Reviewed-on: https://code.wireshark.org/review/11048 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/main_status_bar.cpp | 77 ++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 31 deletions(-) (limited to 'ui/qt/main_status_bar.cpp') diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp index 1e466266be..47598e6615 100644 --- a/ui/qt/main_status_bar.cpp +++ b/ui/qt/main_status_bar.cpp @@ -25,24 +25,26 @@ #include "file.h" -#include "epan/expert.h" -#include "wsutil/filesystem.h" +#include + +#include +#include #include "ui/main_statusbar.h" #include "ui/profile.h" #include "ui/qt/qt_ui_utils.h" -#include + #include "capture_file.h" #include "main_status_bar.h" #include "profile_dialog.h" - -#include -#include -#include - +#include "stock_icon.h" #include "tango_colors.h" +#include +#include +#include +#include // XXX - The GTK+ code assigns priorities to these and pushes/pops accordingly. @@ -116,28 +118,41 @@ MainStatusBar::MainStatusBar(QWidget *parent) : " border-right: 1px solid palette(mid);" "}" )); -#elif defined(Q_OS_MAC) - expert_status_.setAttribute(Qt::WA_MacSmallSize, true); #endif - expert_status_.setTextFormat(Qt::RichText); - expert_status_.hide(); + QString button_ss = + "QToolButton {" + " border: none;" + " background: transparent;" // Disables platform style on Windows. + " padding: 0px;" + " margin: 0px;" + "}"; + + expert_button_ = new QToolButton(this); + expert_button_->setIconSize(QSize(14, 14)); + expert_button_->setStyleSheet(button_ss); + expert_button_->hide(); // We just want a clickable image. Using a QPushButton or QToolButton would require // a lot of adjustment. - comment_label_.setText(""); - comment_label_.setToolTip(tr("Open the Capture File Properties dialog")); - comment_label_.setEnabled(false); - connect(&expert_status_, SIGNAL(linkActivated(QString)), this, SIGNAL(showExpertInfo())); - connect(&comment_label_, SIGNAL(linkActivated(QString)), this, SIGNAL(editCaptureComment())); + StockIcon comment_icon("x-capture-comment-update"); + comment_button_ = new QToolButton(this); + comment_button_->setIcon(comment_icon); + comment_button_->setIconSize(QSize(14, 14)); + comment_button_->setStyleSheet(button_ss); + + comment_button_->setToolTip(tr("Open the Capture File Properties dialog")); + comment_button_->setEnabled(false); + connect(expert_button_, SIGNAL(clicked(bool)), this, SIGNAL(showExpertInfo())); + connect(comment_button_, SIGNAL(clicked(bool)), this, SIGNAL(editCaptureComment())); info_progress_hb->setContentsMargins(0, 0, 0, 0); info_status_.setTemporaryContext(STATUS_CTX_TEMPORARY); info_status_.setShrinkable(true); - info_progress_hb->addWidget(&expert_status_); - info_progress_hb->addWidget(&comment_label_); + info_progress_hb->addWidget(expert_button_); + info_progress_hb->addWidget(comment_button_); info_progress_hb->addWidget(&info_status_); info_progress_hb->addWidget(&progress_frame_); info_progress_hb->addStretch(10); @@ -197,7 +212,7 @@ void MainStatusBar::showExpert() { } void MainStatusBar::captureFileClosing() { - expert_status_.hide(); + expert_button_->hide(); progress_frame_.captureFileClosing(); } @@ -205,39 +220,39 @@ void MainStatusBar::expertUpdate() { // won't load @2x versions in Qt versions earlier than 5.4. // https://bugreports.qt.io/browse/QTBUG-36383 // We might have to switch to a QPushButton. - QString img_text = ""); // break; default: - img_text.append("none"); + stock_name.append("none"); tt_text = tr("No expert information"); break; } - img_text.append(".png\">"); - expert_status_.setText(img_text); - expert_status_.setToolTip(tt_text); - expert_status_.show(); + StockIcon expert_icon(stock_name); + expert_button_->setIcon(expert_icon); + expert_button_->setToolTip(tt_text); + expert_button_->show(); } // ui/gtk/main_statusbar.c @@ -255,7 +270,7 @@ void MainStatusBar::setFileName(CaptureFile &cf) void MainStatusBar::setCaptureFile(capture_file *cf) { cap_file_ = cf; - comment_label_.setEnabled(cap_file_ != NULL); + comment_button_->setEnabled(cap_file_ != NULL); } void MainStatusBar::pushTemporaryStatus(const QString &message) { -- cgit v1.2.1