//! Set commit message in details
void ChangeSelectionDialog::setDetails(int exitCode)
{
    Theme *theme = creatorTheme();

    QPalette palette;
    if (exitCode == 0) {
        m_ui->detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput()));
        palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal));
        m_ui->changeNumberEdit->setPalette(palette);
        enableButtons(true);
    } else {
        m_ui->detailsText->setPlainText(tr("Error: Unknown reference"));
        palette.setColor(QPalette::Text, theme->color(Theme::TextColorError));
        m_ui->changeNumberEdit->setPalette(palette);
    }
}
void ChangeSelectionDialog::recalculateDetails()
{
    terminateProcess();
    enableButtons(false);

    const QString workingDir = workingDirectory();
    QPalette palette = m_ui->workingDirectoryEdit->palette();
    Theme *theme = creatorTheme();
    if (workingDir.isEmpty()) {
        m_ui->detailsText->setPlainText(tr("Error: Bad working directory."));
        palette.setColor(QPalette::Text, theme->color(Theme::TextColorError));
        m_ui->workingDirectoryEdit->setPalette(palette);
        return;
    } else {
        palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal));
        m_ui->workingDirectoryEdit->setPalette(palette);
    }

    const QString ref = change();
    if (ref.isEmpty()) {
        m_ui->detailsText->clear();
        return;
    }

    QStringList args;
    args << QLatin1String("show") << QLatin1String("--stat=80") << ref;

    m_process = new QProcess(this);
    m_process->setWorkingDirectory(workingDir);
    m_process->setProcessEnvironment(m_gitEnvironment);

    connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
            this, &ChangeSelectionDialog::setDetails);

    m_process->start(m_gitExecutable.toString(), args);
    m_process->closeWriteChannel();
    if (!m_process->waitForStarted())
        m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));
    else
        m_ui->detailsText->setPlainText(tr("Fetching commit data..."));
}
Beispiel #3
0
static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText)
{
    QPalette pal;
    Theme *theme = Utils::creatorTheme();
    if (isActive) {
        if (forText) {
            pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor));
            pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundPrimaryColor));
            pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_BackgroundColor));
        } else {
            pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor));
            pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundPrimaryColor));
        }
    } else {
        if (isCursorInside) {
            if (forText) {
                pal.setColor(QPalette::Background, theme->color(Theme::Welcome_HoverColor));
                pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_HoverColor));
                pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor));
            } else {
                pal.setColor(QPalette::Background, theme->color(Theme::Welcome_HoverColor));
                pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundSecondaryColor));
            }
        } else {
            if (forText) {
                pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor));
                pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_BackgroundColor));
                pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor));
            } else {
                pal.setColor(QPalette::Background, theme->color(Theme::Welcome_BackgroundColor));
                pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundSecondaryColor));
            }
        }
    }
    return pal;
}