Пример #1
0
MainWindow::MainWindow()
    : QMainWindow(NULL, Qt::Window)
    , EventReceiver(LowestPriority)
{
    setObjectName("mainwnd");
    setAttribute(Qt::WA_AlwaysShowToolTips);
    Q_ASSERT(s_mainWindow == NULL);
    s_mainWindow = this;
    h_lay	 = NULL;
    m_bNoResize = false;

    m_icon = "SIM";
    setWindowIcon(Icon(m_icon));
    setTitle();

//    setIconSize(QSize(16,16));

    m_bar = NULL;

    main = new QWidget(this);
    setCentralWidget(main);

    lay = new QVBoxLayout(main);
    lay->setMargin(0);

    QStatusBar *status = statusBar();
    status->show();
    status->installEventFilter(this);
}
Пример #2
0
void MainWindow::addStatus(QWidget *w, bool)
{
    QStatusBar *status = statusBar();
    w->reparent(status, QPoint());
    statusWidgets.push_back(w);
    status->addWidget(w, true);
    w->show();
    status->show();
    setGrip();
}
Пример #3
0
void MainWindow::addStatus(QWidget *w, bool)
{
    QStatusBar *status = statusBar();
    w->setParent(status);
    w->move(QPoint());
    statusWidgets.push_back(w);
    status->addWidget(w, true);
    w->show();
    status->setSizeGripEnabled(true);
    status->show();
}
Пример #4
0
void MainWindow::readFromConfig()
{
    //switchLanguage(NULL);

    /* read saved state */
    readSettings(&settings, false);

    toggleASQLow(ui->checkBox_asq_detectLow->isChecked());
    toggleASQHigh(ui->checkBox_asq_detectHigh->isChecked());

    toggleTransmitPilot(ui->checkBox_transmitter_pilot->isChecked());
    toggleTransmitRds(ui->checkBox_transmitter_rds->isChecked());
    toggleTransmitEnabled(ui->checkBox_transmitter_enabled->isChecked());

    toggleRDSaf(ui->checkBox_rds_useaf->isChecked());
    toggleRDSfifo(ui->checkBox_rds_fifo->isChecked());
    toggleRDSPSVisibility(ui->spinBox_rds_ps_msgs->value());
    UpdateRDSRTFileEnabled(ui->checkBox_rds_title_file->isChecked());
    UpdateRDSRTPlusEnabled();
    //updateHTTPListener();

    createLanguageMenu();
    ui->actionSelect_Language->setMenu(languageMenu);

    setupTrayIcon();
    SetWindowMode(!ui->checkBox_mini_mode->isChecked());
    SetAudioCompLimPresetByParams();

    /* actions for querier */
    if(ui->checkBox_rds_time->isChecked()) {
        querier->rdsInterval = ui->spinBox_rds_time_int->value() * 1000;
    }

    /* try to connect */
    toggleConnection(false, false);
    if(ui->checkBox_sw_autoconnect->isChecked())
        querier->timer.start();
    else {
        QStatusBar *status = statusBar();
        status->showMessage(tr("Default config editing mode..."));
        status->show();
    }

    this->adjustSize();
    this->resize(1,1);
    this->updateGeometry();

    qDebug() << __FUNCTION__;
}
Пример #5
0
MainWindow::MainWindow(Geometry &geometry)
    : QMainWindow(NULL, Qt::Window)
    , EventReceiver(LowestPriority)
{
    setObjectName("mainwnd");
    setAttribute(Qt::WA_AlwaysShowToolTips);
    Q_ASSERT(s_mainWindow == NULL);
    s_mainWindow = this;
    h_lay	 = NULL;
    m_bNoResize = false;

    m_icon = "SIM";
    setWindowIcon(Icon(m_icon));
    setTitle();

//    setIconSize(QSize(16,16));

    m_bar = NULL;

    main = new QWidget(this);
    setCentralWidget(main);

    lay = new QVBoxLayout(main);
    lay->setMargin(0);

    QStatusBar *status = statusBar();
    status->show();
    status->installEventFilter(this);
    
    if ((geometry[WIDTH].toLong() == -1) && (geometry[HEIGHT].toLong() == -1))
    {
        geometry[HEIGHT].asLong() = QApplication::desktop()->height() * 2 / 3;
        geometry[WIDTH].asLong()  = geometry[HEIGHT].toLong() / 3;
    }
    if ((geometry[LEFT].toLong() == -1) && (geometry[TOP].toLong() == -1)){
        geometry[LEFT].asLong() = QApplication::desktop()->width() - 25 - geometry[WIDTH].toLong();
        geometry[TOP].asLong() = 5;
    }
    ::restoreGeometry(this, geometry, true, true);
}
Пример #6
0
ExternalHelpWindow::ExternalHelpWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QSettings *settings = Core::ICore::settings();
    settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));

    const QVariant geometry = settings->value(QLatin1String("geometry"));
    if (geometry.isValid())
        restoreGeometry(geometry.toByteArray());
    else
        resize(640, 480);

    settings->endGroup();

    QAction *action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateIndex()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateContents()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateSearch()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateBookmarks()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateOpenPages()));
    addAction(action);

    CentralWidget *centralWidget = CentralWidget::instance();

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
    connect(action, SIGNAL(triggered()), this, SIGNAL(addBookmark()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(copy()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(print()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence::Back);
    action->setEnabled(centralWidget->isBackwardAvailable());
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(backward()));
    connect(centralWidget, SIGNAL(backwardAvailable(bool)), action,
        SLOT(setEnabled(bool)));

    action = new QAction(this);
    action->setShortcut(QKeySequence::Forward);
    action->setEnabled(centralWidget->isForwardAvailable());
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(forward()));
    connect(centralWidget, SIGNAL(forwardAvailable(bool)), action,
        SLOT(setEnabled(bool)));

    QAction *reset = new QAction(this);
    connect(reset, SIGNAL(triggered()), centralWidget, SLOT(resetZoom()));
    addAction(reset);

    QAction *ctrlTab = new QAction(this);
    connect(ctrlTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
        SLOT(gotoPreviousPage()));
    addAction(ctrlTab);

    QAction *ctrlShiftTab = new QAction(this);
    connect(ctrlShiftTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
        SLOT(gotoNextPage()));
    addAction(ctrlShiftTab);

    action = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
        tr("Show Sidebar"), this);
    connect(action, SIGNAL(triggered()), this, SIGNAL(showHideSidebar()));

    if (Utils::HostOsInfo::isMacHost()) {
        reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
        action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
        ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
        ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
    } else {
        reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
        action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
        ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
        ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
    }

    QToolButton *button = new QToolButton;
    button->setDefaultAction(action);

    QStatusBar *statusbar = statusBar();
    statusbar->show();
    statusbar->setProperty("p_styled", true);
    statusbar->addPermanentWidget(button);

    QWidget *w = new QWidget;
    QHBoxLayout *layout = new QHBoxLayout(w);
    layout->addStretch(1);
    statusbar->insertWidget(1, w, 1);

    installEventFilter(this);
    setWindowTitle(tr("Qt Creator Offline Help"));
}
Пример #7
0
void MainWindow::RedrawEverything(bool bFound)
{
    int ret, transmitting;
    char cpuid[32];
    char rev[32];
    QStatusBar *status = statusBar();
    qDebug() << __FUNCTION__;
    fmtxEEPROMInfoClean();

    liveEditingEnabled=false;
    querier->is_ready=false;
    deviceStatus=bFound;

    toggleConnection(bFound, false);
    if(!bFound) {
        querier->is_ready=ui->checkBox_sw_autoconnect->isChecked();
        if(!ui->checkBox_sw_autoconnect->isChecked())
            querier->timer.stop();
        qDebug() << "frontend flagged as" << bFound << " returning.";
        if(!is_normal || !this->isVisible())
            trayIcon->showMessage(tr("FmStick disconnected"),
                        tr("Device disconnected!"),
                        QSystemTrayIcon::Information, 5 * 1000);
        return;
    }

    status->showMessage(tr("(Re)Reading frontend info..."), 10000);
    status->show();

    cpuid[0] = '\0';
    rev[0] = '\0';
    querier->HidAccessMutex.lock();
    ret = fmtxIoAppIdString(cpuid, rev);
    querier->HidAccessMutex.unlock();
    if(ret!=FMTX_MODE_OK) {
        qDebug() << "can't get id string";
        goto redraw_err;
    }
    qDebug() << "got CPU ID: "<<QString(cpuid)<<" rev.:"<<QString(rev);
    ui->lineEdit_hw_id_cpuid->setText(QString(cpuid));
    ui->lineEdit_hw_id_cpufwid->setText(QString(rev));


    status->showMessage(tr("Reading EEPROM..."), 10000);
    status->show();
    qDebug() << "Reading EEPROM...";
    querier->HidAccessMutex.lock();
    fmtxCmdSpecial = FMTX_SPECIAL_EEPROM;   ///< now work with eeprom instead of frontend
    ret=fmtxEEPROMReadConfig();
    fmtxCmdSpecial = FMTX_SPECIAL_FRONTEND;
    querier->HidAccessMutex.unlock();

    ui->checkBox_hw_run_txAtPowerUp->blockSignals(true);
    ui->checkBox_hw_run_txAtPowerUp->setChecked(fmtxEEPROMGetStartupFlag());
    ui->checkBox_hw_run_txAtPowerUp->blockSignals(false);

    if(ret==FMTX_MODE_POWER_DOWN) {
        qDebug() << "EEPROM is empty yet!";
    } else if(ret!=FMTX_MODE_OK) {
        qDebug() << "Can't read EEPROM";
        goto redraw_err;
    }
    qDebug() << "EEPROM Readed..";


    transmitting = 0;
    querier->HidAccessMutex.lock();
    ret = fmtxIoAppFeGetMode(&transmitting);
    querier->HidAccessMutex.unlock();
    qDebug() << "Frontend mode: " << ret << "transmitting: " << transmitting;
    if(ret == FMTX_MODE_POWER_DOWN){
        qDebug() << "Frontend powered down!";
        ret = SetFrontendPowerUp();
    }

    if(ret!=FMTX_MODE_POWER_UP && ret!=FMTX_MODE_TRANSMITTING) {
        qDebug() << "Frontend not found..";
        SetTransmitIcon(ICON_WARN);
        goto redraw_err;
    }

    if(transmitting) {
        qDebug() << "Already transmitting!";
        SetTransmitIcon(ICON_TX);
    }

    /* needed to detect if hardware supports rds */
    querier->HidAccessMutex.lock();
    DisplayFirmwareInfo();
    querier->HidAccessMutex.unlock();
    if(fmtxCmdStatus!=FMTX_MODE_OK)
        goto redraw_err;

    if(ui->checkBox_rewriteCfg->isChecked()) {
        qDebug() << "Forcing configuration from software, instead of hardware!";
        status->showMessage("Writing running config...", 10000);
        status->show();
        if(SetFrontendParams()!=FMTX_MODE_OK)
            goto redraw_err;
        //hack for digital audio
        if(! SetDigitalAudioHack())
                goto redraw_err;
    }

    status->showMessage(tr("Reading running config..."), 10000);
    status->show();
    querier->HidAccessMutex.lock();
    ret=GetFrontendParams();
    querier->HidAccessMutex.unlock();

    if(ret!=FMTX_MODE_OK)
        goto redraw_err;

    liveEditingEnabled=ui->checkBox_sw_live_edit->isChecked();
    statusBar()->hide();
    this->adjustSize();
    this->resize(1,1);
    this->updateGeometry();
    querier->is_ready=true;

    qDebug() << "Redraw everything done! transmitting: " << transmitting;
    if(!is_normal || !this->isVisible())
        trayIcon->showMessage(tr("FmStick connected"),
                    tr("Device found and connected!%1")
                              .arg( transmitting ? tr("\nAnd transmitter is powered on!") : ""),
                    QSystemTrayIcon::Information, 5 * 1000);
    return;

redraw_err:
    if(!is_normal || !this->isVisible())
        trayIcon->showMessage(tr("FmStick not connected"), tr("Can't connect to frontend!"),
                          QSystemTrayIcon::Critical, 5 * 1000);
    status->showMessage(tr("Can't connect to frontend!"), 10000);
    status->show();
    qDebug() << "Error while redraw everything";
    querier->is_ready=true;
    SetTransmitIcon(ICON_ERR);
}