bool CmdLine::eventFilter( QObject *, QEvent *e ) { int type = e->type(); if( type != QEvent::KeyPress ) return false; QKeyEvent *ke = static_cast<QKeyEvent*>(e); switch( ke->key() ) { case Qt::Key_Return: case Qt::Key_Enter: if( expr->text().isEmpty() ) return true; emit invoked( expr->text(), false ); if( history.count() == 0 || history[0] != expr->text() ) { if( history.count() >= maxHistory ) history.removeAt( history.count() - 1 ); history.prepend( expr->text() ); } curHistory = -1; expr->clear(); return true; case Qt::Key_Up: if( curHistory < history.count() - 1 ) { expr->blockSignals(true); expr->setText( history[++curHistory] ); expr->blockSignals(false); } return true; case Qt::Key_Down: if( curHistory > -1 ) { --curHistory; expr->blockSignals(true); if( curHistory == -1 ) expr->clear(); else expr->setText( history[curHistory] ); expr->blockSignals(false); } return true; default: return false; } }
void LocationBar::invoke( int i_id ) { QModelIndex index = model->index( i_id, 0 ); emit invoked ( index ); }
TranslationInterface::TranslationInterface(QObject *parent) : QObject(parent) , m_service(NULL) , m_serviceItem(NULL) , m_busy(false) , m_suppressRetranslate(false) , m_sourceLanguages(new LanguageListModel(this)) , m_targetLanguages(new LanguageListModel(this)) , m_sourceLanguage(NULL) , m_targetLanguage(NULL) , m_dict(new DictionaryModel(this)) #ifdef Q_OS_SAILFISH , m_settings(new QSettings("harbour-taot", "taot", this)) #else , m_settings(new QSettings(QCoreApplication::organizationName(), "taot", this)) # ifdef WITH_ANALYTICS , m_analytics(new QAmplitudeAnalytics(AMPLITUDE_API_KEY)) # endif #endif { #ifdef WITH_ANALYTICS # if defined(Q_OS_SAILFISH) QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); path.append(QDir::separator()).append("harbour-taot"); QDir dir(path); if (!dir.exists()) dir.mkpath("."); m_analytics.reset(new QAmplitudeAnalytics(AMPLITUDE_API_KEY, dir.filePath("QtInAppAnalytics.ini"))); // HACK: Get proper manufacturer and model values // TODO: Remove when QtSystemInfo is allowed in Harbour QAmplitudeAnalytics::DeviceInfo di = m_analytics->deviceInfo(); org::nemo::ssu ssu("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus()); di.manufacturer = ssu.displayName(0 /*Ssu::DeviceManufacturer*/); di.model = ssu.displayName(1 /*Ssu::DeviceModel*/); m_analytics->setDeviceInfo(di); # endif updatePersistentProperties(); m_privacyLevel = PrivacyLevel(m_settings->value("PrivacyLevel", UndefinedPrivacy).toInt()); if (m_privacyLevel != NoPrivacy) m_analytics->setPrivacyEnabled(true); if (m_settings->contains("AppInfo/CurrentVersion")) { const QString version = m_settings->value("AppInfo/CurrentVersion").toString(); if (version != QCoreApplication::applicationVersion()) { QVariantMap props; props.insert("Old Version", version); props.insert("New Version", QCoreApplication::applicationVersion()); m_analytics->trackEvent("Upgrade", props); m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion()); } } else { QVariantMap props; props.insert("Version", QCoreApplication::applicationVersion()); m_analytics->trackEvent("Installation", props); m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion()); } if (m_privacyLevel == NoPrivacy) { trackSessionStart(); } #endif setTranscription(new SourceTranslatedTextPair()); setTranslit(new SourceTranslatedTextPair()); QStringList list; list.insert(GoogleTranslateService, GoogleTranslate::displayName()); list.insert(MicrosoftTranslatorService, MicrosoftTranslator::displayName()); list.insert(YandexTranslateService, YandexTranslate::displayName()); list.insert(YandexDictionariesService, YandexDictionaries::displayName()); m_services = new TranslationServicesModel(list, this); createService(m_settings->value("SelectedService", 0).toUInt()); connect(this, SIGNAL(sourceLanguageChanged()), SLOT(retranslate())); connect(this, SIGNAL(targetLanguageChanged()), SLOT(retranslate())); connect(this, SIGNAL(sourceLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(targetLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(detectedLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(error(QString)), SLOT(onError(QString))); #ifdef Q_OS_SYMBIAN connect(qApp, SIGNAL(visibilityChanged()), this, SIGNAL(appVisibilityChanged())); #endif #ifdef Q_OS_BLACKBERRY m_invoker = new bb::system::InvokeManager(); connect(m_invoker, SIGNAL(invoked(bb::system::InvokeRequest)), this, SLOT(onInvoked(bb::system::InvokeRequest))); #endif }