void TweaksPlugin::initialize() { // TODO: set loglevel LOG_DEBUG(l) << "init translator"; LOG_DEBUG(l) << "QLocale().name(): " << QLocale().name().toStdString(); QTranslator* pTranslator = new QTranslator; pTranslator->load(QString("koboplugins.") + QLocale().name(), ":/koboplugins/translations/"); qApp->installTranslator(pTranslator); // try to register with the qtscript plugin // TODO: use interface, proper casting QtScriptPlugin *qtScriptPlugin = (QtScriptPlugin *) PluginLoader::forMimeType("application/x-qt-script"); if (qtScriptPlugin) { LOG_DEBUG(l) << "found QtScriptPlugin: " << qtScriptPlugin; qtScriptPlugin->registerObject(this, "TweaksPlugin"); } connect(&mapper, SIGNAL(mapped(QString)), this, SLOT(open(QString))); n3SettingsExtrasController = new N3SettingsExtrasController(); connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(windowChanged(int))); LOG_DEBUG(l) << "connected windowChanged signal"; engine.globalObject().setProperty("tweaks", engine.newQObject(this)); }
TweaksPlugin::TweaksPlugin() : pluginSettings(new QSettings(CONFIG_PATH, QSettings::IniFormat)), sw(NULL), lastPatchedMenu(NULL), lastPatchedLibraryMenu(NULL) { // init logging engine //m_pLogBase = LoggerBase::get(); //FileLogger* pLoggerFile = new FileLogger("/mnt/onboard/", true); //m_pLogBase->addLogObject("FileLogger", pLoggerFile); //m_pLogBase->start(); //LOG("checking firmware version"); if(!checkFirmwareVersion()) return; //LOG("init translator"); std::cout << "QLocale().name(): " << QLocale().name().toStdString() << std::endl; QTranslator* pTranslator = new QTranslator; pTranslator->load(QString("koboplugins.") + QLocale().name(), ":/koboplugins/translations/"); qApp->installTranslator(pTranslator); //LOG("TweaksPlugin()"); // try to register with the qtscript plugin // TODO: use interface, proper casting QtScriptPlugin *qtscriptPlugin = (QtScriptPlugin *) PluginLoader::forMimeType("application/x-qt-script"); if (qtscriptPlugin) { //LOG("found qtscript plugin: 0x%x>",qtscriptPlugin); qtscriptPlugin->registerObject(this, "TweaksPlugin"); } // register to get notified when the current main window changes MainWindowController *mwc = MainWindowController::sharedInstance(); if (mwc) { cout << "found MainWindowController: " << mwc << endl << flush; sw = QApplication::activeWindow()->findChild<QStackedWidget *>(); if (sw) { cout << "found QStackedWidget: " << sw << endl << flush; connect(sw, SIGNAL(currentChanged(int)), this, SLOT(windowChanged(int))); cout << "connected windowChanged signal" << endl << flush; } } connect(&mapper, SIGNAL(mapped(QString)), this, SLOT(open(QString))); enableWirelessTimeout(pluginSettings->value("Tweaks/enableWirelessTimeout", false).toBool()); }