mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: scale the kolourpicker applet button icons
has to be done manually Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
99528e7f11
commit
29d2e49d7d
2 changed files with 34 additions and 13 deletions
|
@ -92,6 +92,14 @@ static QColor pickColor(const QPoint &point)
|
|||
#endif
|
||||
}
|
||||
|
||||
static QString latexColor(const QColor& color)
|
||||
{
|
||||
qreal r = (qreal)color.red()/255;
|
||||
qreal g = (qreal)color.green()/255;
|
||||
qreal b = (qreal)color.blue()/255;
|
||||
return QString("\\definecolor{ColorName}{rgb}{%1,%2,%3}").arg(r,0,'f',2).arg(g,0,'f',2).arg(b,0,'f',2);
|
||||
}
|
||||
|
||||
class ColorButton : public Plasma::ToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -158,7 +166,6 @@ void ColorButton::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||
{
|
||||
Plasma::ToolButton::resizeEvent(event);
|
||||
updateColorPixmap();
|
||||
Plasma::ToolButton::nativeWidget()->setIconSize(m_colorpix.size());
|
||||
Plasma::ToolButton::setIcon(colorIcon());
|
||||
}
|
||||
|
||||
|
@ -318,6 +325,29 @@ void Kolourpicker::constraintsEvent(Plasma::Constraints constraints)
|
|||
l->setOrientation(Qt::Vertical);
|
||||
}
|
||||
}
|
||||
|
||||
if (constraints & Plasma::SizeConstraint) {
|
||||
QGraphicsLinearLayout *l = dynamic_cast<QGraphicsLinearLayout *>(layout());
|
||||
switch (l->orientation()) {
|
||||
case Qt::Horizontal: {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
break;
|
||||
}
|
||||
case Qt::Vertical: {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const QSizeF contentsrect = contentsRect().size();
|
||||
const qreal iconsizereal = qMin(contentsrect.width(), contentsrect.height());
|
||||
const QSizeF iconsizef = QSizeF(iconsizereal, iconsizereal);
|
||||
const QSize contentsiconsize = QSize(iconsizereal - s_margin, iconsizereal- s_margin);
|
||||
m_configAndHistory->setPreferredSize(iconsizef);
|
||||
m_configAndHistory->nativeWidget()->setIconSize(contentsiconsize);
|
||||
m_grabButton->setPreferredSize(iconsizef);
|
||||
m_grabButton->nativeWidget()->setIconSize(contentsiconsize);
|
||||
emit sizeHintChanged(Qt::PreferredSize);
|
||||
}
|
||||
}
|
||||
|
||||
bool Kolourpicker::eventFilter(QObject *watched, QEvent *event)
|
||||
|
@ -381,7 +411,7 @@ void Kolourpicker::colorActionTriggered(const QColor &color)
|
|||
} else if(m_color_format == "rrggbb") {
|
||||
text = color.name().mid(1);
|
||||
} else if(m_color_format == "Latex") {
|
||||
text = toLatex(color);
|
||||
text = latexColor(color);
|
||||
} else {
|
||||
text = QString("%1, %2, %3").arg(color.red()).arg(color.green()).arg(color.blue());
|
||||
}
|
||||
|
@ -390,15 +420,6 @@ void Kolourpicker::colorActionTriggered(const QColor &color)
|
|||
QApplication::clipboard()->setMimeData(mime, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
QString Kolourpicker::toLatex(const QColor& color)
|
||||
{
|
||||
qreal r = (qreal)color.red()/255;
|
||||
qreal g = (qreal)color.green()/255;
|
||||
qreal b = (qreal)color.blue()/255;
|
||||
|
||||
return QString("\\definecolor{ColorName}{rgb}{%1,%2,%3}").arg(r,0,'f',2).arg(g,0,'f',2).arg(b,0,'f',2);
|
||||
}
|
||||
|
||||
void Kolourpicker::colorActionTriggered(QAction *act)
|
||||
{
|
||||
if (!act) {
|
||||
|
@ -409,7 +430,7 @@ void Kolourpicker::colorActionTriggered(QAction *act)
|
|||
QString text = act->text().remove('&');
|
||||
|
||||
if(text == i18n("Latex Color")) {
|
||||
text = toLatex(color);
|
||||
text = latexColor(color);
|
||||
}
|
||||
|
||||
QMimeData *mime = new QMimeData();
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
|
||||
void addColor(const QColor &color, bool save = true);
|
||||
void saveData(KConfigGroup &cg);
|
||||
QString toLatex(const QColor& color);
|
||||
|
||||
Plasma::ToolButton *m_grabButton;
|
||||
ColorButton *m_configAndHistory;
|
||||
QMenu *m_configAndHistoryMenu;
|
||||
|
|
Loading…
Add table
Reference in a new issue