[kaffeine] /: mainwindow: add an option to force an specific aspect ratio

Mauro Carvalho Chehab null at kde.org
Tue Nov 6 20:31:09 GMT 2018


Git commit 995981b3d490cae7d26121a3aaffb116fb3e1a47 by Mauro Carvalho Chehab.
Committed on 06/11/2018 at 20:30.
Pushed by mauroc into branch 'master'.

mainwindow: add an option to force an specific aspect ratio

Usually, aspect ratio is something that the user changes as it
wish, depending on the video source. However, users with wide
monitors may opt to always force to a certain aspect ratio, in
order to fit better on their screens.

So, add a command line option to force it.

BUG: 394201

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung at kernel.org>

M  +13   -0    doc/man-kaffeine.1.docbook
M  +28   -0    src/mainwindow.cpp
M  +7    -0    src/mediawidget.cpp
M  +1    -0    src/mediawidget.h

https://commits.kde.org/kaffeine/995981b3d490cae7d26121a3aaffb116fb3e1a47

diff --git a/doc/man-kaffeine.1.docbook b/doc/man-kaffeine.1.docbook
index 42a6df9..a1b0b71 100644
--- a/doc/man-kaffeine.1.docbook
+++ b/doc/man-kaffeine.1.docbook
@@ -37,6 +37,7 @@
 <arg choice="opt"><option>-t, --alwaysontop</option></arg>
 <arg choice="opt"><option>--audiocd</option></arg>
 <arg choice="opt"><option>--videocd</option></arg>
+<arg choice="opt"><option>--aspectratio <replaceable>aspect_ratio</replaceable></option></arg>
 <arg choice="opt"><option>--dvd</option></arg>
 <arg choice="opt"><option>--dumpdvb</option></arg>
 <arg choice="opt"><option>--channel <replaceable>name</replaceable> / <replaceable>number</replaceable></option></arg>
@@ -158,6 +159,18 @@ mouse button and deselecting the always on top button box.</para>
 </listitem>
 </varlistentry>
 
+<varlistentry>
+<term><option>--aspectratio</option> <replaceable>aspect_ratio</replaceable></term>
+<listitem><para>Forces &kaffeine; to start with an specific aspect
+ratio, disabling the automatic mode. This can be useful on wide
+and ultra-wide monitors, where the user always want to see video
+in full screen mode using the maximum possible resolution.
+Valid values are: 1:1, 4:3, 5:4, 16:9, 16:10, 2.21:1, 2.35:1
+and 2.39:1. If an invalid value is passed, or if this option is not
+used, it will default to automatic mode.</para>
+</listitem>
+</varlistentry>
+
 <varlistentry>
 <term><option>--audiocd</option></term>
 <listitem><para>Play Audio CD</para>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 3bc7b72..d40a87a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -474,6 +474,7 @@ MainWindow::MainWindow(KAboutData *aboutData, QCommandLineParser *parser)
 	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("audiocd"), i18n("Play Audio CD")));
 	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("videocd"), i18n("Play Video CD")));
 	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("dvd"), i18n("Play DVD")));
+	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("aspectratio"), "Force starting with an specific aspect ratio", QLatin1String("aspect ratio")));
 
 #if HAVE_DVB == 1
 	parser->addOption(QCommandLineOption(QStringList() << QLatin1String("dumpdvb"), i18nc("command line option", "Dump dvb data (debug option)")));
@@ -530,6 +531,33 @@ void MainWindow::parseArgs(const QString workingDirectory)
 		} /* switch */
 	}
 
+	if (parser->isSet("aspectratio")) {
+		MediaWidget::AspectRatio aspectRatio = MediaWidget::AspectRatioAuto;
+		QString aspect;
+
+		aspect = parser->value("aspectratio");
+
+		if (aspect == "1:1")
+			aspectRatio = MediaWidget::AspectRatio1_1;
+		else if (aspect == "4:3")
+			aspectRatio = MediaWidget::AspectRatio4_3;
+		else if (aspect == "5:4")
+			aspectRatio = MediaWidget::AspectRatio5_4;
+		else if (aspect == "16:9")
+			aspectRatio = MediaWidget::AspectRatio16_9;
+		else if (aspect == "16:10")
+			aspectRatio = MediaWidget::AspectRatio16_10;
+		else if (aspect == "2.21:1")
+			aspectRatio = MediaWidget::AspectRatio221_100;
+		else if (aspect == "2.35:1")
+			aspectRatio = MediaWidget::AspectRatio235_100;
+		else if (aspect == "2.39:1")
+			aspectRatio = MediaWidget::AspectRatio239_100;
+
+		mediaWidget->setAspectRatio(aspectRatio);
+	}
+
+
 #if HAVE_DVB == 1
 	if (parser->isSet("dumpdvb")) {
 		dvbTab->enableDvbDump();
diff --git a/src/mediawidget.cpp b/src/mediawidget.cpp
index f38d301..f72b734 100644
--- a/src/mediawidget.cpp
+++ b/src/mediawidget.cpp
@@ -991,6 +991,13 @@ void MediaWidget::aspectRatioChanged(QAction *action)
 	qCWarning(logMediaWidget, "internal error");
 }
 
+
+void MediaWidget::setAspectRatio(MediaWidget::AspectRatio aspectRatio)
+{
+	backend->setAspectRatio(aspectRatio);
+}
+
+
 void MediaWidget::setVideoSize()
 {
 	float scale = autoResizeFactor / 100.0;
diff --git a/src/mediawidget.h b/src/mediawidget.h
index af59073..75682da 100644
--- a/src/mediawidget.h
+++ b/src/mediawidget.h
@@ -130,6 +130,7 @@ public:
 	void setVolumeUnderMouse(int volume);
 	void toggleMuted();
 	void mediaSourceDestroyed(MediaSource *mediaSource);
+	void setAspectRatio(MediaWidget::AspectRatio aspectRatio);
 
 public slots:
 	void previous();


More information about the kde-doc-english mailing list