示例#1
0
GetText::GetText() : isLoaded(false), iconv_cd_(nullptr)
{
    setCatalogDir("messages", "/usr/share/locale");
    setCatalog("messages");
    setLocale("C");
    setCodepage("ISO-8859-1");
}
示例#2
0
const MessageFormat&
MessageFormat::operator=(const MessageFormat& that)
{
    // Reallocate the arrays BEFORE changing this object
    if (this != &that &&
        allocateSubformats(that.subformatCount) &&
        allocateArgTypes(that.argTypeCount)) {

        // Calls the super class for assignment first.
        Format::operator=(that);

        fPattern = that.fPattern;
        setLocale(that.fLocale);
        
        int32_t j;
        for (j=0; j<subformatCount; ++j) {
            delete subformats[j].format;
        }
        subformatCount = 0;
        
        for (j=0; j<that.subformatCount; ++j) {
            // Subformat::operator= does NOT delete this.format
            subformats[j] = that.subformats[j];
        }
        subformatCount = that.subformatCount;
        
        for (j=0; j<that.argTypeCount; ++j) {
            argTypes[j] = that.argTypes[j];
        }
        argTypeCount = that.argTypeCount;
    }
    return *this;
}
示例#3
0
QcNumberBox::QcNumberBox()
: scroll( true ),
  lastPos( 0 ),
  editedTextColor( QColor( "red" ) ),
  normalTextColor( palette().color(QPalette::Text) ),
  _validator( new QDoubleValidator( this ) ),
  step( 0.1f ),
  scrollStep( 1.0f ),
  dragDist( 10.f ),
  _value( 0. ),
  _valueType( Number ),
  _minDec(0),
  _maxDec(2)
{
  _validator->setDecimals( _maxDec );
  setValidator( _validator );

  // Do not display thousands separator. It only eats up precious space.
  QLocale loc( locale() );
  loc.setNumberOptions( QLocale::OmitGroupSeparator );
  setLocale( loc );

  setLocked( true );

  connect( this, SIGNAL( editingFinished() ),
           this, SLOT( onEditingFinished() ) );
  connect( this, SIGNAL( valueChanged() ),
           this, SLOT( updateText() ), Qt::QueuedConnection );
  setValue( 0 );
}
void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
{
    int newHeight = 0;
    const char *value;

    if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found");
        return;
    }
    if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found");
        return;
    }
    if (pps_decoder_push(m_decoder, "locale") != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS locale object not found");
        return;
    }
    if (pps_decoder_get_string(m_decoder, "languageId", &value) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS languageId field not found");
        return;
    }
    const QString languageId = QString::fromLatin1(value);
    if (pps_decoder_get_string(m_decoder, "countryId", &value) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS size countryId not found");
        return;
    }
    const QString countryId = QString::fromLatin1(value);

    setHeight(newHeight);

    const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
    setLocale(locale);

    qVirtualKeyboardDebug() << Q_FUNC_INFO << "size=" << newHeight << "locale=" << locale;
}
void UBKeyboardPalette::checkLayout()
{
    TISInputSourceRef selectedLocale = TISCopyCurrentKeyboardInputSource();

    CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(selectedLocale,
                                                          kTISPropertyInputSourceID);

    if (sr!=NULL)
    {
        char clId[1024];
        CFStringGetCString(sr, clId, 1024, 0);

        for(int i=0; i<nLocalesCount;i++)
        {
            if (locales[i]->id == clId)
            {
                if (nCurrentLocale!=i)
                {
                    setLocale(i);
                }
                break;
            }
        }
    }
}
示例#6
0
void KConfigBase::writeEntry(const char *pKey, const QString &value, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand)
{
    // the KConfig object is dirty now
    // set this before any IO takes place so that if any derivative
    // classes do caching, they won't try and flush the cache out
    // from under us before we read. A race condition is still
    // possible but minimized.
    if(bPersistent)
        setDirty(true);

    if(!bLocaleInitialized && KGlobal::locale())
        setLocale();

    KEntryKey entryKey(mGroup, pKey);
    entryKey.bLocal = bNLS;

    KEntry aEntryData;
    aEntryData.mValue = value.utf8(); // set new value
    aEntryData.bGlobal = bGlobal;
    aEntryData.bNLS = bNLS;
    aEntryData.bExpand = bExpand;

    if(bPersistent)
        aEntryData.bDirty = true;

    // rewrite the new value
    putData(entryKey, aEntryData, true);
}
示例#7
0
Window::Window(QWidget *parent) : PsMainWindow(parent),
intro(0), main(0), settings(0), layerBG(0), _topWidget(0),
_connecting(0), _clearManager(0), dragging(false), _inactivePress(false), _mediaView(0) {

	icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
	icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation);
	icon64 = icon256.scaledToWidth(64, Qt::SmoothTransformation);

	if (objectName().isEmpty()) {
		setObjectName(qsl("MainWindow"));
	}
	resize(st::wndDefWidth, st::wndDefHeight);
	setWindowOpacity(1);
	setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
	centralwidget = new QWidget(this);
	centralwidget->setObjectName(qsl("centralwidget"));
	setCentralWidget(centralwidget);

	QMetaObject::connectSlotsByName(this);

	_inactiveTimer.setSingleShot(true);
	connect(&_inactiveTimer, SIGNAL(timeout()), this, SLOT(onInactiveTimer()));

	connect(&notifyWaitTimer, SIGNAL(timeout()), this, SLOT(notifyFire()));
}
示例#8
0
void CurrencyWidget::localeChanged(QLocale locale)
{
    setLocale(locale);
    currencySymbol->setText(locale.currencySymbol());
    currencyISO->setText(locale.currencySymbol(QLocale::CurrencyIsoCode));
    currencyName->setText(locale.currencySymbol(QLocale::CurrencyDisplayName));
    updateCurrencyFormatting();
}
示例#9
0
void pTranslationDialog::on_twLocales_itemSelectionChanged()
{
    if ( mTranslationManager ) {
        mTranslationManager->setCurrentLocale( selectedLocale() );
        mTranslationManager->reloadTranslations();
        setLocale( selectedLocale() );
    }
}
示例#10
0
	int Program::run(int argc, char **argv)
	{
		setLocale();
#ifdef WIN32
		auto command_line = po::split_winmain(ucsToUtf8(wstring(GetCommandLine())));
		command_line.erase(command_line.begin());
#else
		vector<string> command_line;
		command_line.resize(argc - 1);
		for (int i = 1; i < argc; i++) {
			command_line[i - 1] = argv[i];
		}
#endif
		auto command_name = getCommandName(command_line);
		if (!command_name.first) return EXIT_FAILURE;

		if (command_name.first && command_name.second == ""){
			printHelp();
			return EXIT_FAILURE;
		}
		auto command = findCommand(command_name.second.c_str());
		if (!command){
			cerr << program_name << ": " << "unknown command '" << command_name.second << "'" << "\n";
			printHelp();
			return EXIT_FAILURE;
		}

		try{
			po::options_description all_options, global_options, options, hidden_options;
			po::positional_options_description positional_options;
			string command_confirm;
			addGlobalOptions(global_options);
			hidden_options.add_options()
				("command",  po::value<string>(&command_confirm), "")
			;
			positional_options.add("command", 1);
			command->addOptions(options, hidden_options);
			command->addPositionalOptions(positional_options);
			all_options.add(global_options).add(options).add(hidden_options);
			auto parsed = po::command_line_parser(command_line).options(all_options).positional(positional_options).run();
			po::variables_map vm;
			po::store(parsed, vm);
			po::notify(vm);
			if (vm.count("help")) {
				printHelp(*command);
				return EXIT_SUCCESS;
			}
			if (!command->checkOptions(vm)){
				printHelp(*command);
				return EXIT_FAILURE;
			}
			return command->run();
		}catch(const exception &e){
			cerr << program_name << ": " << e.what() << "\n";
			return EXIT_FAILURE;
		}
	}
