Merge branch 'master' of github.com:Sankore/Sankore-3.1

Conflicts:
	src/board/UBBoardController.cpp
preferencesAboutTextFull
Aleksei Kanash 13 years ago
commit 07aaa19b55
  1. 2
      lgpl.txt
  2. 1
      src/board/UBBoardController.cpp
  3. 67
      src/core/UBApplication.cpp
  4. 1
      src/core/UBApplication.h
  5. 4
      src/frameworks/UBFileSystemUtils.cpp
  6. 2
      src/frameworks/UBFileSystemUtils.h
  7. 5
      src/frameworks/UBPlatformUtils.h
  8. 17
      src/frameworks/UBPlatformUtils_linux.cpp
  9. 69
      src/frameworks/UBPlatformUtils_mac.mm
  10. 17
      src/frameworks/UBPlatformUtils_win.cpp
  11. 8
      src/gui/UBDocumentNavigator.cpp
  12. 2
      src/gui/UBLeftPalette.cpp
  13. 2
      src/gui/UBRightPalette.cpp
  14. 5
      src/gui/UBThumbnailWidget.cpp

@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Library.

@ -1234,7 +1234,6 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
if(documentChange)
{
emit activeDocumentChanged();
// Notify the navigator palette that the document has changed
emit setDocOnPageNavigator(pDocumentProxy);
UBGraphicsTextItem::lastUsedTextColor = QColor();
}

@ -135,27 +135,13 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
UBResources::resources();
if (!undoStack)
{
undoStack = new QUndoStack(staticMemoryCleaner);
}
mApplicationTranslator = new QTranslator(this);
mApplicationTranslator->load(UBPlatformUtils::preferredTranslation(QString("sankore_")));
installTranslator(mApplicationTranslator);
QString localString;
if (!mApplicationTranslator->isEmpty())
localString = UBPlatformUtils::preferredLanguage();
else
localString = "en_US";
mQtGuiTranslator = new QTranslator(this);
mQtGuiTranslator->load(UBPlatformUtils::preferredTranslation(QString("qt_")));
installTranslator(mQtGuiTranslator);
QString forcedLanguage("");
if(args.contains("-lang"))
forcedLanguage=args.at(args.indexOf("-lang") + 1);
QLocale::setDefault(QLocale(localString));
qDebug() << "Running application in:" << localString;
setupTranslator(forcedLanguage);
UBSettings *settings = UBSettings::settings();
@ -217,6 +203,51 @@ UBApplication::~UBApplication()
staticMemoryCleaner = 0;
}
void UBApplication::setupTranslator(QString forcedLanguage)
{
QStringList availablesTranslations = UBPlatformUtils::availableTranslations();
QString language("");
if(!forcedLanguage.isEmpty()){
if(availablesTranslations.contains(forcedLanguage,Qt::CaseInsensitive))
language = forcedLanguage;
else
qDebug() << "forced language " << forcedLanguage << " not available";
}
else{
QString systemLanguage = UBPlatformUtils::systemLanguage();
if(availablesTranslations.contains(systemLanguage,Qt::CaseInsensitive))
language = systemLanguage;
else
qDebug() << "translation for system language " << systemLanguage << " not found";
}
if(language.isEmpty()){
language = "en_US";
//fallback if no translation are available
}
else{
mApplicationTranslator = new QTranslator(this);
mQtGuiTranslator = new QTranslator(this);
mApplicationTranslator->load(UBPlatformUtils::translationPath(QString("sankore_"),language));
installTranslator(mApplicationTranslator);
mQtGuiTranslator->load(UBPlatformUtils::translationPath(QString("qt_"),language));
if(!mQtGuiTranslator->isEmpty()){
// checked because this translation could be not available
installTranslator(mQtGuiTranslator);
}
else
qDebug() << "Qt gui translation in " << language << " are not available";
}
QLocale::setDefault(QLocale(language));
qDebug() << "Running application in:" << language;
}
int UBApplication::exec(const QString& pFileToImport)
{
QPixmapCache::setCacheLimit(1024 * 100);

@ -121,6 +121,7 @@ class UBApplication : public QtSingleApplication
private:
void updateProtoActionsState();
void setupTranslator(QString forcedLanguage);
QList<QMenu*> mProtoMenus;
bool mIsVerbose;

@ -177,7 +177,7 @@ void UBFileSystemUtils::cleanupGhostTempFolders(const QString& templateString)
}
QStringList UBFileSystemUtils::allFiles(const QString& pDirPath)
QStringList UBFileSystemUtils::allFiles(const QString& pDirPath, bool isRecursive)
{
QStringList result;
if (pDirPath == "" || pDirPath == "." || pDirPath == "..")
@ -187,7 +187,7 @@ QStringList UBFileSystemUtils::allFiles(const QString& pDirPath)
foreach(QFileInfo dirContent, dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot , QDir::Name))
{
if (dirContent.isDir())
if (isRecursive && dirContent.isDir())
{
result << allFiles(dirContent.absoluteFilePath());
}

@ -37,7 +37,7 @@ class UBFileSystemUtils
static QFileInfoList allElementsInDirectory(const QString& pDirPath);
static QStringList allFiles(const QString& pDirPath);
static QStringList allFiles(const QString& pDirPath, const bool isRecurive=true);
static bool deleteDir(const QString& pDirPath);

@ -103,8 +103,8 @@ class UBPlatformUtils
static void setFileType(const QString &filePath, unsigned long fileType);
static void fadeDisplayOut();
static void fadeDisplayIn();
static QString preferredTranslation(QString pFilePrefix);
static QString preferredLanguage();
static QString translationPath(QString pFilePrefix, QString pLanguage);
static QString systemLanguage();
static bool hasVirtualKeyboard();
//static void showVirtualKeyboard();
static void runInstaller(const QString &installerFilePath);
@ -115,6 +115,7 @@ class UBPlatformUtils
static QString computerName();
static UBKeyboardLocale** getKeyboardLayouts(int& nCount);
static QString urlFromClipboard();
static QStringList availableTranslations();
};

