Ejemplo n.º 1
2
QPixmap QzTools::createPixmapForSite(const QIcon &icon, const QString &title, const QString &url)
{
    const QFontMetrics fontMetrics = QApplication::fontMetrics();
    const int padding = 4;
    const int maxWidth = fontMetrics.width(title.length() > url.length() ? title : url) + 3 * padding + 16;

    const int width = qMin(maxWidth, 150);
    const int height = fontMetrics.height() * 2 + fontMetrics.leading() + 2 * padding;

    QPixmap pixmap(width, height);
    QPainter painter(&pixmap);

    // Draw background
    QPen pen(Qt::black);
    pen.setWidth(1);
    painter.setPen(pen);

    painter.fillRect(QRect(0, 0, width, height), Qt::white);
    painter.drawRect(0, 0, width - 1, height - 1);

    // Draw icon
    QRect iconRect(0, 0, 16 + 2 * padding, height);
    icon.paint(&painter, iconRect);

    // Draw title
    QRect titleRect(iconRect.width(), padding, width - padding - iconRect.width(), fontMetrics.height());
    painter.drawText(titleRect, fontMetrics.elidedText(title, Qt::ElideRight, titleRect.width()));

    // Draw url
    QRect urlRect(titleRect.x(), titleRect.bottom() + fontMetrics.leading(), titleRect.width(), titleRect.height());
    painter.setPen(QApplication::palette().color(QPalette::Link));
    painter.drawText(urlRect, fontMetrics.elidedText(url, Qt::ElideRight, urlRect.width()));

    return pixmap;
}
Ejemplo n.º 2
1
void Tab::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(backgroundColor());
    painter.setOpacity(1);
    painter.setBrush(brush);
    painter.setPen(Qt::NoPen);
    painter.drawRect(rect());

    paintHalo(&painter);

    QStylePainter style(this);

    if (!icon().isNull()) {
        style.translate(0, 12);
    }

    QStyleOptionButton option;
    initStyleOption(&option);
    option.features |= QStyleOptionButton::Flat;
    option.iconSize = QSize(-1, -1);  // Prevent icon from being drawn twice

    style.drawControl(QStyle::CE_PushButtonLabel, option);

    if (!icon().isNull()) {
        const QSize &size = iconSize();
        QRect iconRect(QPoint((width()-size.width())/2, 0), size);
        icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal);
    }

    if (!_active) {
        QColor overlayColor = backgroundColor();
        overlayColor.setAlphaF(0.36);

        QBrush overlay;
        overlay.setStyle(Qt::SolidPattern);
        overlay.setColor(overlayColor);
        painter.fillRect(rect(), overlay);
    }

#ifdef DEBUG_LAYOUT
    QPainter debug(this);
    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(2);
    debug.setPen(pen);
    debug.setBrush(Qt::NoBrush);
    debug.drawRect(rect());
