From f7b08934580ddc2716fbf4ac3ecd9684158d3cf7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Jul 2009 16:03:36 +1000 Subject: Video size and aspect ratio. --- tools/qmlviewer/qmlviewer.cpp | 36 +++- tools/qmlviewer/qmlviewer.h | 1 + tools/qmlviewer/recopts.ui | 407 ++++++++++++++++++++++++++++++------------ 3 files changed, 326 insertions(+), 118 deletions(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index d7d8b82..098f749 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -298,7 +298,7 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); recordMenu->addAction(recordAction); - QAction *recordOptions = new QAction(tr("Recording &Options..."), parent); + QAction *recordOptions = new QAction(tr("Video &Options..."), parent); connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); recordMenu->addAction(recordOptions); @@ -416,7 +416,17 @@ void QmlViewer::pickRecordingFile() void QmlViewer::chooseRecordingOptions() { + // File 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()); + } + + // Rate if (record_rate == 24) recdlg->hz24->setChecked(true); else if (record_rate == 25) @@ -429,9 +439,24 @@ void QmlViewer::chooseRecordingOptions() recdlg->hzCustom->setChecked(true); recdlg->hz->setText(QString::number(record_rate)); } + + // Profile recdlg->setArguments(record_args.join(" ")); if (recdlg->exec()) { + // 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()); + // Rate if (recdlg->hz24->isChecked()) record_rate = 24; else if (recdlg->hz25->isChecked()) @@ -443,6 +468,7 @@ void QmlViewer::chooseRecordingOptions() else { record_rate = recdlg->hz->text().toDouble(); } + // Profile record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); } } @@ -686,7 +712,7 @@ void QmlViewer::senseFfmpeg() proc.waitForFinished(2000); QString ffmpegHelp = proc.readAllStandardOutput(); ffmpegAvailable = ffmpegHelp.contains("-s "); - ffmpegHelp = tr("Video recording use ffmpeg:")+"\n\n"+ffmpegHelp; + ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp; QDialog *d = new QDialog(recdlg); QVBoxLayout *l = new QVBoxLayout(d); @@ -729,6 +755,10 @@ void QmlViewer::setRecording(bool on) args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32"); args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height()); args << "-i" << "-"; + if (record_outsize.isValid()) { + args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height()); + args << "-aspect" << QString::number(double(canvas->width())/canvas->height()); + } args += record_args; args << record_file; proc->start("ffmpeg",args); @@ -770,6 +800,8 @@ void QmlViewer::setRecording(bool on) break; QString name; name.sprintf(framename.toLocal8Bit(),frame++); + if (record_outsize.isValid()) + *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); if (record_dither=="ordered") img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); else if (record_dither=="threshold") diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index e3864eb..914f77d 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -88,6 +88,7 @@ private: QmlTimer autoStopTimer; QString record_dither; QString record_file; + QSize record_outsize; QStringList record_args; int record_rate; int record_autotime; diff --git a/tools/qmlviewer/recopts.ui b/tools/qmlviewer/recopts.ui index 041a4c4..ce2da30 100644 --- a/tools/qmlviewer/recopts.ui +++ b/tools/qmlviewer/recopts.ui @@ -6,133 +6,194 @@ 0 0 - 290 - 297 + 316 + 436 - Recording options + Video options - - - - - - 0 - 0 - - - - File: - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + + + + 0 + 0 + + + + File: + + + + + + + + + + ... + + + + - - - - ... + + + + Size - - - - - - 0 - - - + + - Profile: + + + + true - - + + + + VGA + + - - + + + + 720p + + - - + + - Help + QVGA + + + + + + Width: + + + + + + + 1 + + + 9999 + + + + + + + + 0 + 0 + + + + Height: + + + + + + + 1 + + + 9999 + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + - - - - - 0 - + + + + Rate + + - + - + 0 0 - Rate: + 60Hz - - - - - - 24Hz + + true - + 50Hz - + 25Hz - - - - - 0 - 0 - - - - 60Hz - - - true - - - - + 0 @@ -178,6 +239,9 @@ Qt::Horizontal + + QSizePolicy::MinimumExpanding + 40 @@ -188,31 +252,110 @@ + + + + 24Hz + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + - - - - Qt::Vertical - - - - 20 - 40 - + + + + Profile - + + + + + + + + + + + Help + + + + + - + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + file + pickfile + sizeOriginal + sizeVGA + size720p + sizeQVGA + sizeCustom + sizeWidth + sizeHeight + hz60 + hz25 + hz50 + hz24 + hzCustom + hz + profile + args + ffmpegHelp + buttonBox + @@ -222,12 +365,12 @@ setFocus() - 54 - 104 + 43 + 257 - 85 - 107 + 129 + 262 @@ -238,12 +381,12 @@ toggle() - 138 - 102 + 143 + 262 - 49 - 104 + 43 + 257 @@ -254,12 +397,12 @@ toggle() - 110 - 105 + 143 + 262 - 51 - 103 + 43 + 257 @@ -270,8 +413,8 @@ accept() - 280 - 287 + 258 + 424 60 @@ -286,8 +429,8 @@ reject() - 280 - 287 + 258 + 424 92 @@ -302,8 +445,8 @@ pickProfile(int) - 72 - 132 + 92 + 329 48 @@ -318,8 +461,8 @@ storeCustomArgs(QString) - 108 - 161 + 128 + 357 102 @@ -327,6 +470,38 @@ + + sizeWidth + valueChanged(int) + sizeCustom + toggle() + + + 108 + 133 + + + 48 + 133 + + + + + sizeHeight + valueChanged(int) + sizeCustom + toggle() + + + 212 + 133 + + + 64 + 129 + + + filePicked(QString) -- cgit v0.12 From 136c8210cc98bc6d9b17fd4d517d9d399f30e6c2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 16:58:42 +1000 Subject: Don't bounce around when removing the current item. --- src/declarative/fx/qfxlistview.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 3d97dfa..a78fed5 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -278,6 +278,18 @@ public: return -1; } + int lastVisibleIndex() const { + int lastIndex = -1; + for (int i = visibleItems.count()-1; i >= 0; --i) { + FxListItem *listItem = visibleItems.at(i); + if (listItem->index != -1) { + lastIndex = listItem->index; + break; + } + } + return lastIndex; + } + // map a model index to visibleItems index. // These may differ if removed items are still present in the visible list, // e.g. doing a removal animation @@ -542,7 +554,7 @@ void QFxListViewPrivate::layout() pos += item->size(); } // move current item if it is after the visible items. - if (currentItem && currentIndex > visibleItems.last()->index) + if (currentItem && currentIndex > lastVisibleIndex()) currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd)); } if (!isValid()) @@ -647,7 +659,8 @@ void QFxListViewPrivate::createHighlight() const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); highlightPosAnimator = new QmlFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setSpring(3); + highlightPosAnimator->setEpsilon(0.25); + highlightPosAnimator->setSpring(2.5); highlightPosAnimator->setDamping(0.3); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); -- cgit v0.12 From 8358e5b93efcb119cc7dd036c8f5f4ae960f702e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 30 Jul 2009 11:55:50 +0200 Subject: Fixed AST visiting, so UiProgram *members* are visited again. --- src/declarative/qml/parser/qmljsast.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp index caf81e5..11a98b6 100644 --- a/src/declarative/qml/parser/qmljsast.cpp +++ b/src/declarative/qml/parser/qmljsast.cpp @@ -792,6 +792,7 @@ void UiProgram::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(imports, visitor); + accept(members, visitor); } visitor->endVisit(this); -- cgit v0.12 From a80468f33d8216ab06c23551b9f6a7b2722ddc14 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 10:51:42 +1000 Subject: Docs --- src/declarative/util/qmlpalette.cpp | 34 +++++++++++++++++++++++++--------- src/declarative/util/qmlpalette.h | 10 +++++----- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 3a6dadc..25576f1 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -55,10 +55,24 @@ public: QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Palette,QmlPalette) /*! - \internal - \class QmlPalette + \qmlclass Palette QmlPalette \ingroup group_utility - \brief The QmlPalette class gives access to the Qt palettes. + \brief The Palette item gives access to the Qt palettes. + \sa QPalette + + + \code + Palette { id: MyPalette; colorGroup: "Active" } + + Rect { + width: 640; height: 480 + color: MyPalette.window + Text { + anchors.fill: parent + text: "Hello!"; color: MyPalette.windowText + } + } + \endcode */ QmlPalette::QmlPalette(QObject *parent) : QObject(*(new QmlPalettePrivate), parent) @@ -73,12 +87,20 @@ QmlPalette::~QmlPalette() { } +/*! + \qmlproperty Palette::window + \brief The window (general background) color of the current color group. +*/ QColor QmlPalette::window() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Window); } +/*! + \qmlproperty Palette::windowText + \brief The window text (general foreground) color of the current color group. +*/ QColor QmlPalette::windowText() const { Q_D(const QmlPalette); @@ -174,12 +196,6 @@ void QmlPalette::setColorGroup(ColorGroup colorGroup) emit paletteChanged(); } -QPalette QmlPalette::palette() const -{ - Q_D(const QmlPalette); - return d->palette; -} - bool QmlPalette::eventFilter(QObject *watched, QEvent *event) { if (watched == qApp) { diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index 3030557..b601881 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -99,19 +99,19 @@ public: QColor highlight() const; QColor highlightedText() const; - QPalette palette() const; - ColorGroup colorGroup() const; void setColorGroup(ColorGroup); - bool virtual eventFilter(QObject *watched, QEvent *event); - bool virtual event(QEvent *event); - Q_INVOKABLE QColor lighter(const QColor&) const; Q_INVOKABLE QColor darker(const QColor&) const; Q_SIGNALS: void paletteChanged(); + +private: + bool eventFilter(QObject *watched, QEvent *event); + bool event(QEvent *event); + }; QT_END_NAMESPACE -- cgit v0.12 From 62b79ded0e4267d06ecf26ae7fc6b73d8b335df8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 11:16:44 +1000 Subject: QmlFontFamily improvements Add a 'status' property instead of 'loading'. Improve documentaion. --- src/declarative/util/qmlfontfamily.cpp | 33 +++++++++++++++++++++++++-------- src/declarative/util/qmlfontfamily.h | 10 +++++++--- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp index e539085..a82527b 100644 --- a/src/declarative/util/qmlfontfamily.cpp +++ b/src/declarative/util/qmlfontfamily.cpp @@ -57,14 +57,14 @@ class QmlFontFamilyPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlFontFamily); public: - QmlFontFamilyPrivate() : reply(0), loading(false) {} + QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} void addFontToDatabase(const QByteArray &); QUrl url; QString name; QNetworkReply *reply; - bool loading; + QmlFontFamily::Status status; }; QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) @@ -72,6 +72,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) /*! \qmlclass FontFamily QmlFontFamily \ingroup group_utility + \brief This item allows using fonts by name or url. + + \code + FontFamily { id: FixedFont; name: "Courier" } + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } + \endcode */ QmlFontFamily::QmlFontFamily(QObject *parent) : QObject(*(new QmlFontFamilyPrivate), parent) @@ -82,6 +91,10 @@ QmlFontFamily::~QmlFontFamily() { } +/*! + \qmlproperty FontFamily::source + The source for the font. +*/ QUrl QmlFontFamily::source() const { Q_D(const QmlFontFamily); @@ -95,8 +108,8 @@ void QmlFontFamily::setSource(const QUrl &url) return; d->url = qmlContext(this)->resolvedUrl(url); - d->loading = true; - emit loadingChanged(); + d->status = Loading; + emit statusChanged(); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (d->url.scheme() == QLatin1String("file")) { QFile file(d->url.toLocalFile()); @@ -128,10 +141,10 @@ void QmlFontFamily::setName(const QString &name) emit nameChanged(); } -bool QmlFontFamily::isLoading() const +QmlFontFamily::Status QmlFontFamily::status() const { Q_D(const QmlFontFamily); - return d->loading; + return d->status; } void QmlFontFamily::replyFinished() @@ -140,6 +153,9 @@ void QmlFontFamily::replyFinished() if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); d->addFontToDatabase(ba); + } else { + d->status = Error; + emit statusChanged(); } d->reply->deleteLater(); d->reply = 0; @@ -153,11 +169,12 @@ void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) if (id != -1) { name = QFontDatabase::applicationFontFamilies(id).at(0); emit q->nameChanged(); - loading = false; - emit q->loadingChanged(); + status = QmlFontFamily::Ready; } else { + status = QmlFontFamily::Error; qWarning() << "Cannot load font: " << name << url; } + emit q->statusChanged(); } QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfontfamily.h b/src/declarative/util/qmlfontfamily.h index c647f67..17b6635 100644 --- a/src/declarative/util/qmlfontfamily.h +++ b/src/declarative/util/qmlfontfamily.h @@ -56,12 +56,15 @@ class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QmlFontFamily) + Q_ENUMS(Status) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) public: + enum Status { Null = 0, Ready, Loading, Error }; + QmlFontFamily(QObject *parent = 0); ~QmlFontFamily(); @@ -71,14 +74,14 @@ public: QString name() const; void setName(const QString &name); - bool isLoading() const; + Status status() const; private Q_SLOTS: void replyFinished(); Q_SIGNALS: void nameChanged(); - void loadingChanged(); + void statusChanged(); }; QT_END_NAMESPACE @@ -88,3 +91,4 @@ QML_DECLARE_TYPE(QmlFontFamily) QT_END_HEADER #endif // QMLFONTFAMILY_H + -- cgit v0.12