summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-11-18 22:32:16 (GMT)
committerBill King <bill.king@nokia.com>2009-11-18 22:32:16 (GMT)
commit0186faea383f3f8223bffd1844e5a47ca22770a5 (patch)
tree8b17a7c752ada7c06d1d9b88575d5bd467dd3fbe /demos
parentc7ef9c969fb368027135c5e7b0e9b6f53c465702 (diff)
parent80cd617b05ad3e647c87dc063d40cde0617344ca (diff)
downloadQt-0186faea383f3f8223bffd1844e5a47ca22770a5.zip
Qt-0186faea383f3f8223bffd1844e5a47ca22770a5.tar.gz
Qt-0186faea383f3f8223bffd1844e5a47ca22770a5.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'demos')
-rw-r--r--demos/browser/browsermainwindow.cpp43
-rw-r--r--demos/browser/browsermainwindow.h1
-rw-r--r--demos/demos.pro2
-rw-r--r--demos/qmediaplayer/mediaplayer.cpp21
-rw-r--r--demos/qmediaplayer/mediaplayer.h2
-rw-r--r--demos/qtdemo/itemcircleanimation.cpp1
-rw-r--r--demos/sub-attaq/animationmanager.cpp7
-rw-r--r--demos/sub-attaq/animationmanager.h3
-rw-r--r--demos/sub-attaq/boat.cpp6
-rw-r--r--demos/sub-attaq/graphicsscene.cpp1
10 files changed, 39 insertions, 48 deletions
diff --git a/demos/browser/browsermainwindow.cpp b/demos/browser/browsermainwindow.cpp
index fba3ac5..8e3986b 100644
--- a/demos/browser/browsermainwindow.cpp
+++ b/demos/browser/browsermainwindow.cpp
@@ -552,47 +552,6 @@ void BrowserMainWindow::slotViewStatusbar()
m_autoSaver->changeOccurred();
}
-QUrl BrowserMainWindow::guessUrlFromString(const QString &string)
-{
- QString urlStr = string.trimmed();
- QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
-
- // Check if it looks like a qualified URL. Try parsing it and see.
- bool hasSchema = test.exactMatch(urlStr);
- if (hasSchema) {
- QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode);
- if (url.isValid())
- return url;
- }
-
- // Might be a file.
- if (QFile::exists(urlStr)) {
- QFileInfo info(urlStr);
- return QUrl::fromLocalFile(info.absoluteFilePath());
- }
-
- // Might be a shorturl - try to detect the schema.
- if (!hasSchema) {
- int dotIndex = urlStr.indexOf(QLatin1Char('.'));
- if (dotIndex != -1) {
- QString prefix = urlStr.left(dotIndex).toLower();
- QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : QByteArray("http");
- QUrl url =
- QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode);
- if (url.isValid())
- return url;
- }
- }
-
- // Fall back to QUrl's own tolerant parser.
- QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode);
-
- // finally for cases where the user just types in a hostname add http
- if (url.scheme().isEmpty())
- url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode);
- return url;
-}
-
void BrowserMainWindow::loadUrl(const QUrl &url)
{
if (!currentTab() || !url.isValid())
@@ -873,7 +832,7 @@ void BrowserMainWindow::slotSwapFocus()
void BrowserMainWindow::loadPage(const QString &page)
{
- QUrl url = guessUrlFromString(page);
+ QUrl url = QUrl::fromUserInput(page);
loadUrl(url);
}
diff --git a/demos/browser/browsermainwindow.h b/demos/browser/browsermainwindow.h
index f5c14ea..f0f95b1 100644
--- a/demos/browser/browsermainwindow.h
+++ b/demos/browser/browsermainwindow.h
@@ -68,7 +68,6 @@ public:
QSize sizeHint() const;
public:
- static QUrl guessUrlFromString(const QString &url);
TabWidget *tabWidget() const;
WebView *currentTab() const;
QByteArray saveState(bool withTabs = true) const;
diff --git a/demos/demos.pro b/demos/demos.pro
index 5e400ea..a943bfd 100644
--- a/demos/demos.pro
+++ b/demos/demos.pro
@@ -37,7 +37,7 @@ wince*: SUBDIRS += demos_sqlbrowser
}
}
contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer
-contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):SUBDIRS += demos_browser
+contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser
# install
sources.files = README *.pro
diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp
index 624bab7..267a225 100644
--- a/demos/qmediaplayer/mediaplayer.cpp
+++ b/demos/qmediaplayer/mediaplayer.cpp
@@ -355,13 +355,13 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate)
switch (newstate) {
case Phonon::ErrorState:
- QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close);
if (m_MediaObject.errorType() == Phonon::FatalError) {
playButton->setEnabled(false);
rewindButton->setEnabled(false);
} else {
m_MediaObject.pause();
}
+ QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close);
break;
case Phonon::PausedState:
case Phonon::StoppedState:
@@ -471,6 +471,8 @@ void MediaPlayer::effectChanged()
void MediaPlayer::showSettingsDialog()
{
+ playPauseForDialog();
+
if (!settingsDialog)
initSettingsDialog();
@@ -516,6 +518,8 @@ void MediaPlayer::showSettingsDialog()
m_videoWidget->setScaleMode(oldScale);
ui->audioEffectsCombo->setCurrentIndex(currentEffect);
}
+
+ playPauseForDialog();
}
void MediaPlayer::initVideoWindow()
@@ -652,10 +656,25 @@ void MediaPlayer::setFile(const QString &fileName)
m_MediaObject.play();
}
+void MediaPlayer::playPauseForDialog()
+{
+ // If we're running on a small screen, we want to pause the video
+ // when popping up dialogs.
+ if (m_hasSmallScreen &&
+ (Phonon::PlayingState == m_MediaObject.state() ||
+ Phonon::PausedState == m_MediaObject.state()))
+ playPause();
+}
+
void MediaPlayer::openFile()
{
+ playPauseForDialog();
+
QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(),
QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
+
+ playPauseForDialog();
+
m_MediaObject.clearQueue();
if (fileNames.size() > 0) {
QString fileName = fileNames[0];
diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h
index 08db0e5..a1c3d92 100644
--- a/demos/qmediaplayer/mediaplayer.h
+++ b/demos/qmediaplayer/mediaplayer.h
@@ -111,6 +111,8 @@ private slots:
void hasVideoChanged(bool);
private:
+ void playPauseForDialog();
+
QIcon playIcon;
QIcon pauseIcon;
QMenu *fileMenu;
diff --git a/demos/qtdemo/itemcircleanimation.cpp b/demos/qtdemo/itemcircleanimation.cpp
index 8c94eb7..74c3e6a 100644
--- a/demos/qtdemo/itemcircleanimation.cpp
+++ b/demos/qtdemo/itemcircleanimation.cpp
@@ -302,6 +302,7 @@ void ItemCircleAnimation::setupGuides()
int y = 20;
this->qtGuide1 = new GuideCircle(QRectF(x, y, 260, 260), -36, 342);
+ this->currGuide = 0;
new GuideLine(QPointF(x + 240, y + 268), this->qtGuide1);
new GuideLine(QPointF(x + 265, y + 246), this->qtGuide1);
new GuideLine(QPointF(x + 158, y + 134), this->qtGuide1);
diff --git a/demos/sub-attaq/animationmanager.cpp b/demos/sub-attaq/animationmanager.cpp
index eb5a125..b3fc8e1 100644
--- a/demos/sub-attaq/animationmanager.cpp
+++ b/demos/sub-attaq/animationmanager.cpp
@@ -62,11 +62,18 @@ AnimationManager *AnimationManager::self()
void AnimationManager::registerAnimation(QAbstractAnimation *anim)
{
+ QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
animations.append(anim);
}
+void AnimationManager::unregisterAnimation_helper(QObject *obj)
+{
+ unregisterAnimation(static_cast<QAbstractAnimation*>(obj));
+}
+
void AnimationManager::unregisterAnimation(QAbstractAnimation *anim)
{
+ QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
animations.removeAll(anim);
}
diff --git a/demos/sub-attaq/animationmanager.h b/demos/sub-attaq/animationmanager.h
index 8db13eb..48d84d1 100644
--- a/demos/sub-attaq/animationmanager.h
+++ b/demos/sub-attaq/animationmanager.h
@@ -62,6 +62,9 @@ public slots:
void pauseAll();
void resumeAll();
+private slots:
+ void unregisterAnimation_helper(QObject *obj);
+
private:
static AnimationManager *instance;
QList<QAbstractAnimation *> animations;
diff --git a/demos/sub-attaq/boat.cpp b/demos/sub-attaq/boat.cpp
index 0ad31b1..6fed9a9 100644
--- a/demos/sub-attaq/boat.cpp
+++ b/demos/sub-attaq/boat.cpp
@@ -62,7 +62,7 @@ static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
for (int i = 1; i <= 4; i++) {
PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat);
step->setZValue(6);
- step->setOpacity(0);
+ step->setOpacity(0);
//fade-in
QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity");
@@ -92,10 +92,10 @@ Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big),
//The movement animation used to animate the boat
movementAnimation = new QPropertyAnimation(this, "pos");
- //The movement animation used to animate the boat
+ //The destroy animation used to explode the boat
destroyAnimation = setupDestroyAnimation(this);
- //We setup the state machien of the boat
+ //We setup the state machine of the boat
machine = new QStateMachine(this);
QState *moving = new QState(machine);
StopState *stopState = new StopState(this, moving);
diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp
index e29095e..71d4fe7 100644
--- a/demos/sub-attaq/graphicsscene.cpp
+++ b/demos/sub-attaq/graphicsscene.cpp
@@ -278,4 +278,5 @@ void GraphicsScene::clearScene()
boat->stop();
boat->hide();
+ boat->setEnabled(true);
}