#endif
}
Ejemplo n.º 3
0
void StatusView::setMessage(
	BString &title,
	BString &details,
	status_t error) {
	D_OPERATION(("StatusView::setMessage(%s)\n", title.String()));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);

	// append error string
	if (error) {
		title << " (" << strerror(error) << ")";
	}

	// truncate if necessary
	bool truncated = false;
	m_fullText = title;
	if (be_plain_font->StringWidth(title.String()) > Bounds().Width() - 25.0) {
		be_plain_font->TruncateString(&title, B_TRUNCATE_END,
									  Bounds().Width() - 25.0);
		truncated = true;
	}
	BStringView::SetText(title.String());

	if (truncated || details.CountChars() > 0) {
		BString tip = m_fullText;
		if (details.CountChars() > 0) {
			tip << "\n" << details;
		}
		manager->setTip(tip.String(), this);
	}

	if (error) {
		beep();
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8);
	}
	else {
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8);
	}
	m_dirty = true;
	startFade();
	Invalidate();
}
Ejemplo n.º 4
0
void MyNetHeaderView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("My Network Browser");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("This utility allows you to connect to remote computers and access");
	MovePenTo(55, 40);
	DrawString("resources, such as files and printers, that others have chosen to share.");

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Ejemplo n.º 5
0
void TabBarButton::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QPainter p(this);

    QStyleOptionTabBarBaseV2 option;
    initStyleOption(this, option);

    style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &option, &p, this);

    int w = iconSize().width();
    int h = iconSize().height();
    QIcon::Mode mode;
    if ( (option.state & QStyle::State_Enabled) || (option.state & QStyle::State_Active) ) {
        if (option.state & QStyle::State_Sunken)
            mode = QIcon::Selected;
        else if (option.state & QStyle::State_MouseOver)
            mode = QIcon::Active;
        else
            mode = QIcon::Normal;
    } else {
        mode = QIcon::Disabled;
    }

    QRect iconRect((width() - w)/2, (height() - h)/2, w, h);
    icon().paint(&p, iconRect, Qt::AlignCenter, mode);
}
Ejemplo n.º 6
0
void ConsoleHeaderView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("BeServed Domain Management Console");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("Version 1.2.6");
	MovePenTo(55, 40);
	DrawString("");

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Ejemplo n.º 7
0
QRect YaTabBarBase::tabIconRect(int index) const
{
	QRect iconRect(tabRect(index));
	iconRect.setLeft(iconRect.left() + margin());
	iconRect.setWidth(cachedIconSize_.width());
	return iconRect;
}
Ejemplo n.º 8
0
		void Draw(BRect rect)
		{
			BRect r = Bounds();
			BRect iconRect(13.0, 5.0, 45.0, 37.0);
			rgb_color black = { 0, 0, 0, 255 };
			rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

			SetViewColor(gray);
			SetLowColor(gray);
			FillRect(r, B_SOLID_LOW);

			SetHighColor(black);
			SetFont(be_bold_font);
			SetFontSize(11);
			MovePenTo(55, 15);
			DrawString("Connect to Internet Host");

			SetFont(be_plain_font);
			SetFontSize(10);
			MovePenTo(55, 28);
			DrawString("Specify the name or address of a computer located");
			MovePenTo(55, 40);
			DrawString("outside your network, such as on the Internet.");

			SetDrawingMode(B_OP_ALPHA); 
			SetHighColor(0, 0, 0, 180);       
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
			DrawBitmap(icon, iconRect);
		}
Ejemplo n.º 9
0
void GroupPropertiesView::Draw(BRect rect)
{
    BRect r = Bounds();
    BRect iconRect(13.0, 5.0, 45.0, 37.0);
    rgb_color black = { 0, 0, 0, 255 };
    rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

    SetViewColor(gray);
    SetLowColor(gray);
    FillRect(r, B_SOLID_LOW);

    SetHighColor(black);
    SetFont(be_bold_font);
    SetFontSize(11);
    MovePenTo(55, 15);
    BString string(group);
    string += " Properties";
    DrawString(string.String());

    SetFont(be_plain_font);
    SetFontSize(10);
    MovePenTo(55, 28);
    DrawString("Groups are collections of users that will share certain properties,");
    MovePenTo(55, 40);
    DrawString("such as access to files or network resources.");

    MovePenTo(13, 121);
    DrawString("Current Members:");

    SetDrawingMode(B_OP_ALPHA);
    SetHighColor(0, 0, 0, 180);
    SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
    DrawBitmap(icon, iconRect);
}
Ejemplo n.º 10
0
void ListItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItemV4 opt = option;
    initStyleOption(&opt, index);

    const QWidget* w = opt.widget;
    const QStyle* style = w ? w->style() : QApplication::style();
    const Qt::LayoutDirection direction = w ? w->layoutDirection() : QApplication::layoutDirection();

#ifdef Q_OS_WIN
    const QPalette::ColorRole colorRole = QPalette::Text;
#else
    const QPalette::ColorRole colorRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text;
