merge dialog box to select sub windows into master

This commit is contained in:
jfmcarreira committed 2014-05-09 05:33:24 +01:00
1 parent b96bf37227
commit a868442c1f
8 files changed
+302 -14

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

+3
View File
@@ -7,6 +7,9 @@
<file alias="images/exit.png">icons/exit.png</file>
<file alias="images/configuredialog.png">icons/configuredialog.png</file>
<file alias="images/windowstile.png">icons/windowstile.png</file>
<file alias="images/windowscascade.png">icons/windowscascade.png</file>
<file alias="images/zoomin.png">icons/zoomin.png</file>
<file alias="images/zoomout.png">icons/zoomout.png</file>
<file alias="images/zoomtonormal.png">icons/zoomtonormal.png</file>
+155
View File
@@ -0,0 +1,155 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@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.
*/
/**
* \file DialogSubWindowSelector.cpp
* \brief Dialog box to select sub windows
*/
#include "DialogSubWindowSelector.h"
#include "SubWindowHandle.h"
//#include "PlaYUVerFrame.h"
//#include "InputStream.h"
namespace plaYUVer
{
DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdiArea ) :
QDialog( parent )
{
QFont titleFont, menusFont;
// Set variables
m_pcMainWindowMdiArea = mdiArea;
titleFont.setPointSize( 14 );
titleFont.setBold( true );
titleFont.setWeight( 75 );
menusFont.setBold( true );
menusFont.setWeight( 75 );
QSize windowSize( 350, 80 );
resize( windowSize );
setWindowTitle( "Sub Windows Selection" );
QHBoxLayout* MainLayout = new QHBoxLayout( this );
// Window list and add button
m_comboBoxWindowList = new QComboBox();
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
sizePolicy.setHeightForWidth( m_comboBoxWindowList->sizePolicy().hasHeightForWidth() );
m_comboBoxWindowList->setSizePolicy( sizePolicy );
m_comboBoxWindowList->setAcceptDrops( true );
updateSubWindowList();
m_pushButtonAdd = new QPushButton( "Add", this );
m_pushButtonRemove = new QPushButton( "Remove", this );
// Selected Sub Window List
m_listSelectedWindows = new QListWidget( this );
// Confirmation buttons
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
dialogButtonOkCancel->setOrientation( Qt::Vertical );
dialogButtonOkCancel->setCenterButtons( false );
// Create Layouts
QVBoxLayout* LeftVLayout = new QVBoxLayout();
LeftVLayout->addWidget( m_comboBoxWindowList );
//LeftVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
LeftVLayout->addWidget( m_listSelectedWindows );
QVBoxLayout* RightVLayout = new QVBoxLayout();
RightVLayout->addWidget( m_pushButtonAdd );
RightVLayout->addWidget( m_pushButtonRemove );
RightVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
RightVLayout->addWidget( dialogButtonOkCancel );
// Add components
//MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
MainLayout->addLayout( LeftVLayout );
MainLayout->addLayout( RightVLayout );
setLayout( MainLayout );
// Create actions
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addSubWindow() ) );
connect( m_pushButtonRemove, SIGNAL( clicked() ), this, SLOT( removeSubWindow() ) );
QMetaObject::connectSlotsByName( this );
}
Void DialogSubWindowSelector::updateSubWindowList()
{
SubWindowHandle *subWindow;
QString currSubWindowName;
m_pcWindowListNames.clear();
for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->subWindowList().at( i ) );
currSubWindowName = subWindow->getWindowName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) )
m_pcWindowListNames.append( currSubWindowName );
}
m_comboBoxWindowList->clear();
m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames );
m_comboBoxWindowList->setCurrentIndex( -1 );
}
// ----------------------- Slot Functions -----------------------
void DialogSubWindowSelector::addSubWindow()
{
Int iSelectedIdx = m_comboBoxWindowList->currentIndex();
if( iSelectedIdx >= 0 )
{
m_pcSelectedWindowListNames.append( m_pcWindowListNames.at( iSelectedIdx ) );
m_listSelectedWindows->clear();
m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
updateSubWindowList();
}
}
void DialogSubWindowSelector::removeSubWindow()
{
QList<QListWidgetItem*> selectedWindows = m_listSelectedWindows->selectedItems();
if( selectedWindows.size() )
{
for( Int i = 0; i < selectedWindows.size(); i++ )
{
QString currName = selectedWindows.at( i )->text();
qDebug( ) << currName;
Int indexCurrName = m_pcSelectedWindowListNames.indexOf( currName );
qDebug( ) << indexCurrName;
m_pcSelectedWindowListNames.removeAt( indexCurrName );
m_listSelectedWindows->removeItemWidget( selectedWindows[i] );
}
m_listSelectedWindows->clear();
m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
updateSubWindowList();
}
}
} // Namespace SCode
+81
View File
@@ -0,0 +1,81 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@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.
*/
/**
* \file DialogSubWindowSelector.h
* \brief Dialog box to select sub windows
*/
#ifndef __DIALOGSUBWINDOWSELECTOR_H__
#define __DIALOGSUBWINDOWSELECTOR_H__
#include "config.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
#elif( QT_VERSION_PLAYUVER == 4 )
#include <QtGui>
#endif
#include <QtCore>
#include "TypeDef.h"
class QPixmap;
class QColor;
namespace plaYUVer
{
/**
* Class to define the dialog box to select sub windows
* This class enable the selection of several group of windows
*/
class DialogSubWindowSelector: public QDialog
{
Q_OBJECT
public:
DialogSubWindowSelector( QWidget *parent = 0, QMdiArea *mdiArea = 0 );
QStringList getSelectedWindows()
{
return m_pcSelectedWindowListNames;
}
private:
QMdiArea* m_pcMainWindowMdiArea;
QStringList m_pcWindowListNames;
QStringList m_pcSelectedWindowListNames;
QComboBox* m_comboBoxWindowList;
QPushButton* m_pushButtonAdd;
QPushButton* m_pushButtonRemove;
QListWidget* m_listSelectedWindows;
Void updateSubWindowList();
private Q_SLOTS:
void addSubWindow();
void removeSubWindow();
};
} // NAMESPACE
#endif // __DIALOGSUBWINDOWSELECTOR_H__
+4
View File
@@ -156,6 +156,10 @@ public:
m_cWindowName = name;
setWindowTitle( m_cWindowName );
}
QString getWindowName()
{
return m_cWindowName;
}
QString userFriendlyCurrentFile()
{
+56 -14
View File
@@ -25,6 +25,7 @@
#include "plaYUVerApp.h"
#include "SubWindowHandle.h"
#include "InputStream.h"
#include "DialogSubWindowSelector.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
@@ -325,6 +326,20 @@ Void plaYUVerApp::setTimerStatus()
}
}
Void plaYUVerApp::startPlay()
{
if( !m_bIsPlaying )
{
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
qDebug( ) << "Desired frame rate: "
<< QString::number( 1000 / timeInterval )
<< " fps";
playingTimer->start( timeInterval );
m_cTimer.start();
}
}
void plaYUVerApp::play()
{
if( !m_pcCurrentSubWindow )
@@ -361,17 +376,7 @@ void plaYUVerApp::play()
m_uiAveragePlayInterval = 0;
m_bIsPlaying = false;
}
if( !m_bIsPlaying )
{
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
qDebug( ) << "Desired frame rate: "
<< QString::number( 1000 / timeInterval )
<< " fps";
playingTimer->start( timeInterval );
m_cTimer.start();
}
startPlay();
}
void plaYUVerApp::pause()
@@ -531,6 +536,33 @@ void plaYUVerApp::lockButtonEvent()
}
}
void plaYUVerApp::videoSelectionButtonEvent()
{
DialogSubWindowSelector dialogWindowsSelection( this, mdiArea );
if( dialogWindowsSelection.exec() == QDialog::Accepted )
{
QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows();
m_acPlayingSubWindows.clear();
SubWindowHandle *subWindow;
QString windowName;
for( Int i = 0; i < mdiArea->subWindowList().size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( mdiArea->subWindowList().at( i ) );
windowName = subWindow->getWindowName();
if( selectedWindows.contains( windowName ) )
{
m_acPlayingSubWindows.append( subWindow );
subWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
subWindow->play();
m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )subWindow->getInputStream()->getFrameNum() - 1 ) );
}
}
m_arrayActions[VIDEO_LOCK_ACT]->setChecked( true );
startPlay();
return;
}
}
// ----------------------- Zoom Functions -----------------------
void plaYUVerApp::normalSize()
@@ -871,11 +903,12 @@ Void plaYUVerApp::createActions()
mapperSeekVideo = new QSignalMapper( this );
connect( mapperSeekVideo, SIGNAL( mapped(int) ), this, SLOT( seekEvent(int) ) );
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "VideoBackward", this );
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) );
mapperSeekVideo->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 );
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "VideoForward", this );
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this );
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) );
mapperSeekVideo->setMapping( m_arrayActions[VIDEO_FORWARD_ACT], 1 );
@@ -884,11 +917,15 @@ Void plaYUVerApp::createActions()
m_arrayActions[VIDEO_LOOP_ACT]->setCheckable( true );
m_arrayActions[VIDEO_LOOP_ACT]->setChecked( false );
m_arrayActions[VIDEO_LOCK_ACT] = new QAction( "VideoLock", this );
m_arrayActions[VIDEO_LOCK_ACT] = new QAction( "Video Lock", this );
m_arrayActions[VIDEO_LOCK_ACT]->setCheckable( true );
m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false );
connect( m_arrayActions[VIDEO_LOCK_ACT], SIGNAL( triggered() ), this, SLOT( lockButtonEvent() ) );
m_arrayActions[VIDEO_LOCK_SELECTION_ACT] = new QAction( "Video Lock Window Selection", this );
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
connect( m_arrayActions[VIDEO_LOCK_SELECTION_ACT], SIGNAL( triggered() ), this, SLOT( videoSelectionButtonEvent() ) );
m_pcFrameSlider = new QSlider;
m_pcFrameSlider->setOrientation( Qt::Horizontal );
m_pcFrameSlider->setMaximumWidth( 100 );
@@ -918,20 +955,24 @@ Void plaYUVerApp::createActions()
// ------------ Window ------------
m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "&Tile" ), this );
m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) );
m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) );
connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "&Cascade" ), this );
m_arrayActions[CASCADE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowscascade.png" ) );
m_arrayActions[CASCADE_WINDOWS_ACT]->setStatusTip( tr( "Cascade the windows" ) );
connect( m_arrayActions[CASCADE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( cascadeSubWindows() ) );
m_arrayActions[NEXT_WINDOWS_ACT] = new QAction( tr( "Ne&xt" ), this );
m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild );
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) );
m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) );
connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( activateNextSubWindow() ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) );
connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( activatePreviousSubWindow() ) );
@@ -991,6 +1032,7 @@ Void plaYUVerApp::createMenus()
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_FORWARD_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOOP_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_SELECTION_ACT] );
QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() );
connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) );
+3
View File
@@ -72,6 +72,7 @@ private Q_SLOTS:
void seekSliderEvent( int new_frame_num );
void seekEvent( int direction );
void lockButtonEvent();
void videoSelectionButtonEvent();
void selectModule( QAction * );
@@ -122,6 +123,7 @@ private:
//! Playing functions
UInt getMaxFrameNumber();
Void startPlay();
Void setTimerStatus();
Void updateCurrFrameNum();
Void updateTotalFrameNum( UInt total_frame_num = 0 );
@@ -206,6 +208,7 @@ private:
VIDEO_BACKWARD_ACT,
VIDEO_LOOP_ACT,
VIDEO_LOCK_ACT,
VIDEO_LOCK_SELECTION_ACT,
NAVIGATION_TOOL_ACT,
SELECTION_TOOL_ACT,
TILE_WINDOWS_ACT,