Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
d8c00795
Commit
d8c00795
authored
Mar 18, 2013
by
Stéphane Albert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Added Common/Gui/I18nMainWindow.
parent
17ca92ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
454 additions
and
0 deletions
+454
-0
Code/Common/Gui/CMakeLists.txt
Code/Common/Gui/CMakeLists.txt
+2
-0
Code/Common/Gui/mvdI18nMainWindow.cxx
Code/Common/Gui/mvdI18nMainWindow.cxx
+199
-0
Code/Common/Gui/mvdI18nMainWindow.h
Code/Common/Gui/mvdI18nMainWindow.h
+253
-0
No files found.
Code/Common/Gui/CMakeLists.txt
View file @
d8c00795
...
...
@@ -15,6 +15,7 @@ set( Common_Gui_SOURCES
mvdDatasetCreationProgressDialog.cxx
mvdGLImageWidget.cxx
mvdGui.cxx
mvdI18nMainWindow.cxx
mvdImageModelRenderer.cxx
mvdImageViewManipulator.cxx
mvdMainWindowTitleLoader.cxx
...
...
@@ -41,6 +42,7 @@ set( Common_Gui_HEADERS_MOC
mvdDatasetCreationProgressDialog.h
mvdGLImageWidget.h
# mvdGui.h
mvdI18nMainWindow.h
mvdImageModelRenderer.h
mvdImageViewManipulator.h
mvdMainWindowTitleLoader.h
...
...
Code/Common/Gui/mvdI18nMainWindow.cxx
0 → 100644
View file @
d8c00795
/*=========================================================================
Program: Monteverdi2
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdI18nMainWindow.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "otbSystem.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdI18nApplication.h"
#include "Core/mvdDatasetModel.h"
//
#include "Gui/mvdAboutDialog.h"
namespace
mvd
{
/*
TRANSLATOR mvd::I18nMainWindow
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
I18nMainWindow
::
I18nMainWindow
(
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QMainWindow
(
parent
,
flags
)
{
}
/*****************************************************************************/
I18nMainWindow
::~
I18nMainWindow
()
{
}
/*****************************************************************************/
void
I18nMainWindow
::
Initialize
()
{
/*
// Default setup.
setObjectName( "mvd::I18nMainWindow" );
setWindowTitle( PROJECT_NAME );
*/
virtual_SetupUI
();
// Connect Appllication and MainWindow when selected model is about
// to change.
QObject
::
connect
(
qApp
,
SIGNAL
(
AboutToChangeModel
(
const
AbstractModel
*
)
),
this
,
SLOT
(
OnAboutToChangeModel
(
const
AbstractModel
*
)
)
);
// Connect Application and MainWindow when selected model has been
// changed.
QObject
::
connect
(
qApp
,
SIGNAL
(
ModelChanged
(
AbstractModel
*
)
),
this
,
SLOT
(
OnModelChanged
(
AbstractModel
*
)
)
);
virtual_ConnectUI
();
// Change to NULL model to force emitting GUI signals when GUI is
// instanciated. So, GUI will be initialized and controller-widgets
// disabled.
I18nApplication
::
Instance
()
->
SetModel
(
NULL
);
}
/*****************************************************************************/
QDockWidget
*
I18nMainWindow
::
AddWidgetToDock
(
QWidget
*
widget
,
const
QString
&
dockName
,
const
QString
&
dockTitle
,
Qt
::
DockWidgetArea
dockArea
)
{
// New dock.
QDockWidget
*
dockWidget
=
new
QDockWidget
(
dockTitle
,
this
);
// You can use findChild( dockName ) to get dock-widget.
dockWidget
->
setObjectName
(
dockName
);
dockWidget
->
setWidget
(
widget
);
// Features.
dockWidget
->
setFloating
(
false
);
dockWidget
->
setFeatures
(
QDockWidget
::
DockWidgetMovable
|
QDockWidget
::
DockWidgetFloatable
|
QDockWidget
::
DockWidgetClosable
);
// Add dock.
addDockWidget
(
dockArea
,
dockWidget
);
return
dockWidget
;
}
/*****************************************************************************/
void
I18nMainWindow
::
closeEvent
(
QCloseEvent
*
event
)
{
assert
(
event
!=
NULL
);
qDebug
()
<<
"I18nMainWindow::closeEvent("
<<
event
<<
")"
;
// Ensure there is an application instance.
assert
(
I18nApplication
::
ConstInstance
()
!=
NULL
);
// Ensure that there is no model or that the existing model is a
// DatasetModel.
assert
(
I18nApplication
::
ConstInstance
()
->
GetModel
()
==
I18nApplication
::
ConstInstance
()
->
GetModel
<
DatasetModel
>
()
);
// Get model.
DatasetModel
*
model
=
I18nApplication
::
Instance
()
->
GetModel
<
DatasetModel
>
();
if
(
model
==
NULL
||
!
model
->
IsModified
()
)
return
;
QMessageBox
::
StandardButton
clickedButton
=
ConfirmSaveQuit
(
true
);
switch
(
clickedButton
)
{
case
QMessageBox
::
Save
:
model
->
Save
();
break
;
case
QMessageBox
::
Discard
:
break
;
case
QMessageBox
::
Cancel
:
// Ignore event: do not close/quit.
event
->
ignore
();
break
;
default:
// should never be reached.
assert
(
false
);
break
;
}
}
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
void
I18nMainWindow
::
on_action_Quit_triggered
()
{
close
();
}
/*****************************************************************************/
void
I18nMainWindow
::
on_action_About_activated
()
{
AboutDialog
aboutDialog
(
this
);
aboutDialog
.
exec
();
}
/*****************************************************************************/
}
// end namespace 'mvd'
Code/Common/Gui/mvdI18nMainWindow.h
0 → 100644
View file @
d8c00795
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdI18nMainWindow_h
#define __mvdI18nMainWindow_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External class pre-declaration.
namespace
{
}
namespace
mvd
{
//
// Internal class pre-declaration.
class
AbstractModel
;
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class I18nMainWindow
*
* \brief Main-window widget base for the i18n application.
*/
class
Monteverdi2_EXPORT
I18nMainWindow
:
public
QMainWindow
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT
;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public types.
public:
//
// Public methods.
public:
/** \brief Destructor. */
virtual
~
I18nMainWindow
();
/**
*/
void
Initialize
();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// SIGNALS.
signals:
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
/** \brief Constructor. */
I18nMainWindow
(
QWidget
*
Parent
=
0
,
Qt
::
WindowFlags
flags
=
0
);
/**
*/
virtual
void
virtual_SetupUI
()
=
0
;
/**
*/
virtual
void
virtual_ConnectUI
()
=
0
;
//
// QMainWindow overrides.
void
closeEvent
(
QCloseEvent
*
event
);
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private nested classes.
private:
//
// Private methods.
private:
/**
*/
QDockWidget
*
AddWidgetToDock
(
QWidget
*
widget
,
const
QString
&
dockName
,
const
QString
&
dockTitle
,
Qt
::
DockWidgetArea
dockArea
);
/**
* \brief Assign model to the controller which is child of given
* dock-widget.
*
* \param dock The dock-widget which is parent of the controller to
* assign model to.
*
* \param model The model to assign to the controller.
*/
inline
void
SetControllerModel
(
QDockWidget
*
dock
,
AbstractModel
*
model
);
/**
*/
inline
QMessageBox
::
StandardButton
ConfirmSaveQuit
(
bool
canBeCancelled
);
//
// Private attributes.
private:
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Private slots.
private
slots
:
/**
* \brief Qt auto-connected slot which is called when File/Quit menu
* action is activated.
*/
void
on_action_Quit_triggered
();
/**
* \brief Qt auto-connected slot which is called when Help/About
* menu action is activated.
*/
void
on_action_About_activated
();
/**
*/
virtual
void
OnAboutToChangeModel
(
const
AbstractModel
*
)
=
0
;
/**
*/
virtual
void
OnModelChanged
(
AbstractModel
*
)
=
0
;
};
}
// end namespace 'mvd'
/*****************************************************************************/
/* INLINE SECTION */
//
// System includes (sorted by alphabetic order)
#include <cassert>
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "Gui/mvdAbstractModelController.h"
namespace
mvd
{
/*****************************************************************************/
inline
void
I18nMainWindow
::
SetControllerModel
(
QDockWidget
*
dock
,
AbstractModel
*
model
)
{
assert
(
dock
);
AbstractModelController
*
controller
=
dock
->
findChild
<
AbstractModelController
*
>
();
assert
(
controller
!=
NULL
);
controller
->
SetModel
(
model
);
}
/*****************************************************************************/
inline
QMessageBox
::
StandardButton
I18nMainWindow
::
ConfirmSaveQuit
(
bool
canBeCancelled
)
{
return
QMessageBox
::
question
(
this
,
tr
(
PROJECT_NAME
),
tr
(
"Dataset has been modified.
\n
"
"Do you want to save settings before quitting?"
),
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
(
canBeCancelled
?
QMessageBox
::
Cancel
:
QMessageBox
::
NoButton
),
QMessageBox
::
Save
);
}
}
// end namespace 'mvd'
#endif // __I18nMainWindow_h
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment