summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mazescene.cpp32
-rw-r--r--mazescene.h1
-rw-r--r--mediaplayer/mediaplayer.cpp6
3 files changed, 36 insertions, 3 deletions
diff --git a/mazescene.cpp b/mazescene.cpp
index fec21f2..11fbfcb 100644
--- a/mazescene.cpp
+++ b/mazescene.cpp
@@ -278,6 +278,8 @@ WallItem::WallItem(MazeScene *scene, const QPointF &a, const QPointF &b, int typ
if (!childWidget)
return;
+ childWidget->installEventFilter(scene);
+
m_childItem = new QGraphicsProxyWidget(this);
m_childItem->setWidget(childWidget);
m_childItem->setCacheMode(QGraphicsItem::ItemCoordinateCache);
@@ -291,6 +293,36 @@ WallItem::WallItem(MazeScene *scene, const QPointF &a, const QPointF &b, int typ
m_childItem->translate(-center.x(), -center.y());
}
+bool MazeScene::eventFilter(QObject *target, QEvent *event)
+{
+ QWidget *widget = qobject_cast<QWidget *>(target);
+ if (!widget || event->type() != QEvent::Resize)
+ return false;
+
+ foreach (WallItem *item, m_walls) {
+ QGraphicsProxyWidget *proxy = item->childItem();
+ if (!proxy)
+ continue;
+ if (proxy->widget() == widget) {
+ QRectF rect = proxy->boundingRect();
+
+ if (QRectF(-0.5, -0.5, 1, 1).contains(proxy->mapToParent(rect).boundingRect()))
+ continue;
+
+ QPointF center = rect.center();
+
+ qreal scale = qMin(0.8 / rect.width(), 0.8 / rect.height());
+ proxy->resetMatrix();
+ proxy->translate(0, -0.05);
+ proxy->scale(scale, scale);
+ proxy->translate(-center.x(), -center.y());
+ break;
+ }
+ }
+
+ return false;
+}
+
void ProjectedItem::setDepths(qreal za, qreal zb)
{
if (!m_shadowItem)
diff --git a/mazescene.h b/mazescene.h
index 46a850e..3787bfb 100644
--- a/mazescene.h
+++ b/mazescene.h
@@ -119,6 +119,7 @@ public:
protected:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
+ bool eventFilter(QObject *target, QEvent *event);
bool handleKey(int key, bool pressed);
diff --git a/mediaplayer/mediaplayer.cpp b/mediaplayer/mediaplayer.cpp
index 5f3441a..77ed0d4 100644
--- a/mediaplayer/mediaplayer.cpp
+++ b/mediaplayer/mediaplayer.cpp
@@ -359,7 +359,7 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate)
void MediaPlayer::initSettingsDialog()
{
- settingsDialog = new QDialog(this);
+ settingsDialog = new QDialog();
ui = new Ui_settings();
ui->setupUi(settingsDialog);
@@ -618,7 +618,7 @@ void MediaPlayer::setFile(const QString &fileName)
void MediaPlayer::openFile()
{
- QStringList fileNames = QFileDialog::getOpenFileNames(this);
+ QStringList fileNames = QFileDialog::getOpenFileNames();
m_MediaObject.clearQueue();
if (fileNames.size() > 0) {
QString fileName = fileNames[0];
@@ -769,7 +769,7 @@ void MediaPlayer::openUrl()
QSettings settings;
settings.beginGroup(QLatin1String("BrowserMainWindow"));
QString sourceURL = settings.value("location").toString();
- sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL);
+ sourceURL = QInputDialog::getText(0, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL);
if (!sourceURL.isEmpty()) {
setWindowTitle(sourceURL.right(sourceURL.length() - sourceURL.lastIndexOf('/') - 1));
m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(sourceURL.toUtf8())));