diff src/pngplayer.cpp @ 38:26e1521b9afd

Add the possibility to detach the picture label on doubleclick
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 May 2015 18:09:34 +0200
parents 0c05958d254c
children ee696abaab99
line wrap: on
line diff
--- a/src/pngplayer.cpp	Wed May 06 17:17:13 2015 +0200
+++ b/src/pngplayer.cpp	Wed May 06 18:09:34 2015 +0200
@@ -34,6 +34,8 @@
     QVBoxLayout *baseLayout = new QVBoxLayout;
     mPNGLabel = new ImageLabel;
     mPNGLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    connect(mPNGLabel, &ImageLabel::doubleClicked, this, &PNGPlayer::togglePicFullscreen);
+    connect(mPNGLabel, &ImageLabel::closeRequested, this, &PNGPlayer::togglePicFullscreen);
 
     QHBoxLayout *controlArea = new QHBoxLayout;
     QHBoxLayout *controlBtns = new QHBoxLayout;
@@ -197,3 +199,30 @@
     QSettings settings;
     settings.setValue(REPLAY_SPEED_KEY, (mSpeedSlider->value() * REPLAY_SPEED_STEP_MS) / 1000.0);
 }
+
+void PNGPlayer::togglePicFullscreen() {
+    qDebug() << "togglePicFullscreen";
+    QVBoxLayout *baseLayout = qobject_cast<QVBoxLayout*>(layout());
+    if (!baseLayout) {
+        qWarning() << "Wrong layout!";
+        return;
+    }
+    if (baseLayout->indexOf(mPNGLabel) == -1) {
+        baseLayout->insertWidget(0, mPNGLabel);
+    } else {
+        baseLayout->removeWidget(mPNGLabel);
+        mPNGLabel->setParent(NULL, Qt::Tool);
+        mPNGLabel->showMaximized();
+    }
+}
+
+void PNGPlayer::close() {
+    QVBoxLayout *baseLayout = qobject_cast<QVBoxLayout*>(layout());
+    if (!baseLayout) {
+        qWarning() << "Wrong layout!";
+        return;
+    }
+    if (baseLayout->indexOf(mPNGLabel) == -1) {
+        delete mPNGLabel;
+    }
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)