#endif

    int topPosition = opt.rect.top() + m_padding;

    // Draw background
    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w);

    // Draw icon
    QRect iconRect(opt.rect.left() + (opt.rect.width() - m_iconSize) / 2, topPosition, m_iconSize, m_iconSize);
    QRect visualIconRect = style->visualRect(direction, opt.rect, iconRect);
    QPixmap pixmap = index.data(Qt::DecorationRole).value<QIcon>().pixmap(m_iconSize);
    painter->drawPixmap(visualIconRect, pixmap);
    topPosition += m_iconSize + m_padding;

    // Draw title
    const QString title = index.data(Qt::DisplayRole).toString();
    const int leftTitleEdge = opt.rect.left() + m_padding;
    QRect titleRect(leftTitleEdge, topPosition, opt.rect.width() - 2 * m_padding, opt.fontMetrics.height());
    QRect visualTitleRect = style->visualRect(direction, opt.rect, titleRect);
    style->drawItemText(painter, visualTitleRect, Qt::AlignCenter, opt.palette, true, title, colorRole);
}
Ejemplo n.º 11
0
void LoginView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("Login Required");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("The resource you've specified requires");
	MovePenTo(55, 40);
	DrawString("permission to access it.");

	MovePenTo(13, 61);
	DrawString("Resource:");
	MovePenTo(70, 61);
	DrawString(resource);

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Ejemplo n.º 12
0
void OpenDocumentsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if (option.state & QStyle::State_MouseOver) {
        if ((QApplication::mouseButtons() & Qt::LeftButton) == 0)
            pressedIndex = QModelIndex();
        QBrush brush = option.palette.alternateBase();
        if (index == pressedIndex)
            brush = option.palette.dark();
        painter->fillRect(option.rect, brush);
    }


    QStyledItemDelegate::paint(painter, option, index);

    if (closeButtonVisible && index.column() == 1 && option.state & QStyle::State_MouseOver) {
        const QIcon icon(QLatin1String((option.state & QStyle::State_Selected) ?
                                       ":/icons/delete" : ":/icons/delete"));

        QRect iconRect(option.rect.right() - option.rect.height(),
                       option.rect.top(),
                       option.rect.height(),
                       option.rect.height());

        icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter);
    }

}
Ejemplo n.º 13
0
// -----------------------------------------------------------------------------
// CMenuAppUi::SetupImageCommanderL()
// Setup the animation image commander.
// -----------------------------------------------------------------------------
//
void CPaintCursorAppView::SetupImageCommanderL()
    {
    TRACE_INFO(_L("[HID]\tCHidMouseDriver::SetupImageCommanderL()"));
    // Tell client to construct a server side object
    TSize iconRect(13,23);
    iClientCommander.ImageConstructL( CCoeEnv::Static()->RootWin(),
                                      iconRect );
    }
