--- a/DSView/pv/dock/searchcombobox.h +++ b/DSView/pv/dock/searchcombobox.h @@ -58,6 +58,7 @@ public: QString _id; QString _name; + QString _section; void *_data_handle; QWidget *_control; }; @@ -74,7 +75,7 @@ void ShowDlg(QWidget *editline); - void AddDataItem(QString id, QString name, void *data_handle); + void AddDataItem(QString id, QString name, void *data_handle, QString section = QString()); inline void SetItemClickHandle(ISearchItemClick *click){ _item_click = click; @@ -95,6 +96,7 @@ std::vector _items; ISearchItemClick *_item_click; QScrollArea *_scroll; + std::vector > _sections; }; #endif // SEARCHCOMBOBOX_H --- a/DSView/pv/dock/searchcombobox.cpp +++ b/DSView/pv/dock/searchcombobox.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "../config/appconfig.h" #include "../appcontrol.h" #include "../ui/fn.h" @@ -107,8 +108,17 @@ QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); + QString section; for(auto o : _items) - { + { + if (!o->_section.isEmpty() && o->_section != section) { + section = o->_section; + auto heading = new QLabel(section, listPanel); + heading->setFont(font); + heading->setStyleSheet("font-weight: bold; padding: 8px 4px; border-top: 1px solid #344762;"); + listLay->addWidget(heading); + _sections.push_back(std::make_pair(section, heading)); + } ComboButtonItem *bt = new ComboButtonItem(panel, this, o); bt->setText(o->_name); bt->setObjectName("flat"); @@ -143,11 +153,12 @@ this->show(); } -void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle) +void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle, QString section) { SearchDataItem *item = new SearchDataItem(); item->_id = id; item->_name = name; + item->_section = section; item->_data_handle = data_handle; this->_items.push_back(item); } @@ -197,5 +208,14 @@ } } + for (auto section : _sections) { + bool visible = false; + for (auto item : _items) + if (item->_section == section.first && !item->_control->isHidden()) { + visible = true; + break; + } + section.second->setVisible(visible); + } _scroll->verticalScrollBar()->setValue(0); } --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -1060,10 +1060,15 @@ { SearchComboBox *panel = new SearchComboBox(this); - for (auto info : _decoderInfoList) - { - srd_decoder *dec = (srd_decoder *)(info->_data_handle); - panel->AddDataItem(QString(dec->id), QString(dec->name), info); + const QStringList customIds = {"gate_driver_timing", "transistor_pair", "set_uart", "set_can", "pm35_uart"}; + for (bool custom : {true, false}) { + for (auto info : _decoderInfoList) { + srd_decoder *dec = (srd_decoder *)(info->_data_handle); + if (customIds.contains(QString(dec->id)) != custom) + continue; + panel->AddDataItem(QString(dec->id), QString(dec->name), info, + custom ? QString::fromUtf8("Пользовательские") : QString::fromUtf8("Стандартные")); + } } QFont font = this->font(); --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -1329,7 +1329,8 @@ // default dockwidget size AppConfig &app = AppConfig::Instance(); QByteArray st = app.frameOptions.windowState; - if (!st.isEmpty()) + // Standalone toolbar rows must not reserve space above embedded docks. + if (!qApp->property("embeddedHost").toBool() && !st.isEmpty()) { try {