titlebar able process window move

This commit is contained in:
dreamsourcelabTAI 2021-10-22 18:12:41 +08:00
parent 3de6eb1ada
commit dd2630c4fb
26 changed files with 576 additions and 391 deletions

View File

@ -36,7 +36,7 @@ ZipMaker::ZipMaker() :
m_zDoc(NULL) m_zDoc(NULL)
{ {
m_error[0] = 0; m_error[0] = 0;
m_opt_compress_level = Z_DEFAULT_COMPRESSION; m_opt_compress_level = Z_BEST_SPEED;
m_zi = NULL; m_zi = NULL;
} }

View File

@ -0,0 +1,53 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2015 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "applicationpardlg.h"
#include "dsdialog.h"
namespace pv
{
namespace dialogs
{
ApplicationParamDlg::ApplicationParamDlg()
{
m_ret = false;
}
ApplicationParamDlg::~ApplicationParamDlg()
{
}
bool ApplicationParamDlg::ShowDlg(QWidget *parent)
{
DSDialog dlg(parent, true, true);
dlg.exec();
return m_ret;
}
//------------IDlgCallback
void ApplicationParamDlg::OnDlgResult(bool bYes){
m_ret = bYes;
}
} //
}//

View File

@ -0,0 +1,52 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2015 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include <QObject>
#include <QWidget>
#include "../interface/uicallback.h"
namespace pv
{
namespace dialogs
{
class ApplicationParamDlg : private IDlgCallback
{
// Q_OBJECT
public:
ApplicationParamDlg();
~ApplicationParamDlg();
bool ShowDlg(QWidget *parent);
//IDlgCallback
private:
void OnDlgResult(bool bYes);
private:
bool m_ret;
};
}//
}//

View File

@ -40,8 +40,7 @@ namespace dialogs {
DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevInst> dev_inst) : DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevInst> dev_inst) :
DSDialog(parent), DSDialog(parent),
_dev_inst(dev_inst), _dev_inst(dev_inst),
_button_box(QDialogButtonBox::Ok, _button_box(QDialogButtonBox::Ok, Qt::Horizontal, this),
Qt::Horizontal, this),
_device_options_binding(_dev_inst->dev_inst()) _device_options_binding(_dev_inst->dev_inst())
{ {
_props_box = new QGroupBox(tr("Mode"), this); _props_box = new QGroupBox(tr("Mode"), this);

View File

@ -28,118 +28,121 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QAbstractButton> #include <QAbstractButton>
#include "../dsvdef.h"
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
DSDialog::DSDialog(QWidget *parent, bool hasClose) : DSDialog::DSDialog() : DSDialog(NULL, false, false)
QDialog(parent),
_moving(false)
{ {
}
DSDialog::DSDialog(QWidget *parent): DSDialog(parent, false, false)
{
}
DSDialog::DSDialog(QWidget *parent, bool hasClose): DSDialog(parent, hasClose, false)
{
}
DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) :
QDialog(NULL), //must be null, otherwise window can not able to move
m_bBaseButton(bBaseButton)
{
(void)parent;
_base_layout = NULL;
_main_layout = NULL;
_main_widget = NULL;
_titlebar = NULL;
_shadow = NULL;
_base_button = NULL;
m_callback = NULL;
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
build_main(hasClose); build_base(hasClose);
}
_layout = new QVBoxLayout(this); DSDialog::~DSDialog()
_layout->addWidget(_main); {
setLayout(_layout); DESTROY_QT_OBJECT(_base_layout);
DESTROY_QT_OBJECT(_main_layout);
DESTROY_QT_OBJECT(_main_widget);
DESTROY_QT_OBJECT(_titlebar);
DESTROY_QT_OBJECT(_shadow);
DESTROY_QT_OBJECT(_base_button);
} }
void DSDialog::accept() void DSDialog::accept()
{ {
using namespace Qt; using namespace Qt;
if (m_callback){
m_callback->OnDlgResult(true);
}
QDialog::accept(); QDialog::accept();
} }
void DSDialog::reject() void DSDialog::reject()
{ {
using namespace Qt; using namespace Qt;
if (m_callback){
m_callback->OnDlgResult(false);
}
QDialog::reject(); QDialog::reject();
} }
bool DSDialog::eventFilter(QObject *object, QEvent *event)
{
(void)object;
const QEvent::Type type = event->type();
const QMouseEvent *const mouse_event = (QMouseEvent*)event;
if (type == QEvent::MouseMove) {
if (_moving && mouse_event->buttons().testFlag(Qt::LeftButton)) {
move(mouse_event->globalPos() - _startPos);
}
return true;
} else if (type == QEvent::MouseButtonPress) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = true;
#ifndef _WIN32
_startPos = mouse_event->pos() +
QPoint(_layout->margin(), _layout->margin()) +
QPoint(_layout->spacing(), _layout->spacing()) +
QPoint(_mlayout->margin(), _mlayout->margin()) +
QPoint(_mlayout->spacing(), _mlayout->spacing());
#else
_startPos = mouse_event->pos() +
QPoint(_layout->margin(), _layout->margin()) +
QPoint(_layout->spacing(), _layout->spacing());
#endif
}
} else if (type == QEvent::MouseButtonRelease) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = false;
}
}
return false;
}
QVBoxLayout* DSDialog::layout()
{
return _mlayout;
}
QWidget* DSDialog::mainWidget()
{
return _main;
}
void DSDialog::setTitle(QString title) void DSDialog::setTitle(QString title)
{ {
_titlebar->setTitle(title); if (_titlebar){
_titlebar->setTitle(title);
}
} }
void DSDialog::reload(bool hasClose) void DSDialog::reload()
{ {
QString title; show();
if (_titlebar)
title = _titlebar->title();
if (_main)
delete _main;
build_main(hasClose);
_titlebar->setTitle(title);
_layout->addWidget(_main);
} }
void DSDialog::build_main(bool hasClose) int DSDialog::exec()
{ {
_main = new QWidget(this); //ok,cancel
_mlayout = new QVBoxLayout(_main); if (m_bBaseButton){
_main->setLayout(_mlayout); _base_button = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal, this);
//_mlayout->setMargin(5); _main_layout->addWidget(_base_button);//, 5, 1, 1, 1, Qt::AlignHCenter | Qt::AlignBottom);
//_mlayout->setSpacing(5); connect(_base_button, SIGNAL(rejected()), this, SLOT(reject()));
connect(_base_button, SIGNAL(accepted()), this, SLOT(accept()));
}
return QDialog::exec();
}
Shadow *bodyShadow = new Shadow(_main);
bodyShadow->setBlurRadius(10.0);
bodyShadow->setDistance(3.0);
bodyShadow->setColor(QColor(0, 0, 0, 80));
_main->setAutoFillBackground(true);
_main->setGraphicsEffect(bodyShadow);
void DSDialog::build_base(bool hasClose)
{
_main_widget = new QWidget(this);
_main_layout = new QVBoxLayout(_main_widget);
_titlebar = new toolbars::TitleBar(false, this, hasClose); _titlebar = new toolbars::TitleBar(false, this, hasClose);
_titlebar->installEventFilter(this); _base_layout = new QVBoxLayout(this);
_mlayout->addWidget(_titlebar);
} _main_widget->setLayout(_main_layout);
_main_widget->setAutoFillBackground(true);
_shadow = new Shadow(_main_widget);
_shadow->setBlurRadius(10.0);
_shadow->setDistance(3.0);
_shadow->setColor(QColor(0, 0, 0, 80));
_main_widget->setGraphicsEffect(_shadow);
_main_layout->addWidget(_titlebar);
_base_layout->addWidget(_main_widget);
setLayout(_base_layout);
}
} // namespace dialogs } // namespace dialogs
} // namespace pv } // namespace pv

