const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator() { qDebug() << "Loading default translator from text" << defaultTranslatorText; QBuffer textBuffer; textBuffer.setData(defaultTranslatorText,strlen(defaultTranslatorText)); return loadTranslator(&textBuffer,"fallback"); }
nNaveoApplication::nNaveoApplication(int argc, char *argv[]) : QApplication(argc, argv) { //UTF-8 support QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); connect(this, SIGNAL(aboutToQuit()), this, SLOT(close())); console = new nDebugConsole(); checkInstance(); settings = new nSettingsManager(this); translator = new QTranslator(); loadTranslator(); theme = new nTheme(); initWebSettings(); engine = new nGoogleSearchEngine(); downloadManager = new nDownloadManager(); accessManager = new QNetworkAccessManager(this); historyManager = new nHistoryManager(); QWebHistoryInterface::setDefaultInterface(historyManager); setWindowIcon(QIcon(":/icon.png")); connect(settings, SIGNAL(settingsChanged()), this, SIGNAL(settingsChanged())); connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSettings())); updateSettings(); }
djvViewContext::djvViewContext(QObject * parent) : djvGuiContext(parent), _p(new djvViewContextPrivate) { //DJV_DEBUG("djvViewContext::djvViewContext"); // Load translators. loadTranslator("djvViewLib"); // Load preferences. DJV_LOG(debugLog(), "djvViewContext", "Load the preferences..."); _p->filePrefs = new djvViewFilePrefs(this); _p->imagePrefs = new djvViewImagePrefs(this); _p->inputPrefs = new djvViewInputPrefs(this); _p->playbackPrefs = new djvViewPlaybackPrefs(this); _p->shortcutPrefs = new djvViewShortcutPrefs(this); _p->viewPrefs = new djvViewViewPrefs(this); _p->windowPrefs = new djvViewWindowPrefs(this); DJV_LOG(debugLog(), "djvViewContext", ""); // Initialize objects. DJV_LOG(debugLog(), "djvViewContext", "Initialize objects..."); _p->fileCache = new djvViewFileCache(this); _p->fileSave = new djvViewFileSave(this); DJV_LOG(debugLog(), "djvViewContext", ""); }
djvConvertContext::djvConvertContext(QObject * parent) : djvImageContext(parent) { //DJV_DEBUG("djvConvertContext::djvConvertContext"); // Load translators. loadTranslator("djv_convert"); }
KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& name) { const QString& path = findTranslatorPath(name); QFile source(path); if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text)) return 0; return loadTranslator(&source,name); }
void Application::initialize() { QStringList searchDir; searchDir << "." << ".." << QLibraryInfo::location(QLibraryInfo::TranslationsPath); QSettings settings("settings.ini", QSettings::IniFormat); QStringList translations = settings.value("settings/translations", "qt_zh_cn").toStringList(); foreach(QString translatorFileName, translations) { QTranslator *qtTranslator = new QTranslator(this); loadTranslator(qtTranslator, searchDir, translatorFileName); installTranslator(qtTranslator); }
const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator() { // Try to find the default.keytab file if it exists, otherwise // fall back to the hard-coded one const KeyboardTranslator* translator = findTranslator("default"); if (!translator) { QBuffer textBuffer; textBuffer.setData(defaultTranslatorText); textBuffer.open(QIODevice::ReadOnly); translator = loadTranslator(&textBuffer,"fallback"); } return translator; }
const KeyboardTranslator* KeyboardTranslatorManager::findTranslator(const QString& name) { if ( name.isEmpty() ) return defaultTranslator(); if ( _translators.contains(name) && _translators[name] != 0 ) return _translators[name]; KeyboardTranslator* translator = loadTranslator(name); if ( translator != 0 ) _translators[name] = translator; else if ( !name.isEmpty() ) qDebug() << "Unable to load translator" << name; return translator; }
int main(int argc,char *argv[]) { QDir::setCurrent(QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath()); Local::addLibraryPath("./plugins"); Local::setStyle("Fusion"); Local a(argc,argv); Config::load(); int single; if((single=Config::getValue("/Interface/Single",1))){ QLocalSocket socket; socket.connectToServer("BiliLocalInstance"); if(socket.waitForConnected()){ QDataStream s(&socket); s<<a.arguments().mid(1); socket.waitForBytesWritten(); return 0; } } Shield::load(); loadTranslator(); setDefaultFont(); setToolTipBase(); a.connect(&a,&Local::aboutToQuit,[](){ Shield::save(); Config::save(); }); qsrand(QTime::currentTime().msec()); Interface w; Plugin::loadPlugins(); w.show(); w.tryLocal(a.arguments().mid(1)); QLocalServer *server=NULL; if(single){ server=new QLocalServer(qApp); server->listen("BiliLocalInstance"); QObject::connect(server,&QLocalServer::newConnection,[&](){ QLocalSocket *r=server->nextPendingConnection(); r->waitForReadyRead(); QDataStream s(r); QStringList args; s>>args; r->deleteLater(); w.tryLocal(args); }); }
djvLsContext::djvLsContext(QObject * parent) : djvImageContext(parent), _fileInfo (true), _filePath (false), _sequence (djvSequence::COMPRESS_RANGE), _recurse (false), _hidden (false), _columns (djvSystem::terminalWidth()), _sort (djvFileInfoUtil::SORT_NAME), _reverseSort (false), _sortDirsFirst(true) { //DJV_DEBUG("djvLsContext::djvLsContext"); // Load translators. loadTranslator("djv_ls"); }
int main(int argc, char *argv[]) { Local a(argc, argv); int single; if ((single = Config::getValue("/Interface/Single", 1))){ QLocalSocket socket; socket.connectToServer("BiliLocalInstance"); if (socket.waitForConnected()){ QDataStream s(&socket); s << a.arguments().mid(1); socket.waitForBytesWritten(); return 0; } } loadTranslator(); setDefaultFont(); setToolTipBase(); Interface w; Plugin::loadPlugins(); if (!w.testAttribute(Qt::WA_WState_ExplicitShowHide)){ w.show(); } w.tryLocal(a.arguments().mid(1)); QLocalServer *server = nullptr; if (single){ server = new QLocalServer(lApp); server->listen("BiliLocalInstance"); QObject::connect(server, &QLocalServer::newConnection, [&](){ QLocalSocket *r = server->nextPendingConnection(); r->waitForReadyRead(); QDataStream s(r); QStringList args; s >> args; delete r; w.tryLocal(args); }); }