forked from Ivasoft/DSView
switch qt class to 6.0 version
This commit is contained in:
@@ -119,7 +119,10 @@ void _loadFrame(FrameOptions &o, QSettings &st){
|
||||
getFiled("style", st, o.style, "dark");
|
||||
getFiled("language", st, o.language, -1);
|
||||
getFiled("isMax", st, o.isMax, false);
|
||||
o.geometry = st.value("geometry", QByteArray()).toByteArray();
|
||||
getFiled("left", st, o.left, 0);
|
||||
getFiled("top", st, o.top, 0);
|
||||
getFiled("right", st, o.right, 0);
|
||||
getFiled("bottom", st, o.bottom, 0);
|
||||
o.windowState = st.value("windowState", QByteArray()).toByteArray();
|
||||
st.endGroup();
|
||||
|
||||
@@ -135,7 +138,10 @@ void _saveFrame(FrameOptions &o, QSettings &st){
|
||||
setFiled("style", st, o.style);
|
||||
setFiled("language", st, o.language);
|
||||
setFiled("isMax", st, o.isMax);
|
||||
st.setValue("geometry", o.geometry);
|
||||
setFiled("left", st, o.left);
|
||||
setFiled("top", st, o.top);
|
||||
setFiled("right", st, o.right);
|
||||
setFiled("bottom", st, o.bottom);
|
||||
st.setValue("windowState", o.windowState);
|
||||
st.endGroup();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,11 @@ struct AppOptions
|
||||
struct FrameOptions
|
||||
{
|
||||
QString style;
|
||||
int language;
|
||||
QByteArray geometry;
|
||||
int language;
|
||||
int left; //frame region
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
bool isMax;
|
||||
QByteArray windowState;
|
||||
};
|
||||
|
||||
@@ -378,7 +378,7 @@ double DsoSnapshot::cal_vrms(double zero_off, int index)
|
||||
vrms = vrms_pre + vrms / get_sample_count();
|
||||
vrms_pre = vrms;
|
||||
}
|
||||
vrms = std::pow(vrms, 0.5);
|
||||
vrms = pow(vrms, 0.5);
|
||||
|
||||
return vrms;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "about.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QApplication>
|
||||
#include <QTextBrowser>
|
||||
@@ -28,10 +30,9 @@
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QScrollBar>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "about.h"
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
#include "../dsvdef.h"
|
||||
|
||||
namespace pv {
|
||||
namespace dialogs {
|
||||
@@ -88,9 +89,10 @@ About::About(QWidget *parent) :
|
||||
QString filename = dir.absolutePath() + "/NEWS" + QString::number(lan);
|
||||
QFile news(filename);
|
||||
if (news.open(QIODevice::ReadOnly)) {
|
||||
QTextCodec *code=QTextCodec::codecForName("UTF-8");
|
||||
|
||||
QTextStream stream(&news);
|
||||
stream.setCodec(code);
|
||||
app::set_utf8(stream);
|
||||
|
||||
QString line;
|
||||
while (!stream.atEnd()){
|
||||
line = stream.readLine();
|
||||
|
||||
@@ -55,7 +55,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
this);
|
||||
_dynamic_box->setLayout(&_dynamic_layout);
|
||||
_layout.addWidget(_dynamic_box);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != "");
|
||||
|
||||
_layout.addStretch(1);
|
||||
_layout.addWidget(&_button_box);
|
||||
@@ -346,7 +346,7 @@ void DeviceOptions::mode_check()
|
||||
|
||||
if (mode != _mode) {
|
||||
dynamic_widget(_dynamic_layout);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != "");
|
||||
_mode = mode;
|
||||
}
|
||||
}
|
||||
@@ -375,7 +375,7 @@ void DeviceOptions::channel_check()
|
||||
if(sc != NULL)
|
||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(text.toUtf8().data()));
|
||||
dynamic_widget(_dynamic_layout);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
|
||||
_dynamic_box->setVisible(_dynamic_box->title() != "");
|
||||
}
|
||||
|
||||
void DeviceOptions::analog_channel_check()
|
||||
|
||||
@@ -78,9 +78,7 @@ DSDialog::~DSDialog()
|
||||
}
|
||||
|
||||
void DSDialog::accept()
|
||||
{
|
||||
using namespace Qt;
|
||||
|
||||
{
|
||||
_clickYes = true;
|
||||
if (m_callback){
|
||||
m_callback->OnDlgResult(true);
|
||||
@@ -91,8 +89,7 @@ void DSDialog::accept()
|
||||
}
|
||||
|
||||
void DSDialog::reject()
|
||||
{
|
||||
using namespace Qt;
|
||||
{
|
||||
_clickYes = false;
|
||||
|
||||
if (m_callback){
|
||||
@@ -133,24 +130,28 @@ void DSDialog::build_base(bool hasClose)
|
||||
{
|
||||
_main_widget = new QWidget(this);
|
||||
_main_layout = new QVBoxLayout(_main_widget);
|
||||
_titlebar = new toolbars::TitleBar(false, this, hasClose);
|
||||
_base_layout = new QVBoxLayout(this);
|
||||
|
||||
_main_widget->setLayout(_main_layout);
|
||||
_main_widget->setAutoFillBackground(true);
|
||||
|
||||
_shadow = new Shadow(_main_widget);
|
||||
_shadow = new Shadow(this);
|
||||
_shadow->setBlurRadius(10.0);
|
||||
_shadow->setDistance(3.0);
|
||||
_shadow->setColor(QColor(0, 0, 0, 80));
|
||||
_main_widget->setGraphicsEffect(_shadow);
|
||||
|
||||
_main_layout->addWidget(_titlebar);
|
||||
_main_widget->setAutoFillBackground(true);
|
||||
this->setGraphicsEffect(_shadow);
|
||||
|
||||
_titlebar = new toolbars::TitleBar(false, this, hasClose);
|
||||
_main_layout->addWidget(_titlebar);
|
||||
|
||||
QWidget *space = new QWidget(this);
|
||||
space->setFixedHeight(15);
|
||||
_main_layout->addWidget(space);
|
||||
|
||||
_base_layout = new QVBoxLayout(this);
|
||||
_base_layout->addWidget(_main_widget);
|
||||
setLayout(_base_layout);
|
||||
setLayout(_base_layout);
|
||||
|
||||
_main_layout->setAlignment(Qt::AlignCenter | Qt::AlignTop);
|
||||
|
||||
_main_layout->setContentsMargins(10,5,10,10);
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
|
||||
@@ -53,7 +53,7 @@ DSMessageBox::DSMessageBox(QWidget *parent,const char *title) :
|
||||
_main_layout = new QVBoxLayout(_main_widget);
|
||||
_main_widget->setLayout(_main_layout);
|
||||
|
||||
_shadow = new Shadow();
|
||||
_shadow = new Shadow(this);
|
||||
_msg = new QMessageBox(this);
|
||||
_titlebar = new toolbars::TitleBar(false, this);
|
||||
_layout = new QVBoxLayout(this);
|
||||
@@ -63,7 +63,8 @@ DSMessageBox::DSMessageBox(QWidget *parent,const char *title) :
|
||||
_shadow->setColor(QColor(0, 0, 0, 80));
|
||||
|
||||
_main_widget->setAutoFillBackground(true);
|
||||
_main_widget->setGraphicsEffect(_shadow);
|
||||
this->setGraphicsEffect(_shadow);
|
||||
|
||||
_msg->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
|
||||
if (title){
|
||||
@@ -77,7 +78,7 @@ DSMessageBox::DSMessageBox(QWidget *parent,const char *title) :
|
||||
_main_layout->addWidget(_msg);
|
||||
_layout->addWidget(_main_widget);
|
||||
|
||||
setLayout(_layout);
|
||||
setLayout(_layout);
|
||||
|
||||
connect(_msg, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(on_button(QAbstractButton*)));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ void DsoMeasure::add_measure(QWidget *widget, const view::DsoSignal *dsoSig)
|
||||
const int Column = 5;
|
||||
const int IconSizeForText = 5;
|
||||
QGridLayout *layout = new QGridLayout(widget);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
pv::view::DsoSignal *psig = const_cast<pv::view::DsoSignal*>(dsoSig);
|
||||
|
||||
@@ -125,7 +125,6 @@ LissajousOptions::LissajousOptions(SigSession *session, QWidget *parent) :
|
||||
}
|
||||
|
||||
_layout = new QGridLayout();
|
||||
_layout->setMargin(0);
|
||||
_layout->setSpacing(0);
|
||||
_layout->addWidget(lisa_label, 0, 0, 1, 2, Qt::AlignCenter);
|
||||
_layout->addWidget(_enable, 1, 0, 1, 1);
|
||||
|
||||
@@ -139,8 +139,7 @@ MathOptions::MathOptions(SigSession *session, QWidget *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
_layout = new QGridLayout();
|
||||
_layout->setMargin(0);
|
||||
_layout = new QGridLayout();
|
||||
_layout->setSpacing(0);
|
||||
_layout->addWidget(lisa_label, 0, 0, 1, 2, Qt::AlignCenter);
|
||||
_layout->addWidget(_enable, 1, 0, 1, 1);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "../view/decodetrace.h"
|
||||
#include "../data/decodermodel.h"
|
||||
#include "../config/appconfig.h"
|
||||
#include "../dsvdef.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -148,7 +149,7 @@ void ProtocolExp::accept()
|
||||
QFile file(file_name);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
QTextStream out(&file);
|
||||
out.setCodec("UTF-8");
|
||||
app::set_utf8(out);
|
||||
//out.setGenerateByteOrderMark(true); // UTF-8 without BOM
|
||||
|
||||
QFuture<void> future;
|
||||
|
||||
@@ -43,7 +43,7 @@ RegionOptions::RegionOptions(view::View *view, SigSession *session, QWidget *par
|
||||
Qt::Horizontal, this)
|
||||
{
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->setMargin(0);
|
||||
hlayout->setContentsMargins(0,0,0,0);
|
||||
hlayout->setSpacing(0);
|
||||
_start_comboBox = new QComboBox(this);
|
||||
_end_comboBox = new QComboBox(this);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "../view/logicsignal.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
|
||||
namespace pv {
|
||||
@@ -39,8 +39,8 @@ Search::Search(QWidget *parent, SigSession *session, std::map<uint16_t, QString>
|
||||
font.setFixedPitch(true);
|
||||
//this->setMinimumWidth(350);
|
||||
|
||||
QRegExp value_rx("[10XRFCxrfc]+");
|
||||
QValidator *value_validator = new QRegExpValidator(value_rx, this);
|
||||
QRegularExpression value_rx("[10XRFCxrfc]+");
|
||||
QValidator *value_validator = new QRegularExpressionValidator(value_rx, this);
|
||||
|
||||
search_buttonBox.addButton(QDialogButtonBox::Ok);
|
||||
search_buttonBox.addButton(QDialogButtonBox::Cancel);
|
||||
|
||||
@@ -94,7 +94,7 @@ void Shadow::draw(QPainter* painter)
|
||||
painter->setWorldTransform(restoreTransform);
|
||||
}
|
||||
|
||||
QRectF Shadow::boundingRectFor(const QRectF& rect)
|
||||
QRectF Shadow::boundingRectFor(const QRectF& rect) const
|
||||
{
|
||||
qreal delta = blurRadius() + distance();
|
||||
return rect.united(rect.adjusted(-delta, -delta, delta, delta));
|
||||
|
||||
@@ -36,16 +36,16 @@ public:
|
||||
explicit Shadow(QObject *parent = 0);
|
||||
|
||||
void draw(QPainter* painter);
|
||||
QRectF boundingRectFor(const QRectF& rect);
|
||||
QRectF boundingRectFor(const QRectF& rect) const;
|
||||
|
||||
inline void setDistance(qreal distance) { _distance = distance; updateBoundingRect(); }
|
||||
inline qreal distance() { return _distance; }
|
||||
inline qreal distance() const { return _distance; }
|
||||
|
||||
inline void setBlurRadius(qreal blurRadius) { _blurRadius = blurRadius; updateBoundingRect(); }
|
||||
inline qreal blurRadius() { return _blurRadius; }
|
||||
inline qreal blurRadius() const { return _blurRadius; }
|
||||
|
||||
inline void setColor(const QColor& color) { _color = color; }
|
||||
inline QColor color() { return _color; }
|
||||
inline QColor color() const { return _color; }
|
||||
|
||||
private:
|
||||
qreal _distance;
|
||||
|
||||
@@ -38,8 +38,7 @@
|
||||
#include "../dialogs/dsmessagebox.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QRegExpValidator>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
#include "../config/appconfig.h"
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <QHeaderView>
|
||||
#include <QScrollBar>
|
||||
#include <QLineEdit>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QFuture>
|
||||
#include <QProgressDialog>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
@@ -696,7 +696,7 @@ void ProtocolDock::search_nxt()
|
||||
void ProtocolDock::search_done()
|
||||
{
|
||||
QString str = _search_edit->text().trimmed();
|
||||
QRegExp rx("(-)");
|
||||
QRegularExpression rx("(-)");
|
||||
_str_list = str.split(rx);
|
||||
_model_proxy.setFilterFixedString(_str_list.first());
|
||||
if (_str_list.size() > 1)
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
#include "../dialogs/dsmessagebox.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QRegExpValidator>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QMouseEvent>
|
||||
#include <QFuture>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QSplitter>
|
||||
#include <QInputMethodEvent>
|
||||
#include <QApplication>
|
||||
@@ -566,8 +566,8 @@ void TriggerDock::setup_adv_tab()
|
||||
_stage_tabWidget->setUsesScrollButtons(false);
|
||||
|
||||
const QString mask = "N N N N N N N N N N N N N N N N";
|
||||
QRegExp value_rx("[10XRFCxrfc ]+");
|
||||
QValidator *value_validator = new QRegExpValidator(value_rx, _stage_tabWidget);
|
||||
QRegularExpression value_rx("[10XRFCxrfc ]+");
|
||||
QValidator *value_validator = new QRegularExpressionValidator(value_rx, _stage_tabWidget);
|
||||
for (int i = 0; i < TriggerStages; i++) {
|
||||
QComboBox *_logic_comboBox = new QComboBox(_stage_tabWidget);
|
||||
_logic_comboBox->addItem(tr("Or"));
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QStringConverter>
|
||||
#else
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
namespace DecoderDataFormat
|
||||
{
|
||||
int Parse(const char *name){
|
||||
@@ -71,4 +79,13 @@ namespace app
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_utf8(QTextStream &stream){
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
QTextCodec *code=QTextCodec::codecForName("UTF-8");
|
||||
stream.setCodec(code);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
class QWidget;
|
||||
class QTextStream;
|
||||
|
||||
#define DESTROY_OBJECT(p) if((p)){delete (p); p = NULL;}
|
||||
#define DESTROY_QT_OBJECT(p) if((p)){((p))->deleteLater(); p = NULL;}
|
||||
@@ -41,6 +42,8 @@ class QWidget;
|
||||
|
||||
#define RELEASE_ARRAY(a) for (auto ptr : (a)){delete ptr;} (a).clear();
|
||||
|
||||
#define ABS_VAL(x) (x>0?x:-x)
|
||||
|
||||
namespace DecoderDataFormat
|
||||
{
|
||||
enum _data_format
|
||||
@@ -60,5 +63,7 @@ namespace app
|
||||
QWidget* get_app_window_instance(QWidget *ins, bool bSet);
|
||||
|
||||
bool is_app_top_window(QWidget* w);
|
||||
|
||||
void set_utf8(QTextStream &stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "dsvdef.h"
|
||||
#include "config/appconfig.h"
|
||||
@@ -53,6 +54,13 @@ namespace pv {
|
||||
|
||||
MainFrame::MainFrame()
|
||||
{
|
||||
_layout = NULL;
|
||||
_bDraging = false;
|
||||
_hit_border = None;
|
||||
_freezing = false;
|
||||
_titleBar = NULL;
|
||||
_mainWindow = NULL;
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
// Make this a borderless window which can't
|
||||
// be resized or moved via the window system
|
||||
@@ -61,23 +69,17 @@ MainFrame::MainFrame()
|
||||
#else
|
||||
setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
#endif
|
||||
|
||||
setMinimumHeight(minHeight);
|
||||
setMinimumWidth(minWidth);
|
||||
//resize(1024, 768);
|
||||
|
||||
|
||||
// Set the window icon
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/icons/logo.svg"),
|
||||
QSize(), QIcon::Normal, QIcon::Off);
|
||||
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
setWindowIcon(icon);
|
||||
|
||||
app::get_app_window_instance(this, true);
|
||||
|
||||
_bDraging = false;
|
||||
_hit_border = None;
|
||||
_freezing = false;
|
||||
_minimized = false;
|
||||
|
||||
|
||||
// Title
|
||||
_titleBar = new toolbars::TitleBar(true, this);
|
||||
|
||||
@@ -87,7 +89,7 @@ MainFrame::MainFrame()
|
||||
_titleBar->setTitle(_mainWindow->windowTitle());
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout();
|
||||
vbox->setMargin(0);
|
||||
vbox->setContentsMargins(0,0,0,0);
|
||||
vbox->setSpacing(0);
|
||||
vbox->addWidget(_titleBar);
|
||||
vbox->addWidget(_mainWindow);
|
||||
@@ -120,8 +122,8 @@ MainFrame::MainFrame()
|
||||
_bottom_right->installEventFilter(this);
|
||||
|
||||
_layout = new QGridLayout(this);
|
||||
_layout->setMargin(0);
|
||||
_layout->setSpacing(0);
|
||||
_layout->setContentsMargins(0,0,0,0);
|
||||
_layout->addWidget(_top_left, 0, 0);
|
||||
_layout->addWidget(_top, 0, 1);
|
||||
_layout->addWidget(_top_right, 0, 2);
|
||||
@@ -132,28 +134,17 @@ MainFrame::MainFrame()
|
||||
_layout->addWidget(_bottom, 2, 1);
|
||||
_layout->addWidget(_bottom_right, 2, 2);
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(unfreezing()));
|
||||
//readSettings();
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(unfreezing()));
|
||||
}
|
||||
|
||||
void MainFrame::changeEvent(QEvent* event)
|
||||
{
|
||||
QFrame::changeEvent(event);
|
||||
QWindowStateChangeEvent* win_event = static_cast< QWindowStateChangeEvent* >(event);
|
||||
if(win_event->type() == QEvent::WindowStateChange) {
|
||||
if (win_event->oldState() & Qt::WindowMinimized) {
|
||||
if (_minimized) {
|
||||
readSettings();
|
||||
_minimized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainFrame::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QFrame::resizeEvent(event);
|
||||
|
||||
if (_layout == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMaximized()) {
|
||||
hide_border();
|
||||
} else {
|
||||
@@ -201,19 +192,18 @@ void MainFrame::show_border()
|
||||
|
||||
void MainFrame::showNormal()
|
||||
{
|
||||
show_border();
|
||||
show_border();
|
||||
QFrame::showNormal();
|
||||
}
|
||||
|
||||
void MainFrame::showMaximized()
|
||||
{
|
||||
{
|
||||
hide_border();
|
||||
QFrame::showMaximized();
|
||||
}
|
||||
|
||||
void MainFrame::showMinimized()
|
||||
{
|
||||
_minimized = true;
|
||||
{
|
||||
writeSettings();
|
||||
QFrame::showMinimized();
|
||||
}
|
||||
@@ -285,57 +275,69 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
newLeft = mouse_event->globalX();
|
||||
if (newHeight > minimumHeight())
|
||||
newTop = mouse_event->globalY();
|
||||
setGeometry(newLeft, newTop,
|
||||
newWidth, newHeight);
|
||||
setGeometry(newLeft, newTop, newWidth, newHeight);
|
||||
saveWindowRegion();
|
||||
break;
|
||||
|
||||
case BottomLeft:
|
||||
newWidth = std::max(_dragStartGeometry.right() - mouse_event->globalX(), minimumWidth());
|
||||
newHeight = std::max(mouse_event->globalY() - _dragStartGeometry.top(), minimumHeight());
|
||||
newLeft = geometry().left();
|
||||
if (newWidth > minimumWidth())
|
||||
newLeft = mouse_event->globalX();
|
||||
setGeometry(newLeft, _dragStartGeometry.top(),
|
||||
newWidth, newHeight);
|
||||
setGeometry(newLeft, _dragStartGeometry.top(), newWidth, newHeight);
|
||||
saveWindowRegion();
|
||||
break;
|
||||
|
||||
case TopRight:
|
||||
newWidth = std::max(mouse_event->globalX() - _dragStartGeometry.left(), minimumWidth());
|
||||
newHeight = std::max(_dragStartGeometry.bottom() - mouse_event->globalY(), minimumHeight());
|
||||
newTop = geometry().top();
|
||||
if (newHeight > minimumHeight())
|
||||
newTop = mouse_event->globalY();
|
||||
setGeometry(_dragStartGeometry.left(), newTop,
|
||||
newWidth, newHeight);
|
||||
setGeometry(_dragStartGeometry.left(), newTop, newWidth, newHeight);
|
||||
saveWindowRegion();
|
||||
break;
|
||||
|
||||
case BottomRight:
|
||||
newWidth = std::max(mouse_event->globalX() - _dragStartGeometry.left(), minimumWidth());
|
||||
newHeight = std::max(mouse_event->globalY() - _dragStartGeometry.top(), minimumHeight());
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(),
|
||||
newWidth, newHeight);
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), newWidth, newHeight);
|
||||
saveWindowRegion();
|
||||
break;
|
||||
|
||||
case Left:
|
||||
newWidth = _dragStartGeometry.right() - mouse_event->globalX();
|
||||
if (newWidth > minimumWidth())
|
||||
setGeometry(mouse_event->globalX(), _dragStartGeometry.top(),
|
||||
newWidth, height());
|
||||
if (newWidth > minimumWidth()){
|
||||
setGeometry(mouse_event->globalX(), _dragStartGeometry.top(), newWidth, height());
|
||||
saveWindowRegion();
|
||||
}
|
||||
break;
|
||||
|
||||
case Right:
|
||||
newWidth = mouse_event->globalX() - _dragStartGeometry.left();
|
||||
if (newWidth > minimumWidth())
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(),
|
||||
newWidth, height());
|
||||
if (newWidth > minimumWidth()){
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), newWidth, height());
|
||||
saveWindowRegion();
|
||||
}
|
||||
break;
|
||||
|
||||
case Top:
|
||||
newHeight = _dragStartGeometry.bottom() - mouse_event->globalY();
|
||||
if (newHeight > minimumHeight())
|
||||
setGeometry(_dragStartGeometry.left(), mouse_event->globalY(),
|
||||
width(), newHeight);
|
||||
if (newHeight > minimumHeight()){
|
||||
setGeometry(_dragStartGeometry.left(), mouse_event->globalY(),width(), newHeight);
|
||||
saveWindowRegion();
|
||||
}
|
||||
break;
|
||||
|
||||
case Bottom:
|
||||
newHeight = mouse_event->globalY() - _dragStartGeometry.top();
|
||||
if (newHeight > minimumHeight())
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(),
|
||||
width(), newHeight);
|
||||
if (newHeight > minimumHeight()){
|
||||
setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), width(), newHeight);
|
||||
saveWindowRegion();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -366,39 +368,59 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
|
||||
return QFrame::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void MainFrame::saveWindowRegion()
|
||||
{
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
QRect rc = geometry();
|
||||
app._frameOptions.left = rc.left();
|
||||
app._frameOptions.top = rc.top();
|
||||
app._frameOptions.right = rc.right();
|
||||
app._frameOptions.bottom = rc.bottom();
|
||||
}
|
||||
|
||||
void MainFrame::writeSettings()
|
||||
{
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
app._frameOptions.isMax = isMaximized();
|
||||
app._frameOptions.geometry = saveGeometry();
|
||||
app._frameOptions.isMax = isMaximized();
|
||||
|
||||
if (!isMaximized()){
|
||||
saveWindowRegion();
|
||||
}
|
||||
|
||||
app.SaveFrame();
|
||||
}
|
||||
|
||||
void MainFrame::readSettings()
|
||||
{
|
||||
if (_layout == NULL)
|
||||
return;
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
if (app._frameOptions.language > 0){
|
||||
_mainWindow->switchLanguage(app._frameOptions.language);
|
||||
}
|
||||
|
||||
if (app._frameOptions.geometry.isEmpty()) {
|
||||
if (app._frameOptions.right == 0) {
|
||||
QScreen *screen=QGuiApplication::primaryScreen ();
|
||||
const QRect availableGeometry = screen->availableGeometry();
|
||||
resize(availableGeometry.width() / 2, availableGeometry.height() / 1.5);
|
||||
const int origX = std::max(0, (availableGeometry.width() - width()) / 2);
|
||||
const int origY = std::max(0, (availableGeometry.height() - height()) / 2);
|
||||
move(origX, origY);
|
||||
|
||||
} else {
|
||||
try
|
||||
{
|
||||
QByteArray ge = app._frameOptions.geometry;
|
||||
restoreGeometry(ge);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
MsgBox::Show(NULL, "restore frame status error!");
|
||||
}
|
||||
if (app._frameOptions.isMax){
|
||||
showMaximized(); //show max by system api
|
||||
}
|
||||
else{
|
||||
int left = app._frameOptions.left;
|
||||
int top = app._frameOptions.top;
|
||||
int right = app._frameOptions.right;
|
||||
int bottom = app._frameOptions.bottom;
|
||||
resize(right-left, bottom-top);
|
||||
move(left, top);
|
||||
}
|
||||
}
|
||||
|
||||
// restore dockwidgets
|
||||
|
||||
@@ -69,8 +69,7 @@ public:
|
||||
|
||||
void readSettings();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent* event);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
@@ -86,8 +85,8 @@ public slots:
|
||||
private:
|
||||
void hide_border();
|
||||
void show_border();
|
||||
|
||||
void writeSettings();
|
||||
void saveWindowRegion();
|
||||
|
||||
private:
|
||||
toolbars::TitleBar *_titleBar;
|
||||
@@ -107,8 +106,7 @@ private:
|
||||
QRect _dragStartGeometry;
|
||||
int _hit_border;
|
||||
QTimer _timer;
|
||||
bool _freezing;
|
||||
bool _minimized;
|
||||
bool _freezing;
|
||||
};
|
||||
|
||||
} // namespace pv
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <QtGlobal>
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
@@ -84,6 +85,7 @@
|
||||
#include "../ui/msgbox.h"
|
||||
#include "config/appconfig.h"
|
||||
#include "appcontrol.h"
|
||||
#include "../dsvdef.h"
|
||||
|
||||
|
||||
namespace pv {
|
||||
@@ -117,7 +119,6 @@ void MainWindow::setup_ui()
|
||||
|
||||
setObjectName(QString::fromUtf8("MainWindow"));
|
||||
setContentsMargins(0,0,0,0);
|
||||
layout()->setMargin(0);
|
||||
layout()->setSpacing(0);
|
||||
|
||||
// Setup the central widget
|
||||
@@ -1140,7 +1141,8 @@ bool MainWindow::on_store_session(QString name)
|
||||
return false;
|
||||
}
|
||||
QTextStream outStream(&sessionFile);
|
||||
outStream.setCodec("UTF-8");
|
||||
app::set_utf8(outStream);
|
||||
|
||||
//outStream.setGenerateByteOrderMark(true); // UTF-8 without BOM
|
||||
|
||||
AppConfig &app = AppConfig::Instance();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QLocale>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -191,7 +192,7 @@ void DeviceOptions::bind_enum(const QString &name, const QString label, int key,
|
||||
}
|
||||
|
||||
void DeviceOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
||||
optional< std::pair<int64_t, int64_t> > range)
|
||||
boost::optional< std::pair<int64_t, int64_t> > range)
|
||||
{
|
||||
_properties.push_back(
|
||||
new Int(name, label, suffix, range,
|
||||
@@ -200,7 +201,7 @@ void DeviceOptions::bind_int(const QString &name, const QString label, int key,
|
||||
}
|
||||
|
||||
void DeviceOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
||||
optional< std::pair<double, double> > range,
|
||||
boost::optional< std::pair<double, double> > range,
|
||||
int decimals, boost::optional<double> step)
|
||||
{
|
||||
_properties.push_back(
|
||||
|
||||
@@ -163,7 +163,7 @@ void ProbeOptions::bind_enum(const QString &name, const QString label, int key,
|
||||
}
|
||||
|
||||
void ProbeOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
||||
optional< std::pair<int64_t, int64_t> > range)
|
||||
boost::optional< std::pair<int64_t, int64_t> > range)
|
||||
{
|
||||
_properties.push_back(
|
||||
new Int(name, label, suffix, range,
|
||||
@@ -172,7 +172,7 @@ void ProbeOptions::bind_int(const QString &name, const QString label, int key, Q
|
||||
}
|
||||
|
||||
void ProbeOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
||||
optional< std::pair<double, double> > range,
|
||||
boost::optional< std::pair<double, double> > range,
|
||||
int decimals, boost::optional<double> step)
|
||||
{
|
||||
_properties.push_back(
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace prop {
|
||||
Double::Double(QString name, QString label,
|
||||
int decimals,
|
||||
QString suffix,
|
||||
optional< pair<double, double> > range,
|
||||
optional<double> step,
|
||||
boost::optional< pair<double, double> > range,
|
||||
boost::optional<double> step,
|
||||
Getter getter,
|
||||
Setter setter) :
|
||||
Property(name, label, getter, setter),
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace prop {
|
||||
|
||||
Int::Int(QString name, QString label,
|
||||
QString suffix,
|
||||
optional< pair<int64_t, int64_t> > range,
|
||||
boost::optional< pair<int64_t, int64_t> > range,
|
||||
Getter getter,
|
||||
Setter setter) :
|
||||
Property(name, label, getter, setter),
|
||||
|
||||
@@ -52,22 +52,9 @@
|
||||
|
||||
#include <libsigrokdecode4DSL/libsigrokdecode.h>
|
||||
#include "config/appconfig.h"
|
||||
#include "dsvdef.h"
|
||||
|
||||
namespace pv {
|
||||
|
||||
char chunk_name[30] = {0};
|
||||
|
||||
void MakeChunkName(int chunk_num, int index, int type, int version){
|
||||
if (version == 2) {
|
||||
const char *type_name = NULL;
|
||||
type_name = (type == SR_CHANNEL_LOGIC) ? "L" :
|
||||
(type == SR_CHANNEL_DSO) ? "O" :
|
||||
(type == SR_CHANNEL_ANALOG) ? "A" : "U";
|
||||
snprintf(chunk_name, 15, "%s-%d/%d", type_name, index, chunk_num);
|
||||
} else {
|
||||
snprintf(chunk_name, 15, "data");
|
||||
}
|
||||
}
|
||||
namespace pv {
|
||||
|
||||
StoreSession::StoreSession(SigSession *session) :
|
||||
_session(session),
|
||||
@@ -188,7 +175,7 @@ bool StoreSession::save_start()
|
||||
*/
|
||||
|
||||
//make zip file
|
||||
if (meta_file != NULL && m_zipDoc.CreateNew(_file_name.toUtf8().data(), false))
|
||||
if (meta_file != "" && m_zipDoc.CreateNew(_file_name.toUtf8().data(), false))
|
||||
{
|
||||
if (!m_zipDoc.AddFromFile(meta_file.toUtf8().data(), "header")
|
||||
|| !m_zipDoc.AddFromFile(decoders_file.toUtf8().data(), "decoders")
|
||||
@@ -214,6 +201,8 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
|
||||
{
|
||||
assert(snapshot);
|
||||
|
||||
char chunk_name[20] = {0};
|
||||
|
||||
int ret = SR_ERR;
|
||||
int num = 0;
|
||||
data::LogicSnapshot *logic_snapshot = NULL;
|
||||
@@ -253,7 +242,7 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
|
||||
// ret = sr_session_append(_file_name.toUtf8().data(), buf, size,
|
||||
// i, ch_index, ch_type, File_Version);
|
||||
|
||||
MakeChunkName(i, ch_index, ch_type, File_Version);
|
||||
MakeChunkName(chunk_name, i, ch_index, ch_type, File_Version);
|
||||
ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)buf, size) ? SR_OK : -1;
|
||||
|
||||
if (ret != SR_OK) {
|
||||
@@ -304,7 +293,7 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
|
||||
// ret = sr_session_append(_file_name.toUtf8().data(), tmp, size,
|
||||
// i, 0, ch_type, File_Version);
|
||||
|
||||
MakeChunkName(i, 0, ch_type, File_Version);
|
||||
MakeChunkName(chunk_name, i, 0, ch_type, File_Version);
|
||||
ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)tmp, size) ? SR_OK : -1;
|
||||
|
||||
buf += (size - _unit_count);
|
||||
@@ -315,7 +304,7 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
|
||||
// ret = sr_session_append(_file_name.toUtf8().data(), buf, size,
|
||||
// i, 0, ch_type, File_Version);
|
||||
|
||||
MakeChunkName(i, 0, ch_type, File_Version);
|
||||
MakeChunkName(chunk_name, i, 0, ch_type, File_Version);
|
||||
ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)buf, size) ? SR_OK : -1;
|
||||
|
||||
buf += size;
|
||||
@@ -646,8 +635,8 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
|
||||
|
||||
QFile file(_file_name);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
QTextStream out(&file);
|
||||
out.setCodec("UTF-8");
|
||||
QTextStream out(&file);
|
||||
app::set_utf8(out);
|
||||
//out.setGenerateByteOrderMark(true); // UTF-8 without BOM
|
||||
|
||||
// Meta
|
||||
@@ -853,7 +842,7 @@ QString StoreSession::decoders_gen()
|
||||
return NULL;
|
||||
}
|
||||
QTextStream outStream(&sessionFile);
|
||||
outStream.setCodec("UTF-8");
|
||||
app::set_utf8(outStream);
|
||||
//outStream.setGenerateByteOrderMark(true); // UTF-8 without BOM
|
||||
|
||||
QJsonArray dec_array = json_decoders();
|
||||
@@ -1293,5 +1282,22 @@ bool StoreSession::IsLogicDataType()
|
||||
return false;
|
||||
}
|
||||
|
||||
void StoreSession::MakeChunkName(char *chunk_name, int chunk_num, int index, int type, int version)
|
||||
{
|
||||
chunk_name[0] = 0;
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
const char *type_name = NULL;
|
||||
type_name = (type == SR_CHANNEL_LOGIC) ? "L" : (type == SR_CHANNEL_DSO) ? "O"
|
||||
: (type == SR_CHANNEL_ANALOG) ? "A"
|
||||
: "U";
|
||||
snprintf(chunk_name, 15, "%s-%d/%d", type_name, index, chunk_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(chunk_name, 15, "data");
|
||||
}
|
||||
}
|
||||
|
||||
} // pv
|
||||
|
||||
@@ -93,6 +93,7 @@ public:
|
||||
private:
|
||||
QList<QString> getSuportedExportFormats();
|
||||
double get_integer(GVariant * var);
|
||||
void MakeChunkName(char *chunk_name, int chunk_num, int index, int type, int version);
|
||||
|
||||
signals:
|
||||
void progress_updated();
|
||||
|
||||
@@ -75,7 +75,6 @@ SamplingBar::SamplingBar(SigSession *session, QWidget *parent) :
|
||||
{
|
||||
setMovable(false);
|
||||
setContentsMargins(0,0,0,0);
|
||||
layout()->setMargin(0);
|
||||
layout()->setSpacing(0);
|
||||
|
||||
_mode_button.setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
@@ -39,26 +40,26 @@ namespace toolbars {
|
||||
|
||||
TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
|
||||
QWidget(parent)
|
||||
{
|
||||
_title = NULL;
|
||||
{
|
||||
_minimizeButton = NULL;
|
||||
_maximizeButton = NULL;
|
||||
_closeButton = NULL;
|
||||
_lay = NULL;
|
||||
_moving = false;
|
||||
_parent = parent;
|
||||
_isTop = top;
|
||||
_hasClose = hasClose;
|
||||
_title = NULL;
|
||||
|
||||
assert(parent);
|
||||
|
||||
setObjectName("TitleBar");
|
||||
setContentsMargins(0,0,0,0);
|
||||
setFixedHeight(32);
|
||||
setFixedHeight(32);
|
||||
|
||||
QHBoxLayout *lay1 = new QHBoxLayout(this);
|
||||
|
||||
_title = new QLabel(this);
|
||||
_lay = new QHBoxLayout(this);
|
||||
_lay->addWidget(_title);
|
||||
lay1->addWidget(_title);
|
||||
|
||||
if (_isTop) {
|
||||
_minimizeButton = new QToolButton(this);
|
||||
@@ -66,8 +67,8 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
|
||||
_maximizeButton = new QToolButton(this);
|
||||
_maximizeButton->setObjectName("MaximizeButton");
|
||||
|
||||
_lay->addWidget(_minimizeButton);
|
||||
_lay->addWidget(_maximizeButton);
|
||||
lay1->addWidget(_minimizeButton);
|
||||
lay1->addWidget(_maximizeButton);
|
||||
|
||||
connect(this, SIGNAL(normalShow()), parent, SLOT(showNormal()));
|
||||
connect(this, SIGNAL( maximizedShow()), parent, SLOT(showMaximized()));
|
||||
@@ -78,24 +79,22 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) :
|
||||
if (_isTop || _hasClose) {
|
||||
_closeButton= new QToolButton(this);
|
||||
_closeButton->setObjectName("CloseButton");
|
||||
_lay->addWidget(_closeButton);
|
||||
lay1->addWidget(_closeButton);
|
||||
connect(_closeButton, SIGNAL( clicked()), parent, SLOT(close()));
|
||||
}
|
||||
|
||||
_lay->insertStretch(0, 500);
|
||||
_lay->insertStretch(2, 500);
|
||||
_lay->setMargin(0);
|
||||
_lay->setSpacing(0);
|
||||
lay1->insertStretch(0, 500);
|
||||
lay1->insertStretch(2, 500);
|
||||
lay1->setContentsMargins(0,0,0,0);
|
||||
lay1->setSpacing(0);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
TitleBar::~TitleBar(){
|
||||
DESTROY_QT_OBJECT(_title);
|
||||
TitleBar::~TitleBar(){
|
||||
DESTROY_QT_OBJECT(_minimizeButton);
|
||||
DESTROY_QT_OBJECT(_maximizeButton);
|
||||
DESTROY_QT_OBJECT(_closeButton);
|
||||
DESTROY_QT_OBJECT(_lay);
|
||||
}
|
||||
|
||||
void TitleBar::changeEvent(QEvent *event)
|
||||
|
||||
@@ -23,9 +23,10 @@
|
||||
#define DSVIEW_PV_TOOLBARS_TITLEBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
class QLabel;
|
||||
|
||||
class QToolButton;
|
||||
class QHBoxLayout;
|
||||
class QLabel;
|
||||
|
||||
namespace pv {
|
||||
namespace toolbars {
|
||||
@@ -61,12 +62,12 @@ protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
QLabel *_title;
|
||||
|
||||
QToolButton *_minimizeButton;
|
||||
QToolButton *_maximizeButton;
|
||||
QToolButton *_closeButton;
|
||||
QHBoxLayout *_lay;
|
||||
|
||||
QLabel *_title;
|
||||
|
||||
bool _moving;
|
||||
bool _isTop;
|
||||
bool _hasClose;
|
||||
|
||||
@@ -34,8 +34,12 @@ void MsgBox::Show(const char *title, const char *text, QWidget *parent)
|
||||
{
|
||||
assert(text);
|
||||
|
||||
QString str;
|
||||
str.append("\n");
|
||||
str.append(text);
|
||||
|
||||
pv::dialogs::DSMessageBox msg(parent, title);
|
||||
msg.mBox()->setText(QString(text));
|
||||
msg.mBox()->setText(str);
|
||||
// msg.mBox()->setInformativeText(QString(text));
|
||||
msg.mBox()->setStandardButtons(QMessageBox::Ok);
|
||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
||||
@@ -46,8 +50,12 @@ bool MsgBox::Confirm(const char *text, QWidget *parent)
|
||||
{
|
||||
assert(text);
|
||||
|
||||
QString str;
|
||||
str.append("\n");
|
||||
str.append(text);
|
||||
|
||||
pv::dialogs::DSMessageBox msg(parent, "Question");
|
||||
msg.mBox()->setText(QString(text));
|
||||
msg.mBox()->setText(str);
|
||||
msg.mBox()->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msg.mBox()->setIcon(QMessageBox::Question);
|
||||
msg.exec();
|
||||
|
||||
@@ -351,6 +351,7 @@ bool DecodeTrace::create_popup()
|
||||
int ret = false; //setting have changed flag
|
||||
|
||||
dialogs::DSDialog dlg;
|
||||
//dlg.setMinimumSize(500,600);
|
||||
create_popup_form(&dlg);
|
||||
|
||||
if (QDialog::Accepted == dlg.exec())
|
||||
|
||||
@@ -47,7 +47,6 @@ DevMode::DevMode(QWidget *parent, SigSession *session) :
|
||||
|
||||
{
|
||||
_layout = new QHBoxLayout(this);
|
||||
_layout->setMargin(0);
|
||||
_layout->setSpacing(0);
|
||||
_layout->setContentsMargins(2, 0, 0, 0);
|
||||
|
||||
@@ -71,8 +70,7 @@ DevMode::DevMode(QWidget *parent, SigSession *session) :
|
||||
_mode_btn->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
|
||||
|
||||
_layout->addWidget(_close_button);
|
||||
_layout->addWidget(_mode_btn);
|
||||
//_layout->addWidget(new QWidget(this));
|
||||
_layout->addWidget(_mode_btn);
|
||||
_layout->setStretch(1, 100);
|
||||
setLayout(_layout);
|
||||
}
|
||||
|
||||
@@ -20,20 +20,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "header.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "../../extdef.h"
|
||||
#include "trace.h"
|
||||
#include "dsosignal.h"
|
||||
#include "logicsignal.h"
|
||||
#include "analogsignal.h"
|
||||
#include "groupsignal.h"
|
||||
#include "decodetrace.h"
|
||||
#include "../sigsession.h"
|
||||
#include "../device/devinst.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include "header.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QInputDialog>
|
||||
@@ -43,6 +30,20 @@
|
||||
#include <QRect>
|
||||
#include <QStyleOption>
|
||||
#include <QApplication>
|
||||
#include <assert.h>
|
||||
|
||||
#include "view.h"
|
||||
#include "trace.h"
|
||||
#include "dsosignal.h"
|
||||
#include "logicsignal.h"
|
||||
#include "analogsignal.h"
|
||||
#include "groupsignal.h"
|
||||
#include "decodetrace.h"
|
||||
#include "../sigsession.h"
|
||||
#include "../device/devinst.h"
|
||||
#include "../../extdef.h"
|
||||
#include "../dsvdef.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -253,33 +254,74 @@ void Header::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
if (event->orientation() == Qt::Vertical) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int delta = 0;
|
||||
bool isVertical = true;
|
||||
QPoint pos;
|
||||
(void)x;
|
||||
(void)y;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
x = (int)event->position().x();
|
||||
y = (int)event->position().y();
|
||||
int anglex = event->angleDelta().x();
|
||||
int angley = event->angleDelta().y();
|
||||
|
||||
pos.setX(x);
|
||||
pos.setY(y);
|
||||
|
||||
if (anglex == 0 || ABS_VAL(angley) >= ABS_VAL(anglex)){
|
||||
delta = angley;
|
||||
isVertical = true;
|
||||
}
|
||||
else{
|
||||
delta = anglex;
|
||||
isVertical = false; //hori direction
|
||||
}
|
||||
#else
|
||||
x = event->x();
|
||||
delta = event->delta();
|
||||
isVertical = event->orientation() == Qt::Vertical;
|
||||
pos = event->pos();
|
||||
#endif
|
||||
|
||||
if (isVertical)
|
||||
{
|
||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
||||
// Vertical scrolling
|
||||
double shift = 0;
|
||||
#ifdef Q_OS_DARWIN
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
static bool active = true;
|
||||
static int64_t last_time;
|
||||
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
|
||||
if (active) {
|
||||
if (event->source() == Qt::MouseEventSynthesizedBySystem)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
last_time = QDateTime::currentMSecsSinceEpoch();
|
||||
shift = event->delta() > 1.5 ? -1 :
|
||||
event->delta() < -1.5 ? 1 : 0;
|
||||
shift = delta > 1.5 ? -1 : delta < -1.5 ? 1 : 0;
|
||||
}
|
||||
int64_t cur_time = QDateTime::currentMSecsSinceEpoch();
|
||||
if (cur_time - last_time > 100)
|
||||
active = true;
|
||||
else
|
||||
active = false;
|
||||
} else {
|
||||
shift = -event->delta() / 80.0;
|
||||
}
|
||||
#else
|
||||
shift = event->delta() / 80.0;
|
||||
#endif
|
||||
for(auto &t : traces)
|
||||
if (t->mouse_wheel(width(), event->pos(), shift))
|
||||
else
|
||||
{
|
||||
shift = -delta / 80.0;
|
||||
}
|
||||
#else
|
||||
shift = delta / 80.0;
|
||||
#endif
|
||||
|
||||
for (auto &t : traces)
|
||||
{
|
||||
if (t->mouse_wheel(width(), pos, shift))
|
||||
break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
#include "../sigsession.h"
|
||||
#include "../device/devinst.h"
|
||||
#include "dsosignal.h"
|
||||
|
||||
#include <extdef.h>
|
||||
#include "../../extdef.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@@ -38,10 +37,11 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QTextStream>
|
||||
#include <QStyleOption>
|
||||
#include <QStyleOption>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Qt;
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QStyleOption>
|
||||
#include <QPainterPath>
|
||||
#include <math.h>
|
||||
#include <math.h>
|
||||
#include <QWheelEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
#include "../dsvdef.h"
|
||||
@@ -1023,54 +1025,86 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
void Viewport::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
assert(event);
|
||||
|
||||
if (_type == FFT_VIEW) {
|
||||
for(auto &t : _view.session().get_spectrum_traces()) {
|
||||
assert(t);
|
||||
if(t->enabled()) {
|
||||
t->zoom(event->delta() / 80, event->x());
|
||||
int x = 0; //mouse x pos
|
||||
int delta = 0;
|
||||
bool isVertical = true;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
x = (int)event->position().x();
|
||||
int anglex = event->angleDelta().x();
|
||||
int angley = event->angleDelta().y();
|
||||
|
||||
if (anglex == 0 || ABS_VAL(angley) >= ABS_VAL(anglex)){
|
||||
delta = angley;
|
||||
isVertical = true;
|
||||
}
|
||||
else{
|
||||
delta = anglex;
|
||||
isVertical = false; //hori direction
|
||||
}
|
||||
#else
|
||||
x = event->x();
|
||||
delta = event->delta();
|
||||
isVertical = event->orientation() == Qt::Vertical;
|
||||
#endif
|
||||
|
||||
if (_type == FFT_VIEW)
|
||||
{
|
||||
for (auto &t : _view.session().get_spectrum_traces())
|
||||
{
|
||||
if (t->enabled())
|
||||
{
|
||||
t->zoom(delta / 80, x);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (_type == TIME_VIEW){
|
||||
if (event->orientation() == Qt::Vertical) {
|
||||
}
|
||||
else if (_type == TIME_VIEW)
|
||||
{
|
||||
if (isVertical)
|
||||
{
|
||||
// Vertical scrolling is interpreted as zooming in/out
|
||||
const int offset = event->x();
|
||||
#ifdef Q_OS_DARWIN
|
||||
#ifdef Q_OS_DARWIN
|
||||
static bool active = true;
|
||||
static int64_t last_time;
|
||||
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
|
||||
if (active && (event->modifiers() & Qt::ShiftModifier)) {
|
||||
if (event->source() == Qt::MouseEventSynthesizedBySystem)
|
||||
{
|
||||
if (active && (event->modifiers() & Qt::ShiftModifier))
|
||||
{
|
||||
last_time = QDateTime::currentMSecsSinceEpoch();
|
||||
const double scale = event->delta() > 1.5 ? 1 :
|
||||
event->delta() < -1.5 ? -1 : 0;
|
||||
_view.zoom(scale, offset);
|
||||
const double scale = delta > 1.5 ? 1 : (delta < -1.5 ? -1 : 0);
|
||||
_view.zoom(scale, x);
|
||||
}
|
||||
int64_t cur_time = QDateTime::currentMSecsSinceEpoch();
|
||||
if (cur_time - last_time > 50)
|
||||
active = true;
|
||||
else
|
||||
active = false;
|
||||
} else {
|
||||
_view.zoom(-event->delta() / 80, offset);
|
||||
}
|
||||
#else
|
||||
_view.zoom(event->delta() / 80, offset);
|
||||
#endif
|
||||
} else if (event->orientation() == Qt::Horizontal) {
|
||||
else
|
||||
{
|
||||
_view.zoom(-delta / 80, x);
|
||||
}
|
||||
#else
|
||||
_view.zoom(delta / 80, x);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Horizontal scrolling is interpreted as moving left/right
|
||||
if (!(event->modifiers() & Qt::ShiftModifier))
|
||||
_view.set_scale_offset(_view.scale(),
|
||||
_view.offset() - event->delta());
|
||||
_view.set_scale_offset(_view.scale(), _view.offset() - delta);
|
||||
}
|
||||
}
|
||||
|
||||
const auto &sigs = _view.session().get_signals();
|
||||
for(auto &s : sigs) {
|
||||
assert(s);
|
||||
for (auto &s : sigs)
|
||||
{
|
||||
view::DsoSignal *dsoSig = NULL;
|
||||
if ((dsoSig = dynamic_cast<view::DsoSignal*>(s))) {
|
||||
if ((dsoSig = dynamic_cast<view::DsoSignal *>(s)))
|
||||
{
|
||||
dsoSig->auto_end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ QT += svg
|
||||
}
|
||||
CONFIG += exceptions
|
||||
CONFIG += object_parallel_to_source
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
#QMAKE_CFLAGS_ISYSTEM = -I
|
||||
|
||||
TARGET = DSView
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.0, 2021-11-16T18:44:24. -->
|
||||
<!-- Written by QtCreator 4.11.0, 2021-11-19T11:46:54. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
Reference in New Issue
Block a user