Exemple #1
0
DriverViewSettings::DriverViewSettings(QWidget* parent ) :
        QFrame( parent ) {

    //QCursor cursor(Qt::PointingHandCursor);

    QLabel *selectingDriverLabel = new QLabel(tr("Select the CAN device:"),this);
    listBox = new QListWidget(this);
    connect(listBox, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this , SLOT(selectClicked()));

    // Select Button
    selectButton = new QPushButton(tr("&Select"), this);
    buttonBox = new QDialogButtonBox(Qt::Vertical);
    buttonBox->addButton(selectButton, QDialogButtonBox::ActionRole);
    connect(selectButton, SIGNAL(clicked()), this, SLOT(selectClicked()));
    setList(canFactory()->driverList());

    extension = new QWidget;

    QHBoxLayout *extensionLayout = new QHBoxLayout;
    extensionLayout->setMargin(0);
    extensionLayout->addWidget(listBox, 1);
    extensionLayout->addWidget(buttonBox);
    extensionLayout->addStretch();

    QVBoxLayout *extensionVLayout = new QVBoxLayout;
    extensionVLayout->addWidget(selectingDriverLabel);
    extensionVLayout->addLayout(extensionLayout);

    extension->setLayout(extensionVLayout);
    extension->setVisible(false);

    QLabel *settingsLabel = new QLabel(tr("Select CAN device:"),this);
    openSettingsButton = new QPushButton("", this);
    openSettingsButton->setFlat(true);
    openSettingsButton->setCheckable(true);
    openSettingsButton->setIcon(QIcon( ":/nav_up_blue.png" ));
    openSettingsButton->setCursor(QCursor(Qt::PointingHandCursor));

    QHBoxLayout *openSettingsLayout = new QHBoxLayout;
    openSettingsLayout->addStretch();
    openSettingsLayout->addWidget(settingsLabel);
    openSettingsLayout->addWidget(openSettingsButton);

    verticalLayout = new QVBoxLayout;
    verticalLayout->addLayout(openSettingsLayout);
    verticalLayout->addWidget(extension);

    setLayout(verticalLayout);

    connect(openSettingsButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool)));
    connect(openSettingsButton, SIGNAL(toggled(bool)), this, SLOT(setButtonIcon(bool)));
    connect(canFactory(), SIGNAL(driverIsCommunicating(bool)),this, SLOT(enableChangeInSettings(bool)));
    setFixedHeight(50);

}
Exemple #2
0
void ButtonLog::startButton(int id)
{
#ifdef SHOW_SLOTS
  printf("startMapperData(%d)\n",id);
#endif
  RDLogLine::Status status=RDLogLine::Scheduled;
  int line=log_line_box[id]->line();
  RDLogLine *logline=log_log->logLine(line);
  if(line<0) {
    line=log_log->size();
  }
  switch(log_start_button[id]->mode()) {
      case StartButton::Stop:
	log_log->makeNext(line,false);
	log_log->play(line,RDLogLine::StartManual);
	break;

      case StartButton::Pause:
	log_log->play(line,RDLogLine::StartManual);
	break;

      case StartButton::Play:
	if(log_pause_enabled&&(logline!=NULL)&&
	   (logline->cartType()==RDCart::Audio)) {
	    log_log->pause(line);
	}
	else {
	  log_log->stop(line);
	}
	break;

      case StartButton::AddTo:
      case StartButton::DeleteFrom:
      case StartButton::MoveFrom:
      case StartButton::MoveTo:
      case StartButton::CopyFrom:
      case StartButton::CopyTo:
	if((logline=log_log->logLine(line))==NULL) {
	  status=RDLogLine::Scheduled;
	}
	else {
	  status=logline->status();
	}
	emit selectClicked(log_id,line,status);
	break;

      default:
	break;
  }
}
void ListLog::takeButtonData()
{
    int line=0;

    RDLogLine::Status status=CurrentStatus();
    switch(list_action_mode) {
    case RDAirPlayConf::AddTo:
    case RDAirPlayConf::MoveTo:
    case RDAirPlayConf::CopyTo:
        switch(status) {
        case RDLogLine::Finished:
        case RDLogLine::Playing:
        case RDLogLine::Paused:
        case RDLogLine::Finishing:
            return;

        default:
            line=list_log_list->currentItem()->text(15).toInt();
            break;
        }
        break;

    case RDAirPlayConf::CopyFrom:
        line=list_log_list->currentItem()->text(15).toInt();
        if(list_log->logLine(line)!=NULL) {
            switch(list_log->logLine(line)->type()) {
            case RDLogLine::Marker:
            case RDLogLine::OpenBracket:
            case RDLogLine::CloseBracket:
            case RDLogLine::Chain:
            case RDLogLine::Track:
            case RDLogLine::MusicLink:
            case RDLogLine::TrafficLink:
            case RDLogLine::UnknownType:
                return;

            default:
                break;
            }
        }
        break;

    case RDAirPlayConf::MoveFrom:
        switch(status) {
        case RDLogLine::Finished:
        case RDLogLine::Playing:
        case RDLogLine::Paused:
        case RDLogLine::Finishing:
            return;

        default:
            line=list_log_list->currentItem()->text(15).toInt();
            break;
        }
        break;

    case RDAirPlayConf::DeleteFrom:
        switch(status) {
        case RDLogLine::Finished:
        case RDLogLine::Playing:
        case RDLogLine::Finishing:
            return;

        default:
            line=list_log_list->currentItem()->text(15).toInt();
            // Don't try delete "end of log" or other invalid log entries.
            if (line<0) {
                return;
            }
            break;
        }
        break;

    default:
        break;
    }
    emit selectClicked(list_id,line,status);
}
BatchExportDialog::BatchExportDialog(Context *context) : QDialog(context->mainWindow), context(context)
{
    setAttribute(Qt::WA_DeleteOnClose);
    //setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); // must stop using this flag!
    setWindowTitle(tr("Ride Batch Export"));

    // make the dialog a resonable size
    setMinimumWidth(550);
    setMinimumHeight(400);

    QVBoxLayout *layout = new QVBoxLayout;
    setLayout(layout);

    files = new QTreeWidget;
    files->headerItem()->setText(0, tr(""));
    files->headerItem()->setText(1, tr("Filename"));
    files->headerItem()->setText(2, tr("Date"));
    files->headerItem()->setText(3, tr("Time"));
    files->headerItem()->setText(4, tr("Action"));

    files->setColumnCount(5);
    files->setColumnWidth(0, 30); // selector
    files->setColumnWidth(1, 190); // filename
    files->setColumnWidth(2, 95); // date
    files->setColumnWidth(3, 90); // time
    files->setSelectionMode(QAbstractItemView::SingleSelection);
    files->setEditTriggers(QAbstractItemView::SelectedClicked); // allow edit
    files->setUniformRowHeights(true);
    files->setIndentation(0);

    // populate with each ride in the ridelist
    const QTreeWidgetItem *allRides = context->athlete->allRideItems();

    for (int i=0; i<allRides->childCount(); i++) {

        RideItem *rideItem = static_cast<RideItem*>(allRides->child(i));

        QTreeWidgetItem *add = new QTreeWidgetItem(files->invisibleRootItem());
        add->setFlags(add->flags() | Qt::ItemIsEditable);

        // selector
        QCheckBox *checkBox = new QCheckBox("", this);
        checkBox->setChecked(true);
        files->setItemWidget(add, 0, checkBox);

        // we will wipe the original file
        add->setText(1, rideItem->fileName);
        add->setText(2, rideItem->dateTime.toString(tr("dd MMM yyyy")));
        add->setText(3, rideItem->dateTime.toString("hh:mm:ss"));

        // interval action
        add->setText(4, tr("Export"));
    }

    // format and directory
    QGridLayout *grid = new QGridLayout;
    formatLabel = new QLabel(tr("Export as"), this);
    format = new QComboBox(this);

    const RideFileFactory &rff = RideFileFactory::instance();
    foreach(QString suffix, rff.writeSuffixes()) format->addItem(rff.description(suffix));
    format->setCurrentIndex(appsettings->value(this, GC_BE_LASTFMT, "0").toInt());

    selectDir = new QPushButton(tr("Browse"), this);
    dirLabel = new QLabel (tr("Export to"), this);

    // default to last used
    QString dirDefault = appsettings->value(this, GC_BE_LASTDIR, QDir::home().absolutePath()).toString();
    if (!QDir(dirDefault).exists()) dirDefault = QDir::home().absolutePath();

    dirName = new QLabel(dirDefault, this);
    all = new QCheckBox(tr("check/uncheck all"), this);
    all->setChecked(true);

    grid->addWidget(formatLabel, 0,0, Qt::AlignLeft);
    grid->addWidget(format, 0,1, Qt::AlignLeft);
    grid->addWidget(dirLabel, 1,0, Qt::AlignLeft);
    grid->addWidget(dirName, 1,1, Qt::AlignLeft);
    grid->addWidget(selectDir, 1,2, Qt::AlignLeft);
    grid->addWidget(all, 2,0, Qt::AlignLeft);
    grid->setColumnStretch(0, 1);
    grid->setColumnStretch(1, 10);

    // buttons
    QHBoxLayout *buttons = new QHBoxLayout;
    status = new QLabel("", this);
    status->hide();
    overwrite = new QCheckBox(tr("Overwrite existing files"), this);
    cancel = new QPushButton(tr("Cancel"), this);
    ok = new QPushButton(tr("Export"), this);
    buttons->addWidget(overwrite);
    buttons->addWidget(status);
    buttons->addStretch();
    buttons->addWidget(cancel);
    buttons->addWidget(ok);

    layout->addLayout(grid);
    layout->addWidget(files);
    layout->addLayout(buttons);

    exports = fails = 0;

    // connect signals and slots up..
    connect(selectDir, SIGNAL(clicked()), this, SLOT(selectClicked()));
    connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
    connect(all, SIGNAL(stateChanged(int)), this, SLOT(allClicked()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
}