Ejemplo n.º 14
0
void StatusView::setErrorMessage(
	BString text,
	bool error) {
	D_OPERATION(("StatusView::setErrorMessage(%s)\n",
				 text.String()));

	// get the tip manager instance and reset
	TipManager *manager = TipManager::Instance();
	manager->removeAll(this);

	// truncate if necessary
	m_fullText = text;
	if (be_plain_font->StringWidth(text.String()) > Bounds().Width() - 25.0) {
		be_plain_font->TruncateString(&text, B_TRUNCATE_END,
									  Bounds().Width() - 25.0);
		manager->setTip(m_fullText.String(), this);
	}
	BStringView::SetText(text.String());

	if (error) {
		beep();
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8);
	}
	else {
		// set icon
		if (m_icon) {
			delete m_icon;
			m_icon = 0;
		}
		BRect iconRect(0.0, 0.0, 7.0, 11.0);
		m_icon = new BBitmap(iconRect, B_CMAP8);
		m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8);
	}
	m_dirty = true;
	startFade();
	Invalidate();
}
Ejemplo n.º 15
0
bool RenderThemeGtk::paintMediaButton(const RenderObject& renderObject, GraphicsContext* context, const IntRect& rect, const char* symbolicIconName, const char* fallbackStockIconName)
{
    IntRect iconRect(rect.x() + (rect.width() - m_mediaIconSize) / 2,
                     rect.y() + (rect.height() - m_mediaIconSize) / 2,
                     m_mediaIconSize, m_mediaIconSize);
    GRefPtr<GdkPixbuf> icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, symbolicIconName, fallbackStockIconName,
        gtkTextDirection(renderObject.style().direction()), gtkIconState(this, renderObject), iconRect.width());
    paintGdkPixbuf(context, icon.get(), iconRect);
    return true;
}
Ejemplo n.º 16
0
void
Style::drawComboBoxLabel(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
    ASSURE_OPTION(cb, ComboBox);
    OPT_ENABLED

    QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
    painter->save();
    painter->setClipRect(editRect);

    if (!(cb->currentIcon.isNull() || cb->iconSize.isNull()))
    {   // icon ===============================================
        QIcon::Mode mode = isEnabled ? QIcon::Normal : QIcon::Disabled;
        QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
        QRect iconRect(editRect);
        iconRect.setWidth(cb->iconSize.width() + 4);
        iconRect = alignedRect( cb->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect);
//       if (cb->editable)
//          painter->fillRect(iconRect, opt->palette.brush(QPalette::Base));
        drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);

        if (cb->direction == Qt::LeftToRight)
            editRect.setLeft(editRect.left() + cb->iconSize.width() + 4);
        else
            editRect.setRight(editRect.right() - (cb->iconSize.width() + 4));
    }

    if (!cb->currentText.isEmpty() && !cb->editable)
    {   // text ==================================================
        if (cb->frame)
        {
            OPT_FOCUS
            if (animStep < 0)
            {
                OPT_HOVER
                animStep = hover ? 6 : 0;
            }
            else
            {
                if (const QComboBox* combo = qobject_cast<const QComboBox*>(widget))
                if (combo->view() && ((QWidget*)(combo->view()))->isVisible())
                    animStep = 6;
            }
            editRect.adjust(F(3),0, -F(3), -F(1)*(config.chooser.layer != Sunken));
            // trick btnFg
            const int btn_layer = config.btn.layer;
            config.btn.layer = config.chooser.layer;
            painter->setPen(btnFg(PAL, isEnabled, hasFocus, animStep));
            config.btn.layer = btn_layer;
        }
        int tf = Qt::AlignCenter;
        if ( !((cb->subControls & SC_ComboBoxFrame) && cb->frame) )
            tf = Qt::AlignVCenter | (cb->direction == Qt::LeftToRight ? Qt::AlignLeft : Qt::AlignRight);
        drawItemText(painter, editRect, tf, PAL, isEnabled, cb->currentText);
    }
