Qt:
ADDED dynamic translation file loading ADDED File->Exit menu entry SIMPLIFIED menu construction
This commit is contained in:
parent
ccd840dd89
commit
091813b638
121
lang/german.ts
121
lang/german.ts
|
@ -1,102 +1,185 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS><TS version="1.1" language="de_DE">
|
||||
<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>
|
||||
<name>MainWnd</name>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="29"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="35"/>
|
||||
<source>VBA-M</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="40"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="67"/>
|
||||
<source>&File</source>
|
||||
<translation>&Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="41"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="71"/>
|
||||
<source>&Settings</source>
|
||||
<translation>&Einstellungen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="42"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="75"/>
|
||||
<source>&Tools</source>
|
||||
<translation>&Werkzeuge</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="43"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="78"/>
|
||||
<source>&Help</source>
|
||||
<translation>&Hilfe</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="45"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="81"/>
|
||||
<source>About &OpenGL...</source>
|
||||
<translation>Über &OpenGL...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="49"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="80"/>
|
||||
<source>About &VBA-M...</source>
|
||||
<translation>Über &VBA-M...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="53"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="82"/>
|
||||
<source>About &Qt...</source>
|
||||
<translation>Über &Qt...</translation>
|
||||
</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>
|
||||
<translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 2.1 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 2.0 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 1.5 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 1.4 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 1.3 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 1.2 ist verfügbar.</translation>
|
||||
</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>
|
||||
<translation>OpenGL Version 1.1 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="112"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="166"/>
|
||||
<source>OpenGL is NOT available!</source>
|
||||
<translation>OpenGL ist NICHT verfügbar!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="73"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="127"/>
|
||||
<source>About VBA-M</source>
|
||||
<translation>Über VBA-M</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="115"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="169"/>
|
||||
<source>About OpenGL</source>
|
||||
<translation>Über OpenGL</translation>
|
||||
</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>
|
||||
</TS>
|
||||
|
|
|
@ -20,8 +20,14 @@
|
|||
|
||||
#include "glwidget.h"
|
||||
|
||||
MainWnd::MainWnd( QWidget *parent )
|
||||
: QMainWindow( parent )
|
||||
MainWnd::MainWnd( QWidget *parent, QApplication *app, QTranslator **trans )
|
||||
: QMainWindow( parent ),
|
||||
theApp( app ),
|
||||
translator( trans ),
|
||||
fileMenu( 0 ),
|
||||
settingsMenu( 0 ),
|
||||
toolsMenu( 0 ),
|
||||
helpMenu( 0 )
|
||||
{
|
||||
createDisplay();
|
||||
|
||||
|
@ -37,22 +43,43 @@ MainWnd::~MainWnd()
|
|||
|
||||
void MainWnd::createMenus()
|
||||
{
|
||||
QMenu *fileMenu = menuBar()->addMenu( tr( "&File" ) );
|
||||
QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ) );
|
||||
QMenu *toolsMenu = menuBar()->addMenu( tr( "&Tools" ) );
|
||||
QMenu *helpMenu = menuBar()->addMenu( tr( "&Help" ) );
|
||||
if( fileMenu ) {
|
||||
delete fileMenu;
|
||||
fileMenu = 0;
|
||||
}
|
||||
|
||||
QAction *showAboutOpenGLAct = new QAction( tr( "About &OpenGL..." ), this );
|
||||
connect( showAboutOpenGLAct, SIGNAL( triggered() ), this, SLOT( showAboutOpenGL() ) );
|
||||
helpMenu->addAction( showAboutOpenGLAct );
|
||||
if( settingsMenu ) {
|
||||
delete settingsMenu;
|
||||
settingsMenu = 0;
|
||||
}
|
||||
|
||||
QAction *showAboutAct = new QAction( tr( "About &VBA-M..." ), this );
|
||||
connect( showAboutAct, SIGNAL( triggered() ), this, SLOT( showAbout() ) );
|
||||
helpMenu->addAction( showAboutAct );
|
||||
if( toolsMenu ) {
|
||||
delete toolsMenu;
|
||||
toolsMenu = 0;
|
||||
}
|
||||
|
||||
QAction *showAboutQtAct = new QAction( tr( "About &Qt..." ), this );
|
||||
connect( showAboutQtAct, SIGNAL( triggered() ), this, SLOT( showAboutQt() ) );
|
||||
helpMenu->addAction( showAboutQtAct );
|
||||
if( helpMenu ) {
|
||||
delete helpMenu;
|
||||
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()
|
||||
|
@ -68,6 +95,33 @@ bool MainWnd::createDisplay()
|
|||
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()
|
||||
{
|
||||
QMessageBox::about( this, tr( "About VBA-M" ),
|
||||
|
|
|
@ -26,7 +26,7 @@ class MainWnd : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWnd::MainWnd( QWidget *parent = 0 );
|
||||
MainWnd::MainWnd( QWidget *parent = 0, QApplication *app = 0, QTranslator **trans = 0 );
|
||||
MainWnd::~MainWnd();
|
||||
|
||||
private:
|
||||
|
@ -34,9 +34,18 @@ private:
|
|||
bool createDisplay();
|
||||
|
||||
private slots:
|
||||
void selectTranslation();
|
||||
void showAbout();
|
||||
void showAboutQt();
|
||||
void showAboutOpenGL();
|
||||
void showAboutQt();
|
||||
|
||||
private:
|
||||
QApplication *theApp;
|
||||
QTranslator **translator;
|
||||
QMenu *fileMenu;
|
||||
QMenu *settingsMenu;
|
||||
QMenu *toolsMenu;
|
||||
QMenu *helpMenu;
|
||||
};
|
||||
|
||||
#endif // #ifndef MAINWND_H
|
||||
|
|
|
@ -23,12 +23,9 @@
|
|||
int main( int argc, char *argv[] )
|
||||
{
|
||||
QApplication theApp( argc, argv );
|
||||
QTranslator *translator = 0;
|
||||
|
||||
QTranslator translator;
|
||||
translator.load( "lang/german" );
|
||||
theApp.installTranslator( &translator );
|
||||
|
||||
MainWnd *mainWnd = new MainWnd();
|
||||
MainWnd *mainWnd = new MainWnd( 0, &theApp, &translator );
|
||||
mainWnd->show();
|
||||
|
||||
return theApp.exec();
|
||||
|
|
Loading…
Reference in New Issue