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
Shinya Kitaoka 120a6e
StyleIndexLineEdit::StyleIndexLineEdit() : m_pltHandle(0) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
StyleIndexLineEdit::~StyleIndexLineEdit() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void StyleIndexLineEdit::paintEvent(QPaintEvent *pe) {
Shinya Kitaoka 120a6e
  QLineEdit::paintEvent(pe);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TColorStyle *style;
Shinya Kitaoka 120a6e
  if (QString("current").contains(text()))
Shinya Kitaoka 120a6e
    style = m_pltHandle->getStyle();
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    int index = text().toInt();
Shinya Kitaoka 120a6e
    style     = m_pltHandle->getPalette()->getStyle(index);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (style) {
Shinya Kitaoka 120a6e
    QPainter p(this);
Shinya Kitaoka 120a6e
    int w = width();
Shinya Kitaoka 120a6e
    QRect chipRect(w - 18, 4, 14, 14);
Shinya Kitaoka 120a6e
    TRaster32P icon = style->getIcon(qsize2Dimension(chipRect.size()));
Shinya Kitaoka 120a6e
    p.drawPixmap(chipRect.left(), chipRect.top(), rasterToQPixmap(icon));
Shinya Kitaoka 120a6e
    p.setPen(Qt::black);
Shinya Kitaoka 120a6e
    p.drawRect(chipRect);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}