3
3
#include < QFormLayout>
4
4
#include < QMenu>
5
5
#include < QMessageBox>
6
- #include < QToolButton>
7
6
8
7
#include " tools/cabana/commands.h"
9
8
@@ -22,22 +21,22 @@ DetailWidget::DetailWidget(ChartsWidget *charts, QWidget *parent) : charts(chart
22
21
main_layout->addWidget (tabbar);
23
22
24
23
// message title
25
- QToolBar *toolbar = new QToolBar ( this );
26
- toolbar-> setIconSize ({ 16 , 16 } );
24
+ QHBoxLayout *title_layout = new QHBoxLayout ( );
25
+ title_layout-> setContentsMargins ( 0 , 6 , 0 , 0 );
27
26
time_label = new QLabel (this );
28
27
time_label->setToolTip (tr (" Current time" ));
29
28
time_label->setStyleSheet (" QLabel{font-weight:bold;}" );
30
- toolbar ->addWidget (time_label);
29
+ title_layout ->addWidget (time_label);
31
30
name_label = new ElidedLabel (this );
32
- name_label->setContentsMargins (5 , 0 , 5 , 0 );
33
31
name_label->setStyleSheet (" QLabel{font-weight:bold;}" );
34
32
name_label->setAlignment (Qt::AlignCenter);
35
33
name_label->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
36
- toolbar->addWidget (name_label);
37
- toolbar->addAction (utils::icon (" pencil" ), " " , this , &DetailWidget::editMsg)->setToolTip (tr (" Edit Message" ));
38
- remove_msg_act = toolbar->addAction (utils::icon (" x-lg" ), " " , this , &DetailWidget::removeMsg);
39
- remove_msg_act->setToolTip (tr (" Remove Message" ));
40
- main_layout->addWidget (toolbar);
34
+ title_layout->addWidget (name_label);
35
+ auto edit_btn = toolButton (" pencil" , tr (" Edit Message" ));
36
+ title_layout->addWidget (edit_btn);
37
+ remove_btn = toolButton (" x-lg" , tr (" Remove Message" ));
38
+ title_layout->addWidget (remove_btn);
39
+ main_layout->addLayout (title_layout);
41
40
42
41
// warning
43
42
warning_widget = new QWidget (this );
@@ -64,6 +63,8 @@ DetailWidget::DetailWidget(ChartsWidget *charts, QWidget *parent) : charts(chart
64
63
tab_widget->addTab (history_log = new LogsWidget (this ), utils::icon (" stopwatch" ), " &Logs" );
65
64
main_layout->addWidget (tab_widget);
66
65
66
+ QObject::connect (edit_btn, &QToolButton::clicked, this , &DetailWidget::editMsg);
67
+ QObject::connect (remove_btn, &QToolButton::clicked, this , &DetailWidget::removeMsg);
67
68
QObject::connect (binary_view, &BinaryView::resizeSignal, signal_view->model , &SignalModel::resizeSignal);
68
69
QObject::connect (binary_view, &BinaryView::addSignal, signal_view->model , &SignalModel::addSignal);
69
70
QObject::connect (binary_view, &BinaryView::signalHovered, signal_view, &SignalView::signalHovered);
@@ -83,9 +84,7 @@ DetailWidget::DetailWidget(ChartsWidget *charts, QWidget *parent) : charts(chart
83
84
setMessage (tabbar->tabData (index ).value <MessageId>());
84
85
}
85
86
});
86
- QObject::connect (tabbar, &QTabBar::tabCloseRequested, [this ](int index ) {
87
- tabbar->removeTab (index );
88
- });
87
+ QObject::connect (tabbar, &QTabBar::tabCloseRequested, tabbar, &QTabBar::removeTab);
89
88
QObject::connect (charts, &ChartsWidget::seriesChanged, signal_view, &SignalView::updateChartState);
90
89
}
91
90
@@ -141,7 +140,7 @@ void DetailWidget::refresh() {
141
140
} else {
142
141
warnings.push_back (tr (" Drag-Select in binary view to create new signal." ));
143
142
}
144
- remove_msg_act ->setEnabled (msg != nullptr );
143
+ remove_btn ->setEnabled (msg != nullptr );
145
144
name_label->setText (msgName (msg_id));
146
145
147
146
if (!warnings.isEmpty ()) {
0 commit comments