[libcamera-devel,07/21] qcam: main_window: Use icons from system icon theme

Message ID 20200323142205.28342-8-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • qcam: Bypass format conversion when not required
Related show

Commit Message

Laurent Pinchart March 23, 2020, 2:21 p.m. UTC
Use the system icon theme by default, falling back to custom icons if no
theme is available.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/main_window.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Kieran Bingham March 23, 2020, 3:18 p.m. UTC | #1
Hi Laurent,

On 23/03/2020 14:21, Laurent Pinchart wrote:
> Use the system icon theme by default, falling back to custom icons if no
> theme is available.

Aha, I hadn't realised it was easy enough to obtain theme icons.

I 'think' I prefer this except...

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/qcam/main_window.cpp | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 86f92360a1a9..14baf7ec4c2e 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -97,7 +97,9 @@ int MainWindow::createToolbars()
>  	/* Disable right click context menu. */
>  	toolbar_->setContextMenuPolicy(Qt::PreventContextMenu);
>  
> -	action = toolbar_->addAction(QIcon(":x-circle.svg"), "Quit");
> +	action = toolbar_->addAction(QIcon::fromTheme("application-exit",
> +						      QIcon(":x-circle.svg")),
> +				     "Quit");
>  	connect(action, &QAction::triggered, this, &MainWindow::quit);
>  
>  	/* Camera selection. */
> @@ -112,12 +114,16 @@ int MainWindow::createToolbars()
>  
>  	toolbar_->addSeparator();
>  
> -	action = toolbar_->addAction(QIcon(":play-circle.svg"), "Start Capture");
> +	action = toolbar_->addAction(QIcon::fromTheme("media-playback-start",
> +						      QIcon(":play-circle.svg")),
> +				     "Start Capture");
>  	action->setCheckable(true);
>  	connect(action, &QAction::toggled, this, &MainWindow::toggleCapture);
>  	startStopAction_ = action;
>  
> -	action = toolbar_->addAction(QIcon(":save.svg"), "saveAs");
> +	action = toolbar_->addAction(QIcon::fromTheme("document-save-as",

This now looks like a 'document' instead of a disk ... ;-(

But maybe that's not the end of the world, and a potential restriction
of the theme more than this patch ... so ...

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



> +						      QIcon(":save.svg")),
> +				     "Save As...");
>  	connect(action, &QAction::triggered, this, &MainWindow::saveImageAs);
>  
>  	return 0;
>
Laurent Pinchart March 23, 2020, 4:19 p.m. UTC | #2
Hi Kieran,

On Mon, Mar 23, 2020 at 03:18:57PM +0000, Kieran Bingham wrote:
> On 23/03/2020 14:21, Laurent Pinchart wrote:
> > Use the system icon theme by default, falling back to custom icons if no
> > theme is available.
> 
> Aha, I hadn't realised it was easy enough to obtain theme icons.
> 
> I 'think' I prefer this except...
> 
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/qcam/main_window.cpp | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> > index 86f92360a1a9..14baf7ec4c2e 100644
> > --- a/src/qcam/main_window.cpp
> > +++ b/src/qcam/main_window.cpp
> > @@ -97,7 +97,9 @@ int MainWindow::createToolbars()
> >  	/* Disable right click context menu. */
> >  	toolbar_->setContextMenuPolicy(Qt::PreventContextMenu);
> >  
> > -	action = toolbar_->addAction(QIcon(":x-circle.svg"), "Quit");
> > +	action = toolbar_->addAction(QIcon::fromTheme("application-exit",
> > +						      QIcon(":x-circle.svg")),
> > +				     "Quit");
> >  	connect(action, &QAction::triggered, this, &MainWindow::quit);
> >  
> >  	/* Camera selection. */
> > @@ -112,12 +114,16 @@ int MainWindow::createToolbars()
> >  
> >  	toolbar_->addSeparator();
> >  
> > -	action = toolbar_->addAction(QIcon(":play-circle.svg"), "Start Capture");
> > +	action = toolbar_->addAction(QIcon::fromTheme("media-playback-start",
> > +						      QIcon(":play-circle.svg")),
> > +				     "Start Capture");
> >  	action->setCheckable(true);
> >  	connect(action, &QAction::toggled, this, &MainWindow::toggleCapture);
> >  	startStopAction_ = action;
> >  
> > -	action = toolbar_->addAction(QIcon(":save.svg"), "saveAs");
> > +	action = toolbar_->addAction(QIcon::fromTheme("document-save-as",
> 
> This now looks like a 'document' instead of a disk ... ;-(

I'm sorry :-S

> But maybe that's not the end of the world, and a potential restriction
> of the theme more than this patch ... so ...

>From the screenshot you've shown me, I would say it's a bug in the icon
theme, not a restriction.

> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > +						      QIcon(":save.svg")),
> > +				     "Save As...");
> >  	connect(action, &QAction::triggered, this, &MainWindow::saveImageAs);
> >  
> >  	return 0;

Patch

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 86f92360a1a9..14baf7ec4c2e 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -97,7 +97,9 @@  int MainWindow::createToolbars()
 	/* Disable right click context menu. */
 	toolbar_->setContextMenuPolicy(Qt::PreventContextMenu);
 
-	action = toolbar_->addAction(QIcon(":x-circle.svg"), "Quit");
+	action = toolbar_->addAction(QIcon::fromTheme("application-exit",
+						      QIcon(":x-circle.svg")),
+				     "Quit");
 	connect(action, &QAction::triggered, this, &MainWindow::quit);
 
 	/* Camera selection. */
@@ -112,12 +114,16 @@  int MainWindow::createToolbars()
 
 	toolbar_->addSeparator();
 
-	action = toolbar_->addAction(QIcon(":play-circle.svg"), "Start Capture");
+	action = toolbar_->addAction(QIcon::fromTheme("media-playback-start",
+						      QIcon(":play-circle.svg")),
+				     "Start Capture");
 	action->setCheckable(true);
 	connect(action, &QAction::toggled, this, &MainWindow::toggleCapture);
 	startStopAction_ = action;
 
-	action = toolbar_->addAction(QIcon(":save.svg"), "saveAs");
+	action = toolbar_->addAction(QIcon::fromTheme("document-save-as",
+						      QIcon(":save.svg")),
+				     "Save As...");
 	connect(action, &QAction::triggered, this, &MainWindow::saveImageAs);
 
 	return 0;