Qt:
ADDED dynamic translation file loading ADDED File->Exit menu entry SIMPLIFIED menu construction git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@362 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
f4c29fa641
commit
b59b226da8
121
lang/german.ts
121
lang/german.ts
|
@ -1,102 +1,185 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS><TS version="1.1" language="de_DE">
|
<!DOCTYPE TS><TS version="1.1" language="de_DE">
|
||||||
<defaultcodec></defaultcodec>
|
<defaultcodec></defaultcodec>
|
||||||
|
<context>
|
||||||
|
<name>@default</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="96"/>
|
||||||
|
<source>About VBA-M</source>
|
||||||
|
<translation type="obsolete">Über VBA-M</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="97"/>
|
||||||
|
<source>This program is licensed under terms of the GNU General Public License.</source>
|
||||||
|
<translation type="obsolete">Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="111"/>
|
||||||
|
<source>OpenGL version 2.1 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 2.1 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="114"/>
|
||||||
|
<source>OpenGL version 2.0 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 2.0 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="117"/>
|
||||||
|
<source>OpenGL version 1.5 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 1.5 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="120"/>
|
||||||
|
<source>OpenGL version 1.4 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 1.4 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="123"/>
|
||||||
|
<source>OpenGL version 1.3 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 1.3 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="126"/>
|
||||||
|
<source>OpenGL version 1.2 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 1.2 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="129"/>
|
||||||
|
<source>OpenGL version 1.1 is present.</source>
|
||||||
|
<translation type="obsolete">OpenGL Version 1.1 ist verfügbar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="135"/>
|
||||||
|
<source>OpenGL is NOT available!</source>
|
||||||
|
<translation type="obsolete">OpenGL ist NICHT verfügbar!</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="138"/>
|
||||||
|
<source>About OpenGL</source>
|
||||||
|
<translation type="obsolete">Über OpenGL</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MainWnd</name>
|
<name>MainWnd</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="29"/>
|
<location filename="../src/qt/MainWnd.cpp" line="35"/>
|
||||||
<source>VBA-M</source>
|
<source>VBA-M</source>
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="40"/>
|
<location filename="../src/qt/MainWnd.cpp" line="67"/>
|
||||||
<source>&File</source>
|
<source>&File</source>
|
||||||
<translation>&Datei</translation>
|
<translation>&Datei</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="41"/>
|
<location filename="../src/qt/MainWnd.cpp" line="71"/>
|
||||||
<source>&Settings</source>
|
<source>&Settings</source>
|
||||||
<translation>&Einstellungen</translation>
|
<translation>&Einstellungen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="42"/>
|
<location filename="../src/qt/MainWnd.cpp" line="75"/>
|
||||||
<source>&Tools</source>
|
<source>&Tools</source>
|
||||||
<translation>&Werkzeuge</translation>
|
<translation>&Werkzeuge</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="43"/>
|
<location filename="../src/qt/MainWnd.cpp" line="78"/>
|
||||||
<source>&Help</source>
|
<source>&Help</source>
|
||||||
<translation>&Hilfe</translation>
|
<translation>&Hilfe</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="45"/>
|
<location filename="../src/qt/MainWnd.cpp" line="81"/>
|
||||||
<source>About &OpenGL...</source>
|
<source>About &OpenGL...</source>
|
||||||
<translation>Über &OpenGL...</translation>
|
<translation>Über &OpenGL...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="49"/>
|
<location filename="../src/qt/MainWnd.cpp" line="80"/>
|
||||||
<source>About &VBA-M...</source>
|
<source>About &VBA-M...</source>
|
||||||
<translation>Über &VBA-M...</translation>
|
<translation>Über &VBA-M...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="53"/>
|
<location filename="../src/qt/MainWnd.cpp" line="82"/>
|
||||||
<source>About &Qt...</source>
|
<source>About &Qt...</source>
|
||||||
<translation>Über &Qt...</translation>
|
<translation>Über &Qt...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="74"/>
|
<location filename="../src/qt/MainWnd.cpp" line="128"/>
|
||||||
<source>This program is licensed under terms of the GNU General Public License.</source>
|
<source>This program is licensed under terms of the GNU General Public License.</source>
|
||||||
<translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
|
<translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="88"/>
|
<location filename="../src/qt/MainWnd.cpp" line="142"/>
|
||||||
<source>OpenGL version 2.1 is present.</source>
|
<source>OpenGL version 2.1 is present.</source>
|
||||||
<translation>OpenGL Version 2.1 ist verfügbar.</translation>
|
<translation>OpenGL Version 2.1 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="91"/>
|
<location filename="../src/qt/MainWnd.cpp" line="145"/>
|
||||||
<source>OpenGL version 2.0 is present.</source>
|
<source>OpenGL version 2.0 is present.</source>
|
||||||
<translation>OpenGL Version 2.0 ist verfügbar.</translation>
|
<translation>OpenGL Version 2.0 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="94"/>
|
<location filename="../src/qt/MainWnd.cpp" line="148"/>
|
||||||
<source>OpenGL version 1.5 is present.</source>
|
<source>OpenGL version 1.5 is present.</source>
|
||||||
<translation>OpenGL Version 1.5 ist verfügbar.</translation>
|
<translation>OpenGL Version 1.5 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="97"/>
|
<location filename="../src/qt/MainWnd.cpp" line="151"/>
|
||||||
<source>OpenGL version 1.4 is present.</source>
|
<source>OpenGL version 1.4 is present.</source>
|
||||||
<translation>OpenGL Version 1.4 ist verfügbar.</translation>
|
<translation>OpenGL Version 1.4 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="100"/>
|
<location filename="../src/qt/MainWnd.cpp" line="154"/>
|
||||||
<source>OpenGL version 1.3 is present.</source>
|
<source>OpenGL version 1.3 is present.</source>
|
||||||
<translation>OpenGL Version 1.3 ist verfügbar.</translation>
|
<translation>OpenGL Version 1.3 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="103"/>
|
<location filename="../src/qt/MainWnd.cpp" line="157"/>
|
||||||
<source>OpenGL version 1.2 is present.</source>
|
<source>OpenGL version 1.2 is present.</source>
|
||||||
<translation>OpenGL Version 1.2 ist verfügbar.</translation>
|
<translation>OpenGL Version 1.2 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="106"/>
|
<location filename="../src/qt/MainWnd.cpp" line="160"/>
|
||||||
<source>OpenGL version 1.1 is present.</source>
|
<source>OpenGL version 1.1 is present.</source>
|
||||||
<translation>OpenGL Version 1.1 ist verfügbar.</translation>
|
<translation>OpenGL Version 1.1 ist verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="112"/>
|
<location filename="../src/qt/MainWnd.cpp" line="166"/>
|
||||||
<source>OpenGL is NOT available!</source>
|
<source>OpenGL is NOT available!</source>
|
||||||
<translation>OpenGL ist NICHT verfügbar!</translation>
|
<translation>OpenGL ist NICHT verfügbar!</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="73"/>
|
<location filename="../src/qt/MainWnd.cpp" line="127"/>
|
||||||
<source>About VBA-M</source>
|
<source>About VBA-M</source>
|
||||||
<translation>Über VBA-M</translation>
|
<translation>Über VBA-M</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/qt/MainWnd.cpp" line="115"/>
|
<location filename="../src/qt/MainWnd.cpp" line="169"/>
|
||||||
<source>About OpenGL</source>
|
<source>About OpenGL</source>
|
||||||
<translation>Über OpenGL</translation>
|
<translation>Über OpenGL</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="72"/>
|
||||||
|
<source>Select translation...</source>
|
||||||
|
<translation>Übersetzung auswählen...</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="102"/>
|
||||||
|
<source>Select translation</source>
|
||||||
|
<translation>Übersetzung auswählen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="104"/>
|
||||||
|
<source>Translation files (*.qm)</source>
|
||||||
|
<translation>Übersetzungsdateien (*.qm)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="107"/>
|
||||||
|
<source>.qm</source>
|
||||||
|
<translation></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/qt/MainWnd.cpp" line="68"/>
|
||||||
|
<source>Exit</source>
|
||||||
|
<translation>Beenden</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -20,8 +20,14 @@
|
||||||
|
|
||||||
#include "glwidget.h"
|
#include "glwidget.h"
|
||||||
|
|
||||||
MainWnd::MainWnd( QWidget *parent )
|
MainWnd::MainWnd( QWidget *parent, QApplication *app, QTranslator **trans )
|
||||||
: QMainWindow( parent )
|
: QMainWindow( parent ),
|
||||||
|
theApp( app ),
|
||||||
|
translator( trans ),
|
||||||
|
fileMenu( 0 ),
|
||||||
|
settingsMenu( 0 ),
|
||||||
|
toolsMenu( 0 ),
|
||||||
|
helpMenu( 0 )
|
||||||
{
|
{
|
||||||
createDisplay();
|
createDisplay();
|
||||||
|
|
||||||
|
@ -37,22 +43,43 @@ MainWnd::~MainWnd()
|
||||||
|
|
||||||
void MainWnd::createMenus()
|
void MainWnd::createMenus()
|
||||||
{
|
{
|
||||||
QMenu *fileMenu = menuBar()->addMenu( tr( "&File" ) );
|
if( fileMenu ) {
|
||||||
QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ) );
|
delete fileMenu;
|
||||||
QMenu *toolsMenu = menuBar()->addMenu( tr( "&Tools" ) );
|
fileMenu = 0;
|
||||||
QMenu *helpMenu = menuBar()->addMenu( tr( "&Help" ) );
|
}
|
||||||
|
|
||||||
QAction *showAboutOpenGLAct = new QAction( tr( "About &OpenGL..." ), this );
|
if( settingsMenu ) {
|
||||||
connect( showAboutOpenGLAct, SIGNAL( triggered() ), this, SLOT( showAboutOpenGL() ) );
|
delete settingsMenu;
|
||||||
helpMenu->addAction( showAboutOpenGLAct );
|
settingsMenu = 0;
|
||||||
|
}
|
||||||
|
|
||||||
QAction *showAboutAct = new QAction( tr( "About &VBA-M..." ), this );
|
if( toolsMenu ) {
|
||||||
connect( showAboutAct, SIGNAL( triggered() ), this, SLOT( showAbout() ) );
|
delete toolsMenu;
|
||||||
helpMenu->addAction( showAboutAct );
|
toolsMenu = 0;
|
||||||
|
}
|
||||||
|
|
||||||
QAction *showAboutQtAct = new QAction( tr( "About &Qt..." ), this );
|
if( helpMenu ) {
|
||||||
connect( showAboutQtAct, SIGNAL( triggered() ), this, SLOT( showAboutQt() ) );
|
delete helpMenu;
|
||||||
helpMenu->addAction( showAboutQtAct );
|
helpMenu = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File menu
|
||||||
|
fileMenu = menuBar()->addMenu( tr( "&File" ) );
|
||||||
|
fileMenu->addAction( tr( "Exit" ), this, SLOT( close() ) );
|
||||||
|
|
||||||
|
// Settings menu
|
||||||
|
settingsMenu = menuBar()->addMenu( tr( "&Settings" ) );
|
||||||
|
settingsMenu->addAction( tr( "Select translation..." ), this, SLOT( selectTranslation() ) );
|
||||||
|
|
||||||
|
// Tools menu
|
||||||
|
toolsMenu = menuBar()->addMenu( tr( "&Tools" ) );
|
||||||
|
|
||||||
|
// Help menu
|
||||||
|
helpMenu = menuBar()->addMenu( tr( "&Help" ) );
|
||||||
|
|
||||||
|
helpMenu->addAction( tr( "About &VBA-M..." ), this, SLOT( showAbout() ) );
|
||||||
|
helpMenu->addAction( tr( "About &OpenGL..." ), this, SLOT( showAboutOpenGL() ) );
|
||||||
|
helpMenu->addAction( tr( "About &Qt..." ), this, SLOT( showAboutQt() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWnd::createDisplay()
|
bool MainWnd::createDisplay()
|
||||||
|
@ -68,6 +95,33 @@ bool MainWnd::createDisplay()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWnd::selectTranslation()
|
||||||
|
{
|
||||||
|
QString file = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr( "Select translation" ),
|
||||||
|
"lang",
|
||||||
|
tr( "Translation files (*.qm)" ) );
|
||||||
|
|
||||||
|
if( file.isNull() ) return;
|
||||||
|
if( !file.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return;
|
||||||
|
|
||||||
|
// load translation
|
||||||
|
if( *translator != 0 ) {
|
||||||
|
theApp->removeTranslator( *translator );
|
||||||
|
delete *translator;
|
||||||
|
*translator = 0;
|
||||||
|
}
|
||||||
|
file.chop( 3 ); // remove file extension ".qm"
|
||||||
|
*translator = new QTranslator();
|
||||||
|
(*translator)->load( file );
|
||||||
|
theApp->installTranslator( *translator );
|
||||||
|
|
||||||
|
// apply translation
|
||||||
|
createMenus();
|
||||||
|
// the user might have to restart the application to apply changes completely
|
||||||
|
}
|
||||||
|
|
||||||
void MainWnd::showAbout()
|
void MainWnd::showAbout()
|
||||||
{
|
{
|
||||||
QMessageBox::about( this, tr( "About VBA-M" ),
|
QMessageBox::about( this, tr( "About VBA-M" ),
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MainWnd : public QMainWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWnd::MainWnd( QWidget *parent = 0 );
|
MainWnd::MainWnd( QWidget *parent = 0, QApplication *app = 0, QTranslator **trans = 0 );
|
||||||
MainWnd::~MainWnd();
|
MainWnd::~MainWnd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -34,9 +34,18 @@ private:
|
||||||
bool createDisplay();
|
bool createDisplay();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void selectTranslation();
|
||||||
void showAbout();
|
void showAbout();
|
||||||
void showAboutQt();
|
|
||||||
void showAboutOpenGL();
|
void showAboutOpenGL();
|
||||||
|
void showAboutQt();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QApplication *theApp;
|
||||||
|
QTranslator **translator;
|
||||||
|
QMenu *fileMenu;
|
||||||
|
QMenu *settingsMenu;
|
||||||
|
QMenu *toolsMenu;
|
||||||
|
QMenu *helpMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef MAINWND_H
|
#endif // #ifndef MAINWND_H
|
||||||
|
|
|
@ -23,12 +23,9 @@
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
QApplication theApp( argc, argv );
|
QApplication theApp( argc, argv );
|
||||||
|
QTranslator *translator = 0;
|
||||||
|
|
||||||
QTranslator translator;
|
MainWnd *mainWnd = new MainWnd( 0, &theApp, &translator );
|
||||||
translator.load( "lang/german" );
|
|
||||||
theApp.installTranslator( &translator );
|
|
||||||
|
|
||||||
MainWnd *mainWnd = new MainWnd();
|
|
||||||
mainWnd->show();
|
mainWnd->show();
|
||||||
|
|
||||||
return theApp.exec();
|
return theApp.exec();
|
||||||
|
|
Loading…
Reference in New Issue