|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
#include <QDialogButtonBox> |
|
|
|
|
#include <QFormLayout> |
|
|
|
|
#include <QMenu> |
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
@ -22,6 +23,7 @@ DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) { |
|
|
|
|
tabbar->setDrawBase(false); |
|
|
|
|
tabbar->setUsesScrollButtons(true); |
|
|
|
|
tabbar->setAutoHide(true); |
|
|
|
|
tabbar->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
|
main_layout->addWidget(tabbar); |
|
|
|
|
|
|
|
|
|
// message title
|
|
|
|
@ -79,22 +81,47 @@ DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) { |
|
|
|
|
QObject::connect(binary_view, &BinaryView::addSignal, this, &DetailWidget::addSignal); |
|
|
|
|
QObject::connect(can, &CANMessages::updated, this, &DetailWidget::updateState); |
|
|
|
|
QObject::connect(dbc(), &DBCManager::DBCFileChanged, [this]() { dbcMsgChanged(); }); |
|
|
|
|
QObject::connect(tabbar, &QTabBar::currentChanged, [this](int index) { setMessage(messages[index]); }); |
|
|
|
|
QObject::connect(tabbar, &QTabBar::customContextMenuRequested, this, &DetailWidget::showTabBarContextMenu); |
|
|
|
|
QObject::connect(tabbar, &QTabBar::currentChanged, [this](int index) { |
|
|
|
|
if (index != -1 && tabbar->tabText(index) != msg_id) { |
|
|
|
|
setMessage(tabbar->tabText(index)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
QObject::connect(tabbar, &QTabBar::tabCloseRequested, [=](int index) { |
|
|
|
|
messages.removeAt(index); |
|
|
|
|
if (tabbar->currentIndex() == index) { |
|
|
|
|
tabbar->setCurrentIndex(index == tabbar->count() - 1 ? index - 1 : index + 1); |
|
|
|
|
} |
|
|
|
|
tabbar->removeTab(index); |
|
|
|
|
setMessage(messages.isEmpty() ? "" : messages[0]); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DetailWidget::showTabBarContextMenu(const QPoint &pt) { |
|
|
|
|
int index = tabbar->tabAt(pt); |
|
|
|
|
if (index >= 0) { |
|
|
|
|
QMenu menu(this); |
|
|
|
|
menu.addAction(tr("Close Other Tabs")); |
|
|
|
|
if (menu.exec(tabbar->mapToGlobal(pt))) { |
|
|
|
|
for (int i = tabbar->count() - 1; i >= 0; --i) { |
|
|
|
|
if (i != index) |
|
|
|
|
tabbar->removeTab(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DetailWidget::setMessage(const QString &message_id) { |
|
|
|
|
if (message_id.isEmpty()) return; |
|
|
|
|
|
|
|
|
|
int index = messages.indexOf(message_id); |
|
|
|
|
qWarning() << "setmessage" << message_id; |
|
|
|
|
int index = -1; |
|
|
|
|
for (int i = 0; i < tabbar->count(); ++i) { |
|
|
|
|
if (tabbar->tabText(i) == message_id) { |
|
|
|
|
index = i; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (index == -1) { |
|
|
|
|
messages.push_back(message_id); |
|
|
|
|
tabbar->addTab(message_id); |
|
|
|
|
index = tabbar->count() - 1; |
|
|
|
|
index = tabbar->addTab(message_id); |
|
|
|
|
auto msg = dbc()->msg(message_id); |
|
|
|
|
tabbar->setTabToolTip(index, msg ? msg->name.c_str() : "untitled"); |
|
|
|
|
} |
|
|
|
|