Пример #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow), device(NULL), preseed(NULL)

{
    ui->setupUi(this);

    /* Set up logging */
    logger = new Logger();
    logger->addLine("Starting OSMC installer");
    /* UI set up */
    #ifdef Q_WS_QWS
    QWSServer *server = QWSServer::instance();
    if(server)
    {
        server->setCursorVisible(false);
        server->setBackground(QBrush(Qt::black));
        this->setWindowFlags(Qt::Tool|Qt::CustomizeWindowHint);
    }
    #endif
    this->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, this->size(), qApp->desktop()->availableGeometry()));
    QFontDatabase fontDatabase;
    fontDatabase.addApplicationFont(":/assets/resources/SourceSansPro-Regular.ttf");

    /* Populate target list map */
    targetList = new TargetList();
    utils = new Utils(logger);
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent)
    :QWidget(parent)
{
    setupUi(this);
    keyboard = new Keyboard;
    keyboard->setVisible(false);
    layout()->addWidget(keyboard);
    devicesModel = new DevicesListModel;
    listView->setModel(devicesModel);
    deviceDelegate = new DeviceListDelegate;
    listView->setItemDelegate(deviceDelegate);

#if !defined(DEBUG)
    QWSServer *qws = QWSServer::instance();
    if (qws)
        qws->setCursorVisible(false);
#endif

    buttonGroup = new QButtonGroup(this);
    buttonGroup->addButton(pbcRadioButton);
    buttonGroup->addButton(pinRadioButton);
    buttonsEnabled(false);

    pinLineEdit->setEnabled(false);
    goCheckBox->setEnabled(false);

    wpa = new Wpa;

    dynamic_cast<QVBoxLayout *>(layout())->setStretchFactor(scrollArea, 1);
    connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this,
            SLOT(focusChanged(QWidget*, QWidget*)));
    connect(wpa, SIGNAL(status(const QString&)), this,
            SLOT(statusChanged(const QString&)));
    connect(wpa, SIGNAL(deviceFound(Device&)), devicesModel,
            SLOT(addDevice(Device&)));
    connect(wpa, SIGNAL(connectFails(int)), this,
            SLOT(connectionFails(int)));
    connect(wpa, SIGNAL(groupStarted(bool)), this,
            SLOT(groupStarted(bool)));
    connect(wpa, SIGNAL(groupFinished()), this,
            SLOT(groupStopped()));
    connect(wpa, SIGNAL(enabled(bool)), this,
            SLOT(setWifiDirectEnabled(bool)));
    connect(listView, SIGNAL(doubleClicked(const QModelIndex&)), this,
            SLOT(deviceSelected(const QModelIndex&)));
    connect(startGroupButton, SIGNAL(clicked()), this,
            SLOT(startGroupClicked()));
    connect(disconnectButton, SIGNAL(clicked()), this,
            SLOT(disconnectClicked()));
    // connect(intentSlider, SIGNAL(valueChanged(int)), wpa,
    //         SLOT(setIntent(int)));
    // connect(channelSlider, SIGNAL(sliderReleased()), this,
    //         SLOT(channelReleased()));

    if (wpa->isEnabled()) {
        wifiDirectCheckBox->setCheckState(Qt::Checked);
        wpa->getPeers();

        statusChanged(wpa->getStatus());
    }
}
Пример #3
0
int main(int argc, char *argv[])
{
    QtSingleApplication instance(argc, argv, QApplication::GuiServer);
    instance.setApplicationName(APPNAME);
    instance.setOrganizationName(ORGANISATION);

    QStringList argsList = instance.arguments();
    QString argsString = argsList.join(ARGS_SPLIT_TOKEN);

//Hide mouse cursor by default
#ifdef ENABLE_QWS_STUFF
    QWSServer *qserver = QWSServer::instance();
    qserver->setCursorVisible(false);
#endif

    // Show help message
    if (argsList.contains("-h") || argsList.contains("--help")) {
        printf("\tUsage: %s [-d] -qws -nomouse [SetUrl http://example.com/]\n"
               "\tIf -d is specified, this program will run as a daemon.\n"
               "\tFor more info, see http://wiki.chumby.com/index.php/NeTV_local_UI\n",
               argv[0]);
        return 0;
    }

    //Check if another instance is already running & attempt to send arguments to it
    if (instance.sendMessage(argsString))
    {
        printf("Sending arguments to running %s instance: %s\n", TAG, argsString.toLatin1().constData());
        return 0;
    }

    //Give it another go
    if (instance.sendMessage(argsString))
    {
        printf("Sending arguments to running %s instance: %s\n", TAG, argsString.toLatin1().constData());
        return 0;
    }

    bool running = isRunning();
    if (running)
    {
        // For some reason, the local socket in previous instance doesn't accept command. We give up.
        printf("Failed to send arguments to running %s instance: %s\n", TAG, argsString.toLatin1().constData());
        return 1;
    }

    // If the args list contains "-d", then daemonize it
    int temp = 0;
    if (argsList.contains("-d") || argsList.contains("--daemon"))
        temp = daemon(0, 0);

    printf("Starting new %s with args:", TAG);
    printf("%s", argsString.toLatin1().constData());

//Pink background for the entire QWS environment
#ifdef ENABLE_QWS_STUFF
    qserver->setBackground(QBrush(QColor(240,0,240)));
#endif

    MainWindow w;
    w.receiveArgs(argsString);
#ifdef Q_WS_QWS
    w.showFullScreen();
#else
    w.show();
#endif
    instance.setActivationWindow(&w);

    QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), &w, SLOT(receiveArgs(const QString&)));

    return instance.exec();
}