Example #1
0
ShortcutDialog::ShortcutDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::ShortcutDialog)
    , m_shortcut()
    , m_metaPressed(false)
    , m_expectModifier(false)
{
    ui->setupUi(this);

    QPushButton *resetButton = ui->buttonBox->button(QDialogButtonBox::Reset);
    Q_ASSERT(resetButton);
    resetButton->setText(tr("Remove Shortcut"));
    connect(resetButton, SIGNAL(clicked()), SLOT(onResetButtonClicked()));

    ui->lineEditShortcut->installEventFilter(this);
}
Example #2
0
int DriverColorsDialog::exec()
{
    SeasonData &sd = SeasonData::getInstance();
    colors = ColorsManager::getInstance().getDriverColors();
    int i = 0;
    for (; i < sd.getTeams().size(); ++i)
    {
        QList<LTDriver> drivers = sd.getMainDrivers(sd.getTeams()[i]);
        if (drivers.size() != 2)
            continue;

        if ((ui->verticalLayout->count()-2) <= i)
        {
            QHBoxLayout *layout = new QHBoxLayout();
            QLabel *label = new QLabel(this);                        

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            label->updateGeometry();
            QToolButton *button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver1No)*/colors[i*2]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver1No));

//            layout = new QHBoxLayout(this);
            label = new QLabel(this);
            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            label->updateGeometry();
            button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver2No)*/colors[i*2+1]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver2No));

            ui->verticalLayout->insertLayout(ui->verticalLayout->count() - 2, layout);
        }
        else
        {
            QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
            QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
            QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[0].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
            button->setVisible(true);

            label = static_cast<QLabel*>(layout->itemAt(5)->widget());
            button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[1].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
            button->setVisible(true);
        }
    }
    for (; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
        QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
        button->setVisible(false);

        label = static_cast<QLabel*>(layout->itemAt(5)->widget());
        button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
        button->setVisible(false);
    }

    return QDialog::exec();
}