Ejemplo n.º 1
0
void SettingsBase::initApplication()
{
    // Prepare the menu of all modules
    categories = KServiceTypeTrader::self()->query("SystemSettingsCategory");
    modules = KServiceTypeTrader::self()->query("KCModule", "[X-KDE-System-Settings-Parent-Category] != ''");
    modules += KServiceTypeTrader::self()->query("SystemSettingsExternalApp");
    rootModule = new MenuItem( true, 0 );
    initMenuList(rootModule);
    // Handle lost+found modules...
    if (lostFound) {
        for (int i = 0; i < modules.size(); ++i) {
            const KService::Ptr entry = modules.at(i);
            MenuItem * infoItem = new MenuItem(false, lostFound);
            infoItem->setService( entry );
            qDebug() << "Added " << entry->name();
        }
    }

    // Prepare the Base Data
    BaseData::instance()->setMenuItem( rootModule );
    // Load all possible views
    const KService::List pluginObjects = KServiceTypeTrader::self()->query( "SystemSettingsView" );
    const int nbPlugins = pluginObjects.count();
    for( int pluginsDone = 0; pluginsDone < nbPlugins ; ++pluginsDone ) {
        KService::Ptr activeService = pluginObjects.at( pluginsDone );
        QString error;
        BaseMode * controller = activeService->createInstance<BaseMode>(this, QVariantList(), &error);
        if( error.isEmpty() ) {
            possibleViews.insert( activeService->library(), controller );
            controller->init( activeService );
            connect(controller, SIGNAL(changeToolBarItems(BaseMode::ToolBarItems)), this, SLOT(changeToolBar(BaseMode::ToolBarItems)));
            connect(controller, SIGNAL(actionsChanged()), this, SLOT(updateViewActions()));
            connect(searchText, SIGNAL(textChanged(QString)), controller, SLOT(searchChanged(QString)));
            connect(controller, SIGNAL(viewChanged(bool)), this, SLOT(viewChange(bool)));
        } else {
Ejemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    int w, h;
    if (this->size().height() > qApp->desktop()->height())
        h = qApp->desktop()->height() - 150;
    else
        h = this->size().height();
    if (this->size().width() > qApp->desktop()->width())
        w = qApp->desktop()->width() - 150;
    else
        w = this->size().width();
    this->resize(w, h);
    QDir dir;
    dir.mkdir(QDir::currentPath()+"/tmp/");

    this->settingsWidget = new SettingsWidget;
    this->fileWidget = new FileWidget(this, this->settingsWidget);
//    this->fileWidget->settings = this->settingsWidget;
    win7.init(this->winId());

    this->shellWidget = NULL;
    this->screenshotWidget = NULL;
    this->phoneInfoWidget = NULL;
    this->messageWidget = NULL;
    this->appWidget = NULL;
    this->recoveryWidget = NULL;
    this->fastbootWidget = NULL;
    this->logcatDialog = NULL;


    this->systemTray=new QSystemTrayIcon();
    this->systemTray->setIcon(QIcon(":/icons/android.png"));
    this->systemTray->show();

    QMenu *menu = new QMenu;
    QAction *close,*logcat;
    logcat = menu->addAction(QIcon(":icons/logcat.png"),tr("Logcat", "action in system tray menu"),this,SLOT(showLogcat()));
    logcat->setData(QString("logcat"));
    close = menu->addAction(QIcon(":icons/remove.png"),tr("exit", "action in system tray menu"),this,SLOT(close()));
    close->setData(QString("exit"));
    this->systemTray->setContextMenu(menu);


    ui->stackedWidget->addWidget(this->settingsWidget);
    ui->stackedWidget->addWidget(this->fileWidget);
    ui->stackedWidget->setCurrentWidget(ui->pageDisconnected);

    ui->pageDisconnected->setLayout(ui->layoutDisconnected);
    this->currentWidget=ui->pageDisconnected;

//    this->codec = QTextCodec::codecForLocale();

//    ////Debugging
    qDebug()<<QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss");
    qDebug()<<"App version - "<<QCoreApplication::applicationVersion();

//    this->setWindowTitle("QtADB");

    this->ui->centralWidget->setLayout(ui->gridLayout);

    if (this->settingsWidget->saveWindowPosition)
        this->restoreGeometry(this->settingsWidget->windowGeometry);

    this->ui->toolBar->setMovable(false);

    this->addButton(QIcon(":icons/files.png"), tr("Files", "files button"), "Files" , SLOT(showPageFiles()), Action::Device | Action::Recovery);
    this->addButton(QIcon(":icons/apps.png"), tr("Apps", "apps button"), "Apps", SLOT(showPageApps()), Action::Device | Action::Recovery);
    this->addButton(QIcon(":icons/recovery.png"), tr("Recovery", "recovery button"), "Recovery", SLOT(showPageRecovery()), Action::Recovery);
    this->addButton(QIcon(":icons/fastboot.png"), tr("Fastboot", "fastbot button"), "Fastboot", SLOT(showPageFastboot()), Action::Fastboot);
    this->addButton(QIcon(":icons/info.png"), tr("Phone info", "phone info button"), "Phone info", SLOT(showPagePhoneInfo()), Action::Device | Action::Recovery | Action::Disconnected | Action::Fastboot);
    this->addButton(QIcon(":icons/screenshot.png"), tr("Screenshot", "screenshot button"), "Screenshot", SLOT(showPageScreenshot()), Action::Device | Action::Recovery);
    this->addButton(QIcon(":icons/settings.png"), tr("Settings", "settings button"), "Settings", SLOT(showPageSettings()), Action::Disconnected | Action::Device | Action::Recovery | Action::Fastboot);
    this->addButton(QIcon(":icons/shell.png"), tr("Shell", "shell button"), "Shell", SLOT(showPageShell()), Action::Device | Action::Recovery);
    this->addButton(QIcon(":icons/messages.png"), tr("Messages", "messages button"), "Messages", SLOT(showPageMessages()), Action::Device);
//    this->addButton(QIcon(":icons/contacts.png"), tr("Contacts"), SLOT(showPageContacts()), Action::Device);
    this->addButton(QIcon(":icons/logcat.png"), tr("Logcat", "logcat button"), "Logcat", SLOT(showLogcat()), Action::Device | Action::Recovery);


    this->changeToolBar();
    connect(this->fileWidget->phone,SIGNAL(signalConnectionChanged(int)),this,SLOT(phoneConnectionChanged(int)));
//    this->refreshState();
    connect(this->ui->actionAdbReboot, SIGNAL(triggered()), this->fileWidget->phone, SLOT(adbReboot()));
    connect(this->ui->actionAdbRebootBootloader, SIGNAL(triggered()), this->fileWidget->phone, SLOT(adbRebootBootloader()));
    connect(this->ui->actionAdbRebootRecovery, SIGNAL(triggered()), this->fileWidget->phone, SLOT(adbRebootRecovery()));
    connect(this->ui->actionFastbootReboot, SIGNAL(triggered()), this->fileWidget->phone, SLOT(fastbootReboot()));
    connect(this->ui->actionFastbootRebootBootloader, SIGNAL(triggered()), this->fileWidget->phone, SLOT(fastbootRebootBootloader()));


    connect(ui->actionFastbootPowerOff, SIGNAL(triggered()), this->fileWidget->phone, SLOT(fastbootPowerOff()));
    connect(ui->actionFastbootReboot, SIGNAL(triggered()), this->fileWidget->phone, SLOT(fastbootReboot()));
    connect(ui->actionFastbootRebootBootloader, SIGNAL(triggered()), this->fileWidget->phone, SLOT(fastbootRebootBootloader()));

    connect(this->ui->buttonRefresh, SIGNAL(clicked()), this, SLOT(refreshState()));
//    connect(this->fileWidget, SIGNAL(phoneConnectionChanged(int)), this, SLOT(phoneConnectionChanged(int)));

//    //tryb
    connect(this->ui->actionUsb, SIGNAL(triggered()), this, SLOT(restartInUsb()));
    connect(this->ui->actionWifi, SIGNAL(triggered()), this, SLOT(restartInWifi()));

//    //updates
    connect(this->ui->actionCheck_for_updates, SIGNAL(triggered()), this, SLOT(updatesCheck()));
    connect(&this->updateApp, SIGNAL(updateState(bool, QString, QString)), this, SLOT(updatesCheckFinished(bool, QString, QString)));

    connect(&this->animation.animation, SIGNAL(finished()), this, SLOT(animationFinished()));

    connect(this->systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
    connect(this->systemTray, SIGNAL(messageClicked()), this, SLOT(showPageMessages()));
    connect(this->systemTray, SIGNAL(messageClicked()), this, SLOT(show()));
//
#ifdef WIN7PROGRESS
    connect(this->fileWidget, SIGNAL(progressValue(int,int)), this, SLOT(setProgressValue(int, int)));
    connect(this->fileWidget, SIGNAL(copyFinished(int)), this, SLOT(setProgressDisable()));
#endif

    connect(this->settingsWidget, SIGNAL(settingsChanged()), this, SLOT(changeToolBar()));
    this->settingsWidget->clearSettings = false;

    this->fillLanguages();
    this->showNoUpdates = false;
    if (this->settingsWidget->checkForUpdatesOnStart)
        this->updateApp.checkUpdates();

//    this->setWindowTitle("QtADB " + QString::number(this->height()) + "x" + QString::number(this->width()));
}