Ejemplo n.º 17
0
bool KItemListWidget::contains(const QPointF& point) const
{
    if (!QGraphicsWidget::contains(point)) {
        return false;
    }

    return iconRect().contains(point) ||
           textRect().contains(point) ||
           expansionToggleRect().contains(point) ||
           selectionToggleRect().contains(point);
}
Ejemplo n.º 18
0
bool RenderThemeGtk::paintMediaToggleClosedCaptionsButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
{
    IntRect iconRect(rect.x() + (rect.width() - m_mediaIconSize) / 2, rect.y() + (rect.height() - m_mediaIconSize) / 2,
        m_mediaIconSize, m_mediaIconSize);
    GRefPtr<GdkPixbuf> icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, "media-view-subtitles-symbolic", nullptr,
        gtkTextDirection(renderObject.style().direction()), gtkIconState(this, renderObject), iconRect.width());
    if (!icon)
        icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, "user-invisible-symbolic", GTK_STOCK_JUSTIFY_FILL,
            gtkTextDirection(renderObject.style().direction()), gtkIconState(this, renderObject), iconRect.width());
    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
    return true;
}
Ejemplo n.º 19
0
//copied from fancytoolbutton and removed unused things
void UpdateInfoButton::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)
    QPainter painter(this);

    QRect iconRect(0, 0, Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE);


    iconRect.moveCenter(rect().center());
    Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled);

}
Ejemplo n.º 20
0
bool
RoomContainer::LoadWorldMap()
{
	if (fWorldMap != NULL)
		return true;

	_Unload();

	GUI* gui = GUI::Get();

	gui->Clear();
	
	if (!gui->Load("GUIWMAP")) {
		return false;
	}

	gui->ShowWindow(0);
	Window* window = gui->GetWindow(0);
	if (window != NULL) {
		// TODO: Move this into GUI ?
		Control* control = window->GetControlByID(4);
		if (control != NULL)
			control->AssociateRoom(this);
	}

	fAreaOffset.x = fAreaOffset.y = 0;

	Core::Get()->EnteredArea(this, NULL);

	SetName("WORLDMAP");

	GraphicsEngine::Get()->SetWindowCaption(Name());

	fWorldMap = gResManager->GetWMAP(Name());

	worldmap_entry entry = fWorldMap->WorldMapEntry();
	fWorldMapBackground = gResManager->GetMOS(entry.background_mos);
	fWorldMapBitmap = fWorldMapBackground->Image();
	for (uint32 i = 0; i < fWorldMap->CountAreaEntries(); i++) {
		AreaEntry& areaEntry = fWorldMap->AreaEntryAt(i);
		const Bitmap* iconFrame = areaEntry.Icon();
		IE::point position = areaEntry.Position();
		GFX::rect iconRect(int16(position.x - iconFrame->Frame().w / 2),
					int16(position.y - iconFrame->Frame().h / 2),
					iconFrame->Frame().w, iconFrame->Frame().h);

		GraphicsEngine::Get()->BlitBitmap(iconFrame, NULL,
				fWorldMapBitmap, &iconRect);

	}
	return true;
}
Ejemplo n.º 21
0
PatchView::PatchView(BRect rect)
	:
	BView(rect, "PatchView", B_FOLLOW_ALL, B_WILL_DRAW),
	fUnknownDeviceIcon(NULL)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BRect iconRect(0, 0, LARGE_ICON_SIZE - 1, LARGE_ICON_SIZE - 1);
	fUnknownDeviceIcon = new BBitmap(iconRect, B_RGBA32);
	if (BIconUtils::GetVectorIcon(
			UnknownDevice::kVectorIcon,
			sizeof(UnknownDevice::kVectorIcon),
			fUnknownDeviceIcon)	== B_OK)
		return;
	delete fUnknownDeviceIcon;
}
Ejemplo n.º 22
0
void BusyWidget::paint(QPainter* painter,
                       const QStyleOptionGraphicsItem* option,
                       QWidget* widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    QRectF iconRect(0,
                    0,
                    qMin(size().width(), size().height()),
                    qMin(size().width(), size().height()));

    iconRect.moveCenter(boundingRect().center());

    m_svg->paint(painter, iconRect, "notification-active");
}
void DolphinFileItemDelegate::paint(QPainter* painter,
                                    const QStyleOptionViewItem& option,
                                    const QModelIndex& index) const
{
    const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(index.model());
    const DolphinModel* dolphinModel = static_cast<const DolphinModel*>(proxyModel->sourceModel());
    const bool isNameColumn = (index.column() == KDirModel::Name);

    QStyleOptionViewItemV4 opt(option);
    if (m_hasMinimizedNameColumn && isNameColumn) {
        adjustOptionWidth(opt, proxyModel, dolphinModel, index);
    }

    if (!isNameColumn) {
        // Use the inactive text color for all columns except the name column. This indicates for the user that
        // hovering other columns does not change the actions context.
        QPalette palette = opt.palette;
        if (m_cachedInactiveTextColorDirty) {
            m_cachedInactiveTextColor = KColorScheme(QPalette::Active).foreground(KColorScheme::InactiveText).color();
            m_cachedInactiveTextColorDirty = false;
        }
        palette.setColor(QPalette::Text, m_cachedInactiveTextColor);
        opt.palette = palette;
    }

    if (dolphinModel->hasVersionData() && isNameColumn) {
        // The currently shown items are under revision control. Show the current revision
        // state by adding an emblem and changing the text tintColor.
        const QModelIndex dirIndex = proxyModel->mapToSource(index);
        const QModelIndex revisionIndex = dolphinModel->index(dirIndex.row(), DolphinModel::Version, dirIndex.parent());
        const QVariant data = dolphinModel->data(revisionIndex, Qt::DecorationRole);
        const KVersionControlPlugin::VersionState state = static_cast<KVersionControlPlugin::VersionState>(data.toInt());

        adjustOptionTextColor(opt, state);

        KFileItemDelegate::paint(painter, opt, index);

        if (state != KVersionControlPlugin::UnversionedVersion) {
            const QRect rect = iconRect(option, index);
            const QPixmap emblem = emblemForState(state, rect.size());
            painter->drawPixmap(rect.x(), rect.y() + rect.height() - emblem.height(), emblem);
        }
    } else {
        KFileItemDelegate::paint(painter, opt, index);
    }
}
Ejemplo n.º 24
0
inline static QImage renderedLessonIcon(const QString &iconId, int buttonVariation, QSize *size, const QSize &requestedSize)
{
    QImage result(requestedSize, QImage::Format_ARGB32);
    result.fill(Qt::transparent);
    QPainter p(&result);
    QSvgRenderer *renderer = lessonIconsRenderer();
    const QRectF iconRectOriginal = renderer->boundsOnElement(idPrefix + iconId);
    QSizeF iconSize = iconRectOriginal.size();
    iconSize.scale(requestedSize, Qt::KeepAspectRatio);
    QRectF iconRect(QPointF(), iconSize);
    if (requestedSize.height() > requestedSize.width())
        iconRect.moveBottom(requestedSize.height());
    else
        iconRect.moveTop((requestedSize.height() - iconSize.height()) / 2);
    renderer->render(&p, idPrefix + iconId, iconRect);
    const QImage button = renderedDesignElement(DesignElementTypeButton, buttonVariation, size, requestedSize);
    p.drawImage(QPointF(), button);
    return result;
}
Ejemplo n.º 25
0
void FormViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                             const QModelIndex &index) const
{
    // Add the fancy button
    if (option.state & QStyle::State_MouseOver) {
        if ((QApplication::mouseButtons() & Qt::LeftButton) == 0)
            pressedIndex = QModelIndex();
        QBrush brush = option.palette.alternateBase();
        if (index == pressedIndex)
            brush = option.palette.dark();
        painter->fillRect(option.rect, brush);
    }

    QStyledItemDelegate::paint(painter, option, index);

    // Draw fancy button
    if (index.column()==FormTreeModel::EmptyColumn1 &&
            (option.state & QStyle::State_MouseOver)) {
        QIcon icon;
        if (option.state & QStyle::State_Selected) {
            // test the form to be unique or multiple episode
            if (_formTreeModel->isUniqueEpisode(index))
                return;
            if (_formTreeModel->isNoEpisode(index))
                return;
            icon = theme()->icon(Core::Constants::ICONADDLIGHT);
        } else {
            // test the form to be unique or multiple episode
            if (_formTreeModel->isUniqueEpisode(index))
                return;
            if (_formTreeModel->isNoEpisode(index))
                return;
            icon = theme()->icon(Core::Constants::ICONADDDARK);
        }

        QRect iconRect(option.rect.right() - option.rect.height(),
                       option.rect.top(),
                       option.rect.height(),
                       option.rect.height());

        icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter);
    }
}
Ejemplo n.º 26
0
void
TBarMenuTitle::DrawContent()
{
	if (fIcon == NULL)
		return;

	BMenu* menu = Menu();
	BRect frame(Frame());
	BRect iconRect(fIcon->Bounds());

	menu->SetDrawingMode(B_OP_ALPHA);
	iconRect.OffsetTo(frame.LeftTop());

	float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2);
	float heightOffset = rintf((frame.Height() - iconRect.Height()) / 2);
	iconRect.OffsetBy(widthOffset - 1.0f, heightOffset + 2.0f);

	menu->DrawBitmapAsync(fIcon, iconRect);
}
Ejemplo n.º 27
0
void PropertyRowField::redraw(IDrawContext& context)
{
	int buttonCount = this->buttonCount();
	int offset = 0;
	for (int i = 0; i < buttonCount; ++i) {
		Icon icon = buttonIcon(context.tree, i);
		Rect iconRect(context.widgetRect.right() - BUTTON_SIZE * buttonCount + offset, context.widgetRect.top(), BUTTON_SIZE, context.widgetRect.height());
		context.drawIcon(iconRect, icon, userReadOnly() ? ICON_DISABLED : ICON_NORMAL);
		offset += BUTTON_SIZE;
	}

	int iconSpace = offset ? offset + 2 : 0;
    if(multiValue())
		context.drawEntry(context.widgetRect, " ... ", false, userReadOnly(), iconSpace);
    else if(userReadOnly())
		context.drawValueText(pulledSelected(), valueAsString().c_str());
    else
        context.drawEntry(context.widgetRect, valueAsString().c_str(), usePathEllipsis(), false, iconSpace);

}
Ejemplo n.º 28
0
  void EngineItemDelegate::paint(QPainter *painter,
                                 const QStyleOptionViewItem &option,
                                 const QModelIndex &index) const
  {
    QStyledItemDelegate::paint(painter, option, index);

    if (index.isValid() && index.column() == 1) {
      bool hasSettings = (index.data(Qt::ToolTipRole).toString() == tr("Settings"));
      if (!hasSettings)
        return;
      QIcon icon(":/icons/configure.png");
      QRect iconRect(option.rect.right() - option.rect.height(),
                     option.rect.top(),
                     option.rect.height(),
                     option.rect.height());
      icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter,
                 hasSettings ? QIcon::Normal : QIcon::Disabled);
    }

  }
