Commit abc01ec7 authored by Stéphane Albert's avatar Stéphane Albert
Browse files

BUG: MANTIS-1196: (Full fix) Connected OTB-app quit-button to OTB-app window...

BUG: MANTIS-1196: (Full fix) Connected OTB-app quit-button to OTB-app window close-signal; Factorized OTB-app window instantiation in mvd::Wrapper::ApplicationLauncher.
parent 9282be85
......@@ -221,25 +221,15 @@ MainWindow
->GetLauncher()!=NULL
);
Wrapper::QtWidgetView* appWidget =
QWidget * appWindow =
Application::ConstInstance()
->GetModel< OTBApplicationsModel >()
->GetLauncher()
->NewOtbApplicationWidget( appName, true );
->NewOtbApplicationWindow( appName, true, this );
assert( appWidget!=NULL );
assert( appWidget->GetApplication() );
assert( appWindow!=NULL );
QMainWindow * mainWindow = new QMainWindow( /* this */ );
mainWindow->setWindowTitle(
QString( "%1 (OTB-" OTB_VERSION_STRING ")" )
.arg( appWidget->GetApplication()->GetDocName() )
);
mainWindow->setCentralWidget( appWidget );
mainWindow->show();
appWindow->show();
/*
//
......
......@@ -2023,6 +2023,7 @@ MainWindow
Application::ConstInstance()->GetOTBApplicationsModel()->GetLauncher()!=NULL
);
#if USE_TABBED_VIEW
Wrapper::QtWidgetView * appWidget =
Application::ConstInstance()
->GetOTBApplicationsModel()
......@@ -2030,17 +2031,10 @@ MainWindow
->NewOtbApplicationWidget(
appName,
true
#if USE_TABBED_VIEW
#else // USE_TABBED_VIEW
, this
, Qt::Window
#endif // USE_TABBED_VIEW
);
assert( appWidget!=NULL );
#if USE_TABBED_VIEW
//
// add the application in a tab
// TODO : check if this application is already opened ???
......@@ -2051,8 +2045,30 @@ MainWindow
// done. Focus on the newly added tab
m_CentralTabWidget->setCurrentIndex( tabIndex );
//
// on quit widget signal, close its tab
QObject::connect(
appWidget,
SIGNAL( QuitSignal() ),
// to:
this,
SLOT( OnTabCloseRequested() )
);
#else // USE_TABBED_VIEW
QWidget * appWidget =
Application::ConstInstance()
->GetOTBApplicationsModel()
->GetLauncher()
->NewOtbApplicationWindow(
appName,
true,
this
);
assert( appWidget!=NULL );
appWidget->setWindowTitle( docName );
appWidget->show();
......@@ -2079,22 +2095,6 @@ MainWindow
this,
SLOT( OnExecutionDone( int ) )
);
//
// on quit widget signal, close its tab
#if USE_TABBED_VIEW
QObject::connect(
appWidget,
SIGNAL( QuitSignal() ),
// to:
this,
SLOT( OnTabCloseRequested() )
);
#else // USE_TABBED_VIEW
#endif // USE_TABBED_VIEW
}
#endif // defined( OTB_USE_QT4 ) && USE_OTB_APPS
......
......@@ -80,7 +80,7 @@ ApplicationLauncher
}
/*******************************************************************************/
Wrapper::QtWidgetView*
Wrapper::QtWidgetView *
ApplicationLauncher
::NewOtbApplicationWidget( const QString & appName,
bool isStandalone,
......@@ -195,40 +195,82 @@ ApplicationLauncher
}
// Create GUI based on module
Wrapper::QtWidgetView* gui =
Wrapper::QtWidgetView * gui =
new Wrapper::QtWidgetView( otbApp, isStandalone, parent, flags );
gui->CreateGui();
return gui;
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
void
QWidget *
ApplicationLauncher
::OnApplicationToLaunchSelected( const QString& appName )
::NewOtbApplicationWindow( const QString & appName,
bool isStandalone,
QWidget * parent,
Qt::WindowFlags flags ) const
{
QWidget* gui = ApplicationLauncher::NewOtbApplicationWidget( appName );
#if 0
Wrapper::QtWidgetView * appWidget =
ApplicationLauncher::NewOtbApplicationWidget( appName, isStandalone );
assert( appWidget!=NULL );
assert( appWidget->GetApplication() );
QMainWindow * mainWindow = new QMainWindow( parent, flags );
mainWindow->setWindowTitle(
QString( "%1 (OTB-" OTB_VERSION_STRING ")" )
.arg( appWidget->GetApplication()->GetDocName() )
);
mainWindow->setWindowIcon( QIcon( ":/otb_small.png" ) );
mainWindow->setCentralWidget( appWidget );
// Connect OTB-app widget quit signal, to the mainWindow close slot.
QObject::connect(
appWidget,
SIGNAL( QuitSignal() ),
// to:
mainWindow,
SLOT( close() )
);
return mainWindow;
#else
Wrapper::QtWidgetView * appWidget =
ApplicationLauncher::NewOtbApplicationWidget(
appName,
isStandalone,
parent,
flags | Qt::Window
);
assert( appWidget!=NULL );
assert( appWidget->GetApplication() );
assert( gui!=NULL );
appWidget->setWindowTitle(
QString( "%1 (OTB-" OTB_VERSION_STRING ")" )
.arg( appWidget->GetApplication()->GetDocName() )
);
// MainWidget : that contains the view and any other widget
// (progress, logs...)
QMainWindow* mainWindow = new QMainWindow();
mainWindow->setWindowIcon(QIcon( ":/otb_small.png" ));
//mainWindow->setWindowTitle(QString(gui->->GetDocName()).append(" - ").append(OTB_VERSION_STRING));
appWidget->setWindowIcon( QIcon( ":/icons/process" ) );
// build the main window, central widget is the plugin view, other
// are docked widget (progress, logs...)
mainWindow->setCentralWidget( gui );
// Connect the View "Quit" signal, to the mainWindow close slot
QObject::connect(gui, SIGNAL(QuitSignal()), mainWindow, SLOT(close()));
// Show the main window
mainWindow->show();
QObject::connect(
appWidget,
SIGNAL( QuitSignal() ),
// to:
appWidget,
SLOT( close() )
);
return appWidget;
#endif
}
/*******************************************************************************/
/* SLOTS */
} // end namespace 'mvd'
......@@ -33,7 +33,7 @@
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtCore>
#include <QtGui>
//
// System includes (sorted by alphabetic order)
......@@ -98,18 +98,24 @@ public:
* \return A new instance of the automatically-generated widget of
* the given OTB application.
*/
Wrapper::QtWidgetView*
Wrapper::QtWidgetView *
NewOtbApplicationWidget( const QString & appName,
bool isStandalone =false,
QWidget * parent =NULL,
Qt::WindowFlags =0 ) const;
/**
*/
QWidget * NewOtbApplicationWindow( const QString & appName,
bool isStandalone =false,
QWidget * parent =NULL,
Qt::WindowFlags =0 ) const;
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
// Public SLOTS.
public slots:
void OnApplicationToLaunchSelected(const QString& appname);
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
......
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