Commit df4a1dae authored by Stéphane Albert's avatar Stéphane Albert

ENH: Added QTranslator support.

parent c2a8fa5f
......@@ -42,7 +42,7 @@ endif(OTB_FOUND)
#----------------------------------------------------------------------------
# Qt4 settings
find_package( Qt4 REQUIRED QtCore QtGui)
find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL)
# setup Qt environement
set( QT_USE_QTCORE TRUE )
......@@ -111,7 +111,7 @@ set(Monteverdi2_INCLUDE_DIRS
${Monteverdi2_BINARY_DIR}/Code/Application
)
include_directories(${Monteverdi2_INCLUDE_DIRS})
include_directories(${Monteverdi2_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
#----------------------------------------------------------------------------
# Installation vars:
......
......@@ -31,6 +31,7 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "ConfigureMonteverdi2.h"
//
// Class pre-declaration.
......@@ -44,12 +45,12 @@ Application
::Application( int& argc, char** argv ) :
QApplication( argc, argv )
{
InitializeLocale();
QObject::connect(
this, SIGNAL( aboutToQuit() ),
this, SLOT( OnAboutToQuit() )
);
InitializeUI();
}
/*****************************************************************************/
......@@ -58,10 +59,56 @@ Application
{
}
/*****************************************************************************/
/*
bool
Application::Initialize()
{
InitializeLocale();
return true;
}
*/
/*****************************************************************************/
void
Application::InitializeUI()
Application::InitializeLocale()
{
QString localeName( QLocale::system().name() );
QString localeFilename( QString( PROJECT_NAME ).toLower() +
"_" +
localeName );
QTranslator localeTranslator;
if( !localeTranslator.load( localeFilename ) )
{
// TODO: Log error while loading locale translation file.
// TODO: Add QMessageBox::warning()!
qDebug(
">DEBUG> Failed to load '%s' locale translation file",
localeFilename.toLatin1().data()
);
return;
}
installTranslator( &localeTranslator );
qDebug(
">DEBUG> Successfully loaded '%s' locale translation file.",
localeFilename.toLatin1().data()
);
// TODO: Log locale translation filename used.
/* May be usefull...
QTextCodec::setCodecForTr( QTextCodec::codecForName( "utf8" ) );
*/
// TODO: Record locale translation filename used in UI component (e.g.
// AboutDialog, Settings dialog, Information dialog etc.)
}
/*****************************************************************************/
......@@ -71,7 +118,7 @@ void
Application
::OnAboutToQuit()
{
qDebug( ">DEBUG< mvd::Application::OnAboutToQuit()" );
qDebug( ">DEBUG> mvd::Application::OnAboutToQuit()" );
}
/*****************************************************************************/
......
......@@ -57,6 +57,13 @@ public:
/** Destructor */
virtual ~Application();
/**
*/
// bool Initialize();
signals:
//
//
protected:
......@@ -64,7 +71,9 @@ protected:
//
//
private:
void InitializeUI();
/**
*/
void InitializeLocale();
//
// SLOTS
......
......@@ -41,6 +41,7 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "ConfigureMonteverdi2.h"
namespace mvd
{
......@@ -67,6 +68,9 @@ void
MainWindow
::Initialize()
{
setObjectName( "mvd::MainWindow" );
setWindowTitle( PROJECT_NAME );
/*
QDockWidget* dock_widget = new DockWidget( tr( "Dock Widget" ), this );
......@@ -79,12 +83,17 @@ MainWindow
addDockWidget( Qt::LeftDockWidgetArea, dock_widget );
*/
/*
** WARNING: Do not mix QObject allocation system with the ITK one!
** (reason: QObject instances are linked in a parent-children tree;
** deallocaingt an object (especially widgets) deallocates its
** children).
*/
// Instanciate a QImageView
m_ImageView = ImageViewType::New();
// Set the GLImageWidget as the centralWidget in MainWindow.
setCentralWidget( m_ImageView->GetFullWidget() );
// Connect Quit action of main menu to QApplication's quit() slot.
QObject::connect(
......@@ -95,6 +104,18 @@ MainWindow
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
void
MainWindow::OnTranslatorLoaded( const QString& filename )
{
qDebug(
filename.isNull()
? ">DEBUG> Failed to load '%s' translation file."
: ">DEBUG> Loaded '%s' translation file.",
filename.toLatin1().data()
);
}
/*****************************************************************************/
void
MainWindow
......
......@@ -83,6 +83,7 @@ private:
ImageViewType::Pointer m_ImageView;
private slots:
void OnTranslatorLoaded( const QString& );
void on_action_Open_activated();
};
......
......@@ -236,13 +236,15 @@ void GLImageWidget::initializeGL()
glFlush();
std::cout << "Paint GL done "<< std::endl;
// std::cout << "Paint GL done "<< std::endl;
}
void GLImageWidget::mousePressEvent( QMouseEvent * event)
{
/*
std::cout <<" !!!! Mouse press event " << std::endl;
std::cout <<"x " << event->x()<< std::endl;
*/
m_MousePressEventX = event->x();
m_MousePressEventY = event->y();
}
......
......@@ -178,9 +178,11 @@ ImageView<TViewerModel>
{
otbMsgDevMacro(<< "ImageView::UpdateFullWidget(): redrawing full widget");
/*
std::cout <<" m_Model->GetRasterizedExtract()->GetLargestPossibleRegion() "
<< m_Model->GetRasterizedExtract()->GetLargestPossibleRegion() << std::endl;
*/
m_FullWidget->ReadBuffer(m_Model->GetRasterizedExtract(), m_Model->GetRasterizedExtract()
->GetLargestPossibleRegion());
......
......@@ -24,6 +24,7 @@
//
// Qt includes (sorted by alphabetic order)
#include <QObject>
//
// ITK includes (sorted by alphabetic order)
......@@ -45,8 +46,11 @@ namespace mvd
/** \class MyClass
*
*/
class MyClass
class MyClass :
public QObject
{
Q_OBJECT;
public:
/** Constructor */
......@@ -55,11 +59,13 @@ public:
/** Destructor */
virtual ~MyClass();
signals:
protected:
private:
//private slots:
private slots:
};
} // end namespace 'mvd'
......
// Monteverdi version
// Monteverdi2 project
#define PROJECT_NAME "@PROJECT_NAME@"
// Monteverdi2 version
#define Monteverdi2_VERSION_MAJOR @Monteverdi2_VERSION_MAJOR@
#define Monteverdi2_VERSION_MINOR @Monteverdi2_VERSION_MINOR@
#define Monteverdi2_VERSION_PATCH @Monteverdi2_VERSION_PATCH@
#define Monteverdi2_VERSION_STRING "@Monteverdi2_VERSION_STRING@"
#define Monteverdi2_SOURCE_DIR "@Monteverdi2_SOURCE_DIR@"
// Miscellaneous
//#define Monteverdi2_SOURCE_DIR "@Monteverdi2_SOURCE_DIR@"
#define Monteverdi2_FLOATING_TYPE @Monteverdi2_FLOATING_TYPE@
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