forked from Ivasoft/DSView
Merge branch 'dev-tai' of https://github.com/DreamSourceLab/DSView into dev-tai
This commit is contained in:
@@ -248,6 +248,7 @@ set(DSView_SOURCES
|
||||
pv/minizip/ioapi.c
|
||||
pv/dialogs/applicationpardlg.cpp
|
||||
pv/dock/keywordlineedit.cpp
|
||||
pv/dock/searchcombobox.cpp
|
||||
)
|
||||
|
||||
set(DSView_HEADERS
|
||||
@@ -332,6 +333,7 @@ set(DSView_HEADERS
|
||||
pv/minizip/ioapi.h
|
||||
pv/dialogs/applicationpardlg.h
|
||||
pv/dock/keywordlineedit.h
|
||||
pv/dock/searchcombobox.h
|
||||
)
|
||||
|
||||
set(DSView_FORMS
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "sigsession.h"
|
||||
@@ -35,7 +36,8 @@
|
||||
AppControl::AppControl()
|
||||
{
|
||||
sr_ctx = NULL;
|
||||
|
||||
_topWindow = NULL;
|
||||
|
||||
_device_manager = new pv::DeviceManager();
|
||||
_session = new pv::SigSession(_device_manager);
|
||||
}
|
||||
@@ -149,3 +151,11 @@ const char *AppControl::GetLastError()
|
||||
sr_log_loglevel_set(level);
|
||||
srd_log_loglevel_set(level);
|
||||
}
|
||||
|
||||
bool AppControl::TopWindowIsMaximized()
|
||||
{
|
||||
if (_topWindow != NULL){
|
||||
return _topWindow->isMaximized();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <string>
|
||||
|
||||
struct sr_context;
|
||||
class QWidget;
|
||||
|
||||
namespace pv{
|
||||
class DeviceManager;
|
||||
@@ -54,11 +55,23 @@ public:
|
||||
|
||||
void SetLogLevel(int level);
|
||||
|
||||
inline pv::SigSession* GetSession()
|
||||
{ return _session;}
|
||||
inline pv::SigSession* GetSession(){
|
||||
return _session;
|
||||
}
|
||||
|
||||
inline pv::DeviceManager& GetDeviceManager()
|
||||
{ return *_device_manager;}
|
||||
inline pv::DeviceManager& GetDeviceManager(){
|
||||
return *_device_manager;
|
||||
}
|
||||
|
||||
inline void SetTopWindow(QWidget *w){
|
||||
_topWindow = w;
|
||||
}
|
||||
|
||||
inline QWidget* GetTopWindow(){
|
||||
return _topWindow;
|
||||
}
|
||||
|
||||
bool TopWindowIsMaximized();
|
||||
|
||||
public:
|
||||
std::string _open_file_name;
|
||||
@@ -68,4 +81,5 @@ private:
|
||||
struct sr_context *sr_ctx;
|
||||
pv::DeviceManager *_device_manager;
|
||||
pv::SigSession *_session;
|
||||
QWidget *_topWindow;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,29 +20,41 @@
|
||||
*/
|
||||
|
||||
#include "keywordlineedit.h"
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
KeywordLineEdit::KeywordLineEdit(QComboBox *comboBox)
|
||||
:QLineEdit()
|
||||
{
|
||||
assert(comboBox);
|
||||
_comboBox = comboBox;
|
||||
#define PROTOCOL_FIND_TITLE "Protocol search..."
|
||||
#define PROTOCOL_FIND_TITLE_cn "协议查找..."
|
||||
|
||||
KeywordLineEdit::KeywordLineEdit(QWidget *parent, IKeywordActive *active)
|
||||
:QLineEdit(parent)
|
||||
{
|
||||
_bText = false;
|
||||
_active = active;
|
||||
this->ResetText();
|
||||
}
|
||||
|
||||
|
||||
void KeywordLineEdit::focusInEvent(QFocusEvent *e)
|
||||
void KeywordLineEdit::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QLineEdit::focusInEvent(e);
|
||||
QString key(PROTOCOL_FIND_TITLE);
|
||||
if (this->text() == key){
|
||||
this->setText("");
|
||||
}
|
||||
if (e->button() == Qt::LeftButton && _active != NULL){
|
||||
_active->BeginEditKeyword();
|
||||
}
|
||||
QLineEdit::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void KeywordLineEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
QLineEdit::focusOutEvent(e);
|
||||
void KeywordLineEdit::ResetText()
|
||||
{
|
||||
if (_bText){
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->text() == ""){
|
||||
this->setText(PROTOCOL_FIND_TITLE);
|
||||
}
|
||||
if (AppConfig::Instance().IsLangCn())
|
||||
this->setText(PROTOCOL_FIND_TITLE_cn);
|
||||
else
|
||||
this->setText(PROTOCOL_FIND_TITLE);
|
||||
}
|
||||
|
||||
void KeywordLineEdit::SetInputText(QString text)
|
||||
{
|
||||
_bText = true;
|
||||
this->setText(text);
|
||||
}
|
||||
@@ -23,25 +23,32 @@
|
||||
#define KEY_WORD_LINE_EDIT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QFocusEvent>
|
||||
#include <QLineEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QWidget>
|
||||
|
||||
#define PROTOCOL_FIND_TITLE "Protocol search..."
|
||||
class IKeywordActive{
|
||||
public:
|
||||
virtual void BeginEditKeyword()=0;
|
||||
};
|
||||
|
||||
class KeywordLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KeywordLineEdit(QComboBox *comboBox);
|
||||
KeywordLineEdit(QWidget *parent, IKeywordActive *active);
|
||||
|
||||
void ResetText();
|
||||
|
||||
void SetInputText(QString text);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
void focusOutEvent(QFocusEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
QComboBox *_comboBox;
|
||||
IKeywordActive *_active;
|
||||
bool _bText;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <algorithm>
|
||||
#include "../ui/msgbox.h"
|
||||
@@ -53,6 +54,7 @@
|
||||
#include "../data/decode/decoderstatus.h"
|
||||
#include "../data/decode/decoder.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -65,10 +67,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
{
|
||||
_session = session;
|
||||
_cur_search_index = -1;
|
||||
_search_edited = false;
|
||||
_searching = false;
|
||||
_add_silent = false;
|
||||
_bSettingList = false;
|
||||
_search_edited = false;
|
||||
|
||||
_up_widget = new QWidget(this);
|
||||
|
||||
@@ -78,12 +77,8 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
_del_all_button->setFlat(true);
|
||||
_del_all_button->setCheckable(true);
|
||||
|
||||
_protocol_combobox = new DsComboBox(_up_widget);
|
||||
_protocol_combobox->setEditable(true);
|
||||
_protocol_combobox->setLineEdit(new KeywordLineEdit(_protocol_combobox));
|
||||
_protocol_combobox->setCompleter(NULL);
|
||||
|
||||
//GSList *l = g_slist_sort(g_slist_copy((GSList*)srd_decoder_list()), decoder_name_cmp);
|
||||
_keyword_edit = new KeywordLineEdit(_up_widget, this);
|
||||
_keyword_edit->setReadOnly(true);
|
||||
|
||||
GSList *l = const_cast<GSList*>(srd_decoder_list());
|
||||
|
||||
@@ -93,13 +88,12 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
for(; l; l = l->next)
|
||||
{
|
||||
const srd_decoder *const d = (srd_decoder*)l->data;
|
||||
assert(d);
|
||||
// const bool have_probes = (d->channels || d->opt_channels) != 0;
|
||||
assert(d);
|
||||
|
||||
if (true) {
|
||||
DecoderInfoItem *info = new DecoderInfoItem();
|
||||
srd_decoder *dec = (srd_decoder *)(l->data);
|
||||
info->ObjectHandle = dec;
|
||||
info->_data_handle = dec;
|
||||
_decoderInfoList.push_back(info);
|
||||
|
||||
std::string prokey(dec->id);
|
||||
@@ -117,34 +111,23 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
|
||||
//sort protocol list
|
||||
sort(_decoderInfoList.begin(), _decoderInfoList.end(), ProtocolDock::protocol_sort_callback);
|
||||
|
||||
_bSettingList = true;
|
||||
int protocol_index = 0;
|
||||
for (auto info : _decoderInfoList){
|
||||
info->Index = protocol_index;
|
||||
protocol_index++;
|
||||
srd_decoder *dec = (srd_decoder *)(info->ObjectHandle);
|
||||
_protocol_combobox->addItem(QString::fromUtf8(dec->name), QVariant::fromValue(info->Index));
|
||||
}
|
||||
|
||||
_protocol_combobox->setCurrentIndex(-1);
|
||||
_protocol_combobox->lineEdit()->setText(PROTOCOL_FIND_TITLE);
|
||||
_bSettingList = false;
|
||||
|
||||
|
||||
if (repeatNammes != ""){
|
||||
QString err = "Any protocol have repeated id or name: ";
|
||||
err += repeatNammes;
|
||||
MsgBox::Show("error", err.toUtf8().data());
|
||||
}
|
||||
|
||||
_up_layout = new QVBoxLayout();
|
||||
|
||||
_arrow = new QToolButton(_up_widget);
|
||||
|
||||
QHBoxLayout *hori_layout = new QHBoxLayout();
|
||||
hori_layout->addWidget(_add_button);
|
||||
hori_layout->addWidget(_del_all_button);
|
||||
hori_layout->addWidget(_protocol_combobox);
|
||||
hori_layout->addWidget(_keyword_edit);
|
||||
hori_layout->addWidget(_arrow);
|
||||
hori_layout->addStretch(1);
|
||||
|
||||
_up_layout = new QVBoxLayout();
|
||||
_up_layout->addLayout(hori_layout);
|
||||
_up_layout->addStretch(1);
|
||||
|
||||
@@ -228,12 +211,6 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
|
||||
retranslateUi();
|
||||
|
||||
_key_find_timer.SetCallback(std::bind(&ProtocolDock::show_protocol_list_panel, this));
|
||||
//when porotocol list panel was showPopup statu, receive key press event
|
||||
QWidget *popup1 = _protocol_combobox->findChild<QFrame*>();
|
||||
QWidget *wid1 = popup1->findChild<QWidget*>();
|
||||
wid1->installEventFilter(this);
|
||||
|
||||
connect(_dn_nav_button, SIGNAL(clicked()),this, SLOT(nav_table_view()));
|
||||
connect(_dn_save_button, SIGNAL(clicked()),this, SLOT(export_table_view()));
|
||||
connect(_dn_set_button, SIGNAL(clicked()),this, SLOT(set_model()));
|
||||
@@ -250,10 +227,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio
|
||||
|
||||
connect(_search_edit, SIGNAL(editingFinished()), this, SLOT(search_changed()));
|
||||
|
||||
connect(_protocol_combobox->lineEdit(), SIGNAL(textEdited(const QString &)),
|
||||
this, SLOT(on_decoder_name_edited(const QString &)));
|
||||
|
||||
connect(_protocol_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_new_decoder_selected(int)));
|
||||
connect(_arrow, SIGNAL(clicked()), this, SLOT(show_protocol_select()));
|
||||
}
|
||||
|
||||
ProtocolDock::~ProtocolDock()
|
||||
@@ -268,20 +242,13 @@ ProtocolDock::~ProtocolDock()
|
||||
RELEASE_ARRAY(_decoderInfoList);
|
||||
}
|
||||
|
||||
void ProtocolDock::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
retranslateUi();
|
||||
else if (event->type() == QEvent::StyleChange)
|
||||
reStyle();
|
||||
QScrollArea::changeEvent(event);
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -296,16 +263,24 @@ void ProtocolDock::reStyle()
|
||||
_pre_button->setIcon(QIcon(iconPath+"/pre.svg"));
|
||||
_nxt_button->setIcon(QIcon(iconPath+"/next.svg"));
|
||||
_search_button->setIcon(QIcon(iconPath+"/search.svg"));
|
||||
_arrow->setIcon(QIcon(iconPath + "/search.svg"));
|
||||
|
||||
for (auto it = _protocol_lay_items.begin(); it != _protocol_lay_items.end(); it++){
|
||||
(*it)->ResetStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDock::paintEvent(QPaintEvent *)
|
||||
{
|
||||
void ProtocolDock::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
retranslateUi();
|
||||
else if (event->type() == QEvent::StyleChange)
|
||||
reStyle();
|
||||
QScrollArea::changeEvent(event);
|
||||
}
|
||||
|
||||
//void ProtocolDock::paintEvent(QPaintEvent *){}
|
||||
|
||||
void ProtocolDock::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
int width = this->visibleRegion().boundingRect().width();
|
||||
@@ -319,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);
|
||||
}
|
||||
|
||||
@@ -332,7 +308,7 @@ int ProtocolDock::get_protocol_index_by_id(QString id)
|
||||
{
|
||||
int dex = 0;
|
||||
for (auto info : _decoderInfoList){
|
||||
srd_decoder *dec = (srd_decoder *)(info->ObjectHandle);
|
||||
srd_decoder *dec = (srd_decoder *)(info->_data_handle);
|
||||
QString proid(dec->id);
|
||||
if (id == proid){
|
||||
return dex;
|
||||
@@ -340,23 +316,24 @@ int ProtocolDock::get_protocol_index_by_id(QString id)
|
||||
++dex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDock::on_add_protocol()
|
||||
{
|
||||
if (_decoderInfoList.size() == 0){
|
||||
if (_decoderInfoList.size() == 0){
|
||||
MsgBox::Show(NULL, "Protocol list is empty!");
|
||||
return;
|
||||
}
|
||||
if (_protocol_combobox->currentIndex() == -1){
|
||||
if (_selected_protocol_id == ""){
|
||||
MsgBox::Show(NULL, "Please select a protocol!");
|
||||
return;
|
||||
}
|
||||
|
||||
int dex = _protocol_combobox->itemData(_protocol_combobox->currentIndex()).toInt();
|
||||
int dex = this->get_protocol_index_by_id(_selected_protocol_id);
|
||||
assert(dex >= 0);
|
||||
|
||||
//check the base protocol
|
||||
srd_decoder *const dec = (srd_decoder *)(_decoderInfoList[dex]->ObjectHandle);
|
||||
srd_decoder *const dec = (srd_decoder *)(_decoderInfoList[dex]->_data_handle);
|
||||
QString pro_id(dec->id);
|
||||
std::list<data::decode::Decoder*> sub_decoders;
|
||||
|
||||
@@ -373,7 +350,7 @@ void ProtocolDock::on_add_protocol()
|
||||
|
||||
while (base_dex != -1)
|
||||
{
|
||||
srd_decoder *base_dec = (srd_decoder *)(_decoderInfoList[base_dex]->ObjectHandle);
|
||||
srd_decoder *base_dec = (srd_decoder *)(_decoderInfoList[base_dex]->_data_handle);
|
||||
pro_id = QString(base_dec->id); //change base protocol
|
||||
|
||||
assert(base_dec->inputs);
|
||||
@@ -418,7 +395,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::dat
|
||||
return false;
|
||||
}
|
||||
|
||||
srd_decoder *const decoder = (srd_decoder *)(_decoderInfoList[dex]->ObjectHandle);
|
||||
srd_decoder *const decoder = (srd_decoder *)(_decoderInfoList[dex]->_data_handle);
|
||||
DecoderStatus *dstatus = new DecoderStatus();
|
||||
dstatus->m_format = (int)DecoderDataFormat::hex;
|
||||
|
||||
@@ -924,54 +901,12 @@ void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDock::on_decoder_name_edited(const QString &value)
|
||||
{
|
||||
_bSettingList = true;
|
||||
|
||||
while (_protocol_combobox->count())
|
||||
{
|
||||
_protocol_combobox->removeItem(0);
|
||||
}
|
||||
|
||||
for (auto info: _decoderInfoList){
|
||||
srd_decoder *dec = (srd_decoder *)(info->ObjectHandle);
|
||||
QString name(dec->name);
|
||||
QString id(dec->id);
|
||||
|
||||
if (value == ""
|
||||
|| name.indexOf(value, 0, Qt::CaseInsensitive) != -1
|
||||
|| id.indexOf(value, 0, Qt::CaseInsensitive) != -1 ){
|
||||
_protocol_combobox->addItem(QString::fromUtf8(dec->name), QVariant::fromValue(info->Index));
|
||||
}
|
||||
}
|
||||
|
||||
_protocol_combobox->setCurrentIndex(-1);
|
||||
_protocol_combobox->lineEdit()->setText(value);
|
||||
_bSettingList = false;
|
||||
|
||||
if (_key_find_timer.IsActived() == false){
|
||||
//check input keep time
|
||||
_key_find_timer.Start(100);
|
||||
}
|
||||
else{
|
||||
_key_find_timer.ResetActiveTime();
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolDock::show_protocol_list_panel()
|
||||
{
|
||||
//press key end, to popup list panel
|
||||
if (_key_find_timer.GetActiveTimeLong() >= 1000){
|
||||
_key_find_timer.Stop();
|
||||
_protocol_combobox->showPopup();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2)
|
||||
{
|
||||
srd_decoder *dec1 = (srd_decoder *)(o1->ObjectHandle);
|
||||
srd_decoder *dec2 = (srd_decoder *)(o2->ObjectHandle);
|
||||
srd_decoder *dec1 = (srd_decoder *)(o1->_data_handle);
|
||||
srd_decoder *dec2 = (srd_decoder *)(o2->_data_handle);
|
||||
const char *s1 = dec1->name;
|
||||
const char *s2 = dec2->name;
|
||||
char c1 = 0;
|
||||
@@ -1002,24 +937,6 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProtocolDock::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
if (_protocol_combobox->IsPopup()){
|
||||
_protocol_combobox->hidePopup();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProtocolDock::on_new_decoder_selected(int index)
|
||||
{
|
||||
if (index >= 0 && _bSettingList == false){
|
||||
on_add_protocol();
|
||||
}
|
||||
}
|
||||
|
||||
QString ProtocolDock::parse_protocol_id(const char *id)
|
||||
{
|
||||
if (id == NULL || *id == 0){
|
||||
@@ -1056,7 +973,7 @@ bool ProtocolDock::eventFilter(QObject *object, QEvent *event)
|
||||
|
||||
for (auto info : _decoderInfoList)
|
||||
{
|
||||
srd_decoder *dec = (srd_decoder *)(info->ObjectHandle);
|
||||
srd_decoder *dec = (srd_decoder *)(info->_data_handle);
|
||||
if (dec->outputs)
|
||||
{
|
||||
QString output_id = parse_protocol_id((char*)dec->outputs->data);
|
||||
@@ -1074,10 +991,35 @@ bool ProtocolDock::eventFilter(QObject *object, QEvent *event)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------
|
||||
void ProtocolDock::BeginEditKeyword()
|
||||
{
|
||||
show_protocol_select();
|
||||
}
|
||||
|
||||
void ProtocolDock::show_protocol_select()
|
||||
{
|
||||
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);
|
||||
}
|
||||
panel->SetItemClickHandle(this);
|
||||
panel->ShowDlg(_keyword_edit);
|
||||
}
|
||||
|
||||
void ProtocolDock::OnItemClick(void *sender, void *data_handle)
|
||||
{
|
||||
if (data_handle != NULL){
|
||||
DecoderInfoItem *info = (DecoderInfoItem*)data_handle;
|
||||
srd_decoder *dec = (srd_decoder *)(info->_data_handle);
|
||||
this->_keyword_edit->SetInputText(QString(dec->name));
|
||||
_selected_protocol_id = QString(dec->id);
|
||||
this->on_add_protocol();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dock
|
||||
} // namespace pv
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QTableView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
@@ -42,13 +43,11 @@
|
||||
|
||||
#include "../data/decodermodel.h"
|
||||
#include "protocolitemlayer.h"
|
||||
#include "../ui/dscombobox.h"
|
||||
#include "../dstimer.h"
|
||||
#include "keywordlineedit.h"
|
||||
#include "searchcombobox.h"
|
||||
|
||||
struct DecoderInfoItem{
|
||||
int Index;
|
||||
void *ObjectHandle; //srd_decoder* type
|
||||
void *_data_handle; //srd_decoder* type
|
||||
};
|
||||
|
||||
namespace pv {
|
||||
@@ -68,7 +67,10 @@ class View;
|
||||
|
||||
namespace dock {
|
||||
|
||||
class ProtocolDock : public QScrollArea, public IProtocolItemLayerCallback
|
||||
class ProtocolDock : public QScrollArea,
|
||||
public IProtocolItemLayerCallback,
|
||||
public IKeywordActive,
|
||||
public ISearchItemClick
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -88,7 +90,7 @@ private:
|
||||
void reStyle();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
//void paintEvent(QPaintEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
int get_protocol_index_by_id(QString id);
|
||||
@@ -101,6 +103,12 @@ private:
|
||||
void OnProtocolDelete(void *handle);
|
||||
void OnProtocolFormatChanged(QString format, void *handle);
|
||||
|
||||
//IKeywordActive
|
||||
void BeginEditKeyword();
|
||||
|
||||
//ISearchItemClick
|
||||
void OnItemClick(void *sender, void *data_handle);
|
||||
|
||||
signals:
|
||||
void protocol_updated();
|
||||
|
||||
@@ -121,15 +129,12 @@ private slots:
|
||||
void search_done();
|
||||
void search_changed();
|
||||
void search_update();
|
||||
void on_decoder_name_edited(const QString &value);
|
||||
void on_new_decoder_selected(int index);
|
||||
void show_protocol_select();
|
||||
|
||||
private:
|
||||
private:
|
||||
static int decoder_name_cmp(const void *a, const void *b);
|
||||
void resize_table_view(data::DecoderModel *decoder_model);
|
||||
static bool protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2);
|
||||
void show_protocol_list_panel();
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
private:
|
||||
SigSession *_session;
|
||||
@@ -152,8 +157,7 @@ private:
|
||||
QLabel *_dn_title_label;
|
||||
|
||||
QPushButton *_add_button;
|
||||
QPushButton *_del_all_button;
|
||||
DsComboBox *_protocol_combobox;
|
||||
QPushButton *_del_all_button;
|
||||
QVBoxLayout *_up_layout;
|
||||
std::vector <ProtocolItemLayer*> _protocol_lay_items; //protocol item layers
|
||||
|
||||
@@ -162,14 +166,12 @@ private:
|
||||
QPushButton *_dn_nav_button;
|
||||
QPushButton *_search_button;
|
||||
std::vector<DecoderInfoItem*> _decoderInfoList;
|
||||
KeywordLineEdit *_keyword_edit;
|
||||
QString _selected_protocol_id;
|
||||
QToolButton *_arrow;
|
||||
|
||||
mutable std::mutex _search_mutex;
|
||||
bool _search_edited;
|
||||
bool _searching;
|
||||
|
||||
bool _add_silent;
|
||||
DsTimer _key_find_timer;
|
||||
bool _bSettingList;
|
||||
bool _search_edited;
|
||||
};
|
||||
|
||||
} // namespace dock
|
||||
|
||||
169
DSView/pv/dock/searchcombobox.cpp
Normal file
169
DSView/pv/dock/searchcombobox.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
#include "searchcombobox.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPoint>
|
||||
#include <QLineEdit>
|
||||
#include <QScrollBar>
|
||||
#include <QDebug>
|
||||
|
||||
//----------------------ComboButtonItem
|
||||
|
||||
ComboButtonItem::ComboButtonItem(QWidget *parent, ISearchItemClick *click, void *data_handle)
|
||||
:QPushButton(parent)
|
||||
{
|
||||
_click = click;
|
||||
_data_handle = data_handle;
|
||||
}
|
||||
|
||||
void ComboButtonItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (_click != NULL){
|
||||
_click->OnItemClick(this, _data_handle);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------SearchComboBox
|
||||
|
||||
SearchComboBox::SearchComboBox(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
_bShow = false;
|
||||
_item_click = NULL;
|
||||
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
}
|
||||
|
||||
SearchComboBox::~SearchComboBox(){
|
||||
//release resource
|
||||
for (auto o : _items){
|
||||
delete o;
|
||||
}
|
||||
_items.clear();
|
||||
}
|
||||
|
||||
void SearchComboBox::ShowDlg(QWidget *editline)
|
||||
{
|
||||
if (_bShow)
|
||||
return;
|
||||
|
||||
_bShow = true;
|
||||
|
||||
int w = 350;
|
||||
int h = 550;
|
||||
int eh = 20;
|
||||
|
||||
if (editline != NULL){
|
||||
w = editline->width();
|
||||
}
|
||||
|
||||
this->setFixedSize(w, h);
|
||||
|
||||
QVBoxLayout *grid = new QVBoxLayout(this);
|
||||
this->setLayout(grid);
|
||||
grid->setContentsMargins(0,0,0,0);
|
||||
grid->setAlignment(Qt::AlignTop);
|
||||
grid->setSpacing(2);
|
||||
|
||||
QLineEdit *edit = new QLineEdit(this);
|
||||
edit->setMaximumWidth(this->width());
|
||||
grid->addWidget(edit);
|
||||
eh = edit->height();
|
||||
|
||||
QWidget *panel= new QWidget(this);
|
||||
panel->setContentsMargins(0,0,0,0);
|
||||
panel->setFixedSize(w, h - eh);
|
||||
grid->addWidget(panel);
|
||||
|
||||
QWidget *listPanel = new QWidget(panel);
|
||||
QVBoxLayout *listLay = new QVBoxLayout(listPanel);
|
||||
listLay->setContentsMargins(2, 2, 20, 2);
|
||||
listLay->setSpacing(0);
|
||||
listLay->setAlignment(Qt::AlignTop);
|
||||
|
||||
for(auto o : _items)
|
||||
{
|
||||
ComboButtonItem *bt = new ComboButtonItem(panel, this, o);
|
||||
bt->setText(o->_name);
|
||||
bt->setObjectName("flat");
|
||||
bt->setMaximumWidth(w - 20);
|
||||
bt->setMinimumWidth(w - 20);
|
||||
o->_control = bt;
|
||||
listLay->addWidget(bt);
|
||||
}
|
||||
|
||||
_scroll = new QScrollArea(panel);
|
||||
_scroll->setWidget(listPanel);
|
||||
_scroll->setStyleSheet("QScrollArea{border:none;}");
|
||||
_scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
_scroll->setFixedSize(w, h - eh);
|
||||
|
||||
if (editline != NULL)
|
||||
{
|
||||
QPoint p1 = editline->pos();
|
||||
QPoint p2 = editline->mapToGlobal(p1);
|
||||
int x = p2.x() - p1.x();
|
||||
int y = p2.y() - p1.y();
|
||||
this->move(x, y);
|
||||
}
|
||||
|
||||
edit->setFocus();
|
||||
this->show();
|
||||
|
||||
|
||||
connect(edit, SIGNAL(textEdited(const QString &)),
|
||||
this, SLOT(on_keyword_changed(const QString &)));
|
||||
}
|
||||
|
||||
void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle)
|
||||
{
|
||||
SearchDataItem *item = new SearchDataItem();
|
||||
item->_id = id;
|
||||
item->_name = name;
|
||||
item->_data_handle = data_handle;
|
||||
this->_items.push_back(item);
|
||||
}
|
||||
|
||||
void SearchComboBox::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ActivationChange){
|
||||
if (this->isActiveWindow() == false){
|
||||
this->close();
|
||||
this->deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
void SearchComboBox::OnItemClick(void *sender, void *data_handle)
|
||||
{
|
||||
if (data_handle != NULL && _item_click){
|
||||
SearchDataItem *item = (SearchDataItem*)data_handle;
|
||||
this->close();
|
||||
ISearchItemClick *click = _item_click;
|
||||
this->deleteLater();
|
||||
click->OnItemClick(this, item->_data_handle);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchComboBox::on_keyword_changed(const QString &value)
|
||||
{
|
||||
if (_items.size() == 0)
|
||||
return;
|
||||
|
||||
for(auto o : _items)
|
||||
{
|
||||
if (value == ""
|
||||
|| o->_name.indexOf(value, 0, Qt::CaseInsensitive) >= 0
|
||||
|| o->_id.indexOf(value, 0, Qt::CaseInsensitive) >= 0){
|
||||
if (o->_control->isHidden()){
|
||||
o->_control->show();
|
||||
}
|
||||
}
|
||||
else if (o->_control->isHidden() == false){
|
||||
o->_control->hide();
|
||||
}
|
||||
}
|
||||
|
||||
_scroll->verticalScrollBar()->setValue(0);
|
||||
}
|
||||
79
DSView/pv/dock/searchcombobox.h
Normal file
79
DSView/pv/dock/searchcombobox.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef SEARCHCOMBOBOX_H
|
||||
#define SEARCHCOMBOBOX_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include <QEvent>
|
||||
#include <QScrollArea>
|
||||
|
||||
class ISearchItemClick{
|
||||
public:
|
||||
virtual void OnItemClick(void *sender, void *data_handle)=0;
|
||||
};
|
||||
|
||||
//----------------------ComboButtonItem
|
||||
class ComboButtonItem : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ComboButtonItem(QWidget *parent, ISearchItemClick *click, void *data_handle);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
void *_data_handle;
|
||||
ISearchItemClick *_click;
|
||||
};
|
||||
|
||||
//----------------------SearchDataItem
|
||||
|
||||
class SearchDataItem{
|
||||
public:
|
||||
QString _id;
|
||||
QString _name;
|
||||
void *_data_handle;
|
||||
QWidget *_control;
|
||||
};
|
||||
|
||||
//----------------------SearchComboBox
|
||||
|
||||
class SearchComboBox : public QDialog, ISearchItemClick
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchComboBox(QWidget *parent = nullptr);
|
||||
|
||||
~SearchComboBox();
|
||||
|
||||
void ShowDlg(QWidget *editline);
|
||||
|
||||
void AddDataItem(QString id, QString name, void *data_handle);
|
||||
|
||||
inline void SetItemClickHandle(ISearchItemClick *click){
|
||||
_item_click = click;
|
||||
}
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_keyword_changed(const QString &value);
|
||||
|
||||
private:
|
||||
//ISearchItemClick
|
||||
void OnItemClick(void *sender, void *data_handle);
|
||||
|
||||
private:
|
||||
bool _bShow;
|
||||
std::vector<SearchDataItem*> _items;
|
||||
ISearchItemClick *_item_click;
|
||||
QScrollArea *_scroll;
|
||||
};
|
||||
|
||||
#endif // SEARCHCOMBOBOX_H
|
||||
@@ -62,23 +62,6 @@ namespace DecoderDataFormat
|
||||
|
||||
namespace app
|
||||
{
|
||||
QWidget* get_app_window_instance(QWidget *ins, bool bSet){
|
||||
|
||||
static QWidget *g_ins = NULL;
|
||||
if (bSet){
|
||||
g_ins = ins;
|
||||
}
|
||||
return g_ins;
|
||||
}
|
||||
|
||||
bool is_app_top_window(QWidget* w){
|
||||
QWidget *top =get_app_window_instance(NULL, NULL);
|
||||
if (top && top == w){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_utf8(QTextStream &stream){
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
|
||||
@@ -53,7 +53,7 @@ class QTextStream;
|
||||
|
||||
#define RELEASE_ARRAY(a) for (auto ptr : (a)){delete ptr;} (a).clear();
|
||||
|
||||
#define ABS_VAL(x) (x>0?x:-x)
|
||||
#define ABS_VAL(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
namespace DecoderDataFormat
|
||||
{
|
||||
@@ -71,10 +71,6 @@ namespace DecoderDataFormat
|
||||
|
||||
namespace app
|
||||
{
|
||||
QWidget* get_app_window_instance(QWidget *ins, bool bSet);
|
||||
|
||||
bool is_app_top_window(QWidget* w);
|
||||
|
||||
void set_utf8(QTextStream &stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "dsvdef.h"
|
||||
#include "config/appconfig.h"
|
||||
#include "ui/msgbox.h"
|
||||
#include "appcontrol.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -61,6 +62,8 @@ MainFrame::MainFrame()
|
||||
_titleBar = NULL;
|
||||
_mainWindow = NULL;
|
||||
|
||||
AppControl::Instance()->SetTopWindow(this);
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
// Make this a borderless window which can't
|
||||
// be resized or moved via the window system
|
||||
@@ -77,8 +80,6 @@ MainFrame::MainFrame()
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
setWindowIcon(icon);
|
||||
|
||||
app::get_app_window_instance(this, true);
|
||||
|
||||
// Title
|
||||
_titleBar = new toolbars::TitleBar(true, this);
|
||||
|
||||
@@ -103,7 +103,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
_msg(NULL)
|
||||
{
|
||||
_control = AppControl::Instance();
|
||||
_control->GetSession()->set_callback(this);
|
||||
_control->GetSession()->set_callback(this);
|
||||
_bFirstLoad = true;
|
||||
|
||||
setup_ui();
|
||||
@@ -1140,7 +1140,7 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev, bool bDeco
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::gen_session_json(QJsonArray &array){
|
||||
bool MainWindow::gen_session_json(QJsonObject &sessionVar){
|
||||
SigSession *_session = _control->GetSession();
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
@@ -1148,7 +1148,7 @@ bool MainWindow::gen_session_json(QJsonArray &array){
|
||||
GVariant *gvar;
|
||||
gsize num_opts;
|
||||
const sr_dev_inst *const sdi = _session->get_device()->dev_inst();
|
||||
QJsonObject sessionVar;
|
||||
|
||||
QJsonArray channelVar;
|
||||
sessionVar["Version"]= QJsonValue::fromVariant(Session_Version);
|
||||
sessionVar["Device"] = QJsonValue::fromVariant(sdi->driver->name);
|
||||
@@ -1230,8 +1230,7 @@ bool MainWindow::gen_session_json(QJsonArray &array){
|
||||
if (_session->get_device()->dev_inst()->mode == DSO) {
|
||||
sessionVar["measure"] = _view->get_viewstatus()->get_session();
|
||||
}
|
||||
|
||||
array.push_back(sessionVar);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1246,10 +1245,10 @@ bool MainWindow::on_store_session(QString name)
|
||||
QTextStream outStream(&sessionFile);
|
||||
app::set_utf8(outStream);
|
||||
|
||||
QJsonArray jsonArray;
|
||||
if (!gen_session_json(jsonArray))
|
||||
QJsonObject sessionVar;
|
||||
if (!gen_session_json(sessionVar))
|
||||
return false;
|
||||
QJsonDocument sessionDoc(jsonArray);
|
||||
QJsonDocument sessionDoc(sessionVar);
|
||||
//sessionFile.write(QString::fromUtf8(sessionDoc.toJson()));
|
||||
outStream << QString::fromUtf8(sessionDoc.toJson());
|
||||
sessionFile.close();
|
||||
@@ -1258,10 +1257,10 @@ bool MainWindow::on_store_session(QString name)
|
||||
|
||||
bool MainWindow::genSessionData(std::string &str)
|
||||
{
|
||||
QJsonArray jsonArray;
|
||||
if (!gen_session_json(jsonArray))
|
||||
QJsonObject sessionVar;
|
||||
if (!gen_session_json(sessionVar))
|
||||
return false;
|
||||
QJsonDocument sessionDoc(jsonArray);
|
||||
QJsonDocument sessionDoc(sessionVar);
|
||||
QString data = QString::fromUtf8(sessionDoc.toJson());
|
||||
str.append(data.toLatin1().data());
|
||||
return true;
|
||||
|
||||
@@ -178,7 +178,7 @@ private:
|
||||
void data_received();
|
||||
|
||||
//------private
|
||||
bool gen_session_json(QJsonArray &array);
|
||||
bool gen_session_json(QJsonObject &sessionVar);
|
||||
|
||||
private:
|
||||
AppControl *_control;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QStyleOption>
|
||||
#include <assert.h>
|
||||
#include "../config/appconfig.h"
|
||||
#include "../appcontrol.h"
|
||||
|
||||
#include "../dsvdef.h"
|
||||
|
||||
@@ -192,7 +193,8 @@ void TitleBar::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
int x = event->pos().x();
|
||||
int y = event->pos().y();
|
||||
bool bTopWidow = app::is_app_top_window(_parent);
|
||||
|
||||
bool bTopWidow = AppControl::Instance()->GetTopWindow() == _parent;
|
||||
bool bClick = (x >= 6 && y >= 5 && x <= width() - 6); //top window need resize hit check
|
||||
|
||||
if (!bTopWidow || bClick ){
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include "../dsvdef.h"
|
||||
#include "../appcontrol.h"
|
||||
|
||||
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No);
|
||||
@@ -40,7 +41,7 @@ void MsgBox::Show(const char *title, const char *text, QWidget *parent)
|
||||
str.append(text);
|
||||
|
||||
if (parent == NULL){
|
||||
parent = app::get_app_window_instance(NULL, false);
|
||||
parent = AppControl::Instance()->GetTopWindow();
|
||||
}
|
||||
|
||||
pv::dialogs::DSMessageBox msg(parent, title);
|
||||
@@ -59,8 +60,8 @@ bool MsgBox::Confirm(const char *text, QWidget *parent)
|
||||
str.append("\n");
|
||||
str.append(text);
|
||||
|
||||
if (parent == NULL){
|
||||
parent = app::get_app_window_instance(NULL, false);
|
||||
if (parent == NULL){
|
||||
parent = AppControl::Instance()->GetTopWindow();
|
||||
}
|
||||
|
||||
pv::dialogs::DSMessageBox msg(parent, "Question");
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "../dsvdef.h"
|
||||
#include "../ui/dscombobox.h"
|
||||
#include "../ui/msgbox.h"
|
||||
#include "../appcontrol.h"
|
||||
#include <QDebug>
|
||||
|
||||
using namespace boost;
|
||||
@@ -357,7 +358,8 @@ bool DecodeTrace::create_popup()
|
||||
_form_base_height = 0;
|
||||
_decoder_container = NULL;
|
||||
|
||||
dialogs::DSDialog dlg;
|
||||
QWidget *topWindow = AppControl::Instance()->GetTopWindow();
|
||||
dialogs::DSDialog dlg(topWindow);
|
||||
//dlg.setMinimumSize(500,600);
|
||||
create_popup_form(&dlg);
|
||||
|
||||
@@ -741,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 =
|
||||
@@ -756,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) {
|
||||
@@ -777,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);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
#include "../dsvdef.h"
|
||||
#include "../appcontrol.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -88,6 +89,7 @@ Viewport::Viewport(View &parent, View_type type) :
|
||||
_edge_hit = false;
|
||||
transfer_started = false;
|
||||
timer_cnt = 0;
|
||||
_clickX = 0;
|
||||
|
||||
// drag inertial
|
||||
_drag_strength = 0;
|
||||
@@ -499,6 +501,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
_clickX = event->globalPos().x();
|
||||
_mouse_down_point = event->pos();
|
||||
_mouse_down_offset = _view.offset();
|
||||
_drag_strength = 0;
|
||||
@@ -757,6 +760,9 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll;
|
||||
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
|
||||
|
||||
if (_type != TIME_VIEW){
|
||||
update();
|
||||
@@ -769,7 +775,22 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
_view.session().get_capture_state() == SigSession::Stopped) {
|
||||
//priority 1
|
||||
//try to quick scroll view...
|
||||
if (_action_type == NO_ACTION && AppConfig::Instance()._appOptions.quickScroll) {
|
||||
int curX = event->globalPos().x();
|
||||
int moveLong = ABS_VAL(curX - _clickX);
|
||||
int maxWidth = this->geometry().width();
|
||||
float mvk = (float) moveLong / (float)maxWidth;
|
||||
|
||||
if (quickScroll){
|
||||
quickScroll = false;
|
||||
if (isMaxWindow && mvk > 0.5f){
|
||||
quickScroll = true;
|
||||
}
|
||||
else if (!isMaxWindow && mvk > 0.6f){
|
||||
quickScroll = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_action_type == NO_ACTION && quickScroll) {
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
|
||||
if (_elapsed_time.elapsed() < 200 &&
|
||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||
|
||||
@@ -217,10 +217,11 @@ private:
|
||||
int _dso_ym_start;
|
||||
int _dso_ym_end;
|
||||
|
||||
int _waiting_trig;
|
||||
bool _dso_trig_moved;
|
||||
bool _curs_moved;
|
||||
bool _xcurs_moved;
|
||||
int _waiting_trig;
|
||||
bool _dso_trig_moved;
|
||||
bool _curs_moved;
|
||||
bool _xcurs_moved;
|
||||
int _clickX;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -62,6 +62,18 @@ QWidget:item:selected
|
||||
}
|
||||
*/
|
||||
|
||||
QPushButton#flat{
|
||||
text-align:left;
|
||||
border:none;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
QPushButton#flat:hover
|
||||
{
|
||||
background-color: #177cb0;
|
||||
color: #801dae;
|
||||
}
|
||||
|
||||
QCheckBox
|
||||
{
|
||||
spacing: 0px;
|
||||
|
||||
@@ -59,6 +59,18 @@ QWidget:item:selected
|
||||
}
|
||||
*/
|
||||
|
||||
QPushButton#flat{
|
||||
text-align:left;
|
||||
border:none;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
QPushButton#flat:hover
|
||||
{
|
||||
background-color: #44cef6;
|
||||
color: #801dae;
|
||||
}
|
||||
|
||||
QCheckBox
|
||||
{
|
||||
spacing: 0px;
|
||||
|
||||
Reference in New Issue
Block a user