| 859 | } |
| 860 | |
| 861 | void DeviceOptions::try_resize_scroll() |
| 862 | { |
| 863 | this->update_font(); |
| 864 | |
| 865 | // content area height |
| 866 | int contentHeight = _groupHeight1 + _groupHeight2 + 20; // +space |
| 867 | //dialog height |
| 868 | int dlgHeight = contentHeight + 100; // +bottom buttton |
| 869 | |
| 870 | #ifdef Q_OS_DARWIN |
| 871 | dlgHeight += 20; |
| 872 | #endif |
| 873 | |
| 874 | float sk = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96; |
| 875 | |
| 876 | int srcHeight = 600; |
| 877 | int w = _width; |
| 878 | |
| 879 | |
| 880 | #ifdef _WIN32 |
| 881 | QFont font = this->font(); |
| 882 | font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); |
| 883 | QFontMetrics fm(font); |
| 884 | |
| 885 | auto labels = this->findChildren<QLabel*>(); |
| 886 | int max_label_width = 0; |
| 887 | for(auto o : labels) |
| 888 | { |
| 889 | QRect rc = fm.boundingRect(o->text()); |
| 890 | QSize size(rc.width() + 15, rc.height()); |
| 891 | o->setFixedSize(size); |
| 892 | |
| 893 | if (size.width() > max_label_width){ |
| 894 | max_label_width = size.width(); |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | if (_device_agent->get_work_mode() == LOGIC |
| 899 | && _device_agent->is_demo()){ |
| 900 | _dynamic_panel->setFixedWidth(max_label_width + 250); |
| 901 | } |
| 902 | #endif |
| 903 | |
| 904 | if (w == 0) |
| 905 | { |
| 906 | w = this->sizeHint().width(); |
| 907 | _width = w; |
| 908 | } |
| 909 | |
| 910 | QScrollArea *scroll = _scroll; |
| 911 | if (scroll == NULL) |
| 912 | { |
| 913 | scroll = new QScrollArea(_scroll_panel); |
| 914 | scroll->setWidget(_container_panel); |
| 915 | scroll->setStyleSheet("QScrollArea{border:none;}"); |
| 916 | scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 917 | _scroll = scroll; |
| 918 | } |
nothing calls this directly
no test coverage detected