@ -20,6 +20,8 @@
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include "frameworks/UBFileSystemUtils.h"
void UBPlatformUtils::init()
{
@ -55,13 +57,22 @@ void UBPlatformUtils::fadeDisplayIn()
// NOOP
}
QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
QStringList UBPlatformUtils::availableTranslations()
{
QString translationsPath = applicationResourcesDirectory() + "/" + "i18n" + "/";
QStringList translationsList = UBFileSystemUtils::allFiles(translationsPath);
QRegExp sankoreTranslationFiles(".*sankore_.*.qm");
translationsList=translationsList.filter(sankoreTranslationFiles);
return translationsList.replaceInStrings(QRegExp("(.*)sankore_(.*).qm"),"\\2");
}
QString UBPlatformUtils::translationPath(QString pFilePrefix,QString pLanguage)
{
QString qmPath = applicationResourcesDirectory() + "/" + "i18n" + "/" + pFilePrefix + preferredLanguage() + ".qm";
QString qmPath = applicationResourcesDirectory() + "/" + "i18n" + "/" + pFilePrefix + pLanguage + ".qm";
return qmPath;
}
QString UBPlatformUtils::preferredLanguage()
QString UBPlatformUtils::systemLanguage()
{
return QLocale::system().name();
}

@ -184,31 +184,64 @@ void UBPlatformUtils::fadeDisplayIn()
}
}
QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
{
QString qmPath;
NSString* filePrefix = [[NSString alloc] initWithUTF8String:(const char*)(pFilePrefix.toUtf8())];
//QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
//{
// QString qmPath;
// NSString* filePrefix = [[NSString alloc] initWithUTF8String:(const char*)(pFilePrefix.toUtf8())];
// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// NSString *lprojPath = [[[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings"] stringByDeletingLastPathComponent];
// if (lprojPath)
// {
// NSString *lang = [[lprojPath lastPathComponent] stringByDeletingPathExtension];
// NSString *translationFilePath = [lprojPath stringByAppendingPathComponent:[[filePrefix stringByAppendingString:lang] stringByAppendingPathExtension:@"qm"]];
// qmPath = QString::fromUtf8([translationFilePath UTF8String], strlen([translationFilePath UTF8String]));
// }
// [pool drain];
// return qmPath;
//}
//QString UBPlatformUtils::preferredLanguage()
//{
// QFileInfo qmFileInfo = QFileInfo(preferredTranslation("sankore_"));
// QDir lprojPath = qmFileInfo.dir();
// QFileInfo lprojFileInfo = QFileInfo(lprojPath.absolutePath());
// return lprojFileInfo.baseName();
//}
QStringList UBPlatformUtils::availableTranslations()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *lprojPath = [[NSBundle mainBundle] resourcePath];
QString translationsPath = QString::fromUtf8([lprojPath UTF8String], strlen([lprojPath UTF8String]));
QStringList translationsList = UBFileSystemUtils::allFiles(translationsPath, false);
QRegExp sankoreTranslationFiles(".*lproj");
translationsList=translationsList.filter(sankoreTranslationFiles);
[pool drain];
return translationsList.replaceInStrings(QRegExp("(.*)/(.*).lproj"),"\\2");
}
NSString *lprojPath = [[[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings"] stringByDeletingLastPathComponent];
if (lprojPath)
{
NSString *lang = [[lprojPath lastPathComponent] stringByDeletingPathExtension];
NSString *translationFilePath = [lprojPath stringByAppendingPathComponent:[[filePrefix stringByAppendingString:lang] stringByAppendingPathExtension:@"qm"]];
qmPath = QString::fromUtf8([translationFilePath UTF8String], strlen([translationFilePath UTF8String]));
}
QString UBPlatformUtils::translationPath(QString pFilePrefix, QString pLanguage)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *lprojPath = [[NSBundle mainBundle] resourcePath];
QString translationsPath = QString::fromUtf8([lprojPath UTF8String], strlen([lprojPath UTF8String]));
[pool drain];
return qmPath;
return translationsPath + "/" + pLanguage + ".lproj/" + pFilePrefix + pLanguage + ".qm";
}
QString UBPlatformUtils::preferredLanguage()
QString UBPlatformUtils::systemLanguage()
{
QFileInfo qmFileInfo = QFileInfo(preferredTranslation("sankore_"));
QDir lprojPath = qmFileInfo.dir();
QFileInfo lprojFileInfo = QFileInfo(lprojPath.absolutePath());
return lprojFileInfo.baseName();
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];
QString result = QString::fromUtf8([preferredLang UTF8String], strlen([preferredLang UTF8String]));
[pool drain];
return result;
}
void UBPlatformUtils::runInstaller(const QString &installerFilePath)

@ -20,6 +20,7 @@
#include <windows.h>
#include <shellapi.h>
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
void UBPlatformUtils::init()
@ -59,14 +60,22 @@ void UBPlatformUtils::fadeDisplayIn()
// NOOP
}
QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
QStringList UBPlatformUtils::availableTranslations()
{
QString localPreferredLanguage = preferredLanguage();
QString qmPath = applicationResourcesDirectory() + "/" + "i18n" + "/" + pFilePrefix + localPreferredLanguage + ".qm";
QString translationsPath = applicationResourcesDirectory() + "/" + "i18n" + "/";
QStringList translationsList = UBFileSystemUtils::allFiles(translationsPath);
QRegExp sankoreTranslationFiles(".*sankore_.*.qm");
translationsList=translationsList.filter(sankoreTranslationFiles);
return translationsList.replaceInStrings(QRegExp("(.*)sankore_(.*).qm"),"\\2");
}
QString UBPlatformUtils::translationPath(QString pFilePrefix,QString pLanguage)
{
QString qmPath = applicationResourcesDirectory() + "/" + "i18n" + "/" + pFilePrefix + pLanguage + ".qm";
return qmPath;
}
QString UBPlatformUtils::preferredLanguage()
QString UBPlatformUtils::systemLanguage()
{
return QLocale::system().name();
}