void QFacebookGraphUser::requestDone(bool ok) {
    if(ok)
    {
        QVariantMap map = result();
        QVariantMap::const_iterator i;
        for (i = map.constBegin(); i != map.constEnd(); ++i)
        {
            if(i.key() == "name" )
                setName(i.value().toString());
            if(i.key() == "hometown")
                setHometown(i.value().toMap());
            if(i.key() == "last_name")
                setLastName(i.value().toString());
            if(i.key() == "birthday")
                setBirthday(i.value().toString());
            if(i.key() == "education") {
                QFacebookGraphCommonEducationModel *edu = new QFacebookGraphCommonEducationModel();
                for (int j = 0; j < i.value().toList().size(); ++j) {
                    edu->populate(i.value().toList().at(j).toMap());
                    m_education.append(edu);
                    edu = new QFacebookGraphCommonEducationModel();
                }
            }
            if(i.key() == "work") {
                QFacebookGraphCommonWorkModel *work = new QFacebookGraphCommonWorkModel();
                for (int j = 0; j < i.value().toList().size(); ++j) {
                    work->populate(i.value().toList().at(j).toMap());
                    m_work.append(work);
                    work = new QFacebookGraphCommonWorkModel();
                }
            }
            if(i.key() == "first_name")
                setFirstName(i.value().toString());
            if(i.key() == "gender")
                setGender(i.value().toString());
            if(i.key() == "id")
                setFbid(i.value().toString());
            if(i.key() == "link")
                setLink(i.value().toString());
            if(i.key() == "locale")
                setLocale(i.value().toString());
            if(i.key() == "location")
                setLocation(i.value().toMap());
            if(i.key() == "middle_name")
                setMiddleName(i.value().toString());
            if(i.key() == "timezone")
                setTimezone(i.value().toLongLong());
            if(i.key() == "updated_time")
                setUpdatedtime(i.value().toString());
            if(i.key() == "verified")
                setVerified(i.value().toBool());
        }

        emit modelPopulated();
    }
}
示例#12
0
void InfoWidget::localeChanged(QLocale locale)
{
    setLocale(locale);
    name->setText(locale.name());
    bcp47Name->setText(locale.bcp47Name());
    languageName->setText(QLocale::languageToString(locale.language()));
    nativeLanguageName->setText(locale.nativeLanguageName());
    scriptName->setText(QLocale::scriptToString(locale.script()));
    countryName->setText(QLocale::countryToString(locale.country()));
    nativeCountryName->setText(locale.nativeCountryName());
}
示例#13
0
void KConfigBase::parseConfigFiles()
{
    if(!bLocaleInitialized && KGlobal::_locale)
    {
        setLocale();
    }
    if(backEnd)
    {
        backEnd->parseConfigFiles();
        bReadOnly = (backEnd->getConfigState() == ReadOnly);
    }
}
示例#14
0
void Rshare::resetLanguageAndStyle()
{
    /** Translate the GUI to the appropriate language. */
    setLanguage(_args.value(ARG_LANGUAGE));

    /** Set the locale appropriately. */
    setLocale(_args.value(ARG_LANGUAGE));

   /** Set the GUI style appropriately. */
    setStyle(_args.value(ARG_GUISTYLE));

    /** Set the GUI stylesheet appropriately. */
    setSheet(_args.value(ARG_GUISTYLESHEET));
}
示例#15
0
void Eyes::initContext(QQuickView &viewer, QGuiApplication *app)
{
    qDebug("[Salticidae] Init context");

    m_context = viewer.rootContext();
    m_app = app;

    m_context->setContextProperty("app", this);
    m_context->setContextProperty("screenScale",
        QGuiApplication::primaryScreen()->physicalDotsPerInch() * QGuiApplication::primaryScreen()->devicePixelRatio() / 100);

    setLocale(setting("preferences/locale").toString());
    m_app->installTranslator(&m_translator);
}
示例#16
0
文件: MPF.cpp 项目: aaly/MPF
int MPF::updateLayout(QString language)
{
    if (language == "ar" )
    {
		setLayoutDirection(Qt::RightToLeft);
		setLocale(QLocale(QLocale::Arabic));
    }
    else
    {
        setLayoutDirection(Qt::LeftToRight);
    }
	listGridLayout->update();
    return 0;

}
bool QQnxVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event)
{
    if (bps_event_get_code(event) == LOCALE_INFO) {
        const QString language = QString::fromLatin1(locale_event_get_language(event));
        const QString country  = QString::fromLatin1(locale_event_get_country(event));
        const QLocale newLocale(language + QLatin1Char('_') + country);

        qVirtualKeyboardDebug() << Q_FUNC_INFO << "current locale" << locale() << "new locale=" << newLocale;
        setLocale(newLocale);
        return true;
    }

    qVirtualKeyboardDebug() << Q_FUNC_INFO << "Unhandled locale event. code=" << bps_event_get_code(event);

    return false;
}
void FloatSpinBox::init( )
{
//  setValidator( new QDoubleValidator(this) );
//  QDoubleSpinBox::setValue( 0.0 );

  setFocusPolicy( Qt::ClickFocus );
  calcLineStep( );
  
  lineEdit()->setAlignment( Qt::AlignRight );
  setMinimum (-1000000.0);
  setMaximum (1000000.0);
  setLocale(QLocale::C);
  
  setKeyboardTracking(false);
  
//  qDebug ( "float spin box created");  
}
示例#19
0
文件: Home.C 项目: GuLinux/wt
void Home::setLanguage(int index)
{
  if (homePage_) {
    const Lang& l = languages[index];

    setLocale(l.code_);

    std::string langPath = l.path_;
    mainMenu_->setInternalBasePath(langPath);
    examplesMenu_->setInternalBasePath(langPath + "examples");
    BlogView *blog = dynamic_cast<BlogView *>(findWidget("blog"));
    if (blog)
      blog->setInternalBasePath(langPath + "blog/");
    updateTitle();

    language_ = index;
  }
}
示例#20
0
文件: locale.C 项目: 913862627/wt
  void updateLocale()
  {
    std::string tz = boost::any_cast<std::string>
      (timeZones.index(localeCombo_->currentIndex(), 0)
       .data(TimeZoneModel::PosixTimeZoneRole));

    Wt::WLocale l = locale();
    l.setTimeZone(tz);
    setLocale(l);

    Wt::WString format = "yyyy-MM-dd HH:mm:ss Z";

    info_->bindString("time-zone", locale().timeZone());
    info_->bindString("utc-time",
		      Wt::WDateTime::currentDateTime().toString(format));
    info_->bindString("local-time",
		      Wt::WLocalDateTime::currentDateTime().toString(format));
  }
