Ejemplo n.º 1
0
QString LinkLook::toCSS(const QString &cssClass, const QColor &defaultTextColor) const
{
	// Set the link class:
	QString css = QString("   .%1 a { display: block; width: 100%;").arg(cssClass);
	if (underlineOutside())
		css += " text-decoration: underline;";
	else
		css += " text-decoration: none;";
	if (m_italic == true)
		css += " font-style: italic;";
	if (m_bold == true)
		css += " font-weight: bold;";
	QColor textColor = (color().isValid() || m_useLinkColor ? effectiveColor() : defaultTextColor);
	css += QString(" color: %1; }\n").arg(textColor.name());

	// Set the hover state class:
	QString hover;
	if (m_underlining == OnMouseHover)
		hover = "text-decoration: underline;";
	else if (m_underlining == OnMouseOutside)
		hover = "text-decoration: none;";
	if (effectiveHoverColor() != effectiveColor()) {
		if (!hover.isEmpty())
			hover += " ";
		hover += QString("color: %4;").arg(effectiveHoverColor().name());
	}

	// But include it only if it contain a different style than non-hover state:
	if (!hover.isEmpty())
		css += QString("   .%1 a:hover { %2 }\n").arg(cssClass, hover);

	return css;
}
Ejemplo n.º 2
0
void KColorCombo2::mouseMoveEvent(QMouseEvent *event)
{
	if( (event->state() & Qt::LeftButton) &&
	    (event->pos() - m_dragStartPos).manhattanLength() > KGlobalSettings::dndEventDelay() ) {
		// Drag color object:
		K3ColorDrag *colorDrag = new K3ColorDrag(effectiveColor(), this);
		// Replace the drag pixmap with our own rounded one, at the same position and dimetions:
		QPixmap pixmap = colorDrag->pixmap();
		pixmap = colorRectPixmap(effectiveColor(), /*isDefault=*/false, pixmap.width(), pixmap.height());
		colorDrag->setPixmap(pixmap, colorDrag->pixmapHotSpot());
		colorDrag->dragCopy();
		//setDown(false);
	}
}
Ejemplo n.º 3
0
void KColorCombo2::keyPressEvent(QKeyEvent *event)
{
	KKey key(event);

	if (KStandardShortcut::copy().contains(key)) {
		QMimeSource *mime = new K3ColorDrag(effectiveColor());
		QApplication::clipboard()->setData(mime, QClipboard::Clipboard);
	} else if (KStandardShortcut::paste().contains(key)) {
		QColor color;
		K3ColorDrag::decode(QApplication::clipboard()->data(QClipboard::Clipboard), color);
		setColor(color);
	} else
		QComboBox::keyPressEvent(event);
}
Ejemplo n.º 4
0
void KColorCombo2::updateComboBox()
{
	int height = colorRectHeight()*2/3; // fontMetrics().boundingRect(i18n("(Default)")).height() + 2
	QPixmap pixmap = colorRectPixmap(effectiveColor(), !m_color.isValid(), colorRectWidthForHeight(height), height); // TODO: isDefaultColorSelected()
	changeItem(pixmap, (m_color.isValid() ? "" : i18n("(Default)")), /*index=*/0);
}