2
0
forked from Ivasoft/DSView

update: protocol search panel size

This commit is contained in:
dreamsourcelabTAI
2022-04-22 10:04:35 +08:00
parent fcddf9d974
commit aae3278be0
7 changed files with 54 additions and 31 deletions

View File

@@ -116,6 +116,11 @@ public:
void SetProtocolFormat(const std::string &protocolName, const std::string &value);
std::string GetProtocolFormat(const std::string &protocolName);
inline bool IsLangCn()
{
return _frameOptions.language == LAN_CN;
}
public:
AppOptions _appOptions;
UserHistory _userHistory;

View File

@@ -20,14 +20,17 @@
*/
#include "keywordlineedit.h"
#include "../config/appconfig.h"
#define PROTOCOL_FIND_TITLE "Protocol search..."
#define PROTOCOL_FIND_TITLE_cn "协议查找..."
KeywordLineEdit::KeywordLineEdit(QWidget *parent, IKeywordActive *active)
:QLineEdit(parent)
{
_bText = false;
_active = active;
this->setText(PROTOCOL_FIND_TITLE);
this->ResetText();
}
void KeywordLineEdit::mousePressEvent(QMouseEvent *e)
@@ -39,6 +42,19 @@ KeywordLineEdit::KeywordLineEdit(QWidget *parent, IKeywordActive *active)
}
void KeywordLineEdit::ResetText()
{
if (_bText){
return;
}
if (AppConfig::Instance().IsLangCn())
this->setText(PROTOCOL_FIND_TITLE_cn);
else
this->setText(PROTOCOL_FIND_TITLE);
}
void KeywordLineEdit::SetInputText(QString text)
{
this->setText(PROTOCOL_FIND_TITLE);
_bText = true;
this->setText(text);
}

View File

@@ -41,11 +41,14 @@ public:
void ResetText();
void SetInputText(QString text);
protected:
void mousePressEvent(QMouseEvent *e);
private:
IKeywordActive *_active;
bool _bText;
};

View File

@@ -78,7 +78,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
_del_all_button->setCheckable(true);
_keyword_edit = new KeywordLineEdit(_up_widget, this);
_keyword_edit->setReadOnly(true);
_keyword_edit->setReadOnly(true);
GSList *l = const_cast<GSList*>(srd_decoder_list());
@@ -247,6 +247,8 @@ void ProtocolDock::retranslateUi()
_search_edit->setPlaceholderText(tr("search"));
_matchs_title_label->setText(tr("Matching Items:"));
_dn_title_label->setText(tr("Protocol List Viewer"));
_keyword_edit->ResetText();
}
void ProtocolDock::reStyle()
@@ -265,7 +267,7 @@ void ProtocolDock::reStyle()
for (auto it = _protocol_lay_items.begin(); it != _protocol_lay_items.end(); it++){
(*it)->ResetStyle();
}
}
}
void ProtocolDock::changeEvent(QEvent *event)
@@ -292,6 +294,7 @@ void ProtocolDock::resizeEvent(QResizeEvent *event)
_pre_button->width()-_nxt_button->width();
width = std::max(width, 0);
_search_edit->setMinimumWidth(width);
_keyword_edit->setMinimumWidth(width-20);
QScrollArea::resizeEvent(event);
}
@@ -1012,7 +1015,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
if (data_handle != NULL){
DecoderInfoItem *info = (DecoderInfoItem*)data_handle;
srd_decoder *dec = (srd_decoder *)(info->_data_handle);
this->_keyword_edit->setText( QString(dec->name));
this->_keyword_edit->SetInputText(QString(dec->name));
_selected_protocol_id = QString(dec->id);
this->on_add_protocol();
}

View File