View File

@ -26,40 +26,56 @@
#include <QDialog> #include <QDialog>
#include <QWidget> #include <QWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDialogButtonBox>
#include "../toolbars/titlebar.h" #include "../toolbars/titlebar.h"
#include "../interface/uicallback.h"
class QDialogButtonBox;
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
class Shadow;
//DSView any dialog base class
class DSDialog : public QDialog class DSDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
DSDialog(QWidget *parent = 0, bool hasClose = false); DSDialog();
QVBoxLayout *layout(); DSDialog(QWidget *parent);
QWidget *mainWidget(); DSDialog(QWidget *parent, bool hasClose);
DSDialog(QWidget *parent, bool hasClose, bool bBaseButton);
~DSDialog();
inline void SetCallback(IDlgCallback *callback){m_callback = callback;}
inline QVBoxLayout *layout(){return _main_layout;}
void setTitle(QString title); void setTitle(QString title);
void reload(bool hasClose); void reload();
int exec();
protected: protected:
void accept(); void accept();
void reject(); void reject();
//void mousePressEvent(QMouseEvent *event);
//void mouseReleaseEvent(QMouseEvent *event);
bool eventFilter(QObject *object, QEvent *event);
private:
void build_main(bool hasClose);
private: private:
QVBoxLayout *_layout; void build_base(bool hasClose);
QVBoxLayout *_mlayout;
QWidget *_main; private:
toolbars::TitleBar *_titlebar; QVBoxLayout *_base_layout;
bool _moving; QWidget *_main_widget;
QPoint _startPos; QVBoxLayout *_main_layout;
toolbars::TitleBar *_titlebar;
Shadow *_shadow;
QDialogButtonBox *_base_button;
QPoint _startPos;
bool m_bBaseButton;
IDlgCallback *m_callback;
}; };
} // namespace dialogs } // namespace dialogs

View File

@ -28,32 +28,42 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QAbstractButton> #include <QAbstractButton>
#include "../dsvdef.h"
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
DSMessageBox::DSMessageBox(QWidget *parent,const char *title) : DSMessageBox::DSMessageBox(QWidget *parent,const char *title) :
QDialog(parent), QDialog(NULL) //must be null, otherwise window can not able to move
_moving(false),
_clickType(0)
{ {
_layout = NULL;
_main_widget = NULL;
_msg = NULL;
_titlebar = NULL;
_shadow = NULL;
_main_layout = NULL;
_bClickYes = false;
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
_main = new QWidget(this);
QVBoxLayout *mlayout = new QVBoxLayout(_main);
_main->setLayout(mlayout);
Shadow *bodyShadow = new Shadow(); _main_widget = new QWidget(this);
bodyShadow->setBlurRadius(10.0); _main_layout = new QVBoxLayout(_main_widget);
bodyShadow->setDistance(3.0); _main_widget->setLayout(_main_layout);
bodyShadow->setColor(QColor(0, 0, 0, 80));
_main->setAutoFillBackground(true);
_main->setGraphicsEffect(bodyShadow);
_shadow = new Shadow();
_msg = new QMessageBox(this); _msg = new QMessageBox(this);
_msg->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
_titlebar = new toolbars::TitleBar(false, this); _titlebar = new toolbars::TitleBar(false, this);
_layout = new QVBoxLayout(this);
_shadow->setBlurRadius(10.0);
_shadow->setDistance(3.0);
_shadow->setColor(QColor(0, 0, 0, 80));
_main_widget->setAutoFillBackground(true);
_main_widget->setGraphicsEffect(_shadow);
_msg->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
if (title){ if (title){
_titlebar->setTitle(QString(title)); _titlebar->setTitle(QString(title));
@ -61,20 +71,27 @@ DSMessageBox::DSMessageBox(QWidget *parent,const char *title) :
else{ else{
_titlebar->setTitle(tr("Message")); _titlebar->setTitle(tr("Message"));
} }
_titlebar->installEventFilter(this); _main_layout->addWidget(_titlebar);
_main_layout->addWidget(_msg);
_layout->addWidget(_main_widget);
mlayout->addWidget(_titlebar);
mlayout->addWidget(_msg);
_layout = new QVBoxLayout(this);
_layout->addWidget(_main);
setLayout(_layout); setLayout(_layout);
//connect(_msg, SIGNAL(finished(int)), this, SLOT(accept()));
connect(_msg, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(on_button(QAbstractButton*))); connect(_msg, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(on_button(QAbstractButton*)));
} }
DSMessageBox::~DSMessageBox()
{
DESTROY_QT_OBJECT(_layout);
DESTROY_QT_OBJECT(_main_widget);
DESTROY_QT_OBJECT(_msg);
DESTROY_QT_OBJECT(_titlebar);
DESTROY_QT_OBJECT(_shadow);
DESTROY_QT_OBJECT(_main_layout);
}
void DSMessageBox::accept() void DSMessageBox::accept()
{ {
using namespace Qt; using namespace Qt;
@ -88,50 +105,20 @@ void DSMessageBox::reject()
QDialog::reject(); QDialog::reject();
} }
bool DSMessageBox::eventFilter(QObject *object, QEvent *event)
{
(void)object;
const QEvent::Type type = event->type();
const QMouseEvent *const mouse_event = (QMouseEvent*)event;
if (type == QEvent::MouseMove) {
if (_moving && mouse_event->buttons().testFlag(Qt::LeftButton)) {
move(mouse_event->globalPos() - _startPos);
}
return true;
} else if (type == QEvent::MouseButtonPress) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = true;
_startPos = mouse_event->pos() +
QPoint(_layout->margin(), _layout->margin()) +
QPoint(_layout->spacing(), _layout->spacing());
}
} else if (type == QEvent::MouseButtonRelease) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = false;
}
}
return false;
}
QMessageBox* DSMessageBox::mBox() QMessageBox* DSMessageBox::mBox()
{ {
return _msg; return _msg;
} }
int DSMessageBox::exec()
{
//_msg->show();
return QDialog::exec();
}
void DSMessageBox::on_button(QAbstractButton *btn) void DSMessageBox::on_button(QAbstractButton *btn)
{ {
QMessageBox::ButtonRole role = _msg->buttonRole(btn); QMessageBox::ButtonRole role = _msg->buttonRole(btn);
_clickType = (int)role;
if (role == QMessageBox::AcceptRole || role == QMessageBox::YesRole){
if (role == QMessageBox::AcceptRole) _bClickYes = true;
accept(); accept();
}
else else
reject(); reject();
} }

