[libcamera-devel,3/4] qcam: Add the version string to the title

Message ID 20190702114841.19101-3-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/4] Documentation: Make the project brief more expressive
Related show

Commit Message

Kieran Bingham July 2, 2019, 11:48 a.m. UTC
Provide the version string reported by the libcamera library on the qcam
test utility.

This helps confirm the exact version of the library that is being used
while testing.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/qcam/main_window.cpp | 8 ++++++++
 src/qcam/main_window.h   | 2 ++
 2 files changed, 10 insertions(+)

Comments

Laurent Pinchart July 2, 2019, 2:26 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Tue, Jul 02, 2019 at 12:48:40PM +0100, Kieran Bingham wrote:
> Provide the version string reported by the libcamera library on the qcam
> test utility.
> 
> This helps confirm the exact version of the library that is being used
> while testing.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/qcam/main_window.cpp | 8 ++++++++
>  src/qcam/main_window.h   | 2 ++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 16b123132dd9..61d7aa9469f0 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -14,6 +14,7 @@
>  #include <QTimer>
>  
>  #include <libcamera/camera_manager.h>
> +#include <libcamera/version.h>
>  
>  #include "main_window.h"
>  #include "viewfinder.h"
> @@ -25,6 +26,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
>  {
>  	int ret;
>  
> +	setWindowTitle();

Just inline the call here directly. There's also no need for the
QMainWindow:: prefix.

	QString version = QString::fromStdString(libcamera::version));
	setWindowTitle("QCam - " + version);

>  	viewfinder_ = new ViewFinder(this);
>  	setCentralWidget(viewfinder_);
>  	viewfinder_->setFixedSize(500, 500);
> @@ -50,6 +52,12 @@ MainWindow::~MainWindow()
>  	CameraManager::instance()->stop();
>  }
>  
> +void MainWindow::setWindowTitle()
> +{
> +	QMainWindow::setWindowTitle("QCam : "
> +		+ QString::fromStdString(libcamera::version.toString()));
> +}
> +
>  int MainWindow::openCamera()
>  {
>  	CameraManager *cm = CameraManager::instance();
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index fe565cbcb460..b30a86768efc 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -33,6 +33,8 @@ public:
>  	~MainWindow();
>  
>  private:
> +	void setWindowTitle();
> +
>  	int openCamera();
>  
>  	int startCapture();
Kieran Bingham July 3, 2019, 10:48 a.m. UTC | #2
Hi Laurent,

On 02/07/2019 15:26, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Tue, Jul 02, 2019 at 12:48:40PM +0100, Kieran Bingham wrote:
>> Provide the version string reported by the libcamera library on the qcam
>> test utility.
>>
>> This helps confirm the exact version of the library that is being used
>> while testing.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  src/qcam/main_window.cpp | 8 ++++++++
>>  src/qcam/main_window.h   | 2 ++
>>  2 files changed, 10 insertions(+)
>>
>> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
>> index 16b123132dd9..61d7aa9469f0 100644
>> --- a/src/qcam/main_window.cpp
>> +++ b/src/qcam/main_window.cpp
>> @@ -14,6 +14,7 @@
>>  #include <QTimer>
>>  
>>  #include <libcamera/camera_manager.h>
>> +#include <libcamera/version.h>
>>  
>>  #include "main_window.h"
>>  #include "viewfinder.h"
>> @@ -25,6 +26,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
>>  {
>>  	int ret;
>>  
>> +	setWindowTitle();
> 
> Just inline the call here directly. There's also no need for the
> QMainWindow:: prefix.
> 
> 	QString version = QString::fromStdString(libcamera::version));
> 	setWindowTitle("QCam - " + version);


Yes, this is an artifact of me swapping the order of the patches. I
originally had the FPS calculation first, so I already had the function
call.

In fact, perhaps instead I should create the constant title string once
and store it in MainWindow class.

I'll rework it a little and clean up.

--
Kieran

> 
>>  	viewfinder_ = new ViewFinder(this);
>>  	setCentralWidget(viewfinder_);
>>  	viewfinder_->setFixedSize(500, 500);
>> @@ -50,6 +52,12 @@ MainWindow::~MainWindow()
>>  	CameraManager::instance()->stop();
>>  }
>>  
>> +void MainWindow::setWindowTitle()
>> +{
>> +	QMainWindow::setWindowTitle("QCam : "
>> +		+ QString::fromStdString(libcamera::version.toString()));
>> +}
>> +
>>  int MainWindow::openCamera()
>>  {
>>  	CameraManager *cm = CameraManager::instance();
>> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
>> index fe565cbcb460..b30a86768efc 100644
>> --- a/src/qcam/main_window.h
>> +++ b/src/qcam/main_window.h
>> @@ -33,6 +33,8 @@ public:
>>  	~MainWindow();
>>  
>>  private:
>> +	void setWindowTitle();
>> +
>>  	int openCamera();
>>  
>>  	int startCapture();
>

Patch

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 16b123132dd9..61d7aa9469f0 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -14,6 +14,7 @@ 
 #include <QTimer>
 
 #include <libcamera/camera_manager.h>
+#include <libcamera/version.h>
 
 #include "main_window.h"
 #include "viewfinder.h"
@@ -25,6 +26,7 @@  MainWindow::MainWindow(const OptionsParser::Options &options)
 {
 	int ret;
 
+	setWindowTitle();
 	viewfinder_ = new ViewFinder(this);
 	setCentralWidget(viewfinder_);
 	viewfinder_->setFixedSize(500, 500);
@@ -50,6 +52,12 @@  MainWindow::~MainWindow()
 	CameraManager::instance()->stop();
 }
 
+void MainWindow::setWindowTitle()
+{
+	QMainWindow::setWindowTitle("QCam : "
+		+ QString::fromStdString(libcamera::version.toString()));
+}
+
 int MainWindow::openCamera()
 {
 	CameraManager *cm = CameraManager::instance();
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index fe565cbcb460..b30a86768efc 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -33,6 +33,8 @@  public:
 	~MainWindow();
 
 private:
+	void setWindowTitle();
+
 	int openCamera();
 
 	int startCapture();