Hi,

Attach is a revised, rebased retransmit of a patch for pulseview.

Adding improved usability for "Connect to Device" dialog in pulseview:

Add pseudo "autodetect" driver to the top of the driver drop-down list.
This will present the user with an overview of all autodetected devices (those that can be detected).

/Uffe

>From 171f8f40b38e5144eea6e6572c0373bc2a12b28b Mon Sep 17 00:00:00 2001
From: Uffe Jakobsen <[email protected]>
Date: Sun, 28 Dec 2014 02:47:57 +0100
Subject: [PATCH] Improved usability for "Connect to Device" dialog in
 pulseview:

Add pseudo "autodetect" driver to the top of the driver drop-down list.
This will present the user with an overview of all autodetected devices (those that can be detected).
---
 pv/dialogs/connect.cpp | 72 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 49 insertions(+), 23 deletions(-)

diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp
index fcb2103..d63f5b4 100644
--- a/pv/dialogs/connect.cpp
+++ b/pv/dialogs/connect.cpp
@@ -2,6 +2,7 @@
  * This file is part of the PulseView project.
  *
  * Copyright (C) 2012-2013 Joel Holdsworth <[email protected]>
+ * Copyright (C) 2014 Uffe Jakobsen <[email protected]>
  *
  * 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
@@ -81,6 +82,8 @@ Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) :
 	layout_.addWidget(&scan_button_);
 	layout_.addWidget(&device_list_);
 	layout_.addWidget(&button_box_);
+
+	device_selected(0);
 }
 
 shared_ptr<HardwareDevice> Connect::get_selected_device() const
@@ -94,6 +97,8 @@ shared_ptr<HardwareDevice> Connect::get_selected_device() const
 
 void Connect::populate_drivers()
 {
+	drivers_.addItem(QString("Autodetected devices"), qVariantFromValue(NULL));
+
 	for (auto entry : device_manager_.context()->drivers()) {
 		auto name = entry.first;
 		auto driver = entry.second;
@@ -144,16 +149,27 @@ void Connect::scan_pressed()
 {
 	device_list_.clear();
 
-	const int index = drivers_.currentIndex();
-	if (index == -1)
+	const int index_cur = drivers_.currentIndex();
+	if (index_cur == -1)
 		return;
 
-	shared_ptr<Driver> driver =
-		drivers_.itemData(index).value<shared_ptr<Driver>>();
+	int index, index_max;
+	// Using pseudo autodetect driver (index 0): setup indexes for real driver scan
+	if (index_cur == 0) {
+		index = 1;
+		index_max = drivers_.count()-1;
+	} else {
+		index = index_max = index_cur;
+	}
+
+	for(; index <= index_max; index++) {
+
+		shared_ptr<Driver> driver =
+			drivers_.itemData(index).value<shared_ptr<Driver>>();
 
-	assert(driver);
+		assert(driver);
 
-	map<const ConfigKey *, VariantBase> drvopts;
+		map<const ConfigKey *, VariantBase> drvopts;
 
 	if (serial_devices_.isVisible()) {
 		QString serial;
@@ -167,21 +183,26 @@ void Connect::scan_pressed()
 			serial.toUtf8().constData());
 	}
 
-	list< shared_ptr<HardwareDevice> > devices =
-		device_manager_.driver_scan(driver, drvopts);
+		list< shared_ptr<HardwareDevice> > devices =
+			device_manager_.driver_scan(driver, drvopts);
 
-	for (shared_ptr<HardwareDevice> device : devices)
-	{
-		assert(device);
+		for (shared_ptr<HardwareDevice> device : devices)
+		{
+			assert(device);
 
-		QString text = QString::fromStdString(
-			device_manager_.get_display_name(device));
-		text += QString(" with %1 channels").arg(device->channels().size());
+			QString text = QString::fromStdString(
+				device_manager_.get_display_name(device));
+			text += QString(" with %1 channels").arg(device->channels().size());
 
-		QListWidgetItem *const item = new QListWidgetItem(text,
-			&device_list_);
-		item->setData(Qt::UserRole, qVariantFromValue(device));
-		device_list_.addItem(item);
+			// If autodetecting - show originating driver short name
+			if (index_cur == 0)
+				text += QString(" (%1)").arg(driver->name().c_str());
+
+			QListWidgetItem *const item = new QListWidgetItem(text,
+				&device_list_);
+			item->setData(Qt::UserRole, qVariantFromValue(device));
+			device_list_.addItem(item);
+		}
 	}
 
 	device_list_.setCurrentRow(0);
@@ -190,13 +211,18 @@ void Connect::scan_pressed()
 
 void Connect::device_selected(int index)
 {
-	shared_ptr<Driver> driver =
-		drivers_.itemData(index).value<shared_ptr<Driver>>();
-
 	unset_connection();
 
-	if (driver->config_check(ConfigKey::SERIALCOMM, ConfigKey::SCAN_OPTIONS))
-		set_serial_connection(driver);
+	// avoid pseudo autodetect driver (index 0)
+	if (index >= 1) {
+		shared_ptr<Driver> driver =
+			drivers_.itemData(index).value<shared_ptr<Driver>>();
+
+		if (driver->config_check(ConfigKey::SERIALCOMM, ConfigKey::SCAN_OPTIONS))
+				set_serial_connection();
+	}
+
+	scan_pressed();
 }
 
 } // namespace dialogs
-- 
2.2.2

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to