Commits

Ivan Andrianov committed 3584254

Encoder dialog.

Comments (0)

Files changed (8)

 include(${QT_USE_FILE})
 set(CMAKE_AUTOMOC 1)
 
-find_package(PythonInterp 2.7 REQUIRED)
-find_package(PythonLibs 2.7 REQUIRED)
-include_directories(${PYTHON_INCLUDE_DIRS})
-
-execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
-                ERROR_VARIABLE PYTHON_VERSION_FULL)
-string(REGEX MATCH "[0-9]+\\.[0-9]+" PYTHON_VERSION "${PYTHON_VERSION_FULL}")
-
-find_package(SIP 4.13 REQUIRED)
-find_package(PyQt4 4.8 REQUIRED)
-include_directories(${SIP_INCLUDE_DIR})
-
 find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL)
 find_package(FLAC)
 
 include_directories(${FFTRANSCODER_SOURCE_DIR}/src)
+include_directories(${FFTRANSCODER_BINARY_DIR}/src)
 
 if(WIN32)
   set(FFTRANSCODER_BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
   set(FFTRANSCODER_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
   set(FFTRANSCODER_PLUGIN_INSTALL_DIR
       ${FFTRANSCODER_BIN_INSTALL_DIR}/plugins)
-  set(FFTRANSCODER_PYTHON_INSTALL_DIR
-    ${FFTRANSCODER_LIB_INSTALL_DIR}/fftranscoder)
 else(WIN32)
   set(CMAKE_CXX_FLAGS "-fvisibility=hidden")
   set(FFTRANSCODER_BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
   set(FFTRANSCODER_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/fftranscoder)
   set(FFTRANSCODER_PLUGIN_INSTALL_DIR
       ${FFTRANSCODER_LIB_INSTALL_DIR}/fftranscoder/plugins)
-  set(FFTRANSCODER_PYTHON_INSTALL_DIR
-      ${FFTRANSCODER_LIB_INSTALL_DIR}/python${PYTHON_VERSION}/site-packages/fftranscoder)
 endif(WIN32)
 
-add_subdirectory(pysrc/fftranscoder)
 add_subdirectory(src/codecs)
+add_subdirectory(src/ui)
 
 install(FILES fftranscoder.py DESTINATION ${FFTRANSCODER_BIN_INSTALL_DIR})
 

pysrc/fftranscoder/ui/encoderdialog.py

-# Copyright (C) 2012 by Ivan Andrianov
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-
-from PyQt4 import QtCore, QtGui
-
-from fftranscoder import codecs
-
-class EncoderDialog(QtGui.QDialog):
-    MIN_QUALITY = 0
-    MAX_QUALITY = 7
-    
-    def __init__(self, parent = None):
-        QtGui.QDialog.__init__(self, parent)
-
-        self.setWindowTitle(self.tr('Choose a codec'))
-
-        self._layout = QtGui.QVBoxLayout(self)
-
-        self._codecLabel = QtGui.QLabel(self.tr('Codec') + ':')
-        self._layout.addWidget(self._codecLabel)
-
-        self._codecComboBox = QtGui.QComboBox()
-        encoderPlugins = codecs.PluginLoader.instance().encoderPlugins()
-        for encoderPlugin in encoderPlugins:
-            self._codecComboBox.addItem(encoderPlugin.encoderName() + ' ' +
-                                        encoderPlugin.codecName())
-        self._codecComboBox.currentIndexChanged.connect(
-                                        lambda x: self.checkCurrentEncoder())
-        self._layout.addWidget(self._codecComboBox)
-
-        self._qualityLabel = QtGui.QLabel(self.tr('Quality') + ':')
-        self._layout.addWidget(self._qualityLabel)
-
-        self._qualitySlider = QtGui.QSlider(QtCore.Qt.Horizontal)
-        self._qualitySlider.setRange(EncoderDialog.MIN_QUALITY,
-                                     EncoderDialog.MAX_QUALITY)
-        self._qualitySlider.setValue(EncoderDialog.MAX_QUALITY)
-        self._layout.addWidget(self._qualitySlider)
-
-        self._buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
-                                                 QtGui.QDialogButtonBox.Cancel)
-        self._buttonBox.accepted.connect(self.accept)
-        self._buttonBox.rejected.connect(self.reject)
-        self._layout.addWidget(self._buttonBox)
-
-        self.checkCurrentEncoder()
-
-    def checkCurrentEncoder(self):
-        self._qualitySlider.setDisabled(self.encoder.isLossless())
-
-    @property
-    def encoder(self):
-        index = self._codecComboBox.currentIndex()
-        return codecs.PluginLoader.instance().encoderPlugins()[index]
-
-    @property
-    def quality(self):
-        if self._qualitySlider.isEnabled():
-            return self._qualitySlider.value()
-        else:
-            return None

src/ui/CMakeLists.txt

+# Copyright (C) 2012 by Ivan Andrianov
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+set(FFTRANSCODER_UI_SRCS_CXX
+  encoderdialog.cpp
+  global.cpp
+)
+
+set(FFTRANSCODER_UI_SRCS_UI
+  encoderdialog.ui
+)
+
+qt4_wrap_ui(FFTRANSCODER_UI_SRCS_CXX ${FFTRANSCODER_UI_SRCS_UI})
+
+add_library(fftranscoder_ui SHARED ${FFTRANSCODER_UI_SRCS_CXX})
+
+target_link_libraries(fftranscoder_ui fftranscoder_codecs
+		${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+
+install(TARGETS fftranscoder_ui
+        RUNTIME DESTINATION ${FFTRANSCODER_BIN_INSTALL_DIR}
+        LIBRARY DESTINATION ${FFTRANSCODER_LIB_INSTALL_DIR})

src/ui/encoderdialog.cpp

+/*
+ * Copyright (C) 2012 by Ivan Andrianov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "encoderdialog.h"
+
+#include <codecs/encoderplugin.h>
+
+#include <ui/ui_encoderdialog.h>
+
+namespace FFTranscoder
+{
+namespace Ui
+{
+
+class EncoderDialog::Private : public QObject
+{
+public:
+    Private(EncoderDialog * dialog,
+            const QList<Codecs::EncoderPlugin *> encoders);
+    ~Private();
+    void populateCodecComboBox();
+
+    QList<Codecs::EncoderPlugin *> encoders;
+    ::Ui::Form form;
+
+public slots:
+    void checkEncoder(int index);
+};
+
+EncoderDialog::EncoderDialog(const QList<Codecs::EncoderPlugin *> encoders,
+        QWidget * parent)
+    : QDialog(parent), d(new Private(this, encoders))
+{
+}
+
+EncoderDialog::~EncoderDialog()
+{
+}
+
+Codecs::EncoderPlugin * EncoderDialog::getEncoder() const
+{
+    return d->encoders[d->form.codecComboBox->currentIndex()];
+}
+
+int EncoderDialog::getQuality() const
+{
+    if (d->form.qualitySlider->isEnabled())
+    {
+        return d->form.qualitySlider->value();
+    }
+    return -1;
+}
+
+EncoderDialog::Private::Private(EncoderDialog * dialog,
+        const QList<Codecs::EncoderPlugin *> encoders)
+    : encoders(encoders)
+{
+    form.setupUi(dialog);
+    populateCodecComboBox();
+    connect(form.codecComboBox, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(checkEncoder(int)));
+    checkEncoder(0);
+}
+
+EncoderDialog::Private::~Private()
+{
+}
+
+void EncoderDialog::Private::populateCodecComboBox()
+{
+    foreach(Codecs::EncoderPlugin * encoder, encoders)
+    {
+        form.codecComboBox->addItem(
+                    encoder->encoderName() + " " + encoder->codecName());
+    }
+}
+
+void EncoderDialog::Private::checkEncoder(int index)
+{
+    form.qualitySlider->setDisabled(encoders[index]->isLossless());
+}
+
+}
+}

src/ui/encoderdialog.h

+/*
+ * Copyright (C) 2012 by Ivan Andrianov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef FFTRANSCODER_UI_ENCODERDIALOG_H
+#define FFTRANSCODER_UI_ENCODERDIALOG_H
+
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qdialog.h>
+
+#include "global.h"
+
+namespace FFTranscoder
+{
+
+namespace Codecs
+{
+class EncoderPlugin;
+}
+
+namespace Ui
+{
+
+class FFTRANSCODER_UI_API EncoderDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    EncoderDialog(const QList<Codecs::EncoderPlugin *> encoders,
+            QWidget * parent = 0);
+    virtual ~EncoderDialog();
+
+    Codecs::EncoderPlugin * getEncoder() const;
+    int getQuality() const;
+
+private:
+    class Private;
+    QScopedPointer<Private> d;
+};
+
+}
+}
+
+#endif // FFTRANSCODER_UI_ENCODERDIALOG_H

src/ui/encoderdialog.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QDialog" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>300</width>
+    <height>187</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Choose a codec</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="codecLabel">
+     <property name="text">
+      <string>Codec</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QComboBox" name="codecComboBox"/>
+   </item>
+   <item>
+    <widget class="QLabel" name="qualityLabel">
+     <property name="text">
+      <string>Quality</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QSlider" name="qualitySlider">
+     <property name="maximum">
+      <number>7</number>
+     </property>
+     <property name="pageStep">
+      <number>4</number>
+     </property>
+     <property name="value">
+      <number>7</number>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <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>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Form</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>Form</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

src/ui/global.cpp

+/*
+ * Copyright (C) 2012 by Ivan Andrianov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "global.h"
+
+namespace FFTranscoder
+{
+namespace Ui
+{
+
+const char * version()
+{
+    return FFTRANSCODER_UI_VERSION_STRING;
+}
+
+}
+}
+/*
+ * Copyright (C) 2012 by Ivan Andrianov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef FFTRANSCODER_UI_GLOBAL_H
+#define FFTRANSCODER_UI_GLOBAL_H
+
+#include <QtGlobal>
+
+#ifdef Q_CC_MSVC
+#ifdef fftranscoder_ui_EXPORTS
+#define FFTRANSCODER_UI_API __declspec(dllexport)
+#else
+#define FFTRANSCODER_UI_API __declspec(dllimport)
+#endif
+#else
+#ifdef Q_CC_GNU
+#define FFTRANSCODER_UI_API __attribute__ ((visibility ("default")))
+#else
+#define FFTRANSCODER_UI_API
+#endif
+#endif
+
+/**
+ * Compile-time version string of the FFTranscoder UI library.
+ */
+#define FFTRANSCODER_UI_VERSION_STRING "2.0.0"
+
+/**
+ * Compile-time version code of the FFTranscoder UI library.
+ */
+#define FFTRANSCODER_UI_VERSION 0x020000
+
+namespace FFTranscoder
+{
+namespace Ui
+{
+
+/**
+ * Runtime version string of the FFTranscoder Codecs library.
+ */
+FFTRANSCODER_UI_API const char * version();
+
+}
+}
+
+#endif // FFTRANSCODER_UI_GLOBAL_H