diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/lupdate/qdeclarative.cpp | 84 | ||||
-rw-r--r-- | tools/qdoc3/test/qdeclarative.qdocconf | 4 | ||||
-rw-r--r-- | tools/qml/deviceorientation_maemo5.cpp (renamed from tools/qml/deviceorientation_maemo.cpp) | 2 | ||||
-rw-r--r-- | tools/qml/loggerwidget.cpp | 25 | ||||
-rw-r--r-- | tools/qml/loggerwidget.h | 12 | ||||
-rw-r--r-- | tools/qml/main.cpp | 2 | ||||
-rw-r--r-- | tools/qml/proxysettings.cpp | 5 | ||||
-rw-r--r-- | tools/qml/proxysettings.h | 4 | ||||
-rw-r--r-- | tools/qml/proxysettings_maemo5.ui | 177 | ||||
-rw-r--r-- | tools/qml/qdeclarativetester.h | 3 | ||||
-rw-r--r-- | tools/qml/qml.pri | 10 | ||||
-rw-r--r-- | tools/qml/qml.pro | 3 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 513 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 33 | ||||
-rw-r--r-- | tools/qml/recopts_maemo5.ui | 254 | ||||
-rw-r--r-- | tools/qml/texteditautoresizer_maemo5.h | 113 |
16 files changed, 995 insertions, 249 deletions
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp index a734e99..2377416 100644 --- a/tools/linguist/lupdate/qdeclarative.cpp +++ b/tools/linguist/lupdate/qdeclarative.cpp @@ -87,27 +87,31 @@ protected: virtual void endVisit(AST::CallExpression *node) { + m_bSource.clear(); if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) { if (idExpr->name->asString() == QLatin1String("qsTr") || idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) { - if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) { - AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression); - const QString source = literal->value->asString(); + if (!node->arguments) + return; + AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(node->arguments->expression); + if (binary) { + if (!createString(binary)) + m_bSource.clear(); + } + AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression); + if (literal || !m_bSource.isEmpty()) { + const QString source = literal ? literal->value->asString() : m_bSource; QString comment; bool plural = false; AST::ArgumentList *commentNode = node->arguments->next; - if (commentNode) { + if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) { literal = AST::cast<AST::StringLiteral *>(commentNode->expression); comment = literal->value->asString(); AST::ArgumentList *nNode = commentNode->next; - if (nNode) { - AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression); - if (numLiteral) { - plural = true; - } - } + if (nNode) + plural = true; } TranslatorMessage msg(m_component, source, @@ -126,22 +130,25 @@ protected: QString comment; bool plural = false; AST::ArgumentList *sourceNode = node->arguments->next; - if (sourceNode) { - literal = AST::cast<AST::StringLiteral *>(sourceNode->expression); - source = literal->value->asString(); - AST::ArgumentList *commentNode = sourceNode->next; - if (commentNode) { - literal = AST::cast<AST::StringLiteral *>(commentNode->expression); - comment = literal->value->asString(); - - AST::ArgumentList *nNode = commentNode->next; - if (nNode) { - AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression); - if (numLiteral) { - plural = true; - } - } - } + if (!sourceNode) + return; + literal = AST::cast<AST::StringLiteral *>(sourceNode->expression); + AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(sourceNode->expression); + if (binary) { + if (!createString(binary)) + m_bSource.clear(); + } + if (!literal && m_bSource.isEmpty()) + return; + source = literal ? literal->value->asString() : m_bSource; + AST::ArgumentList *commentNode = sourceNode->next; + if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) { + literal = AST::cast<AST::StringLiteral *>(commentNode->expression); + comment = literal->value->asString(); + + AST::ArgumentList *nNode = commentNode->next; + if (nNode) + plural = true; } TranslatorMessage msg(context, source, @@ -156,9 +163,34 @@ protected: } private: + bool createString(AST::BinaryExpression *b) { + if (!b || b->op != 0) + return false; + AST::BinaryExpression *l = AST::cast<AST::BinaryExpression *>(b->left); + AST::BinaryExpression *r = AST::cast<AST::BinaryExpression *>(b->right); + AST::StringLiteral *ls = AST::cast<AST::StringLiteral *>(b->left); + AST::StringLiteral *rs = AST::cast<AST::StringLiteral *>(b->right); + if ((!l && !ls) || (!r && !rs)) + return false; + if (l) { + if (!createString(l)) + return false; + } else + m_bSource.prepend(ls->value->asString()); + + if (r) { + if (!createString(r)) + return false; + } else + m_bSource.append(rs->value->asString()); + + return true; + } + Translator *m_translator; QString m_fileName; QString m_component; + QString m_bSource; }; QString createErrorString(const QString &filename, const QString &code, Parser &parser) diff --git a/tools/qdoc3/test/qdeclarative.qdocconf b/tools/qdoc3/test/qdeclarative.qdocconf index 74fd802..0433c9f 100644 --- a/tools/qdoc3/test/qdeclarative.qdocconf +++ b/tools/qdoc3/test/qdeclarative.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qml description = Qml Reference Documentation -url = http://qt.nokia.com/doc/4.6/ +url = http://qt.nokia.com/doc/4.7/ qmlonly = true edition.Console.modules = QtCore QtDBus QtNetwork QtScript QtSql QtXml \ @@ -21,7 +21,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qml qhp.Qml.file = qml.qhp -qhp.Qml.namespace = com.trolltech.qml.460 +qhp.Qml.namespace = com.trolltech.qml.470 qhp.Qml.virtualFolder = qdoc qhp.Qml.indexTitle = Qml Reference diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo5.cpp index 443edc8..e942579 100644 --- a/tools/qml/deviceorientation_maemo.cpp +++ b/tools/qml/deviceorientation_maemo5.cpp @@ -124,4 +124,4 @@ DeviceOrientation* DeviceOrientation::instance() return o; } -#include "deviceorientation_maemo.moc" +#include "deviceorientation_maemo5.moc" diff --git a/tools/qml/loggerwidget.cpp b/tools/qml/loggerwidget.cpp index 3ae2b5e..8aa029f 100644 --- a/tools/qml/loggerwidget.cpp +++ b/tools/qml/loggerwidget.cpp @@ -39,29 +39,48 @@ ** ****************************************************************************/ -#include "loggerwidget.h" #include <qglobal.h> #include <QDebug> #include <QSettings> #include <QActionGroup> #include <QMenu> +#include <QPlainTextEdit> +#ifdef Q_WS_MAEMO_5 +# include <QScrollArea> +# include <QVBoxLayout> +# include "texteditautoresizer_maemo5.h" +#endif + +#include "loggerwidget.h" QT_BEGIN_NAMESPACE LoggerWidget::LoggerWidget(QWidget *parent) : - QPlainTextEdit(parent), + QMainWindow(parent), m_visibilityOrigin(SettingsOrigin) { setAttribute(Qt::WA_QuitOnClose, false); setWindowTitle(tr("Warnings")); + m_plainTextEdit = new QPlainTextEdit(); + +#ifdef Q_WS_MAEMO_5 + new TextEditAutoResizer(m_plainTextEdit); + setAttribute(Qt::WA_Maemo5StackedWindow); + QScrollArea *area = new QScrollArea(); + area->setWidget(m_plainTextEdit); + area->setWidgetResizable(true); + setCentralWidget(area); +#else + setCentralWidget(m_plainTextEdit); +#endif readSettings(); setupPreferencesMenu(); } void LoggerWidget::append(const QString &msg) { - appendPlainText(msg); + m_plainTextEdit->appendPlainText(msg); if (!isVisible() && (defaultVisibility() == AutoShowWarnings)) setVisible(true); diff --git a/tools/qml/loggerwidget.h b/tools/qml/loggerwidget.h index fd20c41..13c319f 100644 --- a/tools/qml/loggerwidget.h +++ b/tools/qml/loggerwidget.h @@ -42,12 +42,17 @@ #ifndef LOGGERWIDGET_H #define LOGGERWIDGET_H -#include <QPlainTextEdit> +#include <QMainWindow> +#include <QMetaType> QT_BEGIN_NAMESPACE -class LoggerWidget : public QPlainTextEdit { -Q_OBJECT +class QPlainTextEdit; +class QMenu; +class QAction; + +class LoggerWidget : public QMainWindow { + Q_OBJECT public: LoggerWidget(QWidget *parent=0); @@ -80,6 +85,7 @@ private: QMenu *m_preferencesMenu; QAction *m_showWidgetAction; + QPlainTextEdit *m_plainTextEdit; enum ConfigOrigin { CommandLineOrigin, SettingsOrigin }; ConfigOrigin m_visibilityOrigin; diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index a75023b..900a464 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -119,7 +119,7 @@ void usage() qWarning(" -fullscreen............................... run fullscreen"); qWarning(" -stayontop................................ keep viewer window on top"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); - qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); + qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); qWarning(" -warnings [show|hide]..................... show warnings in a separate log window"); qWarning(" -recordfile <output> ..................... set video recording file"); diff --git a/tools/qml/proxysettings.cpp b/tools/qml/proxysettings.cpp index 3255e42..ffaa4c0 100644 --- a/tools/qml/proxysettings.cpp +++ b/tools/qml/proxysettings.cpp @@ -48,11 +48,14 @@ QT_BEGIN_NAMESPACE ProxySettings::ProxySettings (QWidget * parent) - : QDialog (parent), Ui::ProxySettings() + : QDialog (parent), Ui::ProxySettings() { setupUi (this); +#if !defined Q_WS_MAEMO_5 + // the onscreen keyboard can't cope with masks proxyServerEdit->setInputMask ("000.000.000.000;_"); +#endif QIntValidator *validator = new QIntValidator (0, 9999, this); proxyPortEdit->setValidator (validator); diff --git a/tools/qml/proxysettings.h b/tools/qml/proxysettings.h index 325929a..5d4d137 100644 --- a/tools/qml/proxysettings.h +++ b/tools/qml/proxysettings.h @@ -44,7 +44,11 @@ #include <QDialog> #include <QNetworkProxy> +#ifdef Q_WS_MAEMO_5 +#include "ui_proxysettings_maemo5.h" +#else #include "ui_proxysettings.h" +#endif QT_BEGIN_NAMESPACE /** diff --git a/tools/qml/proxysettings_maemo5.ui b/tools/qml/proxysettings_maemo5.ui new file mode 100644 index 0000000..83f0c2a --- /dev/null +++ b/tools/qml/proxysettings_maemo5.ui @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ProxySettings</class> + <widget class="QDialog" name="ProxySettings"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>449</width> + <height>164</height> + </rect> + </property> + <property name="windowTitle"> + <string>HTTP Proxy</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>16</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>16</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <property name="horizontalSpacing"> + <number>16</number> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QCheckBox" name="proxyCheckBox"> + <property name="text"> + <string>Use HTTP Proxy</string> + </property> + </widget> + </item> + <item row="0" column="1" rowspan="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" rowspan="2"> + <widget class="QWidget" name="widget" native="true"> + <layout class="QGridLayout" name="gridLayout"> + <property name="horizontalSpacing"> + <number>16</number> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="serverAddressLabel"> + <property name="text"> + <string>Server</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="proxyServerEdit"> + <property name="placeholderText"> + <string>Name or IP</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Port</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="proxyPortEdit"> + <property name="text"> + <string>8080</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="usernameLabel"> + <property name="text"> + <string>Username</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="usernameEdit"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="passwordLabel"> + <property name="text"> + <string>Password</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="passwordEdit"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>proxyCheckBox</tabstop> + <tabstop>proxyServerEdit</tabstop> + <tabstop>proxyPortEdit</tabstop> + <tabstop>usernameEdit</tabstop> + <tabstop>passwordEdit</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>ProxySettings</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>318</x> + <y>100</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>116</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ProxySettings</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>318</x> + <y>100</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>116</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/qml/qdeclarativetester.h b/tools/qml/qdeclarativetester.h index d49c9b8..021869d 100644 --- a/tools/qml/qdeclarativetester.h +++ b/tools/qml/qdeclarativetester.h @@ -48,6 +48,9 @@ #include <QImage> #include <QUrl> #include <qmlruntime.h> +#include <qdeclarativelist.h> +#include <qdeclarative.h> +#include <QAbstractAnimation> QT_BEGIN_NAMESPACE diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 58d8cc1..3e5a88b 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -19,10 +19,12 @@ SOURCES += $$PWD/qmlruntime.cpp \ RESOURCES = $$PWD/qmlruntime.qrc maemo5 { QT += dbus - SOURCES += $$PWD/deviceorientation_maemo.cpp + HEADERS += $$PWD/texteditautoresizer_maemo5.h + SOURCES += $$PWD/deviceorientation_maemo5.cpp + FORMS = $$PWD/recopts_maemo5.ui \ + $$PWD/proxysettings_maemo5.ui } else { SOURCES += $$PWD/deviceorientation.cpp + FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui } - -FORMS = $$PWD/recopts.ui \ - $$PWD/proxysettings.ui diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 9cdec77..63efff1 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -29,6 +29,9 @@ wince* { QT += webkit } } +maemo5 { + QT += maemo5 +} symbian { TARGET.UID3 = 0x20021317 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 676881d..debc902 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -44,15 +44,23 @@ #ifdef hz #undef hz #endif -#include "ui_recopts.h" +#ifdef Q_WS_MAEMO_5 +# include <QMaemo5ValueButton> +# include <QMaemo5ListPickSelector> +# include <QWidgetAction> +# include <QStringListModel> +# include "ui_recopts_maemo5.h" +#else +# include "ui_recopts.h" +#endif #include "qmlruntime.h" #include <qdeclarativecontext.h> #include <qdeclarativeengine.h> #include <qdeclarativenetworkaccessmanagerfactory.h> #include "qdeclarative.h" -#include <private/qabstractanimation_p.h> #include <QAbstractAnimation> +#include <private/qabstractanimation_p.h> #include <QSettings> #include <QXmlStreamReader> @@ -136,24 +144,59 @@ private: }; -class SizedMenuBar : public QMenuBar -{ + +#if defined(Q_WS_MAEMO_5) + +class Maemo5PickerAction : public QWidgetAction { Q_OBJECT public: - SizedMenuBar(QWidget *parent, QWidget *referenceWidget) - : QMenuBar(parent), refWidget(referenceWidget) + Maemo5PickerAction(const QString &text, QActionGroup *actions, QObject *parent) + : QWidgetAction(parent), m_text(text), m_actions(actions) + { } + + QWidget *createWidget(QWidget *parent) { + QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent); + button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered); + QMaemo5ListPickSelector *pick = new QMaemo5ListPickSelector(button); + button->setPickSelector(pick); + if (m_actions) { + QStringList sl; + int curIdx = -1, idx = 0; + foreach (QAction *a, m_actions->actions()) { + sl << a->text(); + if (a->isChecked()) + curIdx = idx; + idx++; + } + pick->setModel(new QStringListModel(sl)); + pick->setCurrentIndex(curIdx); + } else { + button->setEnabled(false); + } + connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered())); + return button; } - virtual QSize sizeHint() const +private slots: + void emitTriggered() { - return QSize(refWidget->sizeHint().width(), QMenuBar::sizeHint().height()); + QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender()); + if (!pick) + return; + int idx = pick->currentIndex(); + + if (m_actions && idx >= 0 && idx < m_actions->actions().count()) + m_actions->actions().at(idx)->trigger(); } private: - QWidget *refWidget; + QString m_text; + QPointer<QActionGroup> m_actions; }; +#endif // Q_WS_MAEMO_5 + static struct { const char *name, *args; } ffmpegprofiles[] = { {"Maximum Quality", "-sameq"}, {"High Quality", "-qmax 2"}, @@ -170,7 +213,9 @@ public: RecordingDialog(QWidget *parent) : QDialog(parent) { setupUi(this); +#ifndef Q_WS_MAEMO_5 hz->setValidator(new QDoubleValidator(hz)); +#endif for (int i=0; ffmpegprofiles[i].name; ++i) { profile->addItem(ffmpegprofiles[i].name); } @@ -197,6 +242,132 @@ public: return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs; } + void setOriginalSize(const QSize &s) + { + QString str = tr("Original (%1x%2)").arg(s.width()).arg(s.height()); + +#ifdef Q_WS_MAEMO_5 + sizeCombo->setItemText(0, str); +#else + sizeOriginal->setText(str); + if (sizeWidth->value()<=1) { + sizeWidth->setValue(s.width()); + sizeHeight->setValue(s.height()); + } +#endif + } + + void showffmpegOptions(bool b) + { +#ifdef Q_WS_MAEMO_5 + profileLabel->setVisible(b); + profile->setVisible(b); + ffmpegHelp->setVisible(b); + args->setVisible(b); +#else + ffmpegOptions->setVisible(b); +#endif + } + + void showRateOptions(bool b) + { +#ifdef Q_WS_MAEMO_5 + rateLabel->setVisible(b); + rateCombo->setVisible(b); +#else + rateOptions->setVisible(b); +#endif + } + + void setVideoRate(int rate) + { +#ifdef Q_WS_MAEMO_5 + int idx; + if (rate >= 60) + idx = 0; + else if (rate >= 50) + idx = 2; + else if (rate >= 25) + idx = 3; + else if (rate >= 24) + idx = 4; + else if (rate >= 20) + idx = 5; + else if (rate >= 15) + idx = 6; + else + idx = 7; + rateCombo->setCurrentIndex(idx); +#else + if (rate == 24) + hz24->setChecked(true); + else if (rate == 25) + hz25->setChecked(true); + else if (rate == 50) + hz50->setChecked(true); + else if (rate == 60) + hz60->setChecked(true); + else { + hzCustom->setChecked(true); + hz->setText(QString::number(rate)); + } +#endif + } + + int videoRate() const + { +#ifdef Q_WS_MAEMO_5 + switch (rateCombo->currentIndex()) { + case 0: return 60; + case 1: return 50; + case 2: return 25; + case 3: return 24; + case 4: return 20; + case 5: return 15; + case 7: return 10; + default: return 60; + } +#else + if (hz24->isChecked()) + return 24; + else if (hz25->isChecked()) + return 25; + else if (hz50->isChecked()) + return 50; + else if (hz60->isChecked()) + return 60; + else { + return hz->text().toInt(); + } +#endif + } + + QSize videoSize() const + { +#ifdef Q_WS_MAEMO_5 + switch (sizeCombo->currentIndex()) { + case 0: return QSize(); + case 1: return QSize(640,480); + case 2: return QSize(320,240); + case 3: return QSize(1280,720); + default: return QSize(); + } +#else + if (sizeOriginal->isChecked()) + return QSize(); + else if (size720p->isChecked()) + return QSize(1280,720); + else if (sizeVGA->isChecked()) + return QSize(640,480); + else if (sizeQVGA->isChecked()) + return QSize(320,240); + else + return QSize(sizeWidth->value(), sizeHeight->value()); +#endif + } + + + private slots: void pickProfile(int i) { @@ -363,15 +534,10 @@ QString QDeclarativeViewer::getVideoFileName() return QFileDialog::getSaveFileName(this, title, "", types.join(";; ")); } - QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) -#if defined(Q_OS_SYMBIAN) : QMainWindow(parent, flags) -#else - : QWidget(parent, flags) -#endif - , loggerWindow(new LoggerWidget()) - , frame_stream(0), mb(0) + , loggerWindow(new LoggerWidget(this)) + , frame_stream(0) , orientation(0) , showWarningsWindow(0) , m_scriptOptions(0) @@ -381,6 +547,10 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) { QDeclarativeViewer::registerTypes(); setWindowTitle(tr("Qt QML Viewer")); +#ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5StackedWindow); +// setPalette(QApplication::palette("QLabel")); +#endif devicemode = false; canvas = 0; @@ -393,9 +563,9 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) senseFfmpeg(); senseImageMagick(); if (!ffmpegAvailable) - recdlg->ffmpegOptions->hide(); + recdlg->showffmpegOptions(false); if (!ffmpegAvailable && !convertAvailable) - recdlg->rateOptions->hide(); + recdlg->showRateOptions(false); QString warn; if (!ffmpegAvailable) { if (!convertAvailable) @@ -422,33 +592,27 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed())); if (!(flags & Qt::FramelessWindowHint)) { - createMenu(menuBar(),0); + createMenu(); changeOrientation(orientation->actions().value(0)); + } else { + setMenuBar(0); } -#if !defined(Q_OS_SYMBIAN) - QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - setLayout(layout); - if (mb) - layout->addWidget(mb); - layout->addWidget(canvas); -#else setCentralWidget(canvas); -#endif + namFactory = new NetworkAccessManagerFactory; canvas->engine()->setNetworkAccessManagerFactory(namFactory); - connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording())); - connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording())); - connect(&recordTimer, SIGNAL(triggered()), this, SLOT(recordFrame())); + connect(&autoStartTimer, SIGNAL(timeout()), this, SLOT(autoStartRecording())); + connect(&autoStopTimer, SIGNAL(timeout()), this, SLOT(autoStopRecording())); + connect(&recordTimer, SIGNAL(timeout()), this, SLOT(recordFrame())); connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), this, SLOT(orientationChanged()), Qt::QueuedConnection); - autoStartTimer.setRunning(false); - autoStopTimer.setRunning(false); - recordTimer.setRunning(false); - recordTimer.setRepeating(true); + autoStartTimer.setSingleShot(true); + autoStopTimer.setSingleShot(true); + recordTimer.setSingleShot(false); + + QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(appAboutToQuit())); } QDeclarativeViewer::~QDeclarativeViewer() @@ -468,26 +632,6 @@ void QDeclarativeViewer::enableExperimentalGestures() canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); } -int QDeclarativeViewer::menuBarHeight() const -{ - if (!(windowFlags() & Qt::FramelessWindowHint)) - return menuBar()->height(); - else - return 0; // don't create menu -} - -QMenuBar *QDeclarativeViewer::menuBar() const -{ -#if !defined(Q_OS_SYMBIAN) - if (!mb) - mb = new SizedMenuBar((QWidget*)this, canvas); -#else - mb = QMainWindow::menuBar(); -#endif - - return mb; -} - QDeclarativeView *QDeclarativeViewer::view() const { return canvas; @@ -498,120 +642,128 @@ LoggerWidget *QDeclarativeViewer::warningsWidget() const return loggerWindow; } -void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) +void QDeclarativeViewer::createMenu() { - QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu; - - QMenu *fileMenu = flatmenu ? flatmenu : menu->addMenu(tr("&File")); - - QAction *openAction = new QAction(tr("&Open..."), parent); + QAction *openAction = new QAction(tr("&Open..."), this); openAction->setShortcut(QKeySequence("Ctrl+O")); connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - fileMenu->addAction(openAction); - QAction *reloadAction = new QAction(tr("&Reload"), parent); + QAction *reloadAction = new QAction(tr("&Reload"), this); reloadAction->setShortcut(QKeySequence("Ctrl+R")); connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); - fileMenu->addAction(reloadAction); - -#if !defined(Q_OS_SYMBIAN) - if (flatmenu) flatmenu->addSeparator(); - - QMenu *recordMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Recording")); - QAction *snapshotAction = new QAction(tr("&Take Snapshot\tF3"), parent); + QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this); + snapshotAction->setShortcut(QKeySequence("F3")); connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot())); - recordMenu->addAction(snapshotAction); - recordAction = new QAction(tr("Start Recording &Video\tF9"), parent); + recordAction = new QAction(tr("Start Recording &Video"), this); + recordAction->setShortcut(QKeySequence("F9")); connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); - recordMenu->addAction(recordAction); - QAction *recordOptions = new QAction(tr("Video &Options..."), parent); + QAction *recordOptions = new QAction(tr("Video &Options..."), this); connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); - if (flatmenu) - flatmenu->addAction(recordOptions); - - if (flatmenu) flatmenu->addSeparator(); - - QMenu *debugMenu = flatmenu ? flatmenu->addMenu(tr("&Debugging")) : menu->addMenu(tr("&Debugging")); - - QAction *slowAction = new QAction(tr("&Slow Down Animations"), parent); + QAction *slowAction = new QAction(tr("&Slow Down Animations"), this); slowAction->setShortcut(QKeySequence("Ctrl+.")); slowAction->setCheckable(true); connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool))); - debugMenu->addAction(slowAction); - showWarningsWindow = new QAction(tr("Show Warnings"), parent); + showWarningsWindow = new QAction(tr("Show Warnings"), this); showWarningsWindow->setCheckable((true)); showWarningsWindow->setChecked(loggerWindow->isVisible()); connect(showWarningsWindow, SIGNAL(triggered(bool)), this, SLOT(showWarnings(bool))); -#if !defined(Q_OS_SYMBIAN) - debugMenu->addAction(showWarningsWindow); -#endif - - if (flatmenu) flatmenu->addSeparator(); - -#endif // Q_OS_SYMBIAN - - QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings")); - QAction *proxyAction = new QAction(tr("Http &proxy..."), parent); + QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this); connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings())); - settingsMenu->addAction(proxyAction); -#if !defined(Q_OS_SYMBIAN) - if (!flatmenu) - settingsMenu->addAction(recordOptions); - settingsMenu->addMenu(loggerWindow->preferencesMenu()); -#else - QAction *fullscreenAction = new QAction(tr("Full Screen"), parent); + QAction *fullscreenAction = new QAction(tr("Full Screen"), this); fullscreenAction->setCheckable(true); connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); - settingsMenu->addAction(fullscreenAction); -#endif - - if (flatmenu) flatmenu->addSeparator(); - - QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties")); - orientation = new QActionGroup(parent); - - QAction *rotateOrientation = new QAction(tr("Rotate orientation"), parent); + QAction *rotateOrientation = new QAction(tr("Rotate orientation"), this); rotateOrientation->setShortcut(QKeySequence("Ctrl+T")); - settingsMenu->addAction(rotateOrientation); connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation())); + orientation = new QActionGroup(this); orientation->setExclusive(true); connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*))); - orientation->addAction(tr("orientation: Portrait")); - orientation->addAction(tr("orientation: Landscape")); - orientation->addAction(tr("orientation: Portrait (Inverted)")); - orientation->addAction(tr("orientation: Landscape (Inverted)")); - QList<QAction *> actions = orientation->actions(); - for (int i=0; i<actions.count(); i++) { - propertiesMenu->addAction(actions[i]); - actions[i]->setCheckable(true); - } - - if (flatmenu) flatmenu->addSeparator(); + QAction *portraitAction = new QAction(tr("Portrait"), this); + portraitAction->setCheckable(true); + QAction *landscapeAction = new QAction(tr("Landscape"), this); + landscapeAction->setCheckable(true); + QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this); + portraitInvAction->setCheckable(true); + QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this); + landscapeInvAction->setCheckable(true); - QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help")); - QAction *aboutAction = new QAction(tr("&About Qt..."), parent); + QAction *aboutAction = new QAction(tr("&About Qt..."), this); connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - helpMenu->addAction(aboutAction); - QAction *quitAction = new QAction(tr("&Quit"), parent); + QAction *quitAction = new QAction(tr("&Quit"), this); quitAction->setShortcut(QKeySequence("Ctrl+Q")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + QMenuBar *menu = menuBar(); + if (!menu) + return; + +#if defined(Q_WS_MAEMO_5) + menu->addAction(openAction); + menu->addAction(reloadAction); + + menu->addAction(snapshotAction); + menu->addAction(recordAction); + + menu->addAction(recordOptions); + menu->addAction(proxyAction); + + menu->addAction(slowAction); + menu->addAction(showWarningsWindow); + + orientation->addAction(landscapeAction); + orientation->addAction(portraitAction); + menu->addAction(new Maemo5PickerAction(tr("Set orientation"), orientation, this)); + menu->addAction(fullscreenAction); + return; +#endif // Q_WS_MAEMO_5 + + QMenu *fileMenu = menu->addMenu(tr("&File")); + fileMenu->addAction(openAction); + fileMenu->addAction(reloadAction); fileMenu->addSeparator(); fileMenu->addAction(quitAction); - if (menu) { - menu->setFixedHeight(menu->sizeHint().height()); - menu->setMinimumWidth(10); - } + +#if !defined(Q_OS_SYMBIAN) + QMenu *recordMenu = menu->addMenu(tr("&Recording")); + recordMenu->addAction(snapshotAction); + recordMenu->addAction(recordAction); + + QMenu *debugMenu = menu->addMenu(tr("&Debugging")); + debugMenu->addAction(slowAction); + debugMenu->addAction(showWarningsWindow); +#endif // ! Q_OS_SYMBIAN + + QMenu *settingsMenu = menu->addMenu(tr("S&ettings")); + settingsMenu->addAction(proxyAction); +#if !defined(Q_OS_SYMBIAN) + settingsMenu->addAction(recordOptions); + settingsMenu->addMenu(loggerWindow->preferencesMenu()); +#else // ! Q_OS_SYMBIAN + settingsMenu->addAction(fullscreenAction); +#endif // Q_OS_SYMBIAN + settingsMenu->addAction(rotateOrientation); + + QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties")); + + orientation->addAction(portraitAction); + orientation->addAction(landscapeAction); + orientation->addAction(portraitInvAction); + orientation->addAction(landscapeInvAction); + propertiesMenu->addActions(orientation->actions()); + + QMenu *helpMenu = menu->addMenu(tr("&Help")); + helpMenu->addAction(aboutAction); } void QDeclarativeViewer::showProxySettings() @@ -685,25 +837,11 @@ void QDeclarativeViewer::chooseRecordingOptions() recdlg->file->setText(record_file); // Size - recdlg->sizeOriginal->setText(tr("Original (%1x%2)").arg(canvas->width()).arg(canvas->height())); - if (recdlg->sizeWidth->value()<=1) { - recdlg->sizeWidth->setValue(canvas->width()); - recdlg->sizeHeight->setValue(canvas->height()); - } + recdlg->setOriginalSize(canvas->size()); // Rate - if (record_rate == 24) - recdlg->hz24->setChecked(true); - else if (record_rate == 25) - recdlg->hz25->setChecked(true); - else if (record_rate == 50) - recdlg->hz50->setChecked(true); - else if (record_rate == 60) - recdlg->hz60->setChecked(true); - else { - recdlg->hzCustom->setChecked(true); - recdlg->hz->setText(QString::number(record_rate)); - } + recdlg->setVideoRate(record_rate); + // Profile recdlg->setArguments(record_args.join(" ")); @@ -711,28 +849,9 @@ void QDeclarativeViewer::chooseRecordingOptions() // File record_file = recdlg->file->text(); // Size - if (recdlg->sizeOriginal->isChecked()) - record_outsize = QSize(); - else if (recdlg->size720p->isChecked()) - record_outsize = QSize(1280,720); - else if (recdlg->sizeVGA->isChecked()) - record_outsize = QSize(640,480); - else if (recdlg->sizeQVGA->isChecked()) - record_outsize = QSize(320,240); - else - record_outsize = QSize(recdlg->sizeWidth->value(),recdlg->sizeHeight->value()); + record_outsize = recdlg->videoSize(); // Rate - if (recdlg->hz24->isChecked()) - record_rate = 24; - else if (recdlg->hz25->isChecked()) - record_rate = 25; - else if (recdlg->hz50->isChecked()) - record_rate = 50; - else if (recdlg->hz60->isChecked()) - record_rate = 60; - else { - record_rate = recdlg->hz->text().toDouble(); - } + record_rate = recdlg->videoRate(); // Profile record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); } @@ -740,7 +859,7 @@ void QDeclarativeViewer::chooseRecordingOptions() void QDeclarativeViewer::toggleRecordingWithSelection() { - if (!recordTimer.isRunning()) { + if (!recordTimer.isActive()) { if (record_file.isEmpty()) { QString fileName = getVideoFileName(); if (fileName.isEmpty()) @@ -759,7 +878,7 @@ void QDeclarativeViewer::toggleRecording() toggleRecordingWithSelection(); return; } - bool recording = !recordTimer.isRunning(); + bool recording = !recordTimer.isActive(); recordAction->setText(recording ? tr("&Stop Recording Video\tF9") : tr("&Start Recording Video\tF9")); setRecording(recording); } @@ -807,8 +926,9 @@ void QDeclarativeViewer::statusChanged() initialSize = canvas->initialSize(); if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { if (!isFullScreen() && !isMaximized()) { - resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight())); - updateSizeHints(); + canvas->setFixedSize(initialSize); + resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrink + QTimer::singleShot(0, this, SLOT(updateSizeHints())); } } } @@ -917,7 +1037,7 @@ void QDeclarativeViewer::setAutoRecord(int from, int to) if (from==0) from=1; // ensure resized record_autotime = to-from; autoStartTimer.setInterval(from); - autoStartTimer.setRunning(true); + autoStartTimer.start(); } void QDeclarativeViewer::setRecordArgs(const QStringList& a) @@ -1019,7 +1139,7 @@ void QDeclarativeViewer::senseFfmpeg() void QDeclarativeViewer::setRecording(bool on) { - if (on == recordTimer.isRunning()) + if (on == recordTimer.isActive()) return; int period = int(1000/record_rate+0.5); @@ -1028,7 +1148,7 @@ void QDeclarativeViewer::setRecording(bool on) if (on) { canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); recordTimer.setInterval(period); - recordTimer.setRunning(true); + recordTimer.start(); frame_fmt = record_file.right(4).toLower(); frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) { @@ -1059,7 +1179,7 @@ void QDeclarativeViewer::setRecording(bool on) } } else { canvas->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); - recordTimer.setRunning(false); + recordTimer.stop(); if (frame_stream) { qDebug() << "Saving video..."; frame_stream->close(); @@ -1139,7 +1259,7 @@ void QDeclarativeViewer::setRecording(bool on) frames.clear(); } } - qDebug() << "Recording: " << (recordTimer.isRunning()?"ON":"OFF"); + qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); } void QDeclarativeViewer::ffmpegFinished(int code) @@ -1147,11 +1267,21 @@ void QDeclarativeViewer::ffmpegFinished(int code) qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError(); } +void QDeclarativeViewer::appAboutToQuit() +{ + // avoid QGLContext errors about invalid contexts on exit + canvas->setViewport(0); + + // avoid crashes if messages are received after app has closed + delete loggerWindow; + loggerWindow = 0; +} + void QDeclarativeViewer::autoStartRecording() { setRecording(true); autoStopTimer.setInterval(record_autotime); - autoStopTimer.setRunning(true); + autoStopTimer.start(); } void QDeclarativeViewer::autoStopRecording() @@ -1181,14 +1311,14 @@ void QDeclarativeViewer::changeOrientation(QAction *action) return; action->setChecked(true); - QString o = action->text().split(QLatin1Char(':')).value(1).trimmed(); + QString o = action->text(); if (o == QLatin1String("Portrait")) DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait); else if (o == QLatin1String("Landscape")) DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape); - else if (o == QLatin1String("Portrait (Inverted)")) + else if (o == QLatin1String("Portrait (inverted)")) DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted); - else if (o == QLatin1String("Landscape (Inverted)")) + else if (o == QLatin1String("Landscape (inverted)")) DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted); } @@ -1197,9 +1327,11 @@ void QDeclarativeViewer::orientationChanged() if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { if (canvas->rootObject()) { QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size(); - QSize newSize(rootObjectSize.width(), rootObjectSize.height()+menuBarHeight()); - if (size() != newSize) { - resize(newSize); + if (size() != rootObjectSize.toSize()) { + canvas->setMinimumSize(rootObjectSize.toSize()); + canvas->resize(rootObjectSize.toSize()); + resize(rootObjectSize.toSize()); + resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks } } } @@ -1232,6 +1364,8 @@ void QDeclarativeViewer::setUseGL(bool useGL) canvas->setViewport(glWidget); } +#else + Q_UNUSED(useGL) #endif } @@ -1253,16 +1387,15 @@ void QDeclarativeViewer::updateSizeHints() { if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { QSize newWindowSize = canvas->sizeHint(); - newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); if (!isFullScreen() && !isMaximized()) { - resize(newWindowSize); - setFixedSize(newWindowSize); + canvas->setMinimumSize(newWindowSize); + canvas->resize(newWindowSize); + resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks + canvas->setMinimumSize(QSize(0, 0)); } } else { // QDeclarativeView::SizeRootObjectToView canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(16777215,16777215)); - setMinimumSize(QSize(0,0)); - setMaximumSize(QSize(16777215,16777215)); } } diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 27bd217..e70e69f 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -43,8 +43,7 @@ #define QDECLARATIVEVIEWER_H #include <QMainWindow> -#include <QMenuBar> -#include <private/qdeclarativetimer_p.h> +#include <QTimer> #include <QTime> #include <QList> @@ -62,17 +61,16 @@ class QNetworkReply; class QNetworkCookieJar; class NetworkAccessManagerFactory; class QTranslator; +class QActionGroup; +class QMenuBar; class QDeclarativeViewer -#if defined(Q_OS_SYMBIAN) : public QMainWindow -#else - : public QWidget -#endif { -Q_OBJECT + Q_OBJECT + public: - QDeclarativeViewer(QWidget *parent=0, Qt::WindowFlags flags=0); + QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~QDeclarativeViewer(); static void registerTypes(); @@ -95,7 +93,7 @@ public: void setRecordFile(const QString&); void setRecordArgs(const QStringList&); void setRecording(bool on); - bool isRecording() const { return recordTimer.isRunning(); } + bool isRecording() const { return recordTimer.isActive(); } void setAutoRecord(int from, int to); void setDeviceKeys(bool); void setNetworkCacheSize(int size); @@ -103,11 +101,8 @@ public: void addPluginPath(const QString& plugin); void setUseGL(bool use); void setUseNativeFileBrowser(bool); - void updateSizeHints(); void setSizeToView(bool sizeToView); - QMenuBar *menuBar() const; - QDeclarativeView *view() const; LoggerWidget *warningsWidget() const; @@ -132,9 +127,11 @@ public slots: protected: virtual void keyPressEvent(QKeyEvent *); virtual bool event(QEvent *); - void createMenu(QMenuBar *menu, QMenu *flatmenu); + void createMenu(); private slots: + void appAboutToQuit(); + void autoStartRecording(); void autoStopRecording(); void recordFrame(); @@ -148,21 +145,22 @@ private slots: void warningsWidgetOpened(); void warningsWidgetClosed(); + void updateSizeHints(); + private: QString getVideoFileName(); - int menuBarHeight() const; LoggerWidget *loggerWindow; QDeclarativeView *canvas; QSize initialSize; QString currentFileOrUrl; - QDeclarativeTimer recordTimer; + QTimer recordTimer; QString frame_fmt; QImage frame; QList<QImage*> frames; QProcess* frame_stream; - QDeclarativeTimer autoStartTimer; - QDeclarativeTimer autoStopTimer; + QTimer autoStartTimer; + QTimer autoStopTimer; QString record_dither; QString record_file; QSize record_outsize; @@ -173,7 +171,6 @@ private: QAction *recordAction; QString currentSkin; bool scaleSkin; - mutable QMenuBar *mb; RecordingDialog *recdlg; void senseImageMagick(); diff --git a/tools/qml/recopts_maemo5.ui b/tools/qml/recopts_maemo5.ui new file mode 100644 index 0000000..3bb5eca --- /dev/null +++ b/tools/qml/recopts_maemo5.ui @@ -0,0 +1,254 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RecordingOptions</class> + <widget class="QDialog" name="RecordingOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>469</width> + <height>142</height> + </rect> + </property> + <property name="windowTitle"> + <string>Video options</string> + </property> + <layout class="QGridLayout" name="gridLayout" columnstretch="0,2,0"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinAndMaxSize</enum> + </property> + <property name="leftMargin"> + <number>16</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>16</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <property name="horizontalSpacing"> + <number>16</number> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <item row="0" column="1"> + <widget class="QLineEdit" name="file"/> + </item> + <item row="0" column="2" rowspan="3"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>72</width> + <height>56</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Size</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="sizeCombo"> + <item> + <property name="text"> + <string/> + </property> + </item> + <item> + <property name="text"> + <string>VGA</string> + </property> + </item> + <item> + <property name="text"> + <string>QVGA</string> + </property> + </item> + <item> + <property name="text"> + <string>720p</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0" rowspan="2"> + <widget class="QLabel" name="rateLabel"> + <property name="text"> + <string>Rate</string> + </property> + </widget> + </item> + <item row="2" column="1" rowspan="2"> + <widget class="QComboBox" name="rateCombo"> + <item> + <property name="text"> + <string>60 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>50 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>25 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>24 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>20 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>15 Hz</string> + </property> + </item> + <item> + <property name="text"> + <string>10 Hz</string> + </property> + </item> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="args"/> + </item> + <item row="4" column="1"> + <widget class="QComboBox" name="profile"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="profileLabel"> + <property name="text"> + <string>Profile</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QLabel" name="warning"> + <property name="text"> + <string notr="true">warning</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="2" rowspan="3"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QPushButton" name="pickfile"> + <property name="text"> + <string>File</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QPushButton" name="ffmpegHelp"> + <property name="text"> + <string>Options</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>RecordingOptions</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>258</x> + <y>424</y> + </hint> + <hint type="destinationlabel"> + <x>60</x> + <y>219</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>RecordingOptions</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>258</x> + <y>424</y> + </hint> + <hint type="destinationlabel"> + <x>92</x> + <y>219</y> + </hint> + </hints> + </connection> + <connection> + <sender>profile</sender> + <signal>activated(int)</signal> + <receiver>RecordingOptions</receiver> + <slot>pickProfile(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>92</x> + <y>329</y> + </hint> + <hint type="destinationlabel"> + <x>48</x> + <y>194</y> + </hint> + </hints> + </connection> + <connection> + <sender>args</sender> + <signal>textEdited(QString)</signal> + <receiver>RecordingOptions</receiver> + <slot>storeCustomArgs(QString)</slot> + <hints> + <hint type="sourcelabel"> + <x>128</x> + <y>357</y> + </hint> + <hint type="destinationlabel"> + <x>102</x> + <y>189</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <signal>filePicked(QString)</signal> + <signal>argumentsPicked(QString)</signal> + <slot>pickFile()</slot> + <slot>pickProfile(int)</slot> + <slot>storeCustomArgs(QString)</slot> + </slots> +</ui> diff --git a/tools/qml/texteditautoresizer_maemo5.h b/tools/qml/texteditautoresizer_maemo5.h new file mode 100644 index 0000000..bb5567a --- /dev/null +++ b/tools/qml/texteditautoresizer_maemo5.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used 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. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/qplaintextedit.h> +#include <QtGui/qtextedit.h> +#include <QtGui/qabstractkineticscroller.h> +#include <QtGui/qscrollarea.h> +#include <QtDebug> + +#ifndef TEXTEDITAUTORESIZER_H +#define TEXTEDITAUTORESIZER_H + +class TextEditAutoResizer : public QObject +{ + Q_OBJECT +public: + TextEditAutoResizer(QWidget *parent) + : QObject(parent), plainTextEdit(qobject_cast<QPlainTextEdit *>(parent)), + textEdit(qobject_cast<QTextEdit *>(parent)), edit(qobject_cast<QFrame *>(parent)) + { + // parent must either inherit QPlainTextEdit or QTextEdit! + Q_ASSERT(plainTextEdit || textEdit); + + connect(parent, SIGNAL(textChanged()), this, SLOT(textEditChanged())); + connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged())); + + textEditChanged(); + } + +private Q_SLOTS: + inline void textEditChanged(); + +private: + QPlainTextEdit *plainTextEdit; + QTextEdit *textEdit; + QFrame *edit; +}; + +void TextEditAutoResizer::textEditChanged() +{ + QTextDocument *doc = textEdit ? textEdit->document() : plainTextEdit->document(); + QRect cursor = textEdit ? textEdit->cursorRect() : plainTextEdit->cursorRect(); + + QSize s = doc->size().toSize(); + if (plainTextEdit) + s.setHeight((s.height() + 2) * edit->fontMetrics().lineSpacing()); + + const QRect fr = edit->frameRect(); + const QRect cr = edit->contentsRect(); + + edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1))); + + // make sure the cursor is visible in case we have a QAbstractScrollArea parent + QPoint pos = edit->pos(); + QWidget *pw = edit->parentWidget(); + while (pw) { + if (qobject_cast<QScrollArea *>(pw)) + break; + pw = pw->parentWidget(); + } + + if (pw) { + QScrollArea *area = static_cast<QScrollArea *>(pw); + QPoint scrollto = area->widget()->mapFrom(edit, cursor.center()); + QPoint margin(10 + cursor.width(), 2 * cursor.height()); + + if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) { + scroller->ensureVisible(scrollto, margin.x(), margin.y()); + } else { + area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); + } + } +} + +#endif |