@ -263,14 +263,6 @@ void UBDocumentNavigator::resizeEvent(QResizeEvent *event)
// Update the thumbnails width
mThumbnailWidth = (width() > mThumbnailMinWidth) ? width() - 2*border() : mThumbnailMinWidth;
// Update the scene rect
// QRect sceneRect;
// sceneRect.setWidth(width() - 2*border());
// sceneRect.setHeight(height() - 2*border());
// sceneRect.moveLeft(border());
// sceneRect.moveTop(border());
// scene()->setSceneRect(sceneRect);
// Refresh the scene
refreshScene();
}

@ -45,7 +45,7 @@ UBLeftPalette::~UBLeftPalette()
*/
void UBLeftPalette::updateMaxWidth()
{
setMaximumWidth(270);
setMaximumWidth((int)(parentWidget()->width() * 0.45));
}
/**

@ -69,7 +69,7 @@ void UBRightPalette::resizeEvent(QResizeEvent *event)
*/
void UBRightPalette::updateMaxWidth()
{
setMaximumWidth((int)((parentWidget()->width() * 2)/3));
setMaximumWidth((int)(parentWidget()->width() * 0.45));
setMaximumHeight(parentWidget()->height());
setMinimumHeight(parentWidget()->height());
}

@ -887,11 +887,6 @@ void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal heigh
qreal scaleFactor = qMin(scaleWidth, scaleHeight);
UBThumbnail* pix = dynamic_cast<UBThumbnail*>(this->thumbnail);
if(pix)
{
scaleFactor = qMin(scaleFactor, 1.0);
}
QTransform transform;
transform.scale(scaleFactor, scaleFactor);

Loading…
Cancel
Save