Commit 5c154646 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Get rid of NotificationZone class

And use QStatusBar with an additional QProgressBar instead.
parent d4e47d75
......@@ -215,7 +215,6 @@ vlmc_SOURCES += \
src/Gui/timeline/ThumbnailImageProvider.cpp \
src/Gui/widgets/ExtendedLabel.cpp \
src/Gui/widgets/FramelessButton.cpp \
src/Gui/widgets/NotificationZone.cpp \
src/Gui/widgets/SearchLineEdit.cpp \
src/Gui/wizard/GeneralPage.cpp \
src/Gui/wizard/OpenPage.cpp \
......@@ -241,7 +240,6 @@ vlmc_SOURCES += \
src/Gui/widgets/ExtendedLabel.h \
src/Gui/widgets/SearchLineEdit.h \
src/Gui/widgets/CrashHandler.h \
src/Gui/widgets/NotificationZone.h \
src/Gui/MainWindow.h \
src/Gui/wizard/ProjectWizard.h \
src/Gui/wizard/GeneralPage.h \
......@@ -316,7 +314,6 @@ nodist_vlmc_SOURCES += \
src/Gui/timeline/ThumbnailImageProvider.moc.cpp \
src/Gui/settings/LanguageWidget.moc.cpp \
src/Gui/import/TagWidget.moc.cpp \
src/Gui/widgets/NotificationZone.moc.cpp \
src/Gui/settings/DoubleSliderWidget.moc.cpp \
src/Gui/widgets/ExtendedLabel.moc.cpp \
src/Gui/About.moc.cpp \
......@@ -358,7 +355,6 @@ vlmc_UI = \
src/Gui/ui/MainWindow.ui \
src/Gui/ui/Timeline.ui \
src/Gui/ui/WorkflowFileRendererDialog.ui \
src/Gui/ui/NotificationZone.ui \
src/Gui/ui/GeneralPage.ui \
src/Gui/ui/OpenPage.ui \
src/Gui/ui/VideoPage.ui \
......
......@@ -36,6 +36,7 @@
#include <QNetworkProxy>
#include <QSysInfo>
#include <QScrollArea>
#include <QProgressBar>
#include "Main/Core.h"
#include "Project/Project.h"
#include "Library/Library.h"
......@@ -57,7 +58,6 @@
/* Widgets */
#include "effectsengine/EffectsListView.h"
#include "library/MediaLibraryView.h"
#include "widgets/NotificationZone.h"
#include "preview/PreviewWidget.h"
#include "timeline/Timeline.h"
......@@ -106,13 +106,28 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
this, &MainWindow::cleanStateChanged );
connect( Core::instance()->recentProjects(), &RecentProjects::updated,
this, &MainWindow::updateRecentProjects );
connect( Core::instance()->mediaLibrary(), &MediaLibrary::progressUpdated,
NotificationZone::instance(), &NotificationZone::progressUpdated );
connect( Core::instance()->mediaLibrary(), &MediaLibrary::discoveryStarted,
[](const QString& folder) {
NotificationZone::instance()->notify( "Discovering " + folder + "..." );
// Connect the medialibrary before it starts discovering/reloading
connect( Core::instance()->mediaLibrary(), &MediaLibrary::progressUpdated, this,
[this]( int percent ) {
if ( percent < 100 )
m_progressBar->setValue( percent );
else
{
m_progressBar->hide();
m_ui.statusbar->clearMessage();
}
});
connect( Core::instance()->mediaLibrary(), &MediaLibrary::discoveryStarted, this,
[this](const QString& folder) {
m_ui.statusbar->showMessage( "Discovering " + folder + "...", 2500 );
}, Qt::QueuedConnection );
connect( Core::instance()->mediaLibrary(), &MediaLibrary::discoveryCompleted, this,
[this]( const QString& ) {
m_ui.statusbar->showMessage( "Analyzing media" );
}, Qt::QueuedConnection );
//Connecting Library stuff:
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getAbstractRenderer() );
Q_ASSERT( clipRenderer != nullptr );
......@@ -406,21 +421,12 @@ MainWindow::on_actionLoad_Project_triggered()
Core::instance()->loadProject( fileName );
}
void
MainWindow::createNotificationZone()
{
QWidget *notifSpacer = new QWidget( this );
notifSpacer->setFixedWidth( 75 );
m_ui.statusbar->addPermanentWidget( notifSpacer );
m_ui.statusbar->addPermanentWidget( NotificationZone::instance() );
}
void
MainWindow::createStatusBar()
{
//Notifications:
createNotificationZone();
m_progressBar = new QProgressBar( this );
m_ui.statusbar->addPermanentWidget( m_progressBar );
m_progressBar->show();
// Spacer
QWidget* spacer = new QWidget( this );
......
......@@ -24,6 +24,7 @@
#define MAINWINDOW_H
class QUndoView;
class QProgressBar;
#include <QApplication>
#include <QSlider>
......@@ -75,7 +76,6 @@ private:
void initializeDockWidgets();
void checkFolders();
void createStatusBar();
void createNotificationZone();
void createGlobalPreferences();
void createProjectPreferences();
void clearTemporaryFiles();
......@@ -136,6 +136,7 @@ private:
QDockWidget* m_dockedLibrary;
QDockWidget* m_dockedClipPreview;
QDockWidget* m_dockedProjectPreview;
QProgressBar* m_progressBar;
private slots:
void on_actionFullscreen_triggered( bool checked );
......
<?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>
/*****************************************************************************
* NotificationZone.cpp: Handle toolbar notification zone.
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#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() ) );
}
NotificationZone::~NotificationZone()
{
delete m_ui;
}
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( 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-2016 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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 "Tools/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);
virtual ~NotificationZone();
private:
Ui::NotificationZone *m_ui;
QTimer *m_timer;
public slots:
void notify( const QString& message );
/**
* \brief Update the progress bar.
*
* \param percent The progress percent, from 0 to 100
*/
void progressUpdated( int percent );
private slots:
void hideNotification();
friend Singleton_t::AllowInstantiation;
};
#endif // NOTIFICATIONZONE_H
......@@ -38,7 +38,6 @@
#include <QMutex>
#ifdef HAVE_GUI
# include "Gui/widgets/NotificationZone.h"
# include <QMessageBox>
#endif
......@@ -53,10 +52,6 @@ Workspace::Workspace(Settings *settings)
this, SLOT( workspaceChanged( QVariant ) ) );
// Wait for the SettingValue to be loaded.
m_mediasToCopyMutex = new QMutex;
#ifdef HAVE_GUI
connect( this, SIGNAL( notify( QString ) ),
NotificationZone::instance(), SLOT( notify( QString ) ) );
#endif
}
Workspace::~Workspace()
......
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