示例#21
0
Window::Window(QWidget *parent)	: PsMainWindow(parent),
	intro(0), main(0), settings(0), layer(0), layerBG(0), _topWidget(0),
	_connecting(0), _tempDeleter(0), _tempDeleterThread(0), myIcon(QPixmap::fromImage(icon256)), dragging(false), _inactivePress(false) {

	if (objectName().isEmpty())
		setObjectName(qsl("MainWindow"));
	resize(st::wndDefWidth, st::wndDefHeight);
	setWindowOpacity(1);
	setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
	centralwidget = new QWidget(this);
	centralwidget->setObjectName(qsl("centralwidget"));
	setCentralWidget(centralwidget);

	QMetaObject::connectSlotsByName(this);

	_inactiveTimer.setSingleShot(true);
	connect(&_inactiveTimer, SIGNAL(timeout()), this, SLOT(onInactiveTimer()));
}
示例#22
0
/*!
    Sets the contents of the text record to \a text.
*/
void QNdefNfcTextRecord::setText(const QString text)
{
    if (payload().isEmpty())
        setLocale(QLocale().name());

    QByteArray p = payload();

    quint8 status = p.at(0);

    bool utf16 = status & 0x80;
    quint8 codeLength = status & 0x3f;

    p.truncate(1 + codeLength);

    QTextCodec *codec = QTextCodec::codecForName(utf16 ? "UTF-16BE" : "UTF-8");

    p += codec->fromUnicode(text);

    setPayload(p);
}
示例#23
0
文件: kconfig.cpp 项目: KDE/kconfig
KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
                               QStandardPaths::StandardLocation resourceType)
    : openFlags(flags), resourceType(resourceType), mBackend(Q_NULLPTR),
      bDynamicBackend(true),  bDirty(false), bReadDefaults(false),
      bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false),
      configState(KConfigBase::NoAccess)
{
    static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1);
    if (use_etc_kderc.load() < 0) {
        use_etc_kderc.store( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC"));    // for unit tests
    }
    if (use_etc_kderc.load()) {

        etc_kderc =
#ifdef Q_OS_WIN
            QFile::decodeName(qgetenv("WINDIR") + "/kde5rc");
#else
            QStringLiteral("/etc/kde5rc");
#endif
        if (!QFileInfo(etc_kderc).isReadable()) {
            etc_kderc.clear();
        }
    }

//    if (!mappingsRegistered) {
//        KEntryMap tmp;
//        if (!etc_kderc.isEmpty()) {
//            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(etc_kderc, QLatin1String("INI"));
//            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults);
//        }
//        const QString kde5rc(QDir::home().filePath(".kde5rc"));
//        if (KStandardDirs::checkAccess(kde5rc, R_OK)) {
//            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(kde5rc, QLatin1String("INI"));
//            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions());
//        }
//        KConfigBackend::registerMappings(tmp);
//        mappingsRegistered = true;
//    }

    setLocale(QLocale().name());
}
示例#24
0
void Transaction::setProperty(int property, QDBusVariant value)
{
    if (isForeignUser()) {
        sendErrorReply(QDBusError::AccessDenied);
        return;
    }

    switch (property)
    {
    case QApt::TransactionIdProperty:
    case QApt::UserIdProperty:
        // Read-only
        sendErrorReply(QDBusError::Failed);
        break;
    case QApt::RoleProperty:
        setRole((QApt::TransactionProperty)value.variant().toInt());
        break;
    case QApt::StatusProperty:
        setStatus((QApt::TransactionStatus)value.variant().toInt());
        break;
    case QApt::LocaleProperty:
        setLocale(value.variant().toString());
        break;
    case QApt::ProxyProperty:
        setProxy(value.variant().toString());
        break;
    case QApt::DebconfPipeProperty:
        setDebconfPipe(value.variant().toString());
        break;
    case QApt::PackagesProperty:
        setPackages(value.variant().toMap());
        break;
    case QApt::FrontendCapsProperty:
        setFrontendCaps(value.variant().toInt());
        break;
    default:
        sendErrorReply(QDBusError::InvalidArgs);
        break;
    }
}
示例#25
0
void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
{
    int newHeight = 0;
    const char *value;

    if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found");
        return;
    }
    if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found");
        return;
    }
    if (pps_decoder_push(m_decoder, "locale") != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS locale object not found");
        return;
    }
    if (pps_decoder_get_string(m_decoder, "languageId", &value) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS languageId field not found");
        return;
    }
    const QString languageId = QString::fromLatin1(value);
    if (pps_decoder_get_string(m_decoder, "countryId", &value) != PPS_DECODER_OK) {
        qCritical("QQnxVirtualKeyboard: Keyboard PPS size countryId not found");
        return;
    }
    const QString countryId = QString::fromLatin1(value);

    // HUGE hack, should be removed ASAP.
    newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400)

    setHeight(newHeight);

    const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
    setLocale(locale);

    qVirtualKeyboardDebug() << Q_FUNC_INFO << "size=" << newHeight << "locale=" << locale;
}
示例#26
0
void KConfigBase::deleteEntry(const char *pKey, bool bNLS, bool bGlobal)
{
    // the KConfig object is dirty now
    // set this before any IO takes place so that if any derivative
    // classes do caching, they won't try and flush the cache out
    // from under us before we read. A race condition is still
    // possible but minimized.
    setDirty(true);

    if(!bLocaleInitialized && KGlobal::locale())
        setLocale();

    KEntryKey entryKey(mGroup, pKey);
    KEntry aEntryData;

    aEntryData.bGlobal = bGlobal;
    aEntryData.bNLS = bNLS;
    aEntryData.bDirty = true;
    aEntryData.bDeleted = true;

    // rewrite the new value
    putData(entryKey, aEntryData, true);
}
示例#27
0
文件: Home.C 项目: GuLinux/wt
Home::Home(const WEnvironment& env,
	   Wt::Dbo::SqlConnectionPool& blogDb,
	   const std::string& title, const std::string& resourceBundle,
	   const std::string& cssPath)
  : WApplication(env),
    releases_(0),
    blogDb_(blogDb),
    homePage_(0),
    sourceViewer_(0)
{
  messageResourceBundle().use(appRoot() + resourceBundle, false);

  useStyleSheet(cssPath + "/wt.css");
  useStyleSheet(cssPath + "/wt_ie.css", "lt IE 7", "all");
  useStyleSheet("css/home.css");
  useStyleSheet("css/sourceview.css");
  useStyleSheet("css/chatwidget.css");
  useStyleSheet("css/chatwidget_ie6.css", "lt IE 7", "all");
  setTitle(title);

  setLocale("");
  language_ = 0;
}
示例#28
0
文件: llresmgr.cpp 项目: Kiera/Crow
void LLResMgr::setLocale( LLLOCALE_ID locale_id )
{
	mLocale = locale_id;

	//RN: for now, use normal 'C' locale for everything but specific UI input/output routines
	switch( locale_id )
	{
	case LLLOCALE_USA: 
//#if LL_WINDOWS
//		// Windows doesn't use ISO country codes.
//		llinfos << "Setting locale to " << setlocale( LC_ALL, "english-usa" ) << llendl;
//#else	
//		// posix version should work everywhere else.
//		llinfos << "Setting locale to " << setlocale( LC_ALL, "en_US" ) << llendl;
//#endif

//		mStrings	= mUSAStrings;
		mFonts		= mUSAFonts;
		break;
	case LLLOCALE_UK:
//#if LL_WINDOWS
//		// Windows doesn't use ISO country codes.
//		llinfos << "Setting locale to " << setlocale( LC_ALL, "english-uk" ) << llendl;
//#else
//		// posix version should work everywhere else.
//		llinfos << "Setting locale to " << setlocale( LC_ALL, "en_GB" ) << llendl;
//#endif

//		mStrings	= mUKStrings;
		mFonts		= mUKFonts;
		break;
	default:
		llassert(0);
		setLocale(LLLOCALE_USA);
		break;
	}
}
示例#29
0
/*!
    \brief Changes the device system language.  
     
    \attention Symbian specific API
     
    \deprecated HbLanguageUtil::changeLanguage( int language )
        is deprecated. Please use HbLocaleUtil::changeLanguage( const QString &language ) instead.

    \param language identifier of language to set active
    \return true for Symbian if succesfull and false for other platforms
*/ 
bool HbLanguageUtil::changeLanguage( int language )
{
#if defined(Q_OS_SYMBIAN)
    if ( !HbFeatureManager::instance()->featureStatus(HbFeatureManager::LanguageSwitch) ) {
        return false;
    }
    
    CRepository* commonEngineRepository = 0;
    TRAPD( err1, commonEngineRepository = CRepository::NewL( KCRUidCommonEngineKeys ) );    
    if ( err1 != KErrNone ) { 
        return false;
    }
    
    if (!setLocale(language)) {
    		delete commonEngineRepository;
        return false;
    }
        
    // Never set Language code 0 to HAL
    if ( language !=0 ) {
        if ( HAL::Set( HAL::ELanguageIndex, language ) != KErrNone ) {
            delete commonEngineRepository;
            return false;
        }
    }
    if ( commonEngineRepository->Set( KGSDisplayTxtLang, language ) != KErrNone ) {
        delete commonEngineRepository;
        return false;
    }
    delete commonEngineRepository;
    return true;

#else
    Q_UNUSED(language);
    return false;
#endif
}
示例#30
0
App::App(int &argc, char **argv)
: QApplication(argc, argv), d(new Data(this)) {
#ifdef Q_OS_LINUX
    setlocale(LC_NUMERIC,"C");
#endif
    setOrganizationName(u"xylosper"_q);
    setOrganizationDomain(u"xylosper.net"_q);
    setApplicationName(_L(name()));
    setApplicationVersion(_L(version()));

    Record r(APP_GROUP);
    QVariant vLocale;
    r.read(vLocale, u"locale"_q);
    setLocale(Locale::fromVariant(vLocale));

    d->addOption(LineCmd::Open, u"open"_q,
                 tr("Open given %1 for file path or URL."), u"mrl"_q);
    d->addOption(LineCmd::Wake, u"wake"_q,
                 tr("Bring the application window in front."));
    d->addOption(LineCmd::Action, u"action"_q,
                 tr("Exectute %1 action or open %1 menu."), u"id"_q);
    d->addOption(LineCmd::LogLevel, u"log-level"_q,
                 tr("Maximum verbosity for log. %1 should be one of nexts:")
                 % "\n    "_a % Log::options().join(u", "_q), u"lv"_q);
    d->addOption(LineCmd::OpenGLDebug, u"opengl-debug"_q,
                 tr("Turn on OpenGL debug logger."));
    d->addOption(LineCmd::Debug, u"debug"_q,
                 tr("Turn on options for debugging."));
    d->getCommandParser(&d->cmdParser)->process(arguments());
    d->getCommandParser(&d->msgParser);
    d->execute(&d->cmdParser);

#if defined(Q_OS_MAC) && defined(CMPLAYER_RELEASE)
    static const auto path = QApplication::applicationDirPath().toLocal8Bit();
    _Debug("Set $LIBQUVI_SCRIPTSDIR=\"%%\"", path);
    if (setenv("LIBQUVI_SCRIPTSDIR", path.data(), 1) < 0)
        _Error("Cannot set $LIBQUVI_SCRIPTSDIR. "
               "Some streaming functions won't work.");
#endif

    setQuitOnLastWindowClosed(false);
#ifndef Q_OS_MAC
    setWindowIcon(defaultIcon());
#endif

    auto makeStyle = [&]() {
        auto name = r.value(u"style"_q, styleName()).toString();
        if (style()->objectName().compare(name, QCI) == 0)
            return;
        if (!d->styleNames.contains(name, QCI))
            return;
        setStyle(QStyleFactory::create(name));
    };
    d->styleNames = [this] () {
        auto names = QStyleFactory::keys();
        const auto defaultName = style()->objectName();
        for (auto it = ++names.begin(); it != names.end(); ++it) {
            if (defaultName.compare(*it, QCI) == 0) {
                const auto name = *it;
                names.erase(it);
                names.prepend(name);
                break;
            }
        }
        return names;
    }();
    makeStyle();
    connect(&d->connection, &LocalConnection::messageReceived,
             this, &App::handleMessage);
    const auto map = r.value(u"open_folders"_q).toMap();
    QMap<QString, QString> folders;
    for (auto it = map.begin(); it != map.end(); ++it)
        folders.insert(it.key(), it->toString());
    set_open_folders(folders);
}