View File

@ -33,6 +33,8 @@
namespace pv { namespace pv {
namespace dialogs { namespace dialogs {
class Shadow;
class DSMessageBox : public QDialog class DSMessageBox : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -40,30 +42,29 @@ class DSMessageBox : public QDialog
public: public:
DSMessageBox(QWidget *parent, const char *title=0); DSMessageBox(QWidget *parent, const char *title=0);
QMessageBox *mBox(); ~DSMessageBox();
int exec(); QMessageBox *mBox();
inline int GetLastClick(){return _clickType;} inline int IsYes(){return _bClickYes;}
protected: protected:
void accept(); void accept();
void reject(); void reject();
//void mousePressEvent(QMouseEvent *event);
//void mouseReleaseEvent(QMouseEvent *event);
bool eventFilter(QObject *object, QEvent *event);
private slots: private slots:
void on_button(QAbstractButton* btn); void on_button(QAbstractButton* btn);
private: private:
QVBoxLayout *_layout; QVBoxLayout *_layout;
QWidget *_main; QVBoxLayout *_main_layout;
QMessageBox *_msg; QWidget *_main_widget;
toolbars::TitleBar *_titlebar; QMessageBox *_msg;
bool _moving; toolbars::TitleBar *_titlebar;
QPoint _startPos; Shadow *_shadow;
int _clickType;
QPoint _startPos;
bool _bClickYes;
}; };
} // namespace dialogs } // namespace dialogs

View File

@ -210,10 +210,10 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession &sessio
ProtocolDock::~ProtocolDock() ProtocolDock::~ProtocolDock()
{ {
//destroy protocol item layers //destroy protocol item layers
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++){ for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++){
delete (*it); DESTROY_QT_LATER(*it);
} }
_protocolItems.clear(); _protocol_items.clear();
} }
void ProtocolDock::changeEvent(QEvent *event) void ProtocolDock::changeEvent(QEvent *event)
@ -245,7 +245,7 @@ void ProtocolDock::reStyle()
_nxt_button->setIcon(QIcon(iconPath+"/next.svg")); _nxt_button->setIcon(QIcon(iconPath+"/next.svg"));
_search_button->setIcon(QIcon(iconPath+"/search.svg")); _search_button->setIcon(QIcon(iconPath+"/search.svg"));
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++){ for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++){
(*it)->ResetStyle(); (*it)->ResetStyle();
} }
} }
@ -321,8 +321,8 @@ void ProtocolDock::add_protocol(bool silent)
//crate item layer //crate item layer
QString protocolName = _protocol_combobox->currentText(); QString protocolName = _protocol_combobox->currentText();
ProtocolItemLayer *layer = new ProtocolItemLayer(_up_widget, protocolName, this); ProtocolItemLayer *layer = new ProtocolItemLayer(_up_widget, protocolName, this);
_protocolItems.push_back(layer); _protocol_items.push_back(layer);
_up_layout->insertLayout(_protocolItems.size(), layer); _up_layout->insertLayout(_protocol_items.size(), layer);
layer->m_decoderStatus = dstatus; layer->m_decoderStatus = dstatus;
//set current protocol format //set current protocol format
@ -342,7 +342,7 @@ void ProtocolDock::add_protocol(bool silent)
} }
void ProtocolDock::on_del_all_protocol(){ void ProtocolDock::on_del_all_protocol(){
if (_protocolItems.size() == 0){ if (_protocol_items.size() == 0){
MsgBox::Show(NULL, "No Protocol Analyzer to delete!", this); MsgBox::Show(NULL, "No Protocol Analyzer to delete!", this);
return; return;
} }
@ -355,15 +355,14 @@ void ProtocolDock::add_protocol(bool silent)
void ProtocolDock::del_all_protocol() void ProtocolDock::del_all_protocol()
{ {
if (_protocolItems.size() > 0) if (_protocol_items.size() > 0)
{ {
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++) for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++)
{ {
_up_layout->removeItem((*it)); DESTROY_QT_LATER((*it)); //destory control
delete (*it); //destory control
_session.remove_decode_signal(0); _session.remove_decode_signal(0);
} }
_protocolItems.clear(); _protocol_items.clear();
protocol_updated(); protocol_updated();
} }
} }
@ -383,9 +382,9 @@ void ProtocolDock::decoded_progress(int progress)
if (d->decoder()->out_of_memory()) if (d->decoder()->out_of_memory())
err = tr("(Out of Memory)"); err = tr("(Out of Memory)");
if (index < _protocolItems.size()) if (index < _protocol_items.size())
{ {
ProtocolItemLayer &lay = *(_protocolItems.at(index)); ProtocolItemLayer &lay = *(_protocol_items.at(index));
lay.SetProgress(pg, err); lay.SetProgress(pg, err);
//when decode complete, check data format //when decode complete, check data format
@ -745,7 +744,7 @@ void ProtocolDock::search_update()
//-------------------IProtocolItemLayerCallback //-------------------IProtocolItemLayerCallback
void ProtocolDock::OnProtocolSetting(void *handle){ void ProtocolDock::OnProtocolSetting(void *handle){
int dex = 0; int dex = 0;
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++){ for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++){
if ((*it) == handle){ if ((*it) == handle){
_session.rst_decoder(dex); _session.rst_decoder(dex);
protocol_updated(); protocol_updated();
@ -761,13 +760,12 @@ void ProtocolDock::OnProtocolDelete(void *handle){
} }
int dex = 0; int dex = 0;
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++){ for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++){
if ((*it) == handle){ if ((*it) == handle){
delete (*it); DESTROY_QT_LATER(*it);
_up_layout->removeItem((*it)); //remove child control _protocol_items.remove(dex);
_protocolItems.remove(dex);
_session.remove_decode_signal(dex); _session.remove_decode_signal(dex);
protocol_updated(); protocol_updated();
break; break;
} }
dex++; dex++;
@ -775,7 +773,7 @@ void ProtocolDock::OnProtocolDelete(void *handle){
} }
void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){ void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){
for (auto it = _protocolItems.begin(); it != _protocolItems.end(); it++){ for (auto it = _protocol_items.begin(); it != _protocol_items.end(); it++){
if ((*it) == handle){ if ((*it) == handle){
QString &name = (*it)->GetProtocolName(); QString &name = (*it)->GetProtocolName();
AppConfig::Instance().SetProtocolFormat(name.toStdString(), format.toStdString()); AppConfig::Instance().SetProtocolFormat(name.toStdString(), format.toStdString());

View File

@ -133,7 +133,7 @@ private:
QComboBox *_protocol_combobox; QComboBox *_protocol_combobox;
QVector <int > _protocol_index_list; QVector <int > _protocol_index_list;
QVBoxLayout *_up_layout; QVBoxLayout *_up_layout;
QVector <ProtocolItemLayer*> _protocolItems; //protocol item layers QVector <ProtocolItemLayer*> _protocol_items; //protocol item layers
QPushButton *_dn_set_button; QPushButton *_dn_set_button;
QPushButton *_dn_save_button; QPushButton *_dn_save_button;

View File

@ -22,11 +22,11 @@
#include "protocolitemlayer.h" #include "protocolitemlayer.h"
#include "../dsvdef.h" #include "../dsvdef.h"
#include <QtCore> #include <QtCore>
#include <assert.h> #include <assert.h>
namespace pv { namespace pv {
namespace dock { namespace dock {
ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IProtocolItemLayerCallback *callback){ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IProtocolItemLayerCallback *callback){
assert(parent); assert(parent);
assert(callback); assert(callback);
@ -58,7 +58,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro
hori_layout->addWidget(_del_button); hori_layout->addWidget(_del_button);
hori_layout->addWidget(_format_combox); hori_layout->addWidget(_format_combox);
hori_layout->addWidget(_protocol_label); hori_layout->addWidget(_protocol_label);
hori_layout->addWidget(_progress_label); hori_layout->addWidget(_progress_label);
hori_layout->addStretch(1); hori_layout->addStretch(1);
@ -69,13 +69,14 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro
connect(_format_combox, SIGNAL(currentIndexChanged(int)),this, SLOT(on_format_select_changed(int))); connect(_format_combox, SIGNAL(currentIndexChanged(int)),this, SLOT(on_format_select_changed(int)));
} }
ProtocolItemLayer::~ProtocolItemLayer(){ ProtocolItemLayer::~ProtocolItemLayer(){
DESTROY_OBJECT(_set_button); DESTROY_QT_OBJECT(_progress_label);
DESTROY_OBJECT(_del_button); DESTROY_QT_OBJECT(_protocol_label);
DESTROY_OBJECT(_protocol_label); DESTROY_QT_OBJECT(_set_button);
DESTROY_OBJECT(_progress_label); DESTROY_QT_OBJECT(_del_button);
DESTROY_OBJECT(_format_combox); DESTROY_QT_OBJECT(_format_combox);
} }
//-------------control event //-------------control event
void ProtocolItemLayer::on_set_protocol() void ProtocolItemLayer::on_set_protocol()

View File

@ -54,7 +54,7 @@ public:
void LoadFormatSelect(bool bSingle); void LoadFormatSelect(bool bSingle);
inline QString &GetProtocolName(){return _protocolName;} inline QString &GetProtocolName(){return _protocolName;}
void SetProtocolFormat(const char *format); void SetProtocolFormat(const char *format);
private slots: private slots:
void on_set_protocol(); void on_set_protocol();
void on_del_protocol(); void on_del_protocol();

View File

@ -44,3 +44,24 @@ namespace DecoderDataFormat
return (int)ascii; return (int)ascii;
} }
} }
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;
}
}

View File

@ -21,8 +21,12 @@
*/ */
#pragma once #pragma once
#define DESTROY_OBJECT(p) if ((p)){delete (p); p = NULL;} class QWidget;
#define DESTROY_OBJECT(p) if((p)){delete (p); p = NULL;}
#define DESTROY_QT_OBJECT(p) if((p)){((p))->deleteLater(); p = NULL;}
#define DESTROY_QT_LATER(p) ((p))->deleteLater();
namespace DecoderDataFormat namespace DecoderDataFormat
{ {
@ -37,3 +41,10 @@ namespace DecoderDataFormat
int Parse(const char *name); int Parse(const char *name);
} }
namespace app
{
QWidget* get_app_window_instance(QWidget *ins, bool bSet);
bool is_app_top_window(QWidget* w);
}

View File

@ -0,0 +1,8 @@
#pragma once
class IDlgCallback
{
public:
virtual void OnDlgResult(bool bYes)=0;
};

View File

@ -42,6 +42,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QApplication> #include <QApplication>
#include <QScreen> #include <QScreen>
#include "dsvdef.h"
#include <algorithm> #include <algorithm>
@ -68,15 +69,15 @@ MainFrame::MainFrame(DeviceManager &device_manager,
QSize(), QIcon::Normal, QIcon::Off); QSize(), QIcon::Normal, QIcon::Off);
setWindowIcon(icon); setWindowIcon(icon);
_moving = false; app::get_app_window_instance(this, true);
_draging = false;
_startPos = None; _bDraging = false;
_hit_border = None;
_freezing = false; _freezing = false;
_minimized = false; _minimized = false;
// Title // Title
_titleBar = new toolbars::TitleBar(true, this); _titleBar = new toolbars::TitleBar(true, this);
_titleBar->installEventFilter(this);
// MainWindow // MainWindow
_mainWindow = new MainWindow(device_manager, open_file_name, this); _mainWindow = new MainWindow(device_manager, open_file_name, this);
@ -223,41 +224,55 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
int newLeft; int newLeft;
int newTop; int newTop;
if (type == QEvent::MouseMove && !isMaximized()) { if (type != QEvent::MouseMove
if (!(mouse_event->buttons() || Qt::NoButton)) { && type != QEvent::MouseButtonPress
if (object == _top_left) { && type != QEvent::MouseButtonRelease
_startPos = TopLeft; && type != QEvent::Leave){
return QFrame::eventFilter(object, event);
}
//when window is maximized, or is moving, call return
if (isMaximized() || _titleBar->IsMoving()){
return QFrame::eventFilter(object, event);
}
if (!_bDraging && type == QEvent::MouseMove && (!(mouse_event->buttons() || Qt::NoButton))){
if (object == _top_left) {
_hit_border = TopLeft;
setCursor(Qt::SizeFDiagCursor); setCursor(Qt::SizeFDiagCursor);
} else if (object == _bottom_right) { } else if (object == _bottom_right) {
_startPos = BottomRight; _hit_border = BottomRight;
setCursor(Qt::SizeFDiagCursor); setCursor(Qt::SizeFDiagCursor);
} else if (object == _top_right) { } else if (object == _top_right) {
_startPos = TopRight; _hit_border = TopRight;
setCursor(Qt::SizeBDiagCursor); setCursor(Qt::SizeBDiagCursor);
} else if (object == _bottom_left) { } else if (object == _bottom_left) {
_startPos = BottomLeft; _hit_border = BottomLeft;
setCursor(Qt::SizeBDiagCursor); setCursor(Qt::SizeBDiagCursor);
} else if (object == _left) { } else if (object == _left) {
_startPos = Left; _hit_border = Left;
setCursor(Qt::SizeHorCursor); setCursor(Qt::SizeHorCursor);
} else if (object == _right) { } else if (object == _right) {
_startPos = Right; _hit_border = Right;
setCursor(Qt::SizeHorCursor); setCursor(Qt::SizeHorCursor);
} else if (object == _bottom) { } else if (object == _bottom) {
_startPos = Bottom; _hit_border = Bottom;
setCursor(Qt::SizeVerCursor); setCursor(Qt::SizeVerCursor);
} else if (object == _top) { } else if (object == _top) {
_startPos = Top; _hit_border = Top;
setCursor(Qt::SizeVerCursor); setCursor(Qt::SizeVerCursor);
} else { } else {
_startPos = None; _hit_border = None;
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
} }
} else if(mouse_event->buttons().testFlag(Qt::LeftButton)) {
if (_moving) { return QFrame::eventFilter(object, event);
this->move(mouse_event->globalPos() - _lastMousePosition); }
} else if (!_freezing) {
switch (_startPos) { if (type == QEvent::MouseMove) {
if(mouse_event->buttons().testFlag(Qt::LeftButton)) {
if (!_freezing) {
switch (_hit_border) {
case TopLeft: case TopLeft:
newWidth = std::max(_dragStartGeometry.right() - mouse_event->globalX(), minimumWidth()); newWidth = std::max(_dragStartGeometry.right() - mouse_event->globalX(), minimumWidth());
newHeight = std::max(_dragStartGeometry.bottom() - mouse_event->globalY(), minimumHeight()); newHeight = std::max(_dragStartGeometry.bottom() - mouse_event->globalY(), minimumHeight());
@ -325,31 +340,27 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
} }
return true; return true;
} }
} else if (type == QEvent::MouseButtonPress) { }
if (mouse_event->button() == Qt::LeftButton) else if (type == QEvent::MouseButtonPress) {
if (_titleBar->rect().contains(mouse_event->pos()) && if (mouse_event->button() == Qt::LeftButton)
_startPos == None) { if (_hit_border != None)
_moving = true; _bDraging = true;
_lastMousePosition = mouse_event->pos() +
//QPoint(Margin, Margin) +
QPoint(geometry().left() - frameGeometry().left(), frameGeometry().right() - geometry().right());
}
if (_startPos != None)
_draging = true;
_timer.start(50); _timer.start(50);
_dragStartGeometry = geometry(); _dragStartGeometry = geometry();
} else if (type == QEvent::MouseButtonRelease) { }
else if (type == QEvent::MouseButtonRelease) {
if (mouse_event->button() == Qt::LeftButton) { if (mouse_event->button() == Qt::LeftButton) {
_moving = false;
_draging = false; _bDraging = false;
_timer.stop(); _timer.stop();
} }
} else if (!_draging && type == QEvent::Leave) { } else if (!_bDraging && type == QEvent::Leave) {
_startPos = None; _hit_border = None;
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
} }
return QObject::eventFilter(object, event);
return QFrame::eventFilter(object, event);
} }
void MainFrame::writeSettings() void MainFrame::writeSettings()
@ -406,7 +417,7 @@ void MainFrame::show_doc()
const QString DOC_KEY("ShowDocuments"); const QString DOC_KEY("ShowDocuments");
QSettings settings(QApplication::organizationName(), QApplication::applicationName()); QSettings settings(QApplication::organizationName(), QApplication::applicationName());
if (!settings.contains(DOC_KEY)) { if (!settings.contains(DOC_KEY)) {
dialogs::DSDialog dlg(this); dialogs::DSDialog dlg(this, true);
dlg.setTitle(tr("Document")); dlg.setTitle(tr("Document"));
QLabel tipsLabel; QLabel tipsLabel;

View File

@ -104,15 +104,13 @@ private:
widgets::Border *_top_right; widgets::Border *_top_right;
widgets::Border *_bottom_left; widgets::Border *_bottom_left;
widgets::Border *_bottom_right; widgets::Border *_bottom_right;
bool _moving; bool _bDraging;
bool _draging; QRect _dragStartGeometry;
QPoint _lastMousePosition; int _hit_border;
QRect _dragStartGeometry; QTimer _timer;
int _startPos; bool _freezing;
QTimer _timer; bool _minimized;
bool _freezing;
bool _minimized;
}; };
} // namespace pv } // namespace pv

View File

@ -28,8 +28,8 @@
#include <QApplication> #include <QApplication>
#include "filebar.h" #include "filebar.h"
#include "../device/devinst.h" #include "../device/devinst.h"
#include "../dialogs/dsmessagebox.h" #include "../ui/msgbox.h"
#include <deque> #include <deque>
@ -107,7 +107,7 @@ void FileBar::changeEvent(QEvent *event)
void FileBar::retranslateUi() void FileBar::retranslateUi()
{ {
_file_button.setText(tr("File")); _file_button.setText(tr("File"));
_menu_session->setTitle(tr("Settings")); _menu_session->setTitle(tr("Con&fig..."));
_action_load->setText(tr("&Load...")); _action_load->setText(tr("&Load..."));
_action_store->setText(tr("S&tore...")); _action_store->setText(tr("S&tore..."));
_action_default->setText(tr("&Default...")); _action_default->setText(tr("&Default..."));
@ -157,13 +157,8 @@ void FileBar::session_error(
void FileBar::show_session_error( void FileBar::show_session_error(
const QString text, const QString info_text) const QString text, const QString info_text)
{ {
dialogs::DSMessageBox msg(this); MsgBox::Show(NULL, info_text.toStdString().c_str(), this);
msg.mBox()->setText(text);
msg.mBox()->setInformativeText(info_text);
msg.mBox()->setStandardButtons(QMessageBox::Ok);
msg.mBox()->setIcon(QMessageBox::Warning);
msg.exec();
} }
void FileBar::on_actionLoad_triggered() void FileBar::on_actionLoad_triggered()
@ -189,14 +184,9 @@ void FileBar::on_actionDefault_triggered()
QDir dir(QCoreApplication::applicationDirPath()); QDir dir(QCoreApplication::applicationDirPath());
assert(dir.cd("res")); assert(dir.cd("res"));
#endif #endif
if (!dir.exists()) { if (!dir.exists()) {
dialogs::DSMessageBox msg(this); MsgBox::Show(NULL, "Cannot find default session file for this device!", this);
msg.mBox()->setText(tr("Session Load")); return;
msg.mBox()->setInformativeText(tr("Cannot find default session file for this device!"));
msg.mBox()->setStandardButtons(QMessageBox::Ok);
msg.mBox()->setIcon(QMessageBox::Warning);
msg.exec();
return;
} }
QString driver_name = _session.get_device()->name(); QString driver_name = _session.get_device()->name();

View File

@ -30,24 +30,35 @@
#include <QApplication> #include <QApplication>
#include <QPainter> #include <QPainter>
#include <QStyleOption> #include <QStyleOption>
#include <assert.h>
#include "../dsvdef.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) : TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
QWidget(parent), QWidget(parent),
_parent(parent),
_moving(false), _moving(false),
_isTop(top), _isTop(top),
_hasClose(hasClose) _hasClose(hasClose)
{ {
_title = NULL;
_minimizeButton = NULL;
_maximizeButton = NULL;
_closeButton = NULL;
_lay = NULL;
assert(parent);
setObjectName("TitleBar"); setObjectName("TitleBar");
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
setFixedHeight(32); setFixedHeight(32);
_title = new QLabel(this); _title = new QLabel(this);
QHBoxLayout *hbox = new QHBoxLayout(this); _lay = new QHBoxLayout(this);
hbox->addWidget(_title); _lay->addWidget(_title);
if (_isTop) { if (_isTop) {
_minimizeButton = new QToolButton(this); _minimizeButton = new QToolButton(this);
@ -55,8 +66,8 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
_maximizeButton = new QToolButton(this); _maximizeButton = new QToolButton(this);
_maximizeButton->setObjectName("MaximizeButton"); _maximizeButton->setObjectName("MaximizeButton");
hbox->addWidget(_minimizeButton); _lay->addWidget(_minimizeButton);
hbox->addWidget(_maximizeButton); _lay->addWidget(_maximizeButton);
connect(this, SIGNAL( normalShow() ), parent, SLOT(showNormal() ) ); connect(this, SIGNAL( normalShow() ), parent, SLOT(showNormal() ) );
connect(this, SIGNAL( maximizedShow() ), parent, SLOT(showMaximized() ) ); connect(this, SIGNAL( maximizedShow() ), parent, SLOT(showMaximized() ) );
@ -67,17 +78,26 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
if (_isTop || _hasClose) { if (_isTop || _hasClose) {
_closeButton= new QToolButton(this); _closeButton= new QToolButton(this);
_closeButton->setObjectName("CloseButton"); _closeButton->setObjectName("CloseButton");
hbox->addWidget(_closeButton); _lay->addWidget(_closeButton);
connect(_closeButton, SIGNAL( clicked() ), parent, SLOT(close() ) ); connect(_closeButton, SIGNAL( clicked() ), parent, SLOT(close() ) );
} }
hbox->insertStretch(0, 500); _lay->insertStretch(0, 500);
hbox->insertStretch(2, 500); _lay->insertStretch(2, 500);
hbox->setMargin(0); _lay->setMargin(0);
hbox->setSpacing(0); _lay->setSpacing(0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
} }
TitleBar::~TitleBar(){
DESTROY_QT_OBJECT(_title);
DESTROY_QT_OBJECT(_minimizeButton);
DESTROY_QT_OBJECT(_maximizeButton);
DESTROY_QT_OBJECT(_closeButton);
DESTROY_QT_OBJECT(_lay);
}
void TitleBar::changeEvent(QEvent *event) void TitleBar::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::StyleChange) if (event->type() == QEvent::StyleChange)
@ -101,7 +121,8 @@ void TitleBar::reStyle()
} }
void TitleBar::paintEvent(QPaintEvent *event) void TitleBar::paintEvent(QPaintEvent *event)
{ {
//draw logo icon
QStyleOption o; QStyleOption o;
o.initFrom(this); o.initFrom(this);
QPainter p(this); QPainter p(this);
@ -109,7 +130,6 @@ void TitleBar::paintEvent(QPaintEvent *event)
p.setRenderHint(QPainter::Antialiasing, true); p.setRenderHint(QPainter::Antialiasing, true);
//To draw product logo
const int xgap = 2; const int xgap = 2;
const int xstart = 10; const int xstart = 10;
p.setPen(QPen(QColor(213, 15, 37, 255), 2, Qt::SolidLine)); p.setPen(QPen(QColor(213, 15, 37, 255), 2, Qt::SolidLine));
@ -139,12 +159,7 @@ void TitleBar::setTitle(QString title)
{ {
_title->setText(title); _title->setText(title);
} }
QPoint TitleBar::get_startPos() const
{
return _startPos;
}
QString TitleBar::title() const QString TitleBar::title() const
{ {
return _title->text(); return _title->text();
@ -171,35 +186,49 @@ void TitleBar::setRestoreButton(bool max)
_maximizeButton->setIcon(QIcon(iconPath+"/restore.svg")); _maximizeButton->setIcon(QIcon(iconPath+"/restore.svg"));
} }
} }
void TitleBar::mousePressEvent(QMouseEvent* event) void TitleBar::mousePressEvent(QMouseEvent* event)
{ {
if(event->button() == Qt::LeftButton && !parentWidget()->isMaximized()) { if(event->button() == Qt::LeftButton && !parentWidget()->isMaximized()) {
_moving = true; int x = event->pos().x();
_startPos = mapToParent(event->pos()); int y = event->pos().y();
} bool bTopWidow = app::is_app_top_window(_parent);
bool bClick = (x >= 6 && y >= 5 && x <= width() - 6); //top window need resize hit check
if (!bTopWidow || bClick ){
_moving = true;
_startPos = event->globalPos() - _parent->frameGeometry().topLeft();
event->accept();
return;
}
}
QWidget::mousePressEvent(event);
} }
void TitleBar::mouseMoveEvent(QMouseEvent *event) void TitleBar::mouseMoveEvent(QMouseEvent *event)
{ {
if(_moving && event->buttons().testFlag(Qt::LeftButton)) { if(_moving){
parentWidget()->move(event->globalPos() - _startPos); _parent->move(event->globalPos() - _startPos);
} event->accept();
return;
}
QWidget::mouseMoveEvent(event);
} }
void TitleBar::mouseReleaseEvent(QMouseEvent* event) void TitleBar::mouseReleaseEvent(QMouseEvent* event)
{ {
if(event->button() == Qt::LeftButton) { _moving = false;
_moving = false; QWidget::mouseReleaseEvent(event);
}
} }
void TitleBar::mouseDoubleClickEvent(QMouseEvent *event) void TitleBar::mouseDoubleClickEvent(QMouseEvent *event)
{ {
if (_isTop) if (_isTop){
showMaxRestore(); showMaxRestore();
}
QWidget::mouseDoubleClickEvent(event); QWidget::mouseDoubleClickEvent(event);
} }
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@ -25,56 +25,56 @@
#include <QWidget> #include <QWidget>
class QLabel; class QLabel;
class QToolButton; class QToolButton;
class QHBoxLayout;
namespace pv namespace pv {
namespace toolbars {
class TitleBar : public QWidget
{ {
namespace toolbars Q_OBJECT
{
//Window's titlebar, referenced by MainFrame, public:
//The title area above the main screen, TitleBar(bool top, QWidget *parent, bool hasClose = false);
//Display logo and maximize \ minimize button ~TitleBar();
class TitleBar : public QWidget
{ void setTitle(QString title);
Q_OBJECT QString title() const;
public: private:
TitleBar(bool top, QWidget *parent, bool hasClose = false); void changeEvent(QEvent *event);
void setTitle(QString title); void reStyle();
QPoint get_startPos() const;
QString title() const;
private: signals:
void changeEvent(QEvent *event); void normalShow();
void reStyle(); void maximizedShow();
signals: public slots:
void normalShow(); void showMaxRestore();
void maximizedShow(); void setRestoreButton(bool max);
inline bool IsMoving(){return _moving;}
public slots: protected:
void showMaxRestore(); void paintEvent(QPaintEvent *event);
void setRestoreButton(bool max); void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
QLabel *_title;
QToolButton *_minimizeButton;
QToolButton *_maximizeButton;
QToolButton *_closeButton;
QHBoxLayout *_lay;
protected: bool _moving;
void paintEvent(QPaintEvent *event); bool _isTop;
void mousePressEvent(QMouseEvent *event); bool _hasClose;
void mouseMoveEvent(QMouseEvent *event); QPoint _startPos;
void mouseReleaseEvent(QMouseEvent *event); QWidget *_parent;
void mouseDoubleClickEvent(QMouseEvent *event); };
QLabel *_title; } // namespace toolbars
QToolButton *_minimizeButton;
QToolButton *_maximizeButton;
QToolButton *_closeButton;
bool _moving;
bool _isTop;
bool _hasClose;
QPoint _startPos;
};
} // namespace toolbars
} // namespace pv } // namespace pv
#endif // DSVIEW_PV_TOOLBARS_TITLEBAR_H #endif // DSVIEW_PV_TOOLBARS_TITLEBAR_H

View File

@ -30,6 +30,7 @@
#include <QApplication> #include <QApplication>
#include <QBitmap> #include <QBitmap>
#include <QPainter> #include <QPainter>
#include "../dialogs/applicationpardlg.h"
namespace pv { namespace pv {
namespace toolbars { namespace toolbars {
@ -50,16 +51,7 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
{ {
setMovable(false); setMovable(false);
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
connect(&_trig_button, SIGNAL(clicked()),
this, SLOT(trigger_clicked()));
connect(&_protocol_button, SIGNAL(clicked()),
this, SLOT(protocol_clicked()));
connect(&_measure_button, SIGNAL(clicked()),
this, SLOT(measure_clicked()));
connect(&_search_button, SIGNAL(clicked()),
this, SLOT(search_clicked()));
_trig_button.setCheckable(true); _trig_button.setCheckable(true);
#ifdef ENABLE_DECODE #ifdef ENABLE_DECODE
_protocol_button.setCheckable(true); _protocol_button.setCheckable(true);
@ -69,12 +61,10 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
_action_fft = new QAction(this); _action_fft = new QAction(this);
_action_fft->setObjectName(QString::fromUtf8("actionFft")); _action_fft->setObjectName(QString::fromUtf8("actionFft"));
connect(_action_fft, SIGNAL(triggered()), this, SLOT(on_actionFft_triggered()));
_action_math = new QAction(this); _action_math = new QAction(this);
_action_math->setObjectName(QString::fromUtf8("actionMath")); _action_math->setObjectName(QString::fromUtf8("actionMath"));
connect(_action_math, SIGNAL(triggered()), this, SLOT(on_actionMath_triggered()));
_function_menu = new QMenu(this); _function_menu = new QMenu(this);
_function_menu->setContentsMargins(0,0,0,0); _function_menu->setContentsMargins(0,0,0,0);
_function_menu->addAction(_action_fft); _function_menu->addAction(_action_fft);
@ -84,25 +74,27 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
_action_lissajous = new QAction(this); _action_lissajous = new QAction(this);
_action_lissajous->setObjectName(QString::fromUtf8("actionLissajous")); _action_lissajous->setObjectName(QString::fromUtf8("actionLissajous"));
connect(_action_lissajous, SIGNAL(triggered()), this, SLOT(on_actionLissajous_triggered()));
_dark_style = new QAction(this); _dark_style = new QAction(this);
_dark_style->setObjectName(QString::fromUtf8("actionDark")); _dark_style->setObjectName(QString::fromUtf8("actionDark"));
connect(_dark_style, SIGNAL(triggered()), this, SLOT(on_actionDark_triggered()));
_light_style = new QAction(this); _light_style = new QAction(this);
_light_style->setObjectName(QString::fromUtf8("actionLight")); _light_style->setObjectName(QString::fromUtf8("actionLight"));
connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered()));
_themes = new QMenu(this); _themes = new QMenu(this);
_themes->setObjectName(QString::fromUtf8("menuThemes")); _themes->setObjectName(QString::fromUtf8("menuThemes"));
_themes->addAction(_light_style); _themes->addAction(_light_style);
_themes->addAction(_dark_style); _themes->addAction(_dark_style);
_appParam_action = new QAction(this);
_display_menu = new QMenu(this); _display_menu = new QMenu(this);
_display_menu->setContentsMargins(0,0,0,0); _display_menu->setContentsMargins(0,0,0,0);
_display_menu->addAction(_appParam_action);
_display_menu->addAction(_action_lissajous);
_display_menu->addMenu(_themes); _display_menu->addMenu(_themes);
_display_menu->addAction(_action_lissajous);
_display_button.setPopupMode(QToolButton::InstantPopup); _display_button.setPopupMode(QToolButton::InstantPopup);
_display_button.setMenu(_display_menu); _display_button.setMenu(_display_menu);
@ -119,10 +111,22 @@ TrigBar::TrigBar(SigSession &session, QWidget *parent) :
_protocol_action = addWidget(&_protocol_button); _protocol_action = addWidget(&_protocol_button);
_measure_action = addWidget(&_measure_button); _measure_action = addWidget(&_measure_button);
_search_action = addWidget(&_search_button); _search_action = addWidget(&_search_button);
_function_action = addWidget(&_function_button); _function_action = addWidget(&_function_button);
_display_action = addWidget(&_display_button); _display_action = addWidget(&_display_button); //must be created
retranslateUi(); retranslateUi();
connect(&_trig_button, SIGNAL(clicked()),this, SLOT(trigger_clicked()));
connect(&_protocol_button, SIGNAL(clicked()),this, SLOT(protocol_clicked()));
connect(&_measure_button, SIGNAL(clicked()),this, SLOT(measure_clicked()));
connect(&_search_button, SIGNAL(clicked()), this, SLOT(search_clicked()));
connect(_action_fft, SIGNAL(triggered()), this, SLOT(on_actionFft_triggered()));
connect(_action_math, SIGNAL(triggered()), this, SLOT(on_actionMath_triggered()));
connect(_action_lissajous, SIGNAL(triggered()), this, SLOT(on_actionLissajous_triggered()));
connect(_dark_style, SIGNAL(triggered()), this, SLOT(on_actionDark_triggered()));
connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered()));
connect(_appParam_action, SIGNAL(triggered()), this, SLOT(on_application_param()));
} }
void TrigBar::changeEvent(QEvent *event) void TrigBar::changeEvent(QEvent *event)
@ -141,14 +145,18 @@ void TrigBar::retranslateUi()
_measure_button.setText(tr("Measure")); _measure_button.setText(tr("Measure"));
_search_button.setText(tr("Search")); _search_button.setText(tr("Search"));
_function_button.setText(tr("Function")); _function_button.setText(tr("Function"));
_display_button.setText(tr("Display")); _display_button.setText(tr("Setting"));
_action_lissajous->setText(tr("&Lissajous"));
_themes->setTitle(tr("Themes")); _themes->setTitle(tr("Themes"));
_dark_style->setText(tr("Dark")); _dark_style->setText(tr("Dark"));
_light_style->setText(tr("Light")); _light_style->setText(tr("Light"));
_action_lissajous->setText(tr("&Lissajous"));
_action_fft->setText(tr("FFT")); _action_fft->setText(tr("FFT"));
_action_math->setText(tr("Math")); _action_math->setText(tr("Math"));
_appParam_action->setText(tr("Application"));
} }
void TrigBar::reStyle() void TrigBar::reStyle()
@ -167,6 +175,9 @@ void TrigBar::reStyle()
_action_lissajous->setIcon(QIcon(iconPath+"/lissajous.svg")); _action_lissajous->setIcon(QIcon(iconPath+"/lissajous.svg"));
_dark_style->setIcon(QIcon(iconPath+"/dark.svg")); _dark_style->setIcon(QIcon(iconPath+"/dark.svg"));
_light_style->setIcon(QIcon(iconPath+"/light.svg")); _light_style->setIcon(QIcon(iconPath+"/light.svg"));
_appParam_action->setIcon(QIcon(iconPath+"/params.svg"));
_themes->setIcon(QIcon(iconPath+"/"+qApp->property("Style").toString()+".svg")); _themes->setIcon(QIcon(iconPath+"/"+qApp->property("Style").toString()+".svg"));
} }
@ -304,5 +315,13 @@ void TrigBar::on_actionLissajous_triggered()
lissajous_dlg.exec(); lissajous_dlg.exec();
} }
void TrigBar::on_application_param(){
pv::dialogs::MathOptions math_dlg(_session, this);
math_dlg.exec();
return;
pv::dialogs::ApplicationParamDlg dlg;
dlg.ShowDlg(this);
}
} // namespace toolbars } // namespace toolbars
} // namespace pv } // namespace pv

