[libcamera-devel,2/2] qcam: main_window: Fix combo-box entry selection on startup

Message ID 20200430141433.6776-3-email@uajain.com
State Superseded
Headers show
Series
  • Fix combo-box entry selection on startup
Related show

Commit Message

Umang Jain April 30, 2020, 2:15 p.m. UTC
When one of the camera is selected and opened from the
"Select Cameras" items list, the entry of the combo-box
in the main-window doesn't update its item index to reflect
the camera which was earlier selected. Fix that.

Signed-off-by: Umang Jain <email@uajain.com>
---
 src/qcam/main_window.cpp | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kieran Bingham April 30, 2020, 3:07 p.m. UTC | #1
Hi Umang,

On 30/04/2020 15:15, Umang Jain wrote:
> When one of the camera is selected and opened from the
> "Select Cameras" items list, the entry of the combo-box
> in the main-window doesn't update its item index to reflect
> the camera which was earlier selected. Fix that.

Ohh - nice catch - thanks, tested with and without this patch and I see
what you mean!

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 
> Signed-off-by: Umang Jain <email@uajain.com>
> ---
>  src/qcam/main_window.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 344b7ec..fa05515 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -249,6 +249,10 @@ int MainWindow::openCamera()
>  		return -EBUSY;
>  	}
>  
> +	/* Set the combo-box with the current selected Camera */
> +	int camIndex = cameraCombo_->findText(QString::fromStdString(cameraName));
> +	cameraCombo_->setCurrentIndex(camIndex);
> +
>  	return 0;
>  }
>  
>
Laurent Pinchart April 30, 2020, 3:36 p.m. UTC | #2
Hi Umang,

On Thu, Apr 30, 2020 at 04:07:41PM +0100, Kieran Bingham wrote:
> On 30/04/2020 15:15, Umang Jain wrote:
> > When one of the camera is selected and opened from the
> > "Select Cameras" items list, the entry of the combo-box
> > in the main-window doesn't update its item index to reflect
> > the camera which was earlier selected. Fix that.
> 
> Ohh - nice catch - thanks, tested with and without this patch and I see
> what you mean!
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > Signed-off-by: Umang Jain <email@uajain.com>
> > ---
> >  src/qcam/main_window.cpp | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> > index 344b7ec..fa05515 100644
> > --- a/src/qcam/main_window.cpp
> > +++ b/src/qcam/main_window.cpp
> > @@ -249,6 +249,10 @@ int MainWindow::openCamera()
> >  		return -EBUSY;
> >  	}
> >  
> > +	/* Set the combo-box with the current selected Camera */
> > +	int camIndex = cameraCombo_->findText(QString::fromStdString(cameraName));
> > +	cameraCombo_->setCurrentIndex(camIndex);

How about

	cameraCombo_->setCurrentText(QString::fromStdString(cameraName));

?

With that change, or without it if it doesn't work,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > +
> >  	return 0;
> >  }
> >
Umang Jain April 30, 2020, 3:46 p.m. UTC | #3
Hi Laurent,

On Thu, Apr 30, 2020 at 18:36, Laurent Pinchart 
<laurent.pinchart@ideasonboard.com> wrote:
> Hi Umang,
> 
> On Thu, Apr 30, 2020 at 04:07:41PM +0100, Kieran Bingham wrote:
>>  On 30/04/2020 15:15, Umang Jain wrote:
>>  > When one of the camera is selected and opened from the
>>  > "Select Cameras" items list, the entry of the combo-box
>>  > in the main-window doesn't update its item index to reflect
>>  > the camera which was earlier selected. Fix that.
>> 
>>  Ohh - nice catch - thanks, tested with and without this patch and I 
>> see
>>  what you mean!
>> 
>>  Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com 
>> <mailto:kieran.bingham@ideasonboard.com>>
>>  Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com 
>> <mailto:kieran.bingham@ideasonboard.com>>
>> 
>>  > Signed-off-by: Umang Jain <email@uajain.com 
>> <mailto:email@uajain.com>>
>>  > ---
>>  >  src/qcam/main_window.cpp | 4 ++++
>>  >  1 file changed, 4 insertions(+)
>>  >
>>  > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
>>  > index 344b7ec..fa05515 100644
>>  > --- a/src/qcam/main_window.cpp
>>  > +++ b/src/qcam/main_window.cpp
>>  > @@ -249,6 +249,10 @@ int MainWindow::openCamera()
>>  >  		return -EBUSY;
>>  >  	}
>>  >
>>  > +	/* Set the combo-box with the current selected Camera */
>>  > +	int camIndex = 
>> cameraCombo_->findText(QString::fromStdString(cameraName));
>>  > +	cameraCombo_->setCurrentIndex(camIndex);
> 
> How about
> 
> 	cameraCombo_->setCurrentText(QString::fromStdString(cameraName));
> 
> ?

Oh yes, that's quite good. From documentation, it seems setCurrentText()
will do, what is being done in this patch much explicitly.

 > The setter setCurrentText() simply calls setEditText() if the combo 
box is editable.
     Otherwise, if there is a matching text in the list, currentIndex 
is set to the corresponding index.

Thanks.
> 
> With that change, or without it if it doesn't work,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com 
> <mailto:laurent.pinchart@ideasonboard.com>>
> 
>>  > +
>>  >  	return 0;
>>  >  }
>>  >
> 
> --
> Regards,
> 
> Laurent Pinchart

Patch

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 344b7ec..fa05515 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -249,6 +249,10 @@  int MainWindow::openCamera()
 		return -EBUSY;
 	}
 
+	/* Set the combo-box with the current selected Camera */
+	int camIndex = cameraCombo_->findText(QString::fromStdString(cameraName));
+	cameraCombo_->setCurrentIndex(camIndex);
+
 	return 0;
 }