From 7a9bd51e9501bfe6488d3e913195fafdb3f01bf4 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 25 Feb 2016 12:29:38 -0800 Subject: [PATCH] Qt: Capture Interfaces dialog geometry updates. Widen CaptureInterfacesDialog. Manually set some column widths. Change-Id: I84fd060d83b5f7bc186d79e22d5cc608dfdbd6c5 Reviewed-on: https://code.wireshark.org/review/14148 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/capture_interfaces_dialog.cpp | 33 +++++++++++++++++++++++++---- ui/qt/capture_interfaces_dialog.ui | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 8dfc67d05d..82acc44131 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -64,7 +64,6 @@ // - Fix InterfaceTreeDelegate method names. // - You can edit filters via the main CaptureFilterCombo and via each // individual interface row. We should probably do one or the other. -// - resizeColumnToContents isn't shrinking some columns properly. const int stat_update_interval_ = 1000; // ms @@ -148,7 +147,6 @@ CaptureInterfacesDialog::CaptureInterfacesDialog(QWidget *parent) : ui->interfaceTree->setItemDelegateForColumn(col_filter_, &interface_item_delegate_); interface_item_delegate_.setTree(ui->interfaceTree); - ui->interfaceTree->setColumnWidth(col_link_, 100); #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) ui->filenameLineEdit->setPlaceholderText(tr("Leave blank to use a temporary file")); @@ -583,8 +581,35 @@ void CaptureInterfacesDialog::updateInterfaces() } } - for (int i = 0; i < ui->interfaceTree->topLevelItemCount(); i++) { - ui->interfaceTree->resizeColumnToContents(i); + // col_interface_ = 0, + // col_traffic_, + // col_link_, + // col_pmode_, + // col_snaplen_, + // col_buffer_, + // col_monitor_, + // col_filter_, + // col_num_columns_ + // Manually or automatically size some columns as needed. + int one_em = fontMetrics().height(); + for (int col = 0; col < ui->interfaceTree->topLevelItemCount(); col++) { + switch (col) { + case col_pmode_: + ui->interfaceTree->setColumnWidth(col, one_em * 6); + break; + case col_snaplen_: + ui->interfaceTree->setColumnWidth(col, one_em * 4.25); + break; + case col_buffer_: + ui->interfaceTree->setColumnWidth(col, one_em * 4.25); + break; + case col_monitor_: + ui->interfaceTree->setColumnWidth(col, one_em * 5.25); + break; + default: + ui->interfaceTree->resizeColumnToContents(col); + } + } start_bt_->setEnabled((global_capture_opts.num_selected > 0)? true: false); diff --git a/ui/qt/capture_interfaces_dialog.ui b/ui/qt/capture_interfaces_dialog.ui index 267885e396..c9724f367e 100644 --- a/ui/qt/capture_interfaces_dialog.ui +++ b/ui/qt/capture_interfaces_dialog.ui @@ -6,7 +6,7 @@ 0 0 - 750 + 950 440