[vlc-commits] QtPlayer example: small way to fullscreen

Jean-Baptiste Kempf git at videolan.org
Wed Jan 9 12:06:46 CET 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Jan  9 12:06:24 2013 +0100| [14556820289f1621d3a2e87d3864f7fbc1bbcf18] | committer: Jean-Baptiste Kempf

QtPlayer example: small way to fullscreen

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14556820289f1621d3a2e87d3864f7fbc1bbcf18
---

 doc/libvlc/QtPlayer/player.cpp |   21 +++++++++++++++++++++
 doc/libvlc/QtPlayer/player.h   |    1 +
 2 files changed, 22 insertions(+)

diff --git a/doc/libvlc/QtPlayer/player.cpp b/doc/libvlc/QtPlayer/player.cpp
index 77b9682..6a25564 100644
--- a/doc/libvlc/QtPlayer/player.cpp
+++ b/doc/libvlc/QtPlayer/player.cpp
@@ -43,6 +43,7 @@ void Mwindow::initUI() {
     QAction *Open    = new QAction("&Open", this);
     QAction *Quit    = new QAction("&Quit", this);
     QAction *playAc  = new QAction("&Play/Pause", this);
+    QAction *fsAc  = new QAction("&Fullscreen", this);
     QAction *aboutAc = new QAction("&About", this);
 
     Open->setShortcut(QKeySequence("Ctrl+O"));
@@ -52,10 +53,12 @@ void Mwindow::initUI() {
     fileMenu->addAction(aboutAc);
     fileMenu->addAction(Quit);
     editMenu->addAction(playAc);
+    editMenu->addAction(fsAc);
 
     connect(Open,    SIGNAL(triggered()), this, SLOT(openFile()));
     connect(playAc,  SIGNAL(triggered()), this, SLOT(play()));
     connect(aboutAc, SIGNAL(triggered()), this, SLOT(about()));
+    connect(fsAc,    SIGNAL(triggered()), this, SLOT(fullscreen()));
     connect(Quit,    SIGNAL(triggered()), qApp, SLOT(quit()));
 
     /* Buttons for the UI */
@@ -68,6 +71,9 @@ void Mwindow::initUI() {
     QPushButton *muteBut = new QPushButton("Mute");
     QObject::connect(muteBut, SIGNAL(clicked()), this, SLOT(mute()));
 
+    QPushButton *fsBut = new QPushButton("Fullscreen");
+    QObject::connect(fsBut, SIGNAL(clicked()), this, SLOT(fullscreen()));
+
     volumeSlider = new QSlider(Qt::Horizontal);
     QObject::connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int)));
     volumeSlider->setValue(80);
@@ -92,12 +98,15 @@ void Mwindow::initUI() {
 
     /* Put all in layouts */
     QHBoxLayout *layout = new QHBoxLayout;
+    layout->setMargin(0);
     layout->addWidget(playBut);
     layout->addWidget(stopBut);
     layout->addWidget(muteBut);
+    layout->addWidget(fsBut);
     layout->addWidget(volumeSlider);
 
     QVBoxLayout *layout2 = new QVBoxLayout;
+    layout2->setMargin(0);
     layout2->addWidget(videoWidget);
     layout2->addWidget(slider);
     layout2->addLayout(layout);
@@ -225,6 +234,18 @@ void Mwindow::about()
     QMessageBox::about(this, "Qt libVLC player demo", QString::fromUtf8(libvlc_get_version()) );
 }
 
+void Mwindow::fullscreen()
+{
+   if (isFullScreen()) {
+       showNormal();
+       menuWidget()->show();
+   }
+   else {
+       showFullScreen();
+       menuWidget()->hide();
+   }
+}
+
 void Mwindow::closeEvent(QCloseEvent *event) {
     stop();
     event->accept();
diff --git a/doc/libvlc/QtPlayer/player.h b/doc/libvlc/QtPlayer/player.h
index b3649df..495ea95 100644
--- a/doc/libvlc/QtPlayer/player.h
+++ b/doc/libvlc/QtPlayer/player.h
@@ -25,6 +25,7 @@ class Mwindow : public QMainWindow {
                void stop();
                void mute();
                void about();
+               void fullscreen();
 
                int changeVolume(int);
                void changePosition(int);



More information about the vlc-commits mailing list