Commit 5153faba authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Adding a notification zone.

parent 95829b94
......@@ -186,6 +186,7 @@ ELSE(NOT WITH_GUI)
Gui/timeline/TracksView.cpp
Gui/widgets/ElidableLabel.cpp
Gui/widgets/FramelessButton.cpp
Gui/widgets/NotificationZone.cpp
Gui/widgets/SearchLineEdit.cpp
Gui/widgets/TrackControls.cpp
Gui/wizard/GeneralPage.cpp
......@@ -248,6 +249,7 @@ ELSE(NOT WITH_GUI)
Gui/UndoStack.h
Gui/widgets/ElidableLabel.h
Gui/widgets/FramelessButton.h
Gui/widgets/NotificationZone.h
Gui/widgets/SearchLineEdit.h
Gui/widgets/TrackControls.h
Gui/wizard/GeneralPage.h
......@@ -276,6 +278,7 @@ ELSE(NOT WITH_GUI)
Gui/ui/Timeline.ui
Gui/ui/WorkflowFileRendererDialog.ui
Gui/widgets/TrackControls.ui
Gui/widgets/ui/NotificationZone.ui
Gui/wizard/ui/GeneralPage.ui
Gui/wizard/ui/OpenPage.ui
Gui/wizard/ui/VideoPage.ui
......
......@@ -49,6 +49,7 @@
#include "DockWidgetManager.h"
#include "ImportController.h"
#include "MediaLibrary.h"
#include "NotificationZone.h"
#include "PreviewWidget.h"
#include "timeline/Timeline.h"
#include "timeline/TracksView.h"
......@@ -363,9 +364,22 @@ MainWindow::on_actionLoad_Project_triggered()
GUIProjectManager::getInstance()->loadProject();
}
void
MainWindow::createNotificationZone()
{
QWidget *notifSpacer = new QWidget( this );
notifSpacer->setFixedWidth( 75 );
m_ui.statusbar->addPermanentWidget( notifSpacer );
m_ui.statusbar->addPermanentWidget( NotificationZone::getInstance() );
}
void
MainWindow::createStatusBar()
{
//Notifications:
createNotificationZone();
// Mouse (default) tool
QToolButton* mouseTool = new QToolButton( this );
mouseTool->setAutoRaise( true );
......
......@@ -46,11 +46,11 @@ class MainWindow : public QMainWindow
Q_DISABLE_COPY( MainWindow )
public:
explicit MainWindow( QWidget *parent = 0 );
void registerWidgetInWindowMenu( QDockWidget* widget );
~MainWindow();
void registerWidgetInWindowMenu( QDockWidget* widget );
public slots:
void zoomIn();
void zoomOut();
......@@ -63,6 +63,7 @@ private:
void initializeDockWidgets( void );
void setupLibrary();
void createStatusBar();
void createNotificationZone();
void createGlobalPreferences();
void createProjectPreferences();
void initVlmcPreferences();
......@@ -132,7 +133,6 @@ private slots:
signals:
void toolChanged( ToolButtons );
};
#endif // MAINWINDOW_H
/*****************************************************************************
* NotificationZone.cpp: Handle toolbar notification zone.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "NotificationZone.h"
#include <QTimer>
NotificationZone::NotificationZone(QWidget *parent) :
QWidget(parent)
{
m_ui = new Ui::NotificationZone();
m_ui->setupUi( this );
m_ui->container->hide();
m_timer = new QTimer( this );
m_timer->setSingleShot( true );
m_timer->setInterval( 5000 );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( hideNotification() ) );
}
void
NotificationZone::notify( const QString &message )
{
m_ui->progressBar->hide();
m_ui->container->show();
m_ui->message->setText( message );
m_timer->start();
}
void
NotificationZone::progressUpdated( float ratio )
{
progressUpdated( static_cast<int>( ratio * 100.0f ) );
}
void
NotificationZone::progressUpdated( int percent )
{
m_ui->progressBar->show();
m_ui->progressBar->setValue( percent );
if ( percent >= 100 )
m_timer->start();
else
m_timer->stop();
}
void
NotificationZone::hideNotification()
{
//This could be direct connected, but i'd like to make it fade out one day :)
m_ui->container->hide();
}
/*****************************************************************************
* NotificationZone.h: Handle toolbar notification zone.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef NOTIFICATIONZONE_H
#define NOTIFICATIONZONE_H
#include "Singleton.hpp"
class QTimer;
#include <QWidget>
#include "ui_NotificationZone.h"
class NotificationZone : public QWidget, public Singleton<NotificationZone>
{
Q_OBJECT
public:
private:
explicit NotificationZone(QWidget *parent = 0);
private:
Ui::NotificationZone *m_ui;
QTimer *m_timer;
public slots:
void notify( const QString& message );
/**
* \brief Update the progress bar.
*
* \param ratio The progress ratio, from 0.0 to 1.0
*/
void progressUpdated( float ratio );
/**
* \brief Update the progress bar.
*
* \param percent The progress percent, from 0 to 100
*/
void progressUpdated( int percent );
private slots:
void hideNotification();
friend class Singleton<NotificationZone>;
};
#endif // NOTIFICATIONZONE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NotificationZone</class>
<widget class="QWidget" name="NotificationZone">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>172</width>
<height>39</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="container" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="message">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -26,6 +26,7 @@
#include "LibVLCpp/VLCMediaPlayer.h"
#include "Media.h"
#include "MetaDataManager.h"
#include "NotificationZone.h"
#include "SettingsManager.h"
#include <QFileInfo>
......@@ -33,6 +34,10 @@
Transcoder::Transcoder( Media* media ) :
m_media( media )
{
connect( this, SIGNAL( notify( QString ) ),
NotificationZone::getInstance(), SLOT( notify( QString ) ) );
connect( this, SIGNAL( progress( float ) ),
NotificationZone::getInstance(), SLOT( progressUpdated( float ) ) );
}
void
......@@ -49,6 +54,7 @@ Transcoder::transcodeToPs()
LibVLCpp::MediaPlayer *mp = new LibVLCpp::MediaPlayer( media );
connect( mp, SIGNAL( positionChanged( float ) ), this, SIGNAL( progress( float ) ) );
connect( mp, SIGNAL( endReached() ), this, SLOT( transcodeFinished() ) );
emit notify( "Transcoding " + m_media->fileInfo()->absoluteFilePath() + " to " + m_destinationFile );
mp->play();
}
......@@ -58,4 +64,5 @@ Transcoder::transcodeFinished()
m_media->setFilePath( m_destinationFile );
MetaDataManager::getInstance()->computeMediaMetadata( m_media );
emit done();
emit notify( m_media->fileInfo()->fileName() + ": Transcode finished" );
}
......@@ -44,6 +44,8 @@ class Transcoder : public QObject
signals:
void progress( float pos );
void done();
//used for notification:
void notify( QString );
};
#endif // TRANSCODER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment