diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index b921a631..42bc78d3 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -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(); } diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 7cddff2a..f01678ad 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -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; }; diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index a3649f8f..bf389c11 100755 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -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; } diff --git a/DSView/pv/dialogs/about.cpp b/DSView/pv/dialogs/about.cpp index a0a40099..3392d2a0 100755 --- a/DSView/pv/dialogs/about.cpp +++ b/DSView/pv/dialogs/about.cpp @@ -21,6 +21,8 @@ */ +#include "about.h" + #include #include #include @@ -28,10 +30,9 @@ #include #include #include -#include - -#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(); diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index 96436f78..ee506833 100755 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -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() diff --git a/DSView/pv/dialogs/dsdialog.cpp b/DSView/pv/dialogs/dsdialog.cpp index 1d8f15ff..37a0e7cd 100755 --- a/DSView/pv/dialogs/dsdialog.cpp +++ b/DSView/pv/dialogs/dsdialog.cpp @@ -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 diff --git a/DSView/pv/dialogs/dsmessagebox.cpp b/DSView/pv/dialogs/dsmessagebox.cpp index 2df07b6e..1d6fb9ef 100755 --- a/DSView/pv/dialogs/dsmessagebox.cpp +++ b/DSView/pv/dialogs/dsmessagebox.cpp @@ -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*))); } diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/pv/dialogs/dsomeasure.cpp index a25e7307..7e9825ef 100755 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/pv/dialogs/dsomeasure.cpp @@ -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(dsoSig); diff --git a/DSView/pv/dialogs/lissajousoptions.cpp b/DSView/pv/dialogs/lissajousoptions.cpp index 8f8456be..2ae27886 100755 --- a/DSView/pv/dialogs/lissajousoptions.cpp +++ b/DSView/pv/dialogs/lissajousoptions.cpp @@ -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); diff --git a/DSView/pv/dialogs/mathoptions.cpp b/DSView/pv/dialogs/mathoptions.cpp index 21e2d6ab..afc2e9f9 100755 --- a/DSView/pv/dialogs/mathoptions.cpp +++ b/DSView/pv/dialogs/mathoptions.cpp @@ -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); diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index b9445c60..7a9e6104 100755 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -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 future; diff --git a/DSView/pv/dialogs/regionoptions.cpp b/DSView/pv/dialogs/regionoptions.cpp index 62ff127a..ce71775d 100755 --- a/DSView/pv/dialogs/regionoptions.cpp +++ b/DSView/pv/dialogs/regionoptions.cpp @@ -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); diff --git a/DSView/pv/dialogs/search.cpp b/DSView/pv/dialogs/search.cpp index 7f562068..406f1be8 100755 --- a/DSView/pv/dialogs/search.cpp +++ b/DSView/pv/dialogs/search.cpp @@ -23,7 +23,7 @@ #include "../view/logicsignal.h" #include -#include +#include namespace pv { @@ -39,8 +39,8 @@ Search::Search(QWidget *parent, SigSession *session, std::map 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); diff --git a/DSView/pv/dialogs/shadow.cpp b/DSView/pv/dialogs/shadow.cpp index c6fd3426..0fc91ee4 100755 --- a/DSView/pv/dialogs/shadow.cpp +++ b/DSView/pv/dialogs/shadow.cpp @@ -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)); diff --git a/DSView/pv/dialogs/shadow.h b/DSView/pv/dialogs/shadow.h index 952aad24..e37bbbad 100755 --- a/DSView/pv/dialogs/shadow.h +++ b/DSView/pv/dialogs/shadow.h @@ -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; diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index f3b3f62a..68b983bd 100755 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -38,8 +38,7 @@ #include "../dialogs/dsmessagebox.h" #include -#include -#include +#include #include #include "../config/appconfig.h" diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index a9affcdc..ba3f0282 100755 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -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) diff --git a/DSView/pv/dock/searchdock.cpp b/DSView/pv/dock/searchdock.cpp index 33c56f66..bc3de15f 100755 --- a/DSView/pv/dock/searchdock.cpp +++ b/DSView/pv/dock/searchdock.cpp @@ -32,8 +32,7 @@ #include "../dialogs/dsmessagebox.h" #include -#include -#include +#include #include #include #include diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/pv/dock/triggerdock.cpp index 87fa9e94..d90da9fd 100755 --- a/DSView/pv/dock/triggerdock.cpp +++ b/DSView/pv/dock/triggerdock.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -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")); diff --git a/DSView/pv/dsvdef.cpp b/DSView/pv/dsvdef.cpp index 49d0e5df..0ad7c4ef 100644 --- a/DSView/pv/dsvdef.cpp +++ b/DSView/pv/dsvdef.cpp @@ -30,6 +30,14 @@ } #endif +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else +#include +#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 + } } diff --git a/DSView/pv/dsvdef.h b/DSView/pv/dsvdef.h index 9069c153..9a5ef516 100644 --- a/DSView/pv/dsvdef.h +++ b/DSView/pv/dsvdef.h @@ -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); } diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index fca633f7..173c1427 100755 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #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 diff --git a/DSView/pv/mainframe.h b/DSView/pv/mainframe.h index e04ac0ee..25b8df4b 100755 --- a/DSView/pv/mainframe.h +++ b/DSView/pv/mainframe.h @@ -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 diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index e1fa249c..0869e39b 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #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(); diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/pv/prop/binding/deviceoptions.cpp index 1b4f1b15..a0e051c2 100755 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/pv/prop/binding/deviceoptions.cpp @@ -24,6 +24,7 @@ #include #include +#include #include @@ -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 > range) + boost::optional< std::pair > 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 > range, + boost::optional< std::pair > range, int decimals, boost::optional step) { _properties.push_back( diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index be3806c9..cf916b04 100755 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -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 > range) + boost::optional< std::pair > 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 > range, + boost::optional< std::pair > range, int decimals, boost::optional step) { _properties.push_back( diff --git a/DSView/pv/prop/double.cpp b/DSView/pv/prop/double.cpp index 2c832d9a..b5c7c3d7 100755 --- a/DSView/pv/prop/double.cpp +++ b/DSView/pv/prop/double.cpp @@ -35,8 +35,8 @@ namespace prop { Double::Double(QString name, QString label, int decimals, QString suffix, - optional< pair > range, - optional step, + boost::optional< pair > range, + boost::optional step, Getter getter, Setter setter) : Property(name, label, getter, setter), diff --git a/DSView/pv/prop/int.cpp b/DSView/pv/prop/int.cpp index ac7961ee..3648193d 100755 --- a/DSView/pv/prop/int.cpp +++ b/DSView/pv/prop/int.cpp @@ -51,7 +51,7 @@ namespace prop { Int::Int(QString name, QString label, QString suffix, - optional< pair > range, + boost::optional< pair > range, Getter getter, Setter setter) : Property(name, label, getter, setter), diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index a621dc8e..322ebd5f 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -52,22 +52,9 @@ #include #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 diff --git a/DSView/pv/storesession.h b/DSView/pv/storesession.h index daadef74..99db9f12 100755 --- a/DSView/pv/storesession.h +++ b/DSView/pv/storesession.h @@ -93,6 +93,7 @@ public: private: QList getSuportedExportFormats(); double get_integer(GVariant * var); + void MakeChunkName(char *chunk_name, int chunk_num, int index, int type, int version); signals: void progress_updated(); diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 33f52c72..50ceebe8 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -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); diff --git a/DSView/pv/toolbars/titlebar.cpp b/DSView/pv/toolbars/titlebar.cpp index d52b18fc..982fab1d 100755 --- a/DSView/pv/toolbars/titlebar.cpp +++ b/DSView/pv/toolbars/titlebar.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -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) diff --git a/DSView/pv/toolbars/titlebar.h b/DSView/pv/toolbars/titlebar.h index 97245223..47d937fa 100755 --- a/DSView/pv/toolbars/titlebar.h +++ b/DSView/pv/toolbars/titlebar.h @@ -23,9 +23,10 @@ #define DSVIEW_PV_TOOLBARS_TITLEBAR_H #include -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; diff --git a/DSView/pv/ui/msgbox.cpp b/DSView/pv/ui/msgbox.cpp index 88b415db..3b10c38e 100644 --- a/DSView/pv/ui/msgbox.cpp +++ b/DSView/pv/ui/msgbox.cpp @@ -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(); diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 8cc1b1a8..1de94a9b 100755 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -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()) diff --git a/DSView/pv/view/devmode.cpp b/DSView/pv/view/devmode.cpp index 58b31fe5..a69f082d 100755 --- a/DSView/pv/view/devmode.cpp +++ b/DSView/pv/view/devmode.cpp @@ -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); } diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index 90b734f4..b3aed97f 100755 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -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 +#include "header.h" #include #include @@ -43,6 +30,20 @@ #include #include #include +#include + +#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(); } } diff --git a/DSView/pv/view/ruler.cpp b/DSView/pv/view/ruler.cpp index 100292c4..25c54a95 100755 --- a/DSView/pv/view/ruler.cpp +++ b/DSView/pv/view/ruler.cpp @@ -28,8 +28,7 @@ #include "../sigsession.h" #include "../device/devinst.h" #include "dsosignal.h" - -#include +#include "../../extdef.h" #include #include @@ -38,10 +37,11 @@ #include #include #include -#include +#include using namespace std; +using namespace Qt; namespace pv { namespace view { diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 3ca32160..ff65b2fd 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -38,7 +38,9 @@ #include #include #include -#include +#include +#include +#include #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(s))) { + if ((dsoSig = dynamic_cast(s))) + { dsoSig->auto_end(); } } diff --git a/qtpro/DSView.pro b/qtpro/DSView.pro index f8e7fde1..5fd987c2 100644 --- a/qtpro/DSView.pro +++ b/qtpro/DSView.pro @@ -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 diff --git a/qtpro/DSView.pro.user b/qtpro/DSView.pro.user index cf656ba4..8871a8fc 100644 --- a/qtpro/DSView.pro.user +++ b/qtpro/DSView.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId