MainStatusBar::MainStatusBar(QWidget *parent) : QStatusBar(parent), cap_file_(NULL), edit_action_(NULL), delete_action_(NULL) { QSplitter *splitter = new QSplitter(this); #ifdef HAVE_LIBPCAP QString ready_msg(tr("Ready to load or capture")); #else QString ready_msg(tr("Ready to load file")); #endif QWidget *info_progress = new QWidget(this); QHBoxLayout *info_progress_hb = new QHBoxLayout(info_progress); QAction *action; #if defined(Q_OS_WIN) // Handles are the same color as widgets, at least on Windows 7. splitter->setHandleWidth(3); splitter->setStyleSheet(QString( "QSplitter::handle {" " border-left: 1px solid palette(mid);" " 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(); // XXX Add the comment icon info_progress_hb->setContentsMargins(0, 0, 0, 0); info_status_.setTemporaryContext(STATUS_CTX_TEMPORARY); info_progress_hb->addWidget(&expert_status_); info_progress_hb->addWidget(&info_status_); info_progress_hb->addWidget(&progress_bar_); info_progress_hb->addStretch(10); splitter->addWidget(info_progress); splitter->addWidget(&packet_status_); splitter->addWidget(&profile_status_); splitter->setStretchFactor(0, 3); splitter->setStretchFactor(1, 3); splitter->setStretchFactor(2, 1); addWidget(splitter, 1); cur_main_status_bar_ = this; splitter->hide(); info_status_.pushText(ready_msg, STATUS_CTX_MAIN); packets_bar_update(); action = ctx_menu_.addAction(tr("Manage Profiles...")); action->setData(ProfileDialog::ShowProfiles); connect(action, SIGNAL(triggered()), this, SLOT(manageProfile())); ctx_menu_.addSeparator(); action = ctx_menu_.addAction(tr("New...")); action->setData(ProfileDialog::NewProfile); connect(action, SIGNAL(triggered()), this, SLOT(manageProfile())); edit_action_ = ctx_menu_.addAction(tr("Edit...")); edit_action_->setData(ProfileDialog::EditCurrentProfile); connect(edit_action_, SIGNAL(triggered()), this, SLOT(manageProfile())); delete_action_ = ctx_menu_.addAction(tr("Delete")); delete_action_->setData(ProfileDialog::DeleteCurrentProfile); connect(delete_action_, SIGNAL(triggered()), this, SLOT(manageProfile())); ctx_menu_.addSeparator(); profile_menu_.setTitle(tr("Switch to")); ctx_menu_.addMenu(&profile_menu_); connect(wsApp, SIGNAL(appInitialized()), splitter, SLOT(show())); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(pushProfileName())); connect(&info_status_, SIGNAL(toggleTemporaryFlash(bool)), this, SLOT(toggleBackground(bool))); connect(wsApp, SIGNAL(captureCaptureUpdateContinue(capture_session*)), this, SLOT(updateCaptureStatistics(capture_session*))); connect(wsApp, SIGNAL(configurationProfileChanged(const gchar *)), this, SLOT(pushProfileName())); connect(&profile_status_, SIGNAL(mousePressedAt(QPoint,Qt::MouseButton)), this, SLOT(showProfileMenu(QPoint,Qt::MouseButton))); }
MainStatusBar::MainStatusBar(QWidget *parent) : QStatusBar(parent), cap_file_(NULL), edit_action_(NULL), delete_action_(NULL) { QSplitter *splitter = new QSplitter(this); #ifdef HAVE_LIBPCAP QString ready_msg(tr("Ready to load or capture")); #else QString ready_msg(tr("Ready to load file")); #endif QWidget *info_progress = new QWidget(this); QHBoxLayout *info_progress_hb = new QHBoxLayout(info_progress); QAction *action; #if defined(Q_OS_WIN) // Handles are the same color as widgets, at least on Windows 7. splitter->setHandleWidth(3); splitter->setStyleSheet(QString( "QSplitter::handle {" " border-left: 1px solid palette(mid);" " border-right: 1px solid palette(mid);" "}" )); #endif 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(icon_size, icon_size)); 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. StockIcon comment_icon("x-capture-comment-update"); comment_button_ = new QToolButton(this); comment_button_->setIcon(comment_icon); comment_button_->setIconSize(QSize(icon_size, icon_size)); 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(icon_size / 2, 0, 0, 0); info_status_.setTemporaryContext(STATUS_CTX_TEMPORARY); info_status_.setShrinkable(true); 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); splitter->addWidget(info_progress); splitter->addWidget(&packet_status_); splitter->addWidget(&profile_status_); splitter->setStretchFactor(0, 3); splitter->setStretchFactor(1, 3); splitter->setStretchFactor(2, 1); addWidget(splitter, 1); cur_main_status_bar_ = this; splitter->hide(); info_status_.pushText(ready_msg, STATUS_CTX_MAIN); packets_bar_update(); action = ctx_menu_.addAction(tr("Manage Profiles" UTF8_HORIZONTAL_ELLIPSIS)); action->setData(ProfileDialog::ShowProfiles); connect(action, SIGNAL(triggered()), this, SLOT(manageProfile())); ctx_menu_.addSeparator(); action = ctx_menu_.addAction(tr("New" UTF8_HORIZONTAL_ELLIPSIS)); action->setData(ProfileDialog::NewProfile); connect(action, SIGNAL(triggered()), this, SLOT(manageProfile())); edit_action_ = ctx_menu_.addAction(tr("Edit" UTF8_HORIZONTAL_ELLIPSIS)); edit_action_->setData(ProfileDialog::EditCurrentProfile); connect(edit_action_, SIGNAL(triggered()), this, SLOT(manageProfile())); delete_action_ = ctx_menu_.addAction(tr("Delete")); delete_action_->setData(ProfileDialog::DeleteCurrentProfile); connect(delete_action_, SIGNAL(triggered()), this, SLOT(manageProfile())); ctx_menu_.addSeparator(); profile_menu_.setTitle(tr("Switch to")); ctx_menu_.addMenu(&profile_menu_); #ifdef QWINTASKBARPROGRESS_H progress_frame_.enableTaskbarUpdates(true); #endif connect(wsApp, SIGNAL(appInitialized()), splitter, SLOT(show())); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(pushProfileName())); connect(&info_status_, SIGNAL(toggleTemporaryFlash(bool)), this, SLOT(toggleBackground(bool))); connect(wsApp, SIGNAL(profileNameChanged(const gchar *)), this, SLOT(pushProfileName())); connect(&profile_status_, SIGNAL(mousePressedAt(QPoint,Qt::MouseButton)), this, SLOT(showProfileMenu(QPoint,Qt::MouseButton))); connect(&progress_frame_, SIGNAL(stopLoading()), this, SIGNAL(stopLoading())); }