Ejemplo n.º 29
0
void
HTGTweetMenuItem::setLinkIconUrl(std::string& url)
{
	this->linkIconUrl = url;
	
	if(linkIconUrl.find(".ico") == std::string::npos) {
		/*Load generic icon*/
		BRect iconRect(0, 0, B_MINI_ICON-1, B_MINI_ICON-1);
		linkIcon = new BBitmap(iconRect, B_RGBA32);
		BMimeType mimeType("text/html");
		icon_for_type(mimeType,*linkIcon,B_MINI_ICON);
		
		if(Menu()->LockLooper()) {
			Menu()->Invalidate();
			Menu()->UnlockLooper();
		}
	}
	else if(!linkIconDownloadInProgress) {
		downloadLinkIcon();
	}
}
Ejemplo n.º 30
0
bool RenderThemeGtk::paintCapsLockIndicator(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
{
    // The other paint methods don't need to check whether painting is disabled because RenderTheme already checks it
    // before calling them, but paintCapsLockIndicator() is called by RenderTextControlSingleLine which doesn't check it.
    if (paintInfo.context->paintingDisabled())
        return true;

    int iconSize = std::min(rect.width(), rect.height());
    GRefPtr<GdkPixbuf> icon = getStockIconForWidgetType(GTK_TYPE_ENTRY, GTK_STOCK_CAPS_LOCK_WARNING, gtkTextDirection(renderObject.style().direction()), 0, getIconSizeForPixelSize(iconSize));

    // Only re-scale the icon when it's smaller than the minimum icon size.
    if (iconSize >= gtkIconSizeMenu)
        iconSize = gdk_pixbuf_get_height(icon.get());

    // GTK+ locates the icon right aligned in the entry. The given rectangle is already
    // centered vertically by RenderTextControlSingleLine.
    IntRect iconRect(rect.x() + rect.width() - iconSize,
                     rect.y() + (rect.height() - iconSize) / 2,
                     iconSize, iconSize);
    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
    return true;
}