View File

@ -83,6 +83,7 @@ public slots:
void on_actionFft_triggered(); void on_actionFft_triggered();
void on_actionMath_triggered(); void on_actionMath_triggered();
void on_application_param();
private: private:
SigSession& _session; SigSession& _session;
@ -97,7 +98,7 @@ private:
QAction* _protocol_action; QAction* _protocol_action;
QAction* _measure_action; QAction* _measure_action;
QAction* _search_action; QAction* _search_action;
QAction* _function_action; QAction* _function_action;
QAction* _display_action; QAction* _display_action;
QMenu* _function_menu; QMenu* _function_menu;
@ -106,6 +107,7 @@ private:
QMenu* _display_menu; QMenu* _display_menu;
QMenu *_themes; QMenu *_themes;
QAction *_appParam_action;
QAction *_dark_style; QAction *_dark_style;
QAction *_light_style; QAction *_light_style;
QAction* _action_lissajous; QAction* _action_lissajous;

View File

@ -51,6 +51,5 @@ bool MsgBox::Confirm(const char *text, QWidget *parent)
msg.mBox()->setStandardButtons(QMessageBox::Yes | QMessageBox::No); msg.mBox()->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msg.mBox()->setIcon(QMessageBox::Question); msg.mBox()->setIcon(QMessageBox::Question);
msg.exec(); msg.exec();
int click = msg.GetLastClick(); return msg.IsYes();
return (click == (int)QMessageBox::YesRole);
} }

