mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
thumbnailers: implement options for ffmpegthumbs
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5c2cb22446
commit
5656ab78ae
7 changed files with 120 additions and 1 deletions
|
@ -27,6 +27,7 @@ set(ffmpegthumbs_PART_SRCS
|
|||
ffmpegthumbnailer.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(ffmpegthumbs_PART_SRCS ffmpegthumbssettings.kcfgc)
|
||||
kde4_add_plugin(ffmpegthumbs ${ffmpegthumbs_PART_SRCS})
|
||||
|
||||
target_link_libraries(ffmpegthumbs
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "config-ffmpegthumbnailer.h"
|
||||
#include "ffmpegthumbnailer.h"
|
||||
#include "ffmpegthumbssettings.h"
|
||||
#include "ui_ffmpegthumbsform.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QImage>
|
||||
|
@ -40,6 +42,14 @@ void ffmpeg_log_callback(ThumbnailerLogLevel ffmpegloglevel, const char* ffmpegm
|
|||
}
|
||||
}
|
||||
|
||||
class FFMpegThumbsFormWidget : public QWidget, public Ui::FFMpegThumbsForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FFMpegThumbsFormWidget() { setupUi(this); }
|
||||
};
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
KDE_EXPORT ThumbCreator* new_creator()
|
||||
|
@ -69,6 +79,9 @@ bool FFMpegThumbnailer::create(const QString &path, int width, int heigth, QImag
|
|||
return false;
|
||||
}
|
||||
|
||||
FFMpegThumbsSettings* ffmpegthumbssettings = FFMpegThumbsSettings::self();
|
||||
ffmpegthumbssettings->readConfig();
|
||||
|
||||
const QByteArray pathbytes = QFile::encodeName(path);
|
||||
#if defined(HAVE_VIDEO_THUMBNAILER_SET_SIZE)
|
||||
video_thumbnailer_set_size(ffmpegthumb, width, heigth);
|
||||
|
@ -76,7 +89,9 @@ bool FFMpegThumbnailer::create(const QString &path, int width, int heigth, QImag
|
|||
ffmpegthumb->thumbnail_size = qMax(width, heigth);
|
||||
#endif
|
||||
ffmpegthumb->seek_percentage = 20;
|
||||
ffmpegthumb->overlay_film_strip = 1;
|
||||
ffmpegthumb->overlay_film_strip = ffmpegthumbssettings->film_strip();
|
||||
ffmpegthumb->prefer_embedded_metadata = ffmpegthumbssettings->prefer_embedded_metadata();
|
||||
ffmpegthumb->workaround_bugs = ffmpegthumbssettings->workaround_bugs();
|
||||
ffmpegthumb->thumbnail_image_type = ThumbnailerImageType::Png;
|
||||
|
||||
const int ffmpegresult = video_thumbnailer_generate_thumbnail_to_buffer(
|
||||
|
@ -114,3 +129,25 @@ ThumbCreator::Flags FFMpegThumbnailer::flags() const
|
|||
return ThumbCreator::DrawFrame;
|
||||
}
|
||||
|
||||
QWidget *FFMpegThumbnailer::createConfigurationWidget()
|
||||
{
|
||||
FFMpegThumbsSettings* ffmpegthumbssettings = FFMpegThumbsSettings::self();
|
||||
FFMpegThumbsFormWidget* ffmpegthumbsformwidget = new FFMpegThumbsFormWidget();
|
||||
ffmpegthumbsformwidget->filmStripCheckBox->setChecked(ffmpegthumbssettings->film_strip());
|
||||
ffmpegthumbsformwidget->preferEmbeddedMetadataCheckBox->setChecked(ffmpegthumbssettings->prefer_embedded_metadata());
|
||||
ffmpegthumbsformwidget->workaroundBugsCheckBox->setChecked(ffmpegthumbssettings->workaround_bugs());
|
||||
return ffmpegthumbsformwidget;
|
||||
}
|
||||
|
||||
void FFMpegThumbnailer::writeConfiguration(const QWidget *configurationWidget)
|
||||
{
|
||||
const FFMpegThumbsFormWidget *ffmpegthumbsformwidget = qobject_cast<const FFMpegThumbsFormWidget*>(configurationWidget);
|
||||
Q_ASSERT(ffmpegthumbsformwidget);
|
||||
FFMpegThumbsSettings* ffmpegthumbssettings = FFMpegThumbsSettings::self();
|
||||
ffmpegthumbssettings->setFilm_strip(ffmpegthumbsformwidget->filmStripCheckBox->isChecked());
|
||||
ffmpegthumbssettings->setPrefer_embedded_metadata(ffmpegthumbsformwidget->preferEmbeddedMetadataCheckBox->isChecked());
|
||||
ffmpegthumbssettings->setWorkaround_bugs(ffmpegthumbsformwidget->workaroundBugsCheckBox->isChecked());
|
||||
ffmpegthumbssettings->writeConfig();
|
||||
}
|
||||
|
||||
#include "ffmpegthumbnailer.moc"
|
||||
|
|
|
@ -28,6 +28,9 @@ public:
|
|||
|
||||
bool create(const QString &path, int width, int height, QImage &img) final;
|
||||
ThumbCreator::Flags flags() const final;
|
||||
|
||||
QWidget *createConfigurationWidget() final;
|
||||
void writeConfiguration(const QWidget *configurationWidget) final;
|
||||
};
|
||||
|
||||
#endif // FFMPEGTHUMBNAILER_H
|
||||
|
|
|
@ -55,3 +55,4 @@ X-KDE-Library=ffmpegthumbs
|
|||
ServiceTypes=ThumbCreator
|
||||
CacheThumbnail=true
|
||||
IgnoreMaximumSize=true
|
||||
Configurable=true
|
||||
|
|
54
thumbnailers/ffmpegthumbs/ffmpegthumbsform.ui
Normal file
54
thumbnailers/ffmpegthumbs/ffmpegthumbsform.ui
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FFMpegThumbsForm</class>
|
||||
<widget class="QWidget" name="FFMpegThumbsForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>270</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="filmStripCheckBox">
|
||||
<property name="text">
|
||||
<string>Overlay film strip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="preferEmbeddedMetadataCheckBox">
|
||||
<property name="text">
|
||||
<string>Prefer embedded metadata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="workaroundBugsCheckBox">
|
||||
<property name="text">
|
||||
<string>Workaround bugs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<connections/>
|
||||
</ui>
|
19
thumbnailers/ffmpegthumbs/ffmpegthumbssettings.kcfg
Normal file
19
thumbnailers/ffmpegthumbs/ffmpegthumbssettings.kcfg
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg>
|
||||
<kcfgfile name="ffmpegthumbsrc"/>
|
||||
<group name="General">
|
||||
<entry name="film_strip" type="bool">
|
||||
<label>Overlay film strip</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="prefer_embedded_metadata" type="bool">
|
||||
<label>Prefer embedded metadata</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="workaround_bugs" type="bool">
|
||||
<label>Workaround bugs</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
4
thumbnailers/ffmpegthumbs/ffmpegthumbssettings.kcfgc
Normal file
4
thumbnailers/ffmpegthumbs/ffmpegthumbssettings.kcfgc
Normal file
|
@ -0,0 +1,4 @@
|
|||
File=ffmpegthumbssettings.kcfg
|
||||
ClassName=FFMpegThumbsSettings
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Add table
Reference in a new issue