Connect dialog: Let the device list occupy only the minimum space needed
[pulseview.git] / pv / dialogs / connect.cpp
index 43112ae5537f9e99cfeef0edc31c93aed13bd6de..29d5b0269a05d23777d1a78cccdb38067a2d045b 100644 (file)
  * 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
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <cassert>
 
 #include <libsigrokcxx/libsigrokcxx.hpp>
 
-#include <QLabel>
 #include <QGroupBox>
+#include <QLabel>
 #include <QRadioButton>
 
 #include "connect.hpp"
@@ -42,7 +41,6 @@ using Glib::VariantBase;
 
 using sigrok::ConfigKey;
 using sigrok::Driver;
-using sigrok::Error;
 
 using pv::devices::HardwareDevice;
 
@@ -104,6 +102,9 @@ Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) :
        tcp_config_layout->setContentsMargins(0, 0, 0, 0);
        tcp_config_->setEnabled(false);
 
+       // Let the device list occupy only the minimum space needed
+       device_list_.setMaximumHeight(device_list_.minimumSizeHint().height());
+
        QVBoxLayout *vbox_if = new QVBoxLayout;
        vbox_if->addWidget(radiobtn_usb);
        vbox_if->addWidget(radiobtn_serial);
@@ -245,13 +246,10 @@ void Connect::scan_pressed()
        for (shared_ptr<HardwareDevice> device : devices) {
                assert(device);
 
-               QString text = QString::fromStdString(
-                       device->display_name(device_manager_));
-               text += QString(" with %1 channels").arg(
-                       device->device()->channels().size());
+               QString text = QString::fromStdString(device->display_name(device_manager_));
+               text += QString(" with %1 channels").arg(device->device()->channels().size());
 
-               QListWidgetItem *const item = new QListWidgetItem(text,
-                       &device_list_);
+               QListWidgetItem *const item = new QListWidgetItem(text, &device_list_);
                item->setData(Qt::UserRole, qVariantFromValue(device));
                device_list_.addItem(item);
        }