mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Fixed untranslatable strings issue.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "Artist.h"
|
||||
#include "Album.h"
|
||||
@@ -129,6 +130,29 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
|
||||
|
||||
registerMetaTypes();
|
||||
installTranslator();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkApp::installTranslator()
|
||||
{
|
||||
QString locale = QLocale::system().name();
|
||||
if ( locale == "C" )
|
||||
locale = "en";
|
||||
|
||||
QTranslator* translator = new QTranslator( this );
|
||||
if ( translator->load( QString( ":/lang/tomahawk_" ) + locale ) )
|
||||
{
|
||||
tDebug() << "Using system locale:" << locale;
|
||||
}
|
||||
else
|
||||
{
|
||||
tDebug() << "Using default locale, system locale one not found:" << locale;
|
||||
translator->load( QString( ":/lang/tomahawk_en" ) );
|
||||
}
|
||||
|
||||
TOMAHAWK_APPLICATION::installTranslator( translator );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -115,6 +115,7 @@ private slots:
|
||||
void accountManagerReady();
|
||||
|
||||
private:
|
||||
void installTranslator();
|
||||
void registerMetaTypes();
|
||||
|
||||
void printHelp();
|
||||
|
35
src/main.cpp
35
src/main.cpp
@@ -25,8 +25,6 @@
|
||||
#include "config.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QTranslator>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#include "TomahawkApp_Mac.h"
|
||||
#include </System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers/AppleEvents.h>
|
||||
@@ -38,6 +36,7 @@
|
||||
#include "breakpad/BreakPad.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// code from patch attached to QTBUG-19064 by Honglei Zhang
|
||||
LRESULT QT_WIN_CALLBACK qt_LowLevelKeyboardHookProc( int nCode, WPARAM wParam, LPARAM lParam );
|
||||
@@ -48,7 +47,8 @@ LRESULT QT_WIN_CALLBACK qt_LowLevelKeyboardHookProc(int nCode, WPARAM wParam, LP
|
||||
{
|
||||
LPKBDLLHOOKSTRUCT kbHookStruct = reinterpret_cast<LPKBDLLHOOKSTRUCT>(lParam);
|
||||
|
||||
switch(kbHookStruct->vkCode){
|
||||
switch(kbHookStruct->vkCode)
|
||||
{
|
||||
case VK_VOLUME_MUTE:
|
||||
case VK_VOLUME_DOWN:
|
||||
case VK_VOLUME_UP:
|
||||
@@ -60,12 +60,12 @@ LRESULT QT_WIN_CALLBACK qt_LowLevelKeyboardHookProc(int nCode, WPARAM wParam, LP
|
||||
// send message
|
||||
{
|
||||
HWND hWnd = NULL;
|
||||
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
|
||||
foreach ( QWidget *widget, QApplication::topLevelWidgets() )
|
||||
{
|
||||
// relay message to each top level widgets(window)
|
||||
// if the window has focus, we don't send a duplicate message
|
||||
if(QApplication::activeWindow() == widget){
|
||||
if ( QApplication::activeWindow() == widget )
|
||||
continue;
|
||||
}
|
||||
|
||||
hWnd = widget->winId();
|
||||
|
||||
@@ -77,6 +77,7 @@ LRESULT QT_WIN_CALLBACK qt_LowLevelKeyboardHookProc(int nCode, WPARAM wParam, LP
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -89,13 +90,11 @@ LRESULT QT_WIN_CALLBACK qt_LowLevelKeyboardHookProc(int nCode, WPARAM wParam, LP
|
||||
#define argv __argv
|
||||
// code taken from AbiWord, (c) AbiSource Inc.
|
||||
|
||||
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
PSTR szCmdLine, int iCmdShow)
|
||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
|
||||
{
|
||||
hKeyboardHook = NULL;
|
||||
hGuiLibInstance = hInstance;
|
||||
|
||||
|
||||
// setup keyboard hook to receive multimedia key events when application is at background
|
||||
hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL,(HOOKPROC) qt_LowLevelKeyboardHookProc, hGuiLibInstance, 0 );
|
||||
|
||||
@@ -106,7 +105,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
else
|
||||
{
|
||||
typedef BOOL (WINAPI * AttachConsole_t) (DWORD);
|
||||
|
||||
AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress( GetModuleHandleW( L"kernel32.dll" ), "AttachConsole" );
|
||||
|
||||
if ( p_AttachConsole != NULL && p_AttachConsole( ATTACH_PARENT_PROCESS ) )
|
||||
@@ -145,7 +143,6 @@ main( int argc, char *argv[] )
|
||||
new TomahawkSettingsGui( &a );
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESSs
|
||||
#ifdef WITH_BREAKPAD
|
||||
new BreakPad( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() );
|
||||
@@ -158,21 +155,6 @@ main( int argc, char *argv[] )
|
||||
if ( guard.isPrimaryInstance() )
|
||||
a.init();
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
if ( locale == "C" )
|
||||
locale = "en";
|
||||
QTranslator translator;
|
||||
if ( translator.load( QString( ":/lang/tomahawk_" ) + locale ) )
|
||||
{
|
||||
tDebug() << "Using system locale:" << locale;
|
||||
}
|
||||
else
|
||||
{
|
||||
tDebug() << "Using default locale, system locale one not found:" << locale;
|
||||
translator.load( QString( ":/lang/tomahawk_en" ) );
|
||||
}
|
||||
a.installTranslator( &translator );
|
||||
|
||||
if ( argc > 1 )
|
||||
{
|
||||
QString arg = a.arguments()[ 1 ];
|
||||
@@ -188,6 +170,7 @@ main( int argc, char *argv[] )
|
||||
hKeyboardHook = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user