From 0368988a8cf3da9a4b3d5413b3c1d3ce8bd5361c Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 23 Nov 2021 13:35:08 +0800 Subject: [PATCH] fix combobox's bug at macos --- DSView/DSView.desktop | 10 -- DSView/main.cpp | 11 +- DSView/pv/ZipMaker.cpp | 4 +- DSView/pv/appcontrol.cpp | 14 +- DSView/pv/dialogs/deviceoptions.cpp | 2 +- DSView/pv/dialogs/deviceoptions.h | 2 +- DSView/pv/dialogs/fftoptions.cpp | 22 +-- DSView/pv/dialogs/fftoptions.h | 18 +-- DSView/pv/dialogs/protocolexp.cpp | 2 +- DSView/pv/dialogs/protocolexp.h | 4 +- DSView/pv/dialogs/protocollist.cpp | 4 +- DSView/pv/dialogs/protocollist.h | 9 +- DSView/pv/dialogs/regionoptions.cpp | 4 +- DSView/pv/dialogs/regionoptions.h | 6 +- DSView/pv/dock/dsotriggerdock.cpp | 4 +- DSView/pv/dock/dsotriggerdock.h | 7 +- DSView/pv/dock/measuredock.cpp | 10 +- DSView/pv/dock/measuredock.h | 9 +- DSView/pv/dock/protocoldock.cpp | 10 +- DSView/pv/dock/protocoldock.h | 4 +- DSView/pv/dock/protocolitemlayer.cpp | 3 +- DSView/pv/dock/protocolitemlayer.h | 5 +- DSView/pv/dock/searchdock.cpp | 4 +- DSView/pv/dock/searchdock.h | 2 +- DSView/pv/dock/triggerdock.cpp | 12 +- DSView/pv/dock/triggerdock.h | 15 +- DSView/pv/dsvdef.h | 1 + DSView/pv/mainframe.cpp | 47 +++--- DSView/pv/mainwindow.cpp | 14 +- DSView/pv/prop/binding/probeoptions.cpp | 1 + DSView/pv/prop/enum.cpp | 4 +- DSView/pv/prop/enum.h | 4 +- DSView/pv/toolbars/samplingbar.cpp | 6 +- DSView/pv/toolbars/samplingbar.h | 8 +- DSView/pv/ui/dscombobox.cpp | 72 +++++++++ DSView/pv/ui/dscombobox.h | 46 ++++++ DSView/pv/view/decodetrace.cpp | 14 +- DSView/pv/view/decodetrace.h | 10 +- DSView/pv/view/spectrumtrace.cpp | 18 ++- DSView/pv/view/viewport.cpp | 4 +- DSView/pv/view/viewstatus.cpp | 7 +- libsigrok4DSL/config.h | 192 ++++++++++++++++++++++++ libsigrok4DSL/output/gnuplot.c | 2 +- qtpro/DSView.pro | 2 + qtpro/DSView.pro.user | 2 +- 45 files changed, 506 insertions(+), 145 deletions(-) delete mode 100755 DSView/DSView.desktop mode change 100755 => 100644 DSView/pv/mainframe.cpp mode change 100755 => 100644 DSView/pv/mainwindow.cpp create mode 100644 DSView/pv/ui/dscombobox.cpp create mode 100644 DSView/pv/ui/dscombobox.h create mode 100644 libsigrok4DSL/config.h diff --git a/DSView/DSView.desktop b/DSView/DSView.desktop deleted file mode 100755 index e1143240..00000000 --- a/DSView/DSView.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Type=Application -Encoding=UTF-8 -Name=DSView -Comment=GUI Program for DreamSourceLab USB-based Instruments -TryExec=DSView -Exec=DSView -Icon=dsview -Terminal=false -Categories=Development;Electronics;Qt; diff --git a/DSView/main.cpp b/DSView/main.cpp index c0a15a47..210f9241 100755 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -144,12 +144,13 @@ int main(int argc, char *argv[]) return 1; } else if (argcFinal - optind == 1) open_file = argvFinal[argcFinal - 1]; - - // Initialise DS_RES_PATH + QDir dir(QCoreApplication::applicationDirPath()); + +#ifdef Q_OS_LINUX if (dir.cd("..") && dir.cd("share") && - dir.cd(QApplication::applicationName()) && + dir.cd("DSView") && dir.cd("res")) { // the path command like: cd ../share/DSView/res QString res_dir = dir.absolutePath() + "/"; @@ -158,6 +159,10 @@ int main(int argc, char *argv[]) qDebug() << "DSView run ERROR: config files don't exist."; return 1; } +#endif + +//#ifdef Q_OS_DARWIN +//#endif //load app config AppConfig::Instance().LoadAll(); diff --git a/DSView/pv/ZipMaker.cpp b/DSView/pv/ZipMaker.cpp index bf57dd14..18e48fc6 100644 --- a/DSView/pv/ZipMaker.cpp +++ b/DSView/pv/ZipMaker.cpp @@ -23,7 +23,7 @@ #include "ZipMaker.h" #include -#include +#include #include #include #include @@ -251,7 +251,7 @@ const char *ZipMaker::GetError() unzOpenCurrentFile((unzFile)m_uzDoc); //read file data to buffer - void *buf = inf.pData; + char *buf = (char*)inf.pData; long long buflen = inf.dataLen; long long rdlen = 0; diff --git a/DSView/pv/appcontrol.cpp b/DSView/pv/appcontrol.cpp index 39461b2c..fb477aea 100644 --- a/DSView/pv/appcontrol.cpp +++ b/DSView/pv/appcontrol.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include "devicemanager.h" #include "sigsession.h" @@ -72,7 +74,17 @@ bool AppControl::Init() } // const char *decoderScriptDir = "/home/lala/tmpdir/any"; - const char * decoderScriptDir = NULL; + //const char * decoderScriptDir = NULL; + + char decoderScriptDir[256] = {0}; + QDir dir(QCoreApplication::applicationDirPath()); +#ifdef Q_OS_LINUX + dir.cd("../share/DSView/decoders"); +#else + dir.cd("decoders"); +#endif + + strcpy(decoderScriptDir, dir.absolutePath().toUtf8().data()); // Initialise libsigrokdecode if (srd_init(decoderScriptDir) != SRD_OK) diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index ee506833..3fa3be2c 100755 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -391,7 +391,7 @@ void DeviceOptions::analog_channel_check() } } dynamic_widget(_dynamic_layout); - _dynamic_box->setVisible(_dynamic_box->title() != NULL); + _dynamic_box->setVisible(_dynamic_box->title() != ""); } void DeviceOptions::channel_enable() diff --git a/DSView/pv/dialogs/deviceoptions.h b/DSView/pv/dialogs/deviceoptions.h index c09f83aa..7c4d1cdd 100755 --- a/DSView/pv/dialogs/deviceoptions.h +++ b/DSView/pv/dialogs/deviceoptions.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -44,6 +43,7 @@ #include "../prop/binding/probeoptions.h" #include "../toolbars/titlebar.h" #include "../dialogs/dsdialog.h" +#include "../ui/dscombobox.h" using namespace pv::device; diff --git a/DSView/pv/dialogs/fftoptions.cpp b/DSView/pv/dialogs/fftoptions.cpp index 5b8f44d7..10855971 100755 --- a/DSView/pv/dialogs/fftoptions.cpp +++ b/DSView/pv/dialogs/fftoptions.cpp @@ -31,6 +31,7 @@ #include "../view/trace.h" #include "../view/dsosignal.h" #include "../view/spectrumtrace.h" +#include "../dsvdef.h" using namespace boost; @@ -58,15 +59,15 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) : _layout = NULL; _en_checkbox = new QCheckBox(this); - _len_combobox = new QComboBox(this); - _interval_combobox = new QComboBox(this); - _ch_combobox = new QComboBox(this); - _window_combobox = new QComboBox(this); + _len_combobox = new DsComboBox(this); + _interval_combobox = new DsComboBox(this); + _ch_combobox = new DsComboBox(this); + _window_combobox = new DsComboBox(this); _dc_checkbox = new QCheckBox(this); _dc_checkbox->setChecked(true); - _view_combobox = new QComboBox(this); - _dbv_combobox = new QComboBox(this); - + _view_combobox = new DsComboBox(this); + _dbv_combobox = new DsComboBox(this); + // setup _ch_combobox for(auto &s : _session->get_signals()) { view::DsoSignal *dsoSig = NULL; @@ -217,9 +218,9 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) : connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept())); connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject())); - connect(_window_combobox, SIGNAL(currentIndexChanged(QString)), this, SLOT(window_changed(QString))); + connect(_window_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(window_changed(int))); connect(_len_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(len_changed(int))); - connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject())); + connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject())); } FftOptions::~FftOptions(){ @@ -261,8 +262,9 @@ void FftOptions::reject() QDialog::reject(); } -void FftOptions::window_changed(QString str) +void FftOptions::window_changed(int index) { + QString str = _window_combobox->itemText(index); QString hint_pic= ":/icons/" + str +".png"; QPixmap pixmap(hint_pic); _hint_label->setPixmap(pixmap); diff --git a/DSView/pv/dialogs/fftoptions.h b/DSView/pv/dialogs/fftoptions.h index b863d6d5..631713bf 100755 --- a/DSView/pv/dialogs/fftoptions.h +++ b/DSView/pv/dialogs/fftoptions.h @@ -27,13 +27,13 @@ #include #include #include -#include -#include +#include #include "../device/devinst.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" +#include "../ui/dscombobox.h" namespace pv { @@ -58,21 +58,21 @@ protected: void reject(); private slots: - void window_changed(QString str); + void window_changed(int index); void len_changed(int index); private: SigSession *_session; uint64_t _sample_limit; - QComboBox *_len_combobox; - QComboBox *_interval_combobox; + DsComboBox *_len_combobox; + DsComboBox *_interval_combobox; QCheckBox *_en_checkbox; - QComboBox *_ch_combobox; - QComboBox *_window_combobox; + DsComboBox *_ch_combobox; + DsComboBox *_window_combobox; QCheckBox *_dc_checkbox; - QComboBox *_view_combobox; - QComboBox *_dbv_combobox; + DsComboBox *_view_combobox; + DsComboBox *_dbv_combobox; QLabel *_hint_label; QGridLayout *_glayout; diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index 7a9e6104..728410e5 100755 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -52,7 +52,7 @@ ProtocolExp::ProtocolExp(QWidget *parent, SigSession *session) : Qt::Horizontal, this), _export_cancel(false) { - _format_combobox = new QComboBox(this); + _format_combobox = new DsComboBox(this); _format_combobox->addItem(tr("Comma-Separated Values (*.csv)")); _format_combobox->addItem(tr("Text files (*.txt)")); diff --git a/DSView/pv/dialogs/protocolexp.h b/DSView/pv/dialogs/protocolexp.h index 8688fd96..a4894459 100755 --- a/DSView/pv/dialogs/protocolexp.h +++ b/DSView/pv/dialogs/protocolexp.h @@ -28,12 +28,12 @@ #include #include #include -#include #include "../device/devinst.h" #include "../prop/binding/deviceoptions.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" +#include "../ui/dscombobox.h" namespace pv { @@ -68,7 +68,7 @@ private: SigSession *_session; toolbars::TitleBar *_titlebar; - QComboBox *_format_combobox; + DsComboBox *_format_combobox; std::list _row_sel_list; std::list _row_label_list; QFormLayout *_flayout; diff --git a/DSView/pv/dialogs/protocollist.cpp b/DSView/pv/dialogs/protocollist.cpp index 4b094d90..4144cc58 100755 --- a/DSView/pv/dialogs/protocollist.cpp +++ b/DSView/pv/dialogs/protocollist.cpp @@ -45,7 +45,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : { pv::data::DecoderModel* decoder_model = _session->get_decoder_model(); - _map_zoom_combobox = new QComboBox(this); + _map_zoom_combobox = new DsComboBox(this); _map_zoom_combobox->addItem(tr("Fit to Window")); _map_zoom_combobox->addItem(tr("Fixed")); int cur_map_zoom = _session->get_map_zoom(); @@ -57,7 +57,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : connect(_map_zoom_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_set_map_zoom(int))); - _protocol_combobox = new QComboBox(this); + _protocol_combobox = new DsComboBox(this); auto &decode_sigs = _session->get_decode_signals(); int index = 0; diff --git a/DSView/pv/dialogs/protocollist.h b/DSView/pv/dialogs/protocollist.h index f53dfcfa..879787c0 100755 --- a/DSView/pv/dialogs/protocollist.h +++ b/DSView/pv/dialogs/protocollist.h @@ -27,14 +27,13 @@ #include #include #include -#include -#include - +#include #include "../device/devinst.h" #include "../prop/binding/deviceoptions.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" +#include "../ui/dscombobox.h" namespace pv { @@ -62,8 +61,8 @@ private: SigSession *_session; toolbars::TitleBar *_titlebar; - QComboBox *_map_zoom_combobox; - QComboBox *_protocol_combobox; + DsComboBox *_map_zoom_combobox; + DsComboBox *_protocol_combobox; std::list _show_checkbox_list; std::list _show_label_list; QFormLayout *_flayout; diff --git a/DSView/pv/dialogs/regionoptions.cpp b/DSView/pv/dialogs/regionoptions.cpp index ce71775d..8c455d26 100755 --- a/DSView/pv/dialogs/regionoptions.cpp +++ b/DSView/pv/dialogs/regionoptions.cpp @@ -45,8 +45,8 @@ RegionOptions::RegionOptions(view::View *view, SigSession *session, QWidget *par QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); hlayout->setSpacing(0); - _start_comboBox = new QComboBox(this); - _end_comboBox = new QComboBox(this); + _start_comboBox = new DsComboBox(this); + _end_comboBox = new DsComboBox(this); _start_comboBox->addItem(RegionStart); _end_comboBox->addItem(RegionEnd); if (_view) { diff --git a/DSView/pv/dialogs/regionoptions.h b/DSView/pv/dialogs/regionoptions.h index b3e06b78..a66b2811 100755 --- a/DSView/pv/dialogs/regionoptions.h +++ b/DSView/pv/dialogs/regionoptions.h @@ -27,10 +27,10 @@ #include #include #include -#include #include "../toolbars/titlebar.h" #include "dsdialog.h" +#include "../ui/dscombobox.h" namespace pv { @@ -59,8 +59,8 @@ private: SigSession *_session; view::View *_view; - QComboBox *_start_comboBox; - QComboBox *_end_comboBox; + DsComboBox *_start_comboBox; + DsComboBox *_end_comboBox; QDialogButtonBox _button_box; diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/pv/dock/dsotriggerdock.cpp index 6d401770..7fce3f47 100755 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/pv/dock/dsotriggerdock.cpp @@ -61,7 +61,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : connect(_position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int))); _holdoff_label = new QLabel(_widget); - _holdoff_comboBox = new QComboBox(_widget); + _holdoff_comboBox = new DsComboBox(_widget); _holdoff_comboBox->addItem(tr("uS"), QVariant::fromValue(1000)); _holdoff_comboBox->addItem(tr("mS"), QVariant::fromValue(1000000)); _holdoff_comboBox->addItem(tr("S"), QVariant::fromValue(1000000000)); @@ -103,7 +103,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : connect(_falling_radioButton, SIGNAL(clicked()), this, SLOT(type_changed())); _source_group=new QButtonGroup(_widget); - _channel_comboBox = new QComboBox(_widget); + _channel_comboBox = new DsComboBox(_widget); _type_group=new QButtonGroup(_widget); _source_group->addButton(_auto_radioButton); diff --git a/DSView/pv/dock/dsotriggerdock.h b/DSView/pv/dock/dsotriggerdock.h index 4688577e..847194e5 100755 --- a/DSView/pv/dock/dsotriggerdock.h +++ b/DSView/pv/dock/dsotriggerdock.h @@ -27,12 +27,13 @@ #include #include #include -#include #include #include #include +#include "../ui/dscombobox.h" + namespace pv { class SigSession; @@ -79,7 +80,7 @@ private: QWidget *_widget; - QComboBox *_holdoff_comboBox; + DsComboBox *_holdoff_comboBox; QSpinBox *_holdoff_spinBox; QSlider *_holdoff_slider; @@ -89,7 +90,7 @@ private: QSlider *_position_slider; QButtonGroup *_source_group; - QComboBox *_channel_comboBox; + DsComboBox *_channel_comboBox; QButtonGroup *_type_group; QLabel *_position_label; diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index 68b983bd..cd98281f 100755 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -216,7 +216,7 @@ void MeasureDock::reload() else _edge_groupBox->setDisabled(true); - for (QVector ::const_iterator i = _edge_ch_cmb_vec.begin(); + for (QVector ::const_iterator i = _edge_ch_cmb_vec.begin(); i != _edge_ch_cmb_vec.end(); i++) { update_probe_selector(*i); } @@ -416,7 +416,7 @@ void MeasureDock::add_edge_measure() g_label->setContentsMargins(0,0,0,0); QLabel *a_label = new QLabel(tr("@"), row_widget); a_label->setContentsMargins(0,0,0,0); - QComboBox *ch_cmb = create_probe_selector(row_widget); + DsComboBox *ch_cmb = create_probe_selector(row_widget); _edge_del_btn_vec.push_back(del_btn); _edge_s_btn_vec.push_back(s_btn); _edge_e_btn_vec.push_back(e_btn); @@ -643,14 +643,14 @@ void MeasureDock::set_cursor_btn_color(QPushButton *btn) btn->setStyleSheet(style); } -QComboBox* MeasureDock::create_probe_selector(QWidget *parent) +DsComboBox* MeasureDock::create_probe_selector(QWidget *parent) { - QComboBox *selector = new QComboBox(parent); + DsComboBox *selector = new DsComboBox(parent); update_probe_selector(selector); return selector; } -void MeasureDock::update_probe_selector(QComboBox *selector) +void MeasureDock::update_probe_selector(DsComboBox *selector) { selector->clear(); const auto &sigs = _session->get_signals(); diff --git a/DSView/pv/dock/measuredock.h b/DSView/pv/dock/measuredock.h index 379b1d38..63b77b52 100755 --- a/DSView/pv/dock/measuredock.h +++ b/DSView/pv/dock/measuredock.h @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -42,6 +41,8 @@ #include +#include "../ui/dscombobox.h" + namespace pv { class SigSession; @@ -73,8 +74,8 @@ private: void reStyle(); private: - QComboBox* create_probe_selector(QWidget *parent); - void update_probe_selector(QComboBox *selector); + DsComboBox* create_probe_selector(QWidget *parent); + void update_probe_selector(DsComboBox *selector); signals: @@ -129,7 +130,7 @@ private: QVector _edge_del_btn_vec; QVector _edge_s_btn_vec; QVector _edge_e_btn_vec; - QVector _edge_ch_cmb_vec; + QVector _edge_ch_cmb_vec; QVector _edge_r_label_vec; QPushButton *_sel_btn; diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index ba3f0282..28cf86b0 100755 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -75,7 +75,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio _del_all_button = new QPushButton(_up_widget); _del_all_button->setFlat(true); _del_all_button->setCheckable(true); - _protocol_combobox = new QComboBox(_up_widget); + _protocol_combobox = new DsComboBox(_up_widget); GSList *l = g_slist_sort(g_slist_copy( (GSList*)srd_decoder_list()), decoder_name_cmp); @@ -248,8 +248,12 @@ void ProtocolDock::paintEvent(QPaintEvent *) void ProtocolDock::resizeEvent(QResizeEvent *event) { int width = this->visibleRegion().boundingRect().width(); - width = width - _dn_layout->margin() * 2 - - _dn_search_layout->margin() * 2 - + + int mg1 = 10; + int mg2 = 10; + + width = width - mg1 * 2 - + mg2 * 2 - _dn_search_layout->spacing() * 2 - _pre_button->width()-_nxt_button->width(); width = std::max(width, 0); diff --git a/DSView/pv/dock/protocoldock.h b/DSView/pv/dock/protocoldock.h index a83df95b..2fc198e1 100755 --- a/DSView/pv/dock/protocoldock.h +++ b/DSView/pv/dock/protocoldock.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include "../data/decodermodel.h" #include "protocolitemlayer.h" +#include "../ui/dscombobox.h" namespace pv { @@ -135,7 +135,7 @@ private: QPushButton *_add_button; QPushButton *_del_all_button; - QComboBox *_protocol_combobox; + DsComboBox *_protocol_combobox; QVector _protocol_index_list; QVBoxLayout *_up_layout; QVector _protocol_items; //protocol item layers diff --git a/DSView/pv/dock/protocolitemlayer.cpp b/DSView/pv/dock/protocolitemlayer.cpp index bde54209..4dfe4cfb 100644 --- a/DSView/pv/dock/protocolitemlayer.cpp +++ b/DSView/pv/dock/protocolitemlayer.cpp @@ -21,7 +21,6 @@ #include "protocolitemlayer.h" #include "../dsvdef.h" -#include #include #include "../config/appconfig.h" @@ -40,7 +39,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro _progress_label = new QLabel(parent); _set_button = new QPushButton(parent); _del_button = new QPushButton(parent); - _format_combox = new QComboBox(parent); + _format_combox = new DsComboBox(parent); QString iconPath = GetIconPath(); _del_button->setFlat(true); diff --git a/DSView/pv/dock/protocolitemlayer.h b/DSView/pv/dock/protocolitemlayer.h index 45901ef4..3591cb9e 100644 --- a/DSView/pv/dock/protocolitemlayer.h +++ b/DSView/pv/dock/protocolitemlayer.h @@ -23,10 +23,9 @@ #include #include -#include #include -#include #include +#include "../ui/dscombobox.h" class DecoderStatus; @@ -68,7 +67,7 @@ private: QLabel *_progress_label; QPushButton *_set_button; QPushButton *_del_button; - QComboBox *_format_combox; + DsComboBox *_format_combox; IProtocolItemLayerCallback *m_callback; QString _protocolName; bool m_bSetting; diff --git a/DSView/pv/dock/searchdock.cpp b/DSView/pv/dock/searchdock.cpp index bc3de15f..1d7cd1c3 100755 --- a/DSView/pv/dock/searchdock.cpp +++ b/DSView/pv/dock/searchdock.cpp @@ -261,7 +261,9 @@ void SearchDock::on_set() _search_value->setText(search_label); QFontMetrics fm = this->fontMetrics(); - _search_value->setFixedWidth(fm.width(search_label)+_search_button->width()+20); + //fm.width(search_label) + int tw = fm.boundingRect(search_label).width(); + _search_value->setFixedWidth(tw + _search_button->width()+20); if (new_pattern != _pattern) { _view.set_search_pos(_view.get_search_pos(), false); diff --git a/DSView/pv/dock/searchdock.h b/DSView/pv/dock/searchdock.h index 6e940bb3..d53c261e 100755 --- a/DSView/pv/dock/searchdock.h +++ b/DSView/pv/dock/searchdock.h @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include "../widgets/fakelineedit.h" +#include "../ui/dscombobox.h" namespace pv { diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/pv/dock/triggerdock.cpp index d90da9fd..1b869fe0 100755 --- a/DSView/pv/dock/triggerdock.cpp +++ b/DSView/pv/dock/triggerdock.cpp @@ -71,7 +71,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) : _stages_label = new QLabel(_widget); _stages_label->setDisabled(true); - stages_comboBox = new QComboBox(_widget); + stages_comboBox = new DsComboBox(_widget); for (int i = 1; i <= TriggerStages; i++) stages_comboBox->addItem(QString::number(i)); //stages_comboBox->setCurrentIndex(stages_comboBox->count() - 1); @@ -569,7 +569,7 @@ void TriggerDock::setup_adv_tab() 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); + DsComboBox *_logic_comboBox = new DsComboBox(_stage_tabWidget); _logic_comboBox->addItem(tr("Or")); _logic_comboBox->addItem(tr("And")); _logic_comboBox->setCurrentIndex(1); @@ -586,7 +586,7 @@ void TriggerDock::setup_adv_tab() _count_spinBox->setRange(1, INT32_MAX); _count_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons); _count_spinBox_list.push_back(_count_spinBox); - QComboBox *_inv0_comboBox = new QComboBox(_stage_tabWidget); + DsComboBox *_inv0_comboBox = new DsComboBox(_stage_tabWidget); _inv0_comboBox->addItem(tr("==")); _inv0_comboBox->addItem(tr("!=")); _inv0_comboBox_list.push_back(_inv0_comboBox); @@ -598,7 +598,7 @@ void TriggerDock::setup_adv_tab() _value1_lineEdit->setInputMask(mask); _value1_lineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); _value1_lineEdit_list.push_back(_value1_lineEdit); - QComboBox *_inv1_comboBox = new QComboBox(_stage_tabWidget); + DsComboBox *_inv1_comboBox = new DsComboBox(_stage_tabWidget); _inv1_comboBox->addItem(tr("==")); _inv1_comboBox->addItem(tr("!=")); _inv1_comboBox_list.push_back(_inv1_comboBox); @@ -734,7 +734,7 @@ void TriggerDock::setup_adv_tab() _serial_edge_lineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); _serial_data_label = new QLabel(_serial_groupBox); - _serial_data_comboBox = new QComboBox(_serial_groupBox); + _serial_data_comboBox = new DsComboBox(_serial_groupBox); for(int i = 0; i < _cur_ch_num; i++) _serial_data_comboBox->addItem(QString::number(i)); @@ -746,7 +746,7 @@ void TriggerDock::setup_adv_tab() _serial_value_lineEdit->setInputMask(mask); _serial_value_lineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - _serial_bits_comboBox = new QComboBox(_serial_groupBox); + _serial_bits_comboBox = new DsComboBox(_serial_groupBox); for(int i = 1; i <= 16; i++) _serial_bits_comboBox->addItem(QString::number(i)); diff --git a/DSView/pv/dock/triggerdock.h b/DSView/pv/dock/triggerdock.h index 336f5dc7..eef9cab3 100755 --- a/DSView/pv/dock/triggerdock.h +++ b/DSView/pv/dock/triggerdock.h @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -43,6 +42,8 @@ #include +#include "../ui/dscombobox.h" + namespace pv { class SigSession; @@ -108,20 +109,20 @@ private: QSlider *_position_slider; QLabel *_stages_label; - QComboBox *stages_comboBox; + DsComboBox *stages_comboBox; QTabWidget *_stage_tabWidget; QVector _stage_groupBox_list; QVector _mu_label_list; - QVector _logic_comboBox_list; + QVector _logic_comboBox_list; QVector _value0_lineEdit_list; QVector _value0_ext32_lineEdit_list; QVector _count_spinBox_list; - QVector _inv0_comboBox_list; + QVector _inv0_comboBox_list; QVector _value1_lineEdit_list; QVector _value1_ext32_lineEdit_list; - QVector _inv1_comboBox_list; + QVector _inv1_comboBox_list; QVector _contiguous_checkbox_list; QTabWidget *_adv_tabWidget; @@ -136,10 +137,10 @@ private: QLineEdit *_serial_edge_lineEdit; QLineEdit *_serial_edge_ext32_lineEdit; QLabel *_serial_data_label; - QComboBox *_serial_data_comboBox; + DsComboBox *_serial_data_comboBox; QLabel *_serial_value_label; QLineEdit *_serial_value_lineEdit; - QComboBox *_serial_bits_comboBox; + DsComboBox *_serial_bits_comboBox; QLabel *_serial_note_label; QLabel *_data_bits_label; diff --git a/DSView/pv/dsvdef.h b/DSView/pv/dsvdef.h index 9a5ef516..b2b26002 100644 --- a/DSView/pv/dsvdef.h +++ b/DSView/pv/dsvdef.h @@ -23,6 +23,7 @@ #pragma once #include "../config.h" +#include #ifdef DS_DEBUG_TRACE diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp old mode 100755 new mode 100644 index 173c1427..a48232f6 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -229,7 +228,15 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) return QFrame::eventFilter(object, event); } - if (!_bDraging && type == QEvent::MouseMove && (!(mouse_event->buttons() || Qt::NoButton))){ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + int x0 = (int)mouse_event->globalPosition().x(); + int y0 = (int)mouse_event->globalPosition().y(); +#else + int x0 = mouse_event->globalX(); + int y0 = mouse_event->globalY(); +#endif + + if (!_bDraging && type == QEvent::MouseMove && (!(mouse_event->buttons() | Qt::NoButton))){ if (object == _top_left) { _hit_border = TopLeft; setCursor(Qt::SizeFDiagCursor); @@ -267,55 +274,55 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) if (!_freezing) { switch (_hit_border) { case TopLeft: - newWidth = std::max(_dragStartGeometry.right() - mouse_event->globalX(), minimumWidth()); - newHeight = std::max(_dragStartGeometry.bottom() - mouse_event->globalY(), minimumHeight()); + newWidth = std::max(_dragStartGeometry.right() - x0, minimumWidth()); + newHeight = std::max(_dragStartGeometry.bottom() - y0, minimumHeight()); newLeft = geometry().left(); newTop = geometry().top(); if (newWidth > minimumWidth()) - newLeft = mouse_event->globalX(); + newLeft = x0; if (newHeight > minimumHeight()) - newTop = mouse_event->globalY(); + newTop = y0; 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()); + newWidth = std::max(_dragStartGeometry.right() - x0, minimumWidth()); + newHeight = std::max(y0 - _dragStartGeometry.top(), minimumHeight()); newLeft = geometry().left(); if (newWidth > minimumWidth()) - newLeft = mouse_event->globalX(); + newLeft = x0; 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()); + newWidth = std::max(x0 - _dragStartGeometry.left(), minimumWidth()); + newHeight = std::max(_dragStartGeometry.bottom() - y0, minimumHeight()); newTop = geometry().top(); if (newHeight > minimumHeight()) - newTop = mouse_event->globalY(); + newTop = y0; 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()); + newWidth = std::max(x0 - _dragStartGeometry.left(), minimumWidth()); + newHeight = std::max(y0 - _dragStartGeometry.top(), minimumHeight()); setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), newWidth, newHeight); saveWindowRegion(); break; case Left: - newWidth = _dragStartGeometry.right() - mouse_event->globalX(); + newWidth = _dragStartGeometry.right() - x0; if (newWidth > minimumWidth()){ - setGeometry(mouse_event->globalX(), _dragStartGeometry.top(), newWidth, height()); + setGeometry(x0, _dragStartGeometry.top(), newWidth, height()); saveWindowRegion(); } break; case Right: - newWidth = mouse_event->globalX() - _dragStartGeometry.left(); + newWidth = x0 - _dragStartGeometry.left(); if (newWidth > minimumWidth()){ setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), newWidth, height()); saveWindowRegion(); @@ -323,15 +330,15 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) break; case Top: - newHeight = _dragStartGeometry.bottom() - mouse_event->globalY(); + newHeight = _dragStartGeometry.bottom() - y0; if (newHeight > minimumHeight()){ - setGeometry(_dragStartGeometry.left(), mouse_event->globalY(),width(), newHeight); + setGeometry(_dragStartGeometry.left(), y0,width(), newHeight); saveWindowRegion(); } break; case Bottom: - newHeight = mouse_event->globalY() - _dragStartGeometry.top(); + newHeight = y0 - _dragStartGeometry.top(); if (newHeight > minimumHeight()){ setGeometry(_dragStartGeometry.left(), _dragStartGeometry.top(), width(), newHeight); saveWindowRegion(); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp old mode 100755 new mode 100644 index 0869e39b..9f171525 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -39,6 +39,11 @@ #include #include #include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#endif #include "mainwindow.h" @@ -867,7 +872,14 @@ void MainWindow::on_screenShot() { AppConfig &app = AppConfig::Instance(); QString default_name = app._userHistory.screenShotPath + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss"); - QPixmap pixmap = QPixmap::grabWindow(winId()); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QScreen *scr = QGuiApplication::primaryScreen(); + QPixmap pixmap = scr->grabWindow(winId()); +#else + QPixmap pixmap = QPixmap::grabWindow(winId()); +#endif + QString format = "png"; QString fileName = QFileDialog::getSaveFileName( diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index cf916b04..87647d9c 100755 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -23,6 +23,7 @@ #include #include +#include #include diff --git a/DSView/pv/prop/enum.cpp b/DSView/pv/prop/enum.cpp index d5bd8665..e70f1925 100755 --- a/DSView/pv/prop/enum.cpp +++ b/DSView/pv/prop/enum.cpp @@ -22,10 +22,10 @@ #include -#include #include #include "enum.h" +#include "../ui/dscombobox.h" using namespace boost; using namespace std; @@ -62,7 +62,7 @@ QWidget* Enum::get_widget(QWidget *parent, bool auto_commit) return NULL; } - _selector = new QComboBox(parent); + _selector = new DsComboBox(parent); for (unsigned int i = 0; i < _values.size(); i++) { const pair &v = _values[i]; _selector->addItem(v.second, QVariant::fromValue((void*)v.first)); diff --git a/DSView/pv/prop/enum.h b/DSView/pv/prop/enum.h index 6b1214cd..41606271 100755 --- a/DSView/pv/prop/enum.h +++ b/DSView/pv/prop/enum.h @@ -28,7 +28,7 @@ #include "property.h" -class QComboBox; +class DsComboBox; namespace pv { namespace prop { @@ -53,7 +53,7 @@ private slots: private: const std::vector< std::pair > _values; - QComboBox *_selector; + DsComboBox *_selector; }; } // prop diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 50ceebe8..49b84f8b 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -79,9 +79,9 @@ SamplingBar::SamplingBar(SigSession *session, QWidget *parent) : _mode_button.setPopupMode(QToolButton::InstantPopup); - _device_selector.setSizeAdjustPolicy(QComboBox::AdjustToContents); - _sample_rate.setSizeAdjustPolicy(QComboBox::AdjustToContents); - _sample_count.setSizeAdjustPolicy(QComboBox::AdjustToContents); + _device_selector.setSizeAdjustPolicy(DsComboBox::AdjustToContents); + _sample_rate.setSizeAdjustPolicy(DsComboBox::AdjustToContents); + _sample_count.setSizeAdjustPolicy(DsComboBox::AdjustToContents); _device_selector.setMaximumWidth(ComboBoxMaxWidth); //_run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index 3459bb93..81ca3c8c 100755 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -28,11 +28,11 @@ #include #include -#include #include #include #include #include +#include "../ui/dscombobox.h" struct st_dev_inst; class QAction; @@ -134,13 +134,13 @@ namespace pv bool _sampling; QToolButton _device_type; - QComboBox _device_selector; + DsComboBox _device_selector; std::map _device_selector_map; bool _updating_device_selector; QToolButton _configure_button; - QComboBox _sample_count; - QComboBox _sample_rate; + DsComboBox _sample_count; + DsComboBox _sample_rate; bool _updating_sample_rate; bool _updating_sample_count; diff --git a/DSView/pv/ui/dscombobox.cpp b/DSView/pv/ui/dscombobox.cpp new file mode 100644 index 00000000..f405b6b9 --- /dev/null +++ b/DSView/pv/ui/dscombobox.cpp @@ -0,0 +1,72 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2012 Joel Holdsworth + * Copyright (C) 2013 DreamSourceLab + * + * 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 "dscombobox.h" +#include +#include +#include "../config/appconfig.h" + +DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent) +{ + _contentWidth = 0; + QComboBox::setSizeAdjustPolicy(QComboBox::AdjustToContents); +} + + void DsComboBox::addItem(const QString &atext, const QVariant &auserData) + { + QComboBox::addItem(atext, auserData); + +#ifdef Q_OS_DARWIN + if (!atext.isEmpty()){ + QFontMetrics fm = this->fontMetrics(); + int w = fm.boundingRect(atext).width(); + if (w > _contentWidth){ + _contentWidth = w; + this->setStyleSheet("QAbstractItemView{min-width:" + QString::number(w + 30) + "px;}"); + } + } +#endif + } + + void DsComboBox::showPopup() + { + QComboBox::showPopup(); + +#ifdef Q_OS_DARWIN + + QWidget *popup = this->findChild(); + auto rc = popup->geometry(); + int x = rc.left() + 6; + int y = rc.top(); + int w = rc.right() - rc.left(); + int h = rc.bottom() - rc.top() + 15; + popup->setGeometry(x, y, w, h); + + if (AppConfig::Instance()._frameOptions.style == "dark"){ + popup->setStyleSheet("background-color:#262626;"); + } + else{ + popup->setStyleSheet("background-color:#white;"); + } +#endif + } diff --git a/DSView/pv/ui/dscombobox.h b/DSView/pv/ui/dscombobox.h new file mode 100644 index 00000000..c8d1230e --- /dev/null +++ b/DSView/pv/ui/dscombobox.h @@ -0,0 +1,46 @@ + +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2012 Joel Holdsworth + * Copyright (C) 2013 DreamSourceLab + * + * 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 + */ + + +#ifndef DSCOMBOBOX_H +#define DSCOMBOBOX_H + +#include + +class DsComboBox : public QComboBox +{ + Q_OBJECT + +public: + explicit DsComboBox(QWidget *parent = nullptr); + + void addItem(const QString &atext, const QVariant &userData = QVariant()); + +protected: + void showPopup(); + +private: + int _contentWidth; +}; + +#endif // DSCOMBOBOX_H diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 1de94a9b..aea46fe0 100755 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include "../view/cursor.h" #include "../toolbars/titlebar.h" #include "../dsvdef.h" +#include "../ui/dscombobox.h" using namespace boost; using namespace std; @@ -418,8 +418,8 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) } //Add region combobox - _start_comboBox = new QComboBox(parent); - _end_comboBox = new QComboBox(parent); + _start_comboBox = new DsComboBox(parent); + _end_comboBox = new DsComboBox(parent); _start_comboBox->addItem(RegionStart); _end_comboBox->addItem(RegionEnd); @@ -726,7 +726,7 @@ void DecodeTrace::create_decoder_form( for(l = decoder->channels; l; l = l->next) { const struct srd_channel *const pdch = (struct srd_channel *)l->data; - QComboBox *const combo = create_probe_selector(parent, dec, pdch); + DsComboBox *const combo = create_probe_selector(parent, dec, pdch); decoder_form->addRow(tr("%1 (%2) *") .arg(QString::fromUtf8(pdch->name)) @@ -742,7 +742,7 @@ void DecodeTrace::create_decoder_form( for(l = decoder->opt_channels; l; l = l->next) { const struct srd_channel *const pdch = (struct srd_channel *)l->data; - QComboBox *const combo = create_probe_selector(parent, dec, pdch); + DsComboBox *const combo = create_probe_selector(parent, dec, pdch); decoder_form->addRow(tr("%1 (%2)") .arg(QString::fromUtf8(pdch->name)) @@ -770,7 +770,7 @@ void DecodeTrace::create_decoder_form( connect(group, SIGNAL(del_stack(data::decode::Decoder*)), this, SLOT(on_del_stack(data::decode::Decoder*))); } -QComboBox* DecodeTrace::create_probe_selector( +DsComboBox* DecodeTrace::create_probe_selector( QWidget *parent, const data::decode::Decoder *dec, const srd_channel *const pdch) { @@ -783,7 +783,7 @@ QComboBox* DecodeTrace::create_probe_selector( data::decode::Decoder *_dec = const_cast(dec); auto probe_iter = _dec->channels().find(pdch); - QComboBox *selector = new QComboBox(parent); + DsComboBox *selector = new DsComboBox(parent); selector->addItem("-", QVariant::fromValue(-1)); diff --git a/DSView/pv/view/decodetrace.h b/DSView/pv/view/decodetrace.h index 5b361e5c..4f70df85 100755 --- a/DSView/pv/view/decodetrace.h +++ b/DSView/pv/view/decodetrace.h @@ -36,7 +36,7 @@ struct srd_channel; struct srd_decoder; -class QComboBox; +class DsComboBox; namespace pv { @@ -66,7 +66,7 @@ class DecodeTrace : public Trace private: struct ProbeSelector { - const QComboBox *_combo; + const DsComboBox *_combo; const pv::data::decode::Decoder *_decoder; const srd_channel *_pdch; }; @@ -180,7 +180,7 @@ private: pv::data::decode::Decoder *dec, QWidget *parent, QFormLayout *form); - QComboBox* create_probe_selector(QWidget *parent, + DsComboBox* create_probe_selector(QWidget *parent, const pv::data::decode::Decoder *dec, const srd_channel *const pdch); @@ -219,8 +219,8 @@ private: int _start_count; int _end_count; - QComboBox *_start_comboBox; - QComboBox *_end_comboBox; + DsComboBox *_start_comboBox; + DsComboBox *_end_comboBox; QFormLayout *_pub_input_layer; int _progress; diff --git a/DSView/pv/view/spectrumtrace.cpp b/DSView/pv/view/spectrumtrace.cpp index 8e6bb11e..3527a013 100755 --- a/DSView/pv/view/spectrumtrace.cpp +++ b/DSView/pv/view/spectrumtrace.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "spectrumtrace.h" #include "../sigsession.h" @@ -208,12 +209,17 @@ QString SpectrumTrace::format_freq(double freq, unsigned precision) const int prefix = floor((order - FirstSIPrefixPower)/ 3.0f); const double divider = pow(10.0, max(prefix * 3.0 + FirstSIPrefixPower, 0.0)); - QString s; - QTextStream ts(&s); - ts.setRealNumberPrecision(precision); - ts << fixed << freq / divider << - FreqPrefixes[prefix] << "Hz"; - return s; + //QString s; + //QTextStream ts(&s); + //ts.setRealNumberPrecision(precision); + //ts << fixed << freq / divider << FreqPrefixes[prefix] << "Hz"; + //return s; + char buf[20] = {0}; + char format[10] = {0}; + sprintf(format, "%%.%df%%s", precision); + QString prev = FreqPrefixes[prefix] + "Hz"; + sprintf(buf, format, freq / divider, prev.toLatin1().data()); + return QString(buf); } } diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index ff65b2fd..6bbaa6da 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -1597,7 +1597,9 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back) QString delta_text = _view.get_index_delta(_edge_start, _edge_end) + "/" + QString::number(delta); QFontMetrics fm = this->fontMetrics(); - const int rectW = fm.width(delta_text) + 60; + // const int rectW = fm.width(delta_text) + 60; + const int rectW = fm.boundingRect(delta_text).width() + 60; + const int rectH = fm.height() + 10; //const int rectY = (_cur_aftY >= _cur_preY) ? _cur_preY_top : _cur_preY_bottom; //const int rectX = (_cur_aftX >= _cur_preX) ? _cur_preX : _cur_preX - rectW; diff --git a/DSView/pv/view/viewstatus.cpp b/DSView/pv/view/viewstatus.cpp index 635c02d4..ccd3872a 100755 --- a/DSView/pv/view/viewstatus.cpp +++ b/DSView/pv/view/viewstatus.cpp @@ -54,7 +54,12 @@ ViewStatus::ViewStatus(SigSession *session, View &parent) : void ViewStatus::paintEvent(QPaintEvent *) { QStyleOption opt; - opt.init(this); + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + opt.initFrom(this); + #else + opt.init(this); + #endif + QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); diff --git a/libsigrok4DSL/config.h b/libsigrok4DSL/config.h new file mode 100644 index 00000000..1c40c8d3 --- /dev/null +++ b/libsigrok4DSL/config.h @@ -0,0 +1,192 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +#ifndef SR_CONFIG_H +#define SR_CONFIG_H /* To stop multiple inclusions. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* DreamSourceLab hardware driver support */ +#define HAVE_DSL_DEVICE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Demo driver support */ +#define HAVE_LA_DEMO 1 + +/* Specifies whether we have libserialport. */ +/* #undef HAVE_LIBSERIALPORT */ + +/* Specifies whether we have a libusb.h header. */ +#define HAVE_LIBUSB_1_0 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strcspn' function. */ +#define HAVE_STRCSPN 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libsigrok4DSL" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "support@dreamsourcelab.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libsigrok4DSL" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libsigrok4DSL 0.2.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libsigrok4DSL" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.dreamsourcelab.com" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.2.0" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.2.0" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int16_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +/* #undef int8_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ + +#endif /* SR_CONFIG_H */ diff --git a/libsigrok4DSL/output/gnuplot.c b/libsigrok4DSL/output/gnuplot.c index 92b01324..1644fceb 100755 --- a/libsigrok4DSL/output/gnuplot.c +++ b/libsigrok4DSL/output/gnuplot.c @@ -25,7 +25,7 @@ #include #include #include -#include "config.h" /* Needed for PACKAGE_STRING and others. */ +#include "../config.h" /* Needed for PACKAGE_STRING and others. */ #define LOG_PREFIX "output/gnuplot" diff --git a/qtpro/DSView.pro b/qtpro/DSView.pro index 5fd987c2..5d30bed6 100644 --- a/qtpro/DSView.pro +++ b/qtpro/DSView.pro @@ -163,6 +163,7 @@ SOURCES += \ ../DSView/pv/ZipMaker.cpp \ ../DSView/pv/data/decode/AnnotationResTable.cpp \ ../DSView/pv/ui/msgbox.cpp \ + ../DSView/pv/ui/dscombobox.cpp \ ../DSView/pv/dock/protocolitemlayer.cpp \ ../DSView/pv/config/appconfig.cpp \ ../DSView/pv/dsvdef.cpp \ @@ -262,6 +263,7 @@ HEADERS += \ ../DSView/pv/ZipMaker.h \ ../DSView/pv/data/decode/AnnotationResTable.h \ ../DSView/pv/ui/msgbox.h \ + ../DSView/pv/ui/dscombobox.h \ ../DSView/pv/dock/protocolitemlayer.h \ ../DSView/pv/config/appconfig.h \ ../DSView/pv/dsvdef.h \ diff --git a/qtpro/DSView.pro.user b/qtpro/DSView.pro.user index 8871a8fc..c4f4a0b2 100644 --- a/qtpro/DSView.pro.user +++ b/qtpro/DSView.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId