Esempio n. 1
0
void TweaksPlugin::connectWifi() {
    WirelessWorkflowManager* p = WirelessWorkflowManager::sharedInstance();

    if(p) {
        if(p->isConnectedToHotspot())
            p->turnWifiOff();
        else
            p->connectWireless(false);
    }
}
Esempio n. 2
0
void TweaksPlugin::open(QString mimeType)
{
	if(!hmc)
		hmc = QApplication::activeWindow()->findChild<HomeMenuController *>();

    LibraryMenuController *lmc = QApplication::activeWindow()->findChild<LibraryMenuController *>();

    cout << "TweaksPlugin::open(\"" << mimeType.toStdString() << "\")" << endl << flush; 
    if (mimeType == MENTRY_BROWSER) {
        WirelessWorkflowManager::sharedInstance()->openBrowser(QUrl());
    } 
    else if (mimeType == MENTRY_TWEAKS) {
        // TODO: proper parent/lifecycle management
        TweaksSettingsView *settingsView = new TweaksSettingsView(this, 0);
        TweaksSettingsPageView *v = new TweaksSettingsPageView(QApplication::activeWindow(), settingsView, false);
        MainWindowController::sharedInstance()->pushView(v);
    }
    else if (mimeType == MENTRY_WIFIONOFF) {
        WirelessWorkflowManager* wfm = WirelessWorkflowManager::sharedInstance();
        if(!wfm->isAirplaneMode()) {
            wfm->turnWifiOff();
            wfm->setAirplaneMode(true);
        } else {
            wfm->setAirplaneMode(false);
            wfm->connectWirelessSilently();
            enableWirelessTimeout(wirelessTimeoutEnabled());
        }
    }
    else if (mimeType == MENTRY_LIBRARY) {
    	library();
    }
    else if (mimeType == MENTRY_DICTIONARY) {
        if(hmc)
            hmc->dictionary();
    }
    else if (mimeType == MENTRY_SETTINGS) {
        if(hmc)
            hmc->settings();
    }
    else if (mimeType == MENTRY_READINGLIFE) {
        if(hmc)
            hmc->readingLife();
    }
    else if (mimeType == MENTRY_STORE) {
        if(hmc)
            hmc->store();
    }
    else if (mimeType == MENTRY_SYNC) {
        if(hmc)
            hmc->sync();
    }
    else if (mimeType == MENTRY_HELP) {
        if(hmc)
            hmc->help();
    }
    else if (mimeType == MENTRY_AIRPLANEMODE) {
        N3SettingsWirelessController* p = QApplication::activeWindow()->findChild<N3SettingsWirelessController *>();    
        if(p)
            p->airplaneModeToggled();
    }
    else if (mimeType == MENTRY_SHORTLIST) {
        if(lmc)
            lmc->favourites();
    }
    else if (mimeType == MENTRY_BOOKS) {
        if(lmc)
            lmc->lists();
    }
    else if (mimeType == MENTRY_CREATESHELF) {
        if(lmc)
            lmc->createShelf();
    }
    else if (mimeType == MENTRY_SHELVES) {
        if(lmc)
            lmc->shelves();
    }
    else if (mimeType == MENTRY_LIBRARYSEARCH) {
        if(lmc)
            lmc->search();
    }
    else if (mimeType == MENTRY_POWEROFF) {
        N3PowerWorkflowManager::sharedInstance()->showPowerOffView();
        DevicePowerWorkflowManager* p = qApp->findChild<DevicePowerWorkflowManager *>();    
        if(p)
            p->powerOff(false);
    }
    else if (mimeType == MENTRY_SLEEP) {
    	sleep();
    }
    else {
        Volume v;
        v.setMimeType(mimeType);
        v.setTitle("Tweaks");
        N3ReaderOpener *ro = (N3ReaderOpener*) ((ReadingViewMixin*) this)->createReader(v, NULL);
        ro->openReader();
    }
}