diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index d4fff5ea..2ffb5fbe 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -74,8 +74,8 @@ MainFrame::MainFrame() setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); #endif - setMinimumHeight(minHeight); - setMinimumWidth(minWidth); + setMinimumWidth(MainWindow::Min_Width); + setMinimumHeight(MainWindow::Min_Height); // Set the window icon QIcon icon; diff --git a/DSView/pv/mainframe.h b/DSView/pv/mainframe.h index fe699185..3f8c3dbd 100644 --- a/DSView/pv/mainframe.h +++ b/DSView/pv/mainframe.h @@ -49,9 +49,6 @@ class DSDialog; class MainFrame : public QFrame { Q_OBJECT -public: - static const int minWidth = 800; - static const int minHeight = 520; public: static const int Margin = 5; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 425d8f93..0dd6dfc8 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -107,6 +107,7 @@ namespace pv : QMainWindow(parent) { _msg = NULL; + _frame = parent; _session = AppControl::Instance()->GetSession(); _session->set_callback(this); @@ -1765,6 +1766,7 @@ namespace pv } } } + calc_min_height(); break; case DSV_MSG_DEVICE_OPTIONS_UPDATED: @@ -1813,6 +1815,8 @@ namespace pv } } } + + calc_min_height(); break; case DSV_MSG_NEW_USB_DEVICE: @@ -1923,7 +1927,9 @@ namespace pv } } } + calc_min_height(); break; + case DSV_MSG_BEGIN_DEVICE_OPTIONS: if(_device_agent->is_demo()) { @@ -1933,8 +1939,28 @@ namespace pv _pattern_mode = g_variant_get_string(gvar,NULL); g_variant_unref(gvar); } - } + } } } + void MainWindow::calc_min_height() + { + if (_frame != NULL) + { + if (_device_agent->get_work_mode() == LOGIC) + { + int ch_num = _session->get_ch_num(-1); + int win_height = Base_Height + Per_Chan_Height * ch_num; + + if (win_height < Min_Height) + _frame->setMinimumHeight(win_height); + else + _frame->setMinimumHeight(Min_Height); + } + else{ + _frame->setMinimumHeight(Min_Height); + } + } + } + } // namespace pv diff --git a/DSView/pv/mainwindow.h b/DSView/pv/mainwindow.h index 15affc4c..be8780cf 100644 --- a/DSView/pv/mainwindow.h +++ b/DSView/pv/mainwindow.h @@ -81,6 +81,12 @@ class MainWindow : { Q_OBJECT +public: + static const int Min_Width = 800; + static const int Min_Height = 520; + static const int Base_Height = 150; + static const int Per_Chan_Height = 35; + public: explicit MainWindow(QWidget *parent = 0); @@ -139,6 +145,7 @@ private: void load_device_config(); QJsonDocument get_session_json_from_file(QString file); QJsonArray get_decoder_json_from_file(QString file); + void calc_min_height(); private: //ISessionCallback @@ -215,6 +222,7 @@ private: high_resolution_clock::time_point _last_key_press_time; bool _is_save_confirm_msg; std::string _pattern_mode; + QWidget *_frame; int _key_value; bool _key_vaild;