Blame toonz/sources/toonzqt/styleindexlineedit.cpp
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/styleindexlineedit.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StyleIndexLineEdit::StyleIndexLineEdit()
|
|
Toshihiro Shimizu |
890ddd |
: m_pltHandle(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StyleIndexLineEdit::~StyleIndexLineEdit()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void StyleIndexLineEdit::paintEvent(QPaintEvent *pe)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLineEdit::paintEvent(pe);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle *style;
|
|
Toshihiro Shimizu |
890ddd |
if (QString("current").contains(text()))
|
|
Toshihiro Shimizu |
890ddd |
style = m_pltHandle->getStyle();
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
int index = text().toInt();
|
|
Toshihiro Shimizu |
890ddd |
style = m_pltHandle->getPalette()->getStyle(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (style) {
|
|
Toshihiro Shimizu |
890ddd |
QPainter p(this);
|
|
Toshihiro Shimizu |
890ddd |
int w = width();
|
|
Toshihiro Shimizu |
890ddd |
QRect chipRect(w - 18, 4, 14, 14);
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P icon = style->getIcon(qsize2Dimension(chipRect.size()));
|
|
Toshihiro Shimizu |
890ddd |
p.drawPixmap(chipRect.left(), chipRect.top(), rasterToQPixmap(icon));
|
|
Toshihiro Shimizu |
890ddd |
p.setPen(Qt::black);
|
|
Toshihiro Shimizu |
890ddd |
p.drawRect(chipRect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|