View File

@ -146,14 +146,7 @@ DecodeTrace::DecodeTrace(pv::SigSession &session,
} }
DecodeTrace::~DecodeTrace() DecodeTrace::~DecodeTrace()
{ { _cur_row_headings.clear();
DESTROY_OBJECT(_start_comboBox);
DESTROY_OBJECT(_end_comboBox);
DESTROY_OBJECT(_pub_input_layer);
DESTROY_OBJECT(_popup_form);
DESTROY_OBJECT(_popup);
_cur_row_headings.clear();
_decoder_forms.clear(); _decoder_forms.clear();
_probe_selectors.clear(); _probe_selectors.clear();
_bindings.clear(); _bindings.clear();
@ -371,13 +364,7 @@ bool DecodeTrace::create_popup()
} }
} }
//destroy object //destroy object
DESTROY_OBJECT(_start_comboBox);
DESTROY_OBJECT(_end_comboBox);
DESTROY_OBJECT(_pub_input_layer);
DESTROY_OBJECT(_popup_form);
DESTROY_OBJECT(_popup);
return ret; return ret;
} }
@ -389,7 +376,7 @@ void DecodeTrace::create_popup_form()
// which then goes out of scope destroying the layout and all the child // which then goes out of scope destroying the layout and all the child
// widgets. // widgets.
if (_popup_form) if (_popup_form)
_popup->reload(false); _popup->reload();
_popup_form = new QFormLayout(); _popup_form = new QFormLayout();
_popup_form->setVerticalSpacing(5); _popup_form->setVerticalSpacing(5);

View File

@ -501,7 +501,7 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
void Viewport::mousePressEvent(QMouseEvent *event) void Viewport::mousePressEvent(QMouseEvent *event)
{ {
assert(event); assert(event);
_mouse_down_point = event->pos(); _mouse_down_point = event->pos();
_mouse_down_offset = _view.offset(); _mouse_down_offset = _view.offset();
_drag_strength = 0; _drag_strength = 0;

View File

@ -168,8 +168,8 @@ static const struct DEMO_profile supported_Demo[] = {
(1 << DEMO_LOGIC100x16) | (1 << DEMO_LOGIC100x16) |
(1 << DEMO_ANALOG10x2) | (1 << DEMO_ANALOG10x2) |
(1 << DEMO_DSO200x2), (1 << DEMO_DSO200x2),
SR_Mn(100), //SR_Mn(100),
// SR_Gn(16), SR_Gn(16),
SR_Kn(20), SR_Kn(20),
0, 0,
vdivs10to2000, vdivs10to2000,