Exemplo n.º 1
0
void GenericCodeEditor::zoomOut(int steps)
{
    zoomFont(-steps);
}
Exemplo n.º 2
0
void GenericCodeEditor::zoomIn(int steps)
{
    zoomFont(steps);
}
Exemplo n.º 3
0
void PostWindow::zoomIn(int steps)
{
    zoomFont(steps);
}
Exemplo n.º 4
0
void PostWindow::zoomOut(int steps)
{
    zoomFont(-steps);
}
void RepoItemDelegate::paintRepoItem(QPainter *painter,
                                     const QStyleOptionViewItem& option,
                                     const RepoItem *item) const
{
    const ServerRepo& repo = item->repo();
    QBrush backBrush;
    QColor foreColor;
    bool hover = false;
    bool selected = false;
    if (option.state & (QStyle::State_HasFocus | QStyle::State_Selected)) {
        backBrush = option.palette.brush(QPalette::Highlight);
        foreColor = option.palette.color(QPalette::HighlightedText);
        selected = true;

    } else if (option.state & QStyle::State_MouseOver) {
        // backBrush = option.palette.color( QPalette::Highlight ).lighter(115);
        // foreColor = option.palette.color( QPalette::HighlightedText );
        // hover = true;

    } else {
        backBrush = option.palette.brush( QPalette::Base );
        foreColor = option.palette.color( QPalette::Text );
    }

    QStyle *style = QApplication::style();
    QStyleOptionViewItemV4 opt(option);
    if (hover)
    {
        Qt::BrushStyle bs = opt.backgroundBrush.style();
        if (bs > Qt::NoBrush && bs < Qt::TexturePattern)
            opt.backgroundBrush = opt.backgroundBrush.color().lighter(115);
        else
            opt.backgroundBrush = backBrush;
    }
    painter->save();
    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, 0);
    painter->restore();

    // Paint repo icon
    QPoint repo_icon_pos(kMarginLeft + kPadding, kMarginTop + kPadding);
    repo_icon_pos += option.rect.topLeft();
    painter->save();
    painter->drawPixmap(repo_icon_pos,
                        repo.getPixmap().scaled(kRepoIconWidth, kRepoIconHeight));
    painter->restore();

    // Paint repo name
    painter->save();
    QPoint repo_name_pos = repo_icon_pos + QPoint(kRepoIconWidth + kMarginBetweenRepoIconAndName, 0);
    QRect repo_name_rect(repo_name_pos, QSize(kRepoNameWidth, kRepoNameHeight));
    painter->setPen(foreColor);
    painter->drawText(repo_name_rect,
                      Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
                      fitTextToWidth(repo.name, option.font, kRepoNameWidth),
                      &repo_name_rect);

    // Paint repo description
    QPoint repo_desc_pos = repo_name_rect.bottomLeft() + QPoint(0, 5);
    QRect repo_desc_rect(repo_desc_pos, QSize(kRepoNameWidth, kRepoNameHeight));
    painter->setPen(selected ? foreColor.darker(115) : foreColor.lighter(150));
    painter->setFont(zoomFont(painter->font(), 0.8));
    painter->drawText(repo_desc_rect,
                      Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
                      fitTextToWidth(translateCommitTime(repo.mtime), option.font, kRepoNameWidth),
                      &repo_desc_rect);
    painter->restore();

    // Paint repo status icon
    QPoint status_icon_pos = option.rect.topRight() - QPoint(80, 0);
    QRect status_icon_rect(status_icon_pos, option.rect.bottomRight());
    if (!item->localRepo().isValid()
        || item->localRepo().sync_state != LocalRepo::SYNC_STATE_WAITING) {

        painter->save();
        painter->setFont(awesome->font(kRepoStatusIconHeight));
        if (selected)
            painter->setPen(QColor("white"));
        else
            painter->setPen(QColor("#f17f49"));
        painter->drawText(status_icon_rect,
                          Qt::AlignCenter,
                          getSyncStatusIcon(item), &status_icon_rect);
        painter->restore();
    }

    // Update the metrics of this item
    RepoItem::Metrics metrics;
    QPoint shift(-option.rect.topLeft().x(), -option.rect.topLeft().y());
    metrics.icon_rect = QRect(repo_icon_pos, QSize(kRepoIconWidth, kRepoIconHeight));
    metrics.name_rect = repo_name_rect;
    metrics.subtitle_rect = repo_desc_rect;
    metrics.status_icon_rect = status_icon_rect;

    metrics.icon_rect.translate(shift);
    metrics.name_rect.translate(shift);
    metrics.subtitle_rect.translate(shift);
    metrics.status_icon_rect.translate(shift);

    item->setMetrics(metrics);
}