From 5d196e4faf0a64d6d218a6b1b2aae1be8cafbc3f Mon Sep 17 00:00:00 2001 From: Roman Moravcik Date: Fri, 24 Jun 2011 15:04:56 +0200 Subject: [PATCH] Added DUI control panel applet --- qmafw-gst-subtitles-renderer/applet/dcpsubtitles.h | 30 + .../applet/subtitles.desktop | 19 + .../applet/subtitlesapplet.cpp | 80 +++ .../applet/subtitlesapplet.h | 49 ++ .../applet/subtitlesapplet.pro | 53 ++ .../applet/subtitlesbrief.cpp | 27 + .../applet/subtitlesbrief.h | 32 + .../applet/subtitleswidget.cpp | 668 ++++++++++++++++++++ .../applet/subtitleswidget.h | 74 +++ .../applet/translations/subtitlesapplet_en.qm | Bin 0 -> 80 bytes .../applet/translations/subtitlesapplet_en.ts | 252 ++++++++ .../qmafw-gst-subtitles-renderer.pro | 2 + 12 files changed, 1286 insertions(+) create mode 100644 qmafw-gst-subtitles-renderer/applet/dcpsubtitles.h create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitles.desktop create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitlesapplet.cpp create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitlesapplet.h create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitlesapplet.pro create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitlesbrief.cpp create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitlesbrief.h create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitleswidget.cpp create mode 100644 qmafw-gst-subtitles-renderer/applet/subtitleswidget.h create mode 100644 qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.qm create mode 100644 qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.ts diff --git a/qmafw-gst-subtitles-renderer/applet/dcpsubtitles.h b/qmafw-gst-subtitles-renderer/applet/dcpsubtitles.h new file mode 100644 index 0000000..285e591 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/dcpsubtitles.h @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#ifndef DCPSUBTITLES_H +#define DCPSUBTITLES_H + +namespace DcpSubtitles +{ +enum { + None = -1, + Main = 0 +}; +} + +#endif // DCPSUBTITLES_H diff --git a/qmafw-gst-subtitles-renderer/applet/subtitles.desktop b/qmafw-gst-subtitles-renderer/applet/subtitles.desktop new file mode 100644 index 0000000..20599ca --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitles.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Type=ControlPanelApplet +Name=Subtitles +Icon= +Exec= +X-logical-id=Subtitles +X-translation-catalog=subtitlesapplet +X-Maemo-Service=com.nokia.DuiControlPanel +X-Maemo-Method=com.nokia.DuiControlPanelIf.appletPage +X-Maemo-Object-Path=/ +X-Maemo-Fixed-Args=Subtitles + +[DUI] +X-DUIApplet-Applet=libsubtitlesapplet.so + +[DCP] +Category=Application settings +Order=1 +WidgetType=Label diff --git a/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.cpp b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.cpp new file mode 100644 index 0000000..bcbedf0 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#include "subtitlesapplet.h" +#include "subtitleswidget.h" + +#include "dcpsubtitles.h" + +#include + +#include +#include + +#include +M_LIBRARY + +Q_EXPORT_PLUGIN2(subtitlesapplet, SubtitlesApplet) + +SubtitlesApplet::SubtitlesApplet () : + m_MainWidget (0) +{ +} + +SubtitlesApplet::~SubtitlesApplet () +{ +} + +void SubtitlesApplet::init () +{ +} + +DcpStylableWidget * +SubtitlesApplet::constructStylableWidget (int widgetId) +{ + Q_UNUSED (widgetId); + /* + * Please note that the m_MainWidget is a QPointer that will nullify itself + * when the widget is destroyed. Then we need to create a new one when we + * asked for it. + */ + if (m_MainWidget == NULL) + m_MainWidget = new SubtitlesWidget (); + + return m_MainWidget; +} + +QString SubtitlesApplet::title() const +{ + return qtTrId ("Subtitles"); +} + +QVector +SubtitlesApplet::viewMenuItems () +{ + QVector vector; + + return vector; +} + +DcpBrief* +SubtitlesApplet::constructBrief (int partId) +{ + Q_UNUSED (partId); + return 0; +} diff --git a/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.h b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.h new file mode 100644 index 0000000..923f577 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#ifndef SUBTITLESAPPLET_H +#define SUBTITLESAPPLET_H + +#include +#include +#include + +class DcpWidget; +class MAction; +class SubtitlesWidget; + +class Q_DECL_EXPORT SubtitlesApplet : public QObject, public DcpAppletIf +{ + Q_OBJECT + Q_INTERFACES(DcpAppletIf) + +public: + SubtitlesApplet (); + ~SubtitlesApplet (); + + virtual void init (); + virtual DcpStylableWidget *constructStylableWidget (int widgetId); + virtual QString title () const; + virtual QVector viewMenuItems (); + virtual DcpBrief* constructBrief (int partId = 0); + +private: + QPointer m_MainWidget; +}; + +#endif diff --git a/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.pro b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.pro new file mode 100644 index 0000000..a7aeebe --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitlesapplet.pro @@ -0,0 +1,53 @@ +TEMPLATE = lib +TARGET = subtitlesapplet + +isEmpty(PREFIX) { + PREFIX=/usr +} + +isEmpty(MODE) { + CONFIG += release + QMAKE_CXXFLAGS += -g + QMAKE_CFLAGS += -g +} + +contains(MODE, release) { + CONFIG += release + DEFINES += G_DISABLE_ASSERT + QMAKE_CXXFLAGS += -g + QMAKE_CFLAGS += -g +} + +contains(MODE, debug) { + CONFIG += debug +} + +CONFIG += plugin gui meegotouch duicontrolpanel link_pkgconfig +PKGCONFIG += pango + +QMAKE_CXXFLAGS += -Wall -Werror +QMAKE_CFLAGS += -Wall -Werror + +QMAKE_CLEAN += build-stamp \ + configure-stamp + +# Input +HEADERS += subtitlesapplet.h \ + subtitleswidget.h \ + subtitlesbrief.h + +SOURCES += subtitlesapplet.cpp \ + subtitleswidget.cpp \ + subtitlesbrief.cpp + +TRANSLATIONS += translations/subtitlesapplet_en.ts + +target.path += $$PREFIX/lib/duicontrolpanel/applets + +desktop.files += subtitles.desktop +desktop.path = $$PREFIX/share/duicontrolpanel/desktops + +translations.files += translations/*.qm +translations.path = $$PREFIX/share/l10n/meegotouch + +INSTALLS += target desktop translations diff --git a/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.cpp b/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.cpp new file mode 100644 index 0000000..430b6d7 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "subtitlesbrief.h" +#include + +int +SubtitlesBrief::widgetTypeID () const +{ + return DcpWidgetType::Label; +} diff --git a/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.h b/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.h new file mode 100644 index 0000000..3c938b5 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitlesbrief.h @@ -0,0 +1,32 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#ifndef SUBTITLESBRIEF_H +#define SUBTITLESBRIEF_H + +#include + +class SubtitlesBrief: public DcpBrief +{ + Q_OBJECT + +public: + virtual int widgetTypeID () const; +}; + +#endif diff --git a/qmafw-gst-subtitles-renderer/applet/subtitleswidget.cpp b/qmafw-gst-subtitles-renderer/applet/subtitleswidget.cpp new file mode 100644 index 0000000..a3ce0f3 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitleswidget.cpp @@ -0,0 +1,668 @@ +/****************************************************************************+ +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#include "subtitleswidget.h" +#include "dcpsubtitles.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +M_REGISTER_WIDGET_NO_CREATE (SubtitlesWidget); + +#include + +const QString RENDERER_PLUGIN_CONFIG_FILE = "/usr/share/qmafw/mafw-gst-renderer-plugin.conf"; + +typedef enum +{ + FONT_STYLE_REGULAR, + FONT_STYLE_ITALIC, + FONT_STYLE_BOLD, + FONT_STYLE_ITALIC_BOLD, + FONT_STYLE_LAST, +} FontStyleIndex; + +typedef struct { + int index; + const QString name; +} FontStyle; + +static FontStyle font_styles[] = { + {FONT_STYLE_REGULAR, qtTrId("Regular")}, + {FONT_STYLE_ITALIC, qtTrId("Italic")}, + {FONT_STYLE_BOLD, qtTrId("Bold")}, + {FONT_STYLE_ITALIC_BOLD, qtTrId("Italic Bold")}, +}; + +static const int font_sizes[] = +{ + 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, -1 +}; + +typedef enum +{ + SUBTITLE_ENCODING_ISO_8859_6, + SUBTITLE_ENCODING_IBM_864, + SUBTITLE_ENCODING_MAC_ARABIC, + SUBTITLE_ENCODING_WINDOWS_1256, + + SUBTITLE_ENCODING_ARMSCII_8, + + SUBTITLE_ENCODING_ISO_8859_4, + SUBTITLE_ENCODING_ISO_8859_13, + SUBTITLE_ENCODING_WINDOWS_1257, + + SUBTITLE_ENCODING_ISO_8859_14, + + SUBTITLE_ENCODING_ISO_8859_2, + SUBTITLE_ENCODING_IBM_852, + SUBTITLE_ENCODING_MAC_CE, + SUBTITLE_ENCODING_WINDOWS_1250, + + SUBTITLE_ENCODING_GB18030, + SUBTITLE_ENCODING_GB2312, + SUBTITLE_ENCODING_GBK, + SUBTITLE_ENCODING_HZ, + + SUBTITLE_ENCODING_BIG5, + SUBTITLE_ENCODING_BIG5_HKSCS, + SUBTITLE_ENCODING_EUC_TW, + + SUBTITLE_ENCODING_MAC_CROATIAN, + + SUBTITLE_ENCODING_ISO_8859_5, + SUBTITLE_ENCODING_IBM_855, + SUBTITLE_ENCODING_ISO_IR_111, + SUBTITLE_ENCODING_KOI8_R, + SUBTITLE_ENCODING_MAC_CYRILLIC, + SUBTITLE_ENCODING_WINDOWS_1251, + + SUBTITLE_ENCODING_CP_866, + + SUBTITLE_ENCODING_MAC_UKRAINIAN, + SUBTITLE_ENCODING_KOI8_U, + + SUBTITLE_ENCODING_GEOSTD8, + + SUBTITLE_ENCODING_ISO_8859_7, + SUBTITLE_ENCODING_MAC_GREEK, + SUBTITLE_ENCODING_WINDOWS_1253, + + SUBTITLE_ENCODING_MAC_GUJARATI, + + SUBTITLE_ENCODING_MAC_GURMUKHI, + + SUBTITLE_ENCODING_ISO_8859_8_I, + SUBTITLE_ENCODING_IBM_862, + SUBTITLE_ENCODING_MAC_HEBREW, + SUBTITLE_ENCODING_WINDOWS_1255, + + SUBTITLE_ENCODING_ISO_8859_8, + + SUBTITLE_ENCODING_MAC_DEVANAGARI, + + SUBTITLE_ENCODING_MAC_ICELANDIC, + + SUBTITLE_ENCODING_EUC_JP, + SUBTITLE_ENCODING_ISO_2022_JP, + SUBTITLE_ENCODING_SHIFT_JIS, + + SUBTITLE_ENCODING_EUC_KR, + SUBTITLE_ENCODING_ISO_2022_KR, + SUBTITLE_ENCODING_JOHAB, + SUBTITLE_ENCODING_UHC, + + SUBTITLE_ENCODING_ISO_8859_10, + + SUBTITLE_ENCODING_MAC_FARSI, + + SUBTITLE_ENCODING_ISO_8859_16, + SUBTITLE_ENCODING_MAC_ROMANIAN, + + SUBTITLE_ENCODING_ISO_8859_3, + + SUBTITLE_ENCODING_TIS_620, + + SUBTITLE_ENCODING_ISO_8859_9, + SUBTITLE_ENCODING_IBM_857, + SUBTITLE_ENCODING_MAC_TURKISH, + SUBTITLE_ENCODING_WINDOWS_1254, + + SUBTITLE_ENCODING_UTF_7, + SUBTITLE_ENCODING_UTF_8, + SUBTITLE_ENCODING_UTF_16, + SUBTITLE_ENCODING_UCS_2, + SUBTITLE_ENCODING_UCS_4, + + SUBTITLE_ENCODING_ISO_8859_1, + SUBTITLE_ENCODING_ISO_8859_15, + SUBTITLE_ENCODING_IBM_850, + SUBTITLE_ENCODING_MAC_ROMAN, + SUBTITLE_ENCODING_WINDOWS_1252, + + SUBTITLE_ENCODING_TCVN, + SUBTITLE_ENCODING_VISCII, + SUBTITLE_ENCODING_WINDOWS_1258, + + SUBTITLE_ENCODING_CURRENT_LOCALE, + + SUBTITLE_ENCODING_LAST +} SubtitleEncodingIndex; + +typedef struct { + int index; + const QString charset; + const QString name; +} SubtitleEncoding; + +static SubtitleEncoding encodings[] = { + {SUBTITLE_ENCODING_ISO_8859_6, "ISO-8859-6", qtTrId("Arabic")}, + {SUBTITLE_ENCODING_IBM_864, "IBM864", qtTrId("Arabic")}, + {SUBTITLE_ENCODING_MAC_ARABIC, "MAC_ARABIC", qtTrId("Arabic")}, + {SUBTITLE_ENCODING_WINDOWS_1256, "WINDOWS-1256", qtTrId("Arabic")}, + + {SUBTITLE_ENCODING_ARMSCII_8, "ARMSCII-8", qtTrId("Armenian")}, + + {SUBTITLE_ENCODING_ISO_8859_4, "ISO-8859-4", qtTrId("Baltic")}, + {SUBTITLE_ENCODING_ISO_8859_13, "ISO-8859-13", qtTrId("Baltic")}, + {SUBTITLE_ENCODING_WINDOWS_1257, "WINDOWS-1257", qtTrId("Baltic")}, + + {SUBTITLE_ENCODING_ISO_8859_14, "ISO-8859-14", qtTrId("Celtic")}, + + {SUBTITLE_ENCODING_ISO_8859_2, "ISO-8859-2", qtTrId("Central European")}, + {SUBTITLE_ENCODING_IBM_852, "IBM852", qtTrId("Central European")}, + {SUBTITLE_ENCODING_MAC_CE, "MAC_CE", qtTrId("Central European")}, + {SUBTITLE_ENCODING_WINDOWS_1250, "WINDOWS-1250", qtTrId("Central European")}, + + {SUBTITLE_ENCODING_GB18030, "GB18030", qtTrId("Chinese Simplified")}, + {SUBTITLE_ENCODING_GB2312, "GB2312", qtTrId("Chinese Simplified")}, + {SUBTITLE_ENCODING_GBK, "GBK", qtTrId("Chinese Simplified")}, + {SUBTITLE_ENCODING_HZ, "HZ", qtTrId("Chinese Simplified")}, + + {SUBTITLE_ENCODING_BIG5, "BIG5", qtTrId("Chinese Traditional")}, + {SUBTITLE_ENCODING_BIG5_HKSCS, "BIG5-HKSCS", qtTrId("Chinese Traditional")}, + {SUBTITLE_ENCODING_EUC_TW, "EUC-TW", qtTrId("Chinese Traditional")}, + + {SUBTITLE_ENCODING_MAC_CROATIAN, "MAC_CROATIAN", qtTrId("Croatian")}, + + {SUBTITLE_ENCODING_ISO_8859_5, "ISO-8859-5", qtTrId("Cyrillic")}, + {SUBTITLE_ENCODING_IBM_855, "IBM855", qtTrId("Cyrillic")}, + {SUBTITLE_ENCODING_ISO_IR_111, "ISO-IR-111", qtTrId("Cyrillic")}, + {SUBTITLE_ENCODING_KOI8_R, "KOI8-R", qtTrId("Cyrillic")}, + {SUBTITLE_ENCODING_MAC_CYRILLIC, "MAC-CYRILLIC", qtTrId("Cyrillic")}, + {SUBTITLE_ENCODING_WINDOWS_1251, "WINDOWS-1251", qtTrId("Cyrillic")}, + + {SUBTITLE_ENCODING_CP_866, "CP866", qtTrId("Cyrillic/Russian")}, + + {SUBTITLE_ENCODING_MAC_UKRAINIAN, "MAC_UKRAINIAN", qtTrId("Cyrillic/Ukrainian")}, + {SUBTITLE_ENCODING_KOI8_U, "KOI8-U", qtTrId("Cyrillic/Ukrainian")}, + + {SUBTITLE_ENCODING_GEOSTD8, "GEORGIAN-PS", qtTrId("Georgian")}, + + {SUBTITLE_ENCODING_ISO_8859_7, "ISO-8859-7", qtTrId("Greek")}, + {SUBTITLE_ENCODING_MAC_GREEK, "MAC_GREEK", qtTrId("Greek")}, + {SUBTITLE_ENCODING_WINDOWS_1253, "WINDOWS-1253", qtTrId("Greek")}, + + {SUBTITLE_ENCODING_MAC_GUJARATI, "MAC_GUJARATI", qtTrId("Gujarati")}, + + {SUBTITLE_ENCODING_MAC_GURMUKHI, "MAC_GURMUKHI", qtTrId("Gurmukhi")}, + + {SUBTITLE_ENCODING_ISO_8859_8_I, "ISO-8859-8-I", qtTrId("Hebrew")}, + {SUBTITLE_ENCODING_IBM_862, "IBM862", qtTrId("Hebrew")}, + {SUBTITLE_ENCODING_MAC_HEBREW, "MAC_HEBREW", qtTrId("Hebrew")}, + {SUBTITLE_ENCODING_WINDOWS_1255, "WINDOWS-1255", qtTrId("Hebrew")}, + + {SUBTITLE_ENCODING_ISO_8859_8, "ISO-8859-8", qtTrId("Hebrew Visual")}, + + {SUBTITLE_ENCODING_MAC_DEVANAGARI, "MAC_DEVANAGARI", qtTrId("Hindi")}, + + {SUBTITLE_ENCODING_MAC_ICELANDIC, "MAC_ICELANDIC", qtTrId("Icelandic")}, + + {SUBTITLE_ENCODING_EUC_JP, "EUC-JP", qtTrId("Japanese")}, + {SUBTITLE_ENCODING_ISO_2022_JP, "ISO2022JP", qtTrId("Japanese")}, + {SUBTITLE_ENCODING_SHIFT_JIS, "SHIFT-JIS", qtTrId("Japanese")}, + + {SUBTITLE_ENCODING_EUC_KR, "EUC-KR", qtTrId("Korean")}, + {SUBTITLE_ENCODING_ISO_2022_KR, "ISO2022KR", qtTrId("Korean")}, + {SUBTITLE_ENCODING_JOHAB, "JOHAB", qtTrId("Korean")}, + {SUBTITLE_ENCODING_UHC, "UHC", qtTrId("Korean")}, + + {SUBTITLE_ENCODING_ISO_8859_10, "ISO-8859-10", qtTrId("Nordic")}, + + {SUBTITLE_ENCODING_MAC_FARSI, "MAC_FARSI", qtTrId("Persian")}, + + {SUBTITLE_ENCODING_ISO_8859_16, "ISO-8859-16", qtTrId("Romanian")}, + {SUBTITLE_ENCODING_MAC_ROMANIAN, "MAC_ROMANIAN", qtTrId("Romanian")}, + + {SUBTITLE_ENCODING_ISO_8859_3, "ISO-8859-3", qtTrId("South European")}, + + {SUBTITLE_ENCODING_TIS_620, "TIS-620", qtTrId("Thai")}, + + {SUBTITLE_ENCODING_ISO_8859_9, "ISO-8859-9", qtTrId("Turkish")}, + {SUBTITLE_ENCODING_IBM_857, "IBM857", qtTrId("Turkish")}, + {SUBTITLE_ENCODING_MAC_TURKISH, "MAC_TURKISH", qtTrId("Turkish")}, + {SUBTITLE_ENCODING_WINDOWS_1254, "WINDOWS-1254", qtTrId("Turkish")}, + + {SUBTITLE_ENCODING_UTF_7, "UTF-7", qtTrId("Unicode")}, + {SUBTITLE_ENCODING_UTF_8, "UTF-8", qtTrId("Unicode")}, + {SUBTITLE_ENCODING_UTF_16, "UTF-16", qtTrId("Unicode")}, + {SUBTITLE_ENCODING_UCS_2, "UCS-2", qtTrId("Unicode")}, + {SUBTITLE_ENCODING_UCS_4, "UCS-4", qtTrId("Unicode")}, + + {SUBTITLE_ENCODING_ISO_8859_1, "ISO-8859-1", qtTrId("Western")}, + {SUBTITLE_ENCODING_ISO_8859_15, "ISO-8859-15", qtTrId("Western")}, + {SUBTITLE_ENCODING_IBM_850, "IBM850", qtTrId("Western")}, + {SUBTITLE_ENCODING_MAC_ROMAN, "MAC_ROMAN", qtTrId("Western")}, + {SUBTITLE_ENCODING_WINDOWS_1252, "WINDOWS-1252", qtTrId("Western")}, + + {SUBTITLE_ENCODING_TCVN, "TCVN", qtTrId("Vietnamese")}, + {SUBTITLE_ENCODING_VISCII, "VISCII", qtTrId("Vietnamese")}, + {SUBTITLE_ENCODING_WINDOWS_1258, "WINDOWS-1258", qtTrId("Vietnamese")}, + + {SUBTITLE_ENCODING_CURRENT_LOCALE, NULL, qtTrId("Current Locale")} +}; + +/****************************************************************************** + * SubtitlesWidget implementation. + */ +SubtitlesWidget::SubtitlesWidget (QGraphicsWidget *parent) : + DcpStylableWidget (parent), + m_MainLayout (0), + m_TitleLabel (0), + m_AutoloadSubtitlesSwitch (0), + m_FontStyleLabel (0), + m_RegularStyleButton (0), + m_ItalicStyleButton (0), + m_BoldStyleButton (0), + m_SubtitlesFontSizeCombo (0), + m_SubtitlesEncodingCombo (0), + m_SubtitlesSettings (0) +{ + m_SubtitlesSettings = new QSettings (RENDERER_PLUGIN_CONFIG_FILE, QSettings::NativeFormat); + m_SubtitlesSettings->beginGroup ("pipeline"); + + setContentsMargins (0.0, 0.0, 0.0, 0.0); + + initWidget (); +} + +SubtitlesWidget::~SubtitlesWidget () +{ +} + +bool +SubtitlesWidget::back () +{ + return true; // back is handled by main window by default +} + +void +SubtitlesWidget::initWidget () +{ + MLayout *layout; + int index = 0; + + layout = new MLayout (this); + m_MainLayout = new MLinearLayoutPolicy (layout, Qt::Vertical); + m_MainLayout->setContentsMargins (0.0, 0.0, 0.0, 0.0); + m_MainLayout->setSpacing (0.0); + setLayout (layout); + + addHeaderContainer (); + + addAutoloadSubtitlesContainer (); + addSubtitlesFontStyleContainer (); + addSubtitlesFontSizeContainer (); + addSubtitlesEncodingContainer (); + + m_MainLayout->addStretch (); + + bool autoload_subtitles = m_SubtitlesSettings->value ("autoload_subtitles").toBool (); + m_AutoloadSubtitlesSwitch->setChecked (autoload_subtitles); + + QString subtitle_font = m_SubtitlesSettings->value ("subtitle_font").toString (); + PangoFontDescription *font_desc = pango_font_description_from_string ((const char *) subtitle_font.toAscii().data()); + if (font_desc) { + index = 0; + while (font_sizes[index] != -1) { + if (font_sizes[index] == (pango_font_description_get_size (font_desc) / PANGO_SCALE)) { + m_SubtitlesFontSizeCombo->setCurrentIndex (index); + break; + } + index++; + } + + PangoStyle font_style = pango_font_description_get_style (font_desc); + if (font_style == PANGO_STYLE_NORMAL) + m_RegularStyleButton->setChecked (true); + else + m_ItalicStyleButton->setChecked (true); + + PangoWeight font_weight = pango_font_description_get_weight (font_desc); + if (font_weight == PANGO_WEIGHT_BOLD) + m_BoldStyleButton->setChecked (true); + else + m_BoldStyleButton->setChecked (false); + + pango_font_description_free (font_desc); + } + + QString subtitle_encoding = m_SubtitlesSettings->value ("subtitle_encoding").toString (); + index = 0; + while (index < SUBTITLE_ENCODING_LAST) { + if (encodings[index].charset == subtitle_encoding) { + m_SubtitlesEncodingCombo->setCurrentIndex (index); + break; + } + index++; + } +} + +void +SubtitlesWidget::addHeaderContainer () +{ + QGraphicsLinearLayout *layout; + + Q_ASSERT (m_MainLayout); + + layout = new QGraphicsLinearLayout (Qt::Horizontal); + layout->setContentsMargins (0.0, 0.0, 0.0, 0.0); + + m_TitleLabel = new MLabel (qtTrId ("Subtitles")); + m_TitleLabel->setStyleName ("CommonHeaderInverted"); + layout->addItem (m_TitleLabel); + layout->setAlignment (m_TitleLabel, Qt::AlignLeft); + + m_MainLayout->addItem (layout); + m_MainLayout->setStretchFactor (layout, 0); +} + +void +SubtitlesWidget::addAutoloadSubtitlesContainer () +{ + MContainer *container; + QGraphicsLinearLayout *layout; + + Q_ASSERT (m_MainLayout); + + container = new MContainer (this); + container->setContentsMargins (0,0,0,0); + container->setStyleName ("CommonLargePanelInverted"); + container->setHeaderVisible (false); + + layout = new QGraphicsLinearLayout (Qt::Horizontal); + layout->setContentsMargins (0,0,0,0); + layout->setSpacing (0); + container->centralWidget()->setLayout (layout); + + MLabel *label = new MLabel; + label->setWordWrap (true); + label->setStyleName ("CommonSingleTitleInverted"); + label->setText (qtTrId ("Automatically load subtitles")); + layout->addItem (label); + layout->setAlignment (label, Qt::AlignVCenter); + + m_AutoloadSubtitlesSwitch = new MButton; + m_AutoloadSubtitlesSwitch->setCheckable (true); + m_AutoloadSubtitlesSwitch->setViewType (MButton::switchType); + m_AutoloadSubtitlesSwitch->setStyleName ("CommonRightSwitchInverted"); + + connect (m_AutoloadSubtitlesSwitch, SIGNAL (toggled (bool)), + this, SLOT (AutoloadSubtitlesToggled (bool))); + + layout->addItem (m_AutoloadSubtitlesSwitch); + layout->setAlignment (m_AutoloadSubtitlesSwitch, Qt::AlignVCenter | Qt::AlignRight); + + m_MainLayout->addItem (container); + m_MainLayout->setStretchFactor (container, 0); +} + +void +SubtitlesWidget::addSubtitlesFontStyleContainer () +{ + MContainer *container; + QGraphicsLinearLayout *layout; + MLayout *buttonGroup; + MLinearLayoutPolicy *buttonGroupLayout; + MSeparator *spacer; + + Q_ASSERT (m_MainLayout); + + container = new MContainer (this); + container->setContentsMargins (0,0,0,0); + container->setStyleName ("CommonLargePanelInverted"); + container->setHeaderVisible (false); + + layout = new QGraphicsLinearLayout (Qt::Vertical); + layout->setContentsMargins (0, 0, 0, 0); + layout->setSpacing (0.0); + container->centralWidget()->setLayout (layout); + + m_FontStyleLabel = new MLabel (qtTrId ("Font style")); + m_FontStyleLabel->setStyleName ("CommonTitleInverted"); + + layout->addItem (m_FontStyleLabel); + layout->setAlignment (m_FontStyleLabel, Qt::AlignLeft); + + spacer = new MSeparator; + spacer->setStyleName ("CommonSpacer"); + layout->addItem (spacer); + + buttonGroup = new MLayout; + buttonGroupLayout = new MLinearLayoutPolicy (buttonGroup, Qt::Horizontal); + buttonGroupLayout->setNotifyWidgetsOfLayoutPositionEnabled (true); + buttonGroupLayout->setContentsMargins (14, 0, 14, 0); + buttonGroupLayout->setSpacing (0.0); + + m_RegularStyleButton = new MButton (); + m_RegularStyleButton->setCheckable (true); + m_RegularStyleButton->setViewType (MButton::groupType); + m_RegularStyleButton->setText (font_styles[0].name); + buttonGroupLayout->addItem (m_RegularStyleButton); + + connect (m_RegularStyleButton, SIGNAL (toggled (bool)), + this, SLOT (RegularStyleButtonToggled (bool))); + + m_ItalicStyleButton = new MButton (); + m_ItalicStyleButton->setCheckable (true); + m_ItalicStyleButton->setViewType (MButton::groupType); + m_ItalicStyleButton->setText (font_styles[1].name); + buttonGroupLayout->addItem (m_ItalicStyleButton); + + connect (m_ItalicStyleButton, SIGNAL (toggled (bool)), + this, SLOT (ItalicStyleButtonToggled (bool))); + + m_BoldStyleButton = new MButton (); + m_BoldStyleButton->setCheckable (true); + m_BoldStyleButton->setViewType (MButton::groupType); + m_BoldStyleButton->setText (font_styles[2].name); + buttonGroupLayout->addItem (m_BoldStyleButton); + + connect (m_BoldStyleButton, SIGNAL (toggled (bool)), + this, SLOT (BoldStyleButtonToggled (bool))); + + layout->addItem (buttonGroup); + layout->setAlignment(buttonGroup, Qt::AlignLeft); + + spacer = new MSeparator; + spacer->setStyleName ("CommonXLargeSpacer"); + layout->addItem (spacer); + + m_MainLayout->addItem (container); + m_MainLayout->setStretchFactor (container, 0); +} + +void +SubtitlesWidget::addSubtitlesFontSizeContainer () +{ + int index = 0; + + m_SubtitlesFontSizeCombo = new MComboBox(); + m_SubtitlesFontSizeCombo->setTitle(qtTrId ("Font size")); + m_SubtitlesFontSizeCombo->setStyleName ("CommonComboBoxInverted"); + + while (font_sizes[index] != -1) { + m_SubtitlesFontSizeCombo->addItem(QString::number(font_sizes[index])); + index++; + } + + connect (m_SubtitlesFontSizeCombo, SIGNAL (activated (int)), + this, SLOT (SubtitlesFontSizeActivated (int))); + + m_MainLayout->addItem (m_SubtitlesFontSizeCombo); + m_MainLayout->setStretchFactor (m_SubtitlesFontSizeCombo, 0); +} + +void +SubtitlesWidget::addSubtitlesEncodingContainer () +{ + int index = 0; + + m_SubtitlesEncodingCombo = new MComboBox(); + m_SubtitlesEncodingCombo->setTitle(qtTrId ("Encoding")); + m_SubtitlesEncodingCombo->setStyleName ("CommonComboBoxInverted"); + + while (index < SUBTITLE_ENCODING_LAST) { + if (encodings[index].charset.isNull()) { + m_SubtitlesEncodingCombo->addItem(encodings[index].name); + } else { + m_SubtitlesEncodingCombo->addItem(QString("%1 (%2)").arg(encodings[index].name) + .arg(encodings[index].charset)); + } + index++; + } + + connect (m_SubtitlesEncodingCombo, SIGNAL (activated (int)), + this, SLOT (SubtitlesEncodingActivated (int))); + + m_MainLayout->addItem (m_SubtitlesEncodingCombo); + m_MainLayout->setStretchFactor (m_SubtitlesEncodingCombo, 0); +} + +void +SubtitlesWidget::retranslateUi () +{ + if (m_TitleLabel) + m_TitleLabel->setText (qtTrId("Subtitles")); +} + +void +SubtitlesWidget::AutoloadSubtitlesToggled (bool enabled) +{ + m_SubtitlesSettings->setValue ("autoload_subtitles", enabled); +} + +void +SubtitlesWidget::RegularStyleButtonToggled (bool toggled) +{ + if (toggled) { + if (m_ItalicStyleButton->isChecked ()) + m_ItalicStyleButton->setChecked (false); + } else { + m_ItalicStyleButton->setChecked (true); + } + + QString subtitle_font = m_SubtitlesSettings->value ("subtitle_font").toString (); + PangoFontDescription *font_desc = pango_font_description_from_string ( + (const char *) subtitle_font.toAscii().data()); + if (font_desc) { + if (toggled) { + pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL); + } else { + pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC); + } + + m_SubtitlesSettings->setValue ("subtitle_font", pango_font_description_to_string (font_desc)); + pango_font_description_free (font_desc); + } +} + +void +SubtitlesWidget::ItalicStyleButtonToggled (bool toggled) +{ + if (toggled) { + if (m_RegularStyleButton->isChecked ()) + m_RegularStyleButton->setChecked (false); + } else { + m_RegularStyleButton->setChecked (true); + } + + QString subtitle_font = m_SubtitlesSettings->value ("subtitle_font").toString (); + PangoFontDescription *font_desc = pango_font_description_from_string ( + (const char *) subtitle_font.toAscii().data()); + if (font_desc) { + if (toggled) { + pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC); + } else { + pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL); + } + + m_SubtitlesSettings->setValue ("subtitle_font", pango_font_description_to_string (font_desc)); + pango_font_description_free (font_desc); + } +} + +void +SubtitlesWidget::BoldStyleButtonToggled (bool toggled) +{ + QString subtitle_font = m_SubtitlesSettings->value ("subtitle_font").toString (); + PangoFontDescription *font_desc = pango_font_description_from_string ( + (const char *) subtitle_font.toAscii().data()); + if (font_desc) { + if (toggled) { + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); + } else { + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL); + } + + m_SubtitlesSettings->setValue ("subtitle_font", pango_font_description_to_string (font_desc)); + pango_font_description_free (font_desc); + } +} + +void +SubtitlesWidget::SubtitlesFontSizeActivated (int index) +{ + QString subtitle_font = m_SubtitlesSettings->value ("subtitle_font").toString (); + PangoFontDescription *font_desc = pango_font_description_from_string ( + (const char *) subtitle_font.toAscii().data()); + if (font_desc) { + if (pango_font_description_get_size (font_desc) != (font_sizes[index] * PANGO_SCALE)) { + pango_font_description_set_size (font_desc, font_sizes[index] * PANGO_SCALE); + m_SubtitlesSettings->setValue ("subtitle_font", pango_font_description_to_string (font_desc)); + } + pango_font_description_free (font_desc); + } +} + +void +SubtitlesWidget::SubtitlesEncodingActivated (int index) +{ + m_SubtitlesSettings->setValue ("subtitle_encoding", encodings[index].charset); +} diff --git a/qmafw-gst-subtitles-renderer/applet/subtitleswidget.h b/qmafw-gst-subtitles-renderer/applet/subtitleswidget.h new file mode 100644 index 0000000..3ea5b78 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/subtitleswidget.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of meegotouch-controlpanelapplets. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#ifndef SUBTITLESWIDGET_H +#define SUBTITLESWIDGET_H + +#include +#include + +class MButton; +class MComboBox; +class MLabel; +class MLayout; +class MLinearLayoutPolicy; +class MContainer; + +class SubtitlesWidget : public DcpStylableWidget +{ + Q_OBJECT + +public: + SubtitlesWidget (QGraphicsWidget *parent = 0); + ~SubtitlesWidget (); + bool back (); + +protected: + void initWidget(); + +private slots: + void AutoloadSubtitlesToggled (bool enabled); + void RegularStyleButtonToggled (bool toggled); + void ItalicStyleButtonToggled (bool toggled); + void BoldStyleButtonToggled (bool toggled); + void SubtitlesFontSizeActivated (int index); + void SubtitlesEncodingActivated (int index); + +private: + void addHeaderContainer (); + void addAutoloadSubtitlesContainer (); + void addSubtitlesFontStyleContainer (); + void addSubtitlesFontSizeContainer (); + void addSubtitlesEncodingContainer (); + + void retranslateUi (); + +private: + MLinearLayoutPolicy *m_MainLayout; + MLabel *m_TitleLabel; + MButton *m_AutoloadSubtitlesSwitch; + MLabel *m_FontStyleLabel; + MButton *m_RegularStyleButton; + MButton *m_ItalicStyleButton; + MButton *m_BoldStyleButton; + MComboBox *m_SubtitlesFontSizeCombo; + MComboBox *m_SubtitlesEncodingCombo; + QSettings *m_SubtitlesSettings; +}; + +#endif // SUBTITLESWIDGET_H diff --git a/qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.qm b/qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.qm new file mode 100644 index 0000000000000000000000000000000000000000..6657a288a50af92d8531322de6f1c5b424c8f98d GIT binary patch literal 80 zcmcE7ks@*G{hX<16=n7(EZlq7iGhKE1Be-cm?0C0)tP~W5JNCSDMJ!N2~ennA%`KA Vp%|oyfel2kg9yeBAi>1Q2mmBK4iEqU literal 0 HcmV?d00001 diff --git a/qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.ts b/qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.ts new file mode 100644 index 0000000..df9d544 --- /dev/null +++ b/qmafw-gst-subtitles-renderer/applet/translations/subtitlesapplet_en.ts @@ -0,0 +1,252 @@ + + + + + + + + + + + Subtitles + + + + + Regular + + + + + Italic + + + + + Bold + + + + + Italic Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Automatically load subtitles + + + + + + + + + + Font size + + + + + Encoding + + + diff --git a/qmafw-gst-subtitles-renderer/qmafw-gst-subtitles-renderer.pro b/qmafw-gst-subtitles-renderer/qmafw-gst-subtitles-renderer.pro index 05636b4..a8fed95 100644 --- a/qmafw-gst-subtitles-renderer/qmafw-gst-subtitles-renderer.pro +++ b/qmafw-gst-subtitles-renderer/qmafw-gst-subtitles-renderer.pro @@ -34,6 +34,8 @@ LIBS += -lgstinterfaces-0.10 -lgstpbutils-0.10 -ldbus-qeventloop -ltotem-plpars DEPENDPATH += . inc src INCLUDEPATH += . inc $$system(pkg-config --variable=includedir qmafw) +SUBDIRS += applet + #DEFINES += QT_NO_DEBUG_OUTPUT QMAKE_CXXFLAGS += -Wall -Werror -- 1.7.9.5