/[svn]/qsampler/trunk/src/qsampler.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2415 by capela, Thu Feb 14 14:57:43 2013 UTC revision 2677 by capela, Thu Oct 9 08:50:14 2014 UTC
# Line 1  Line 1 
1  // qsampler.cpp  // qsampler.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 28  Line 28 
28  #include <QLibraryInfo>  #include <QLibraryInfo>
29  #include <QTranslator>  #include <QTranslator>
30  #include <QLocale>  #include <QLocale>
31    
32  #if defined(__APPLE__)  // Toshi Nagata 20080105  #if defined(__APPLE__)  // Toshi Nagata 20080105
33  #include <QDir>  #include <QDir>
34  #endif  #endif
35    
 #if QT_VERSION < 0x040300  
 #define lighter(x)      light(x)  
 #define darker(x)       dark(x)  
 #endif  
   
36  #define CONFIG_QUOTE1(x) #x  #define CONFIG_QUOTE1(x) #x
37  #define CONFIG_QUOTED(x) CONFIG_QUOTE1(x)  #define CONFIG_QUOTED(x) CONFIG_QUOTE1(x)
38    
# Line 46  Line 42 
42  #define CONFIG_DATADIR CONFIG_PREFIX "/share"  #define CONFIG_DATADIR CONFIG_PREFIX "/share"
43  #endif  #endif
44    
 #if defined(LOCALEDIR)  
 #define CONFIG_LOCALEDIR CONFIG_QUOTED(LOCALEDIR)  
 #else  
 #define CONFIG_LOCALEDIR CONFIG_DATADIR "/locale"  
 #endif  
   
45  #if WIN32  #if WIN32
46  #define RELATIVE_LOCALE_DIR "/share/locale"  #define RELATIVE_LOCALE_DIR "/share/locale"
47  #elif defined(__APPLE__)  #elif defined(__APPLE__)
# Line 92  public: Line 82  public:
82                          if (m_pQtTranslator->load(sLocName, sLocPath)) {                          if (m_pQtTranslator->load(sLocName, sLocPath)) {
83                                  QApplication::installTranslator(m_pQtTranslator);                                  QApplication::installTranslator(m_pQtTranslator);
84                          } else {                          } else {
85                  #ifdef RELATIVE_LOCALE_DIR                          #ifdef RELATIVE_LOCALE_DIR
86                                  sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;                                  sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;
87                                  if (m_pQtTranslator->load(sLocName, sLocPath)) {                                  if (m_pQtTranslator->load(sLocName, sLocPath)) {
88                                          QApplication::installTranslator(m_pQtTranslator);                                          QApplication::installTranslator(m_pQtTranslator);
89                                  } else {                                  } else {
90                  #endif                          #endif
91                                  delete m_pQtTranslator;                                  delete m_pQtTranslator;
92                                  m_pQtTranslator = 0;                                  m_pQtTranslator = 0;
93                  #ifdef CONFIG_DEBUG                          #ifdef CONFIG_DEBUG
94                                  qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",                                  qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",
95                                          loc.name().toUtf8().constData(),                                          loc.name().toUtf8().constData(),
96                                          sLocPath.toUtf8().constData(),                                          sLocPath.toUtf8().constData(),
97                                          sLocName.toUtf8().constData());                                          sLocName.toUtf8().constData());
98                  #endif                          #endif
99                  #ifdef RELATIVE_LOCALE_DIR                          #ifdef RELATIVE_LOCALE_DIR
100                                  }                                  }
101                  #endif                          #endif
102                          }                          }
103                          // Try own application translation...                          // Try own application translation...
104                          m_pMyTranslator = new QTranslator(this);                          m_pMyTranslator = new QTranslator(this);
# Line 116  public: Line 106  public:
106                          if (m_pMyTranslator->load(sLocName, sLocPath)) {                          if (m_pMyTranslator->load(sLocName, sLocPath)) {
107                                  QApplication::installTranslator(m_pMyTranslator);                                  QApplication::installTranslator(m_pMyTranslator);
108                          } else {                          } else {
109                  #ifdef RELATIVE_LOCALE_DIR                          #ifdef RELATIVE_LOCALE_DIR
110                                  sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;                                  sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;
111                  #else                          #else
112                                  sLocPath = CONFIG_LOCALEDIR;                                  sLocPath = CONFIG_DATADIR "/qsampler/translations";
113                  #endif                          #endif
114                                  if (m_pMyTranslator->load(sLocName, sLocPath)) {                                  if (m_pMyTranslator->load(sLocName, sLocPath)) {
115                                          QApplication::installTranslator(m_pMyTranslator);                                          QApplication::installTranslator(m_pMyTranslator);
116                                  } else {                                  } else {
117                                          delete m_pMyTranslator;                                          delete m_pMyTranslator;
118                                          m_pMyTranslator = 0;                                          m_pMyTranslator = 0;
119                  #ifdef CONFIG_DEBUG                                  #ifdef CONFIG_DEBUG
120                                          qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",                                          qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",
121                                                  loc.name().toUtf8().constData(),                                                  loc.name().toUtf8().constData(),
122                                                  sLocPath.toUtf8().constData(),                                                  sLocPath.toUtf8().constData(),
123                                                  sLocName.toUtf8().constData());                                                  sLocName.toUtf8().constData());
124                  #endif                                  #endif
125                                  }                                  }
126                          }                          }
127                  }                  }
# Line 403  int main ( int argc, char **argv ) Line 393  int main ( int argc, char **argv )
393          }          }
394    
395          // Set default base font...          // Set default base font...
         int iBaseFontSize = app.font().pointSize();  
396          if (options.iBaseFontSize > 0)          if (options.iBaseFontSize > 0)
397                  iBaseFontSize = options.iBaseFontSize;                  app.setFont(QFont(app.font().family(), options.iBaseFontSize));
         app.setFont(QFont(app.font().family(), iBaseFontSize));  
398    
399          // Construct, setup and show the main form.          // Construct, setup and show the main form.
400          QSampler::MainForm w;          QSampler::MainForm w;

Legend:
Removed from v.2415  
changed lines
  Added in v.2677

  ViewVC Help
Powered by ViewVC