@@ -4,7 +4,7 @@
#include <QPoint>
#include <QLineEdit>
#include <QScrollBar>
#include <QDebug>
//----------------------ComboButtonItem
@@ -29,9 +29,7 @@ SearchComboBox::SearchComboBox(QWidget *parent)
{
_bShow = false;
_item_click = NULL;
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
// setAttribute(Qt::WA_TranslucentBackground);
}
SearchComboBox::~SearchComboBox(){
@@ -50,14 +48,14 @@ void SearchComboBox::ShowDlg(QWidget *editline)
_bShow = true;
int w = 350;
int h = 450;
int h = 550;
int eh = 20;
if (editline != NULL){
w = editline->width() + 7;
w = editline->width();
}
this->setMinimumSize(w, h);
this->setMaximumSize(w, h);
this->setFixedSize(w, h);
QVBoxLayout *grid = new QVBoxLayout(this);
this->setLayout(grid);
@@ -67,19 +65,15 @@ void SearchComboBox::ShowDlg(QWidget *editline)
QLineEdit *edit = new QLineEdit(this);
edit->setMaximumWidth(this->width());
grid->addWidget(edit);
QWidget *panel = new QWidget(this);
grid->addWidget(panel);
grid->addWidget(edit);
eh = edit->height();
QWidget *panel= new QWidget(this);
panel->setContentsMargins(0,0,0,0);
panel->setMinimumSize(w, h - edit->height() - 5);
panel->setMaximumSize(w, h - edit->height() - 5);
panel->setFixedSize(w, h - eh);
grid->addWidget(panel);
QWidget *listPanel = new QWidget(panel);
listPanel->setMinimumSize(w-2, panel->height());
listPanel->setMaximumWidth(w-2);
QVBoxLayout *listLay = new QVBoxLayout(listPanel);
listLay->setContentsMargins(2, 2, 20, 2);
listLay->setSpacing(0);
@@ -98,8 +92,9 @@ void SearchComboBox::ShowDlg(QWidget *editline)
_scroll = new QScrollArea(panel);
_scroll->setWidget(listPanel);
// pScrollArea->setStyleSheet("QScrollArea{border:none; background:red;}");
_scroll->setStyleSheet("QScrollArea{border:none;}");
_scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
_scroll->setFixedSize(w, h - eh);
if (editline != NULL)
{
@@ -153,6 +148,9 @@ void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle)
void SearchComboBox::on_keyword_changed(const QString &value)
{
if (_items.size() == 0)
return;
for(auto o : _items)
{
if (value == ""
@@ -166,6 +164,6 @@ void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle)
o->_control->hide();
}
}
_scroll->verticalScrollBar()->setValue(0);
}

View File

@@ -70,10 +70,10 @@ private:
void OnItemClick(void *sender, void *data_handle);
private:
bool _bShow;
bool _bShow;
std::vector<SearchDataItem*> _items;
ISearchItemClick *_item_click;
QScrollArea *_scroll;
ISearchItemClick *_item_click;
QScrollArea *_scroll;
};
#endif // SEARCHCOMBOBOX_H

View File

@@ -743,7 +743,7 @@ void DecodeTrace::create_decoder_form(
decoder_form->setFormAlignment(Qt::AlignLeft);
decoder_form->setLabelAlignment(Qt::AlignLeft);
decoder_form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
// Add the mandatory channels
for(l = decoder->channels; l; l = l->next) {
const struct srd_channel *const pdch =
@@ -758,7 +758,7 @@ void DecodeTrace::create_decoder_form(
_probe_selectors.push_back(s);
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_probe_selected(int)));
}
}
// Add the optional channels
for(l = decoder->opt_channels; l; l = l->next) {
@@ -779,10 +779,8 @@ void DecodeTrace::create_decoder_form(
// Add the options
auto binding = new prop::binding::DecoderOptions(decoder_stack, dec);
binding->add_properties_to_form(decoder_form, true);
_bindings.push_back(binding);
pv::widgets::DecoderGroupBox *const group =
new pv::widgets::DecoderGroupBox(decoder_stack, dec, decoder_form, parent);