void RGBText_Test::verticalScroll() { RGBText text(m_doc); text.setText("QLC"); text.setAnimationStyle(RGBText::Vertical); QFontMetrics fm(text.font()); QCOMPARE(text.rgbMapStepCount(QSize()), fm.ascent() * 3); // Q, L, C // Since fonts and their rendering differs from installation to installation, // these tests are here only to check that nothing crashes. The end result is // more or less OS, platform, HW and SW dependent and testing individual pixels // would thus be rather pointless. for (int i = 0; i < fm.ascent() * 3; i++) { RGBMap map = text.rgbMap(QSize(10, 10), QRgb(0xFFFFFFFF), i); QCOMPARE(map.size(), 10); for (int y = 0; y < 10; y++) QCOMPARE(map[y].size(), 10); } // Invalid step RGBMap map = text.rgbMap(QSize(10, 10), QRgb(0xFFFFFFFF), fm.ascent() * 4); QCOMPARE(map.size(), 10); for (int i = 0; i < 10; i++) { QCOMPARE(map[i].size(), 10); for (int j = 0; j < 10; j++) { QCOMPARE(map[i][j], QRgb(0)); } } }
void ToolColor::loadSettings() { Settings::AppSettings appsett; QSettings &sett = appsett.get(); sett.beginGroup("window-image-editor"); sett.beginGroup("tools"); sett.beginGroup("color"); bool ok; unsigned int a = sett.value("foreColor", QVariant("none")).toUInt(&ok); if (ok) { this->mForeColor = Parsing::Conversion::BitmapHelper::fromRgba(QRgb(a)); } else { this->mForeColor = QColor("black"); } a = sett.value("backColor", QVariant("none")).toUInt(&ok); if (ok) { this->mBackColor = Parsing::Conversion::BitmapHelper::fromRgba(QRgb(a)); } else { this->mBackColor = QColor("white"); } sett.endGroup(); sett.endGroup(); sett.endGroup(); }
bool RGBMatrix::loadXML(const QDomElement& root) { if (root.tagName() != KXMLQLCFunction) { qWarning() << Q_FUNC_INFO << "Function node not found"; return false; } if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::RGBMatrix)) { qWarning() << Q_FUNC_INFO << "Function is not an RGB matrix"; return false; } /* Load matrix contents */ QDomNode node = root.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCFunctionSpeed) { loadXMLSpeed(tag); } else if (tag.tagName() == KXMLQLCRGBAlgorithm) { setAlgorithm(RGBAlgorithm::loader(doc(), tag)); } else if (tag.tagName() == KXMLQLCRGBMatrixFixtureGroup) { setFixtureGroup(tag.text().toUInt()); } else if (tag.tagName() == KXMLQLCFunctionDirection) { loadXMLDirection(tag); } else if (tag.tagName() == KXMLQLCFunctionRunOrder) { loadXMLRunOrder(tag); } else if (tag.tagName() == KXMLQLCRGBMatrixStartColor) { setStartColor(QColor::fromRgb(QRgb(tag.text().toUInt()))); } else if (tag.tagName() == KXMLQLCRGBMatrixEndColor) { setEndColor(QColor::fromRgb(QRgb(tag.text().toUInt()))); } else { qWarning() << Q_FUNC_INFO << "Unknown RGB matrix tag:" << tag.tagName(); } node = node.nextSibling(); } return true; }
bool SpannerQRgbAttribute::merge(void*& parent, void* children[], bool postRead) const { if (postRead) { for (int i = 0; i < MERGE_COUNT; i++) { if (qAlpha(decodeInline<QRgb>(children[i])) != 0) { return false; } } return true; } QRgb parentValue = decodeInline<QRgb>(parent); int totalAlpha = qAlpha(parentValue) * Attribute::MERGE_COUNT; int totalRed = qRed(parentValue) * totalAlpha; int totalGreen = qGreen(parentValue) * totalAlpha; int totalBlue = qBlue(parentValue) * totalAlpha; bool allChildrenTransparent = true; for (int i = 0; i < Attribute::MERGE_COUNT; i++) { QRgb value = decodeInline<QRgb>(children[i]); int alpha = qAlpha(value); totalRed += qRed(value) * alpha; totalGreen += qGreen(value) * alpha; totalBlue += qBlue(value) * alpha; totalAlpha += alpha; allChildrenTransparent &= (alpha == 0); } if (totalAlpha == 0) { parent = encodeInline(QRgb()); } else { parent = encodeInline(qRgba(totalRed / totalAlpha, totalGreen / totalAlpha, totalBlue / totalAlpha, totalAlpha / MERGE_COUNT)); } return allChildrenTransparent; }
RGBMap RGBText::renderStaticLetters(const QSize& size, uint rgb, int step) const { QImage image(size, QImage::Format_RGB32); image.fill(QRgb(0)); QPainter p(&image); p.setRenderHint(QPainter::TextAntialiasing, false); p.setRenderHint(QPainter::Antialiasing, false); p.setFont(m_font); p.setPen(QColor(rgb)); // Draw one letter at a time QRect rect(xOffset(), yOffset(), size.width(), size.height()); p.drawText(rect, Qt::AlignCenter, m_text.mid(step, 1)); p.end(); RGBMap map(size.height()); for (int y = 0; y < size.height(); y++) { map[y].resize(size.width()); for (int x = 0; x < size.width(); x++) map[y][x] = image.pixel(x, y); } return map; }
RGBMap RGBText::renderScrollingText(const QSize& size, uint rgb, int step) const { QImage image; if (animationStyle() == Horizontal) image = QImage(scrollingTextStepCount(), size.height(), QImage::Format_RGB32); else image = QImage(size.width(), scrollingTextStepCount(), QImage::Format_RGB32); image.fill(QRgb(0)); QPainter p(&image); p.setRenderHint(QPainter::TextAntialiasing, false); p.setRenderHint(QPainter::Antialiasing, false); p.setFont(m_font); p.setPen(QColor(rgb)); if (animationStyle() == Vertical) { QFontMetrics fm(m_font); QRect rect(0, 0, image.width(), image.height()); for (int i = 0; i < m_text.length(); i++) { rect.setY((i * fm.ascent()) + yOffset()); rect.setX(xOffset()); rect.setHeight(fm.ascent()); p.drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, m_text.mid(i, 1)); } } else { // Draw the whole text each time QRect rect(xOffset(), yOffset(), image.width(), image.height()); p.drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, m_text); } p.end(); // Treat the RGBMap as a "window" on top of the fully-drawn text and pick the // correct pixels according to $step. RGBMap map(size.height()); for (int y = 0; y < size.height(); y++) { map[y].resize(size.width()); for (int x = 0; x < size.width(); x++) { if (animationStyle() == Horizontal) { if (step + x < image.width()) map[y][x] = image.pixel(step + x, y); } else { if (step + y < image.height()) map[y][x] = image.pixel(x, step + y); } } } return map; }
void RGBText_Test::horizontalScroll() { RGBText text(m_doc); text.setText("QLC"); text.setAnimationStyle(RGBText::Horizontal); QFontMetrics fm(text.font()); #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0)) QCOMPARE(text.rgbMapStepCount(QSize()), fm.width("QLC")); #else QCOMPARE(text.rgbMapStepCount(QSize()), fm.horizontalAdvance("QLC")); #endif // Since fonts and their rendering differs from installation to installation, // these tests are here only to check that nothing crashes. The end result is // more or less OS, platform, HW and SW dependent and testing individual pixels // would thus be rather pointless. #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0)) for (int i = 0; i < fm.width("QLC"); i++) #else for (int i = 0; i < fm.horizontalAdvance("QLC"); i++) #endif { RGBMap map = text.rgbMap(QSize(10, 10), QRgb(0xFFFFFFFF), i); QCOMPARE(map.size(), 10); for (int y = 0; y < 10; y++) QCOMPARE(map[y].size(), 10); } // Invalid step #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0)) RGBMap map = text.rgbMap(QSize(10, 10), QRgb(0xFFFFFFFF), fm.width("QLC")); #else RGBMap map = text.rgbMap(QSize(10, 10), QRgb(0xFFFFFFFF), fm.horizontalAdvance("QLC")); #endif QCOMPARE(map.size(), 10); for (int i = 0; i < 10; i++) { QCOMPARE(map[i].size(), 10); for (int j = 0; j < 10; j++) { QCOMPARE(map[i][j], QRgb(0)); } } }
QNEConnection::QNEConnection(QGraphicsItem *parent) : QGraphicsPathItem(parent) { setPen(QPen(QColor(QRgb(0x2c3e50)), 3)); setBrush(Qt::NoBrush); setZValue(-1); setAcceptHoverEvents(true); setAcceptTouchEvents(true); }
void EditingSkinDialog::on_pushButtonOtherCandColor_released() { QColorDialog::setCustomColor(0,QRgb(0x0000FF)); QColor color = QColorDialog::getColor(QColor(0,0,255)); QString str; if(color.isValid()){ str.sprintf("rgb(%d,%d,%d)",color.red(), color.green(), color.blue()); otherColorConf.sprintf("%d %d %d",color.red(),color.green(),color.blue()); ui->pushButtonOtherCandColor->setStyleSheet("QPushButton { background-color: " + str +";border: none;" +"}"); } }
QColor FontDocument::background() const { bool ok; quint32 rgbValue = this->mContainer->commonInfo("background").toUInt(&ok); if (ok) { return Parsing::Conversion::BitmapHelper::fromRgba(QRgb(rgbValue)); } return Settings::FontEditorOptions::backColor(); }
bool PackedNormalAttribute::merge(void*& parent, void* children[], bool postRead) const { QRgb firstValue = decodeInline<QRgb>(children[0]); glm::vec3 total = unpackNormal(firstValue) * (float)qAlpha(firstValue); bool allChildrenEqual = true; for (int i = 1; i < Attribute::MERGE_COUNT; i++) { QRgb value = decodeInline<QRgb>(children[i]); total += unpackNormal(value) * (float)qAlpha(value); allChildrenEqual &= (firstValue == value); } float length = glm::length(total); parent = encodeInline(length < EPSILON ? QRgb() : packNormal(total / length)); return allChildrenEqual; }
void PaletteDialog::loadSettings(QSettings &settings) { schemeString_ = settings.value("slectedScheme", defaultScheme_).toString(); for (std::size_t i = 0; i < sizeof currentColors_ / sizeof *currentColors_; ++i) for (std::size_t j = 0; j < sizeof *currentColors_ / sizeof **currentColors_; ++j) { currentColors_[i][j] = qvariant_cast<QRgb>( settings.value(quads_[i]->title() + QString::number(j), QRgb((3 - (j & 3)) * 85 * 0x010101))); } restore(); store(); }
void qt_set_color(t_colorspec* colorspec) { if (colorspec->type == TC_LT) qt_linetype(colorspec->lt); else if (colorspec->type == TC_FRAC) { rgb_color rgb; rgb1maxcolors_from_gray(colorspec->value, &rgb); QColor color; color.setRgbF(rgb.r, rgb.g, rgb.b); qt_out << GEPenColor << color; } else if (colorspec->type == TC_RGB) qt_out << GEPenColor << QColor(QRgb(colorspec->lt)); }
QRgb CScreenShotView::getPixmapPosRgb(const QPixmap &pixmap, const QPoint &pos) { QPixmap posPixmap = pixmap.copy(pos.x(), pos.y(), 1, 1); if (!posPixmap.isNull()) { QImage image = posPixmap.toImage(); if (!image.isNull()) { if(image.valid(0, 0)) { return image.pixel(0, 0); } } } return QRgb(); }
void qt_set_color(t_colorspec* colorspec) { if (colorspec->type == TC_LT) { if (colorspec->lt <= LT_NODRAW) qt_out << GEBackgroundColor; else qt_out << GEPenColor << qt_colorList[colorspec->lt % 9 + 3]; } else if (colorspec->type == TC_FRAC) { rgb_color rgb; rgb1maxcolors_from_gray(colorspec->value, &rgb); QColor color; color.setRgbF(rgb.r, rgb.g, rgb.b); qt_out << GEPenColor << color; } else if (colorspec->type == TC_RGB) qt_out << GEPenColor << QColor(QRgb(colorspec->lt)); }
void qt_set_color(t_colorspec* colorspec) { if (colorspec->type == TC_LT) qt_linetype(colorspec->lt); else if (colorspec->type == TC_FRAC) { rgb_color rgb; rgb1maxcolors_from_gray(colorspec->value, &rgb); QColor color; color.setRgbF(rgb.r, rgb.g, rgb.b); qt_out << GEPenColor << color; } else if (colorspec->type == TC_RGB) { QColor color = QRgb(colorspec->lt); int alpha = (colorspec->lt >> 24) & 0xff; if (alpha > 0) color.setAlpha(255-alpha); qt_out << GEPenColor << color; }
bool SpannerPackedNormalAttribute::merge(void*& parent, void* children[], bool postRead) const { if (postRead) { for (int i = 0; i < MERGE_COUNT; i++) { if (qAlpha(decodeInline<QRgb>(children[i])) != 0) { return false; } } return true; } QRgb parentValue = decodeInline<QRgb>(parent); glm::vec3 total = unpackNormal(parentValue) * (float)(qAlpha(parentValue) * Attribute::MERGE_COUNT); bool allChildrenTransparent = true; for (int i = 0; i < Attribute::MERGE_COUNT; i++) { QRgb value = decodeInline<QRgb>(children[i]); int alpha = qAlpha(value); total += unpackNormal(value) * (float)alpha; allChildrenTransparent &= (alpha == 0); } float length = glm::length(total); parent = encodeInline(length < EPSILON ? QRgb() : packNormal(total / length)); return allChildrenTransparent; }
/** Default constructor */ NewTag::NewTag(MsgTagType &Tags, uint32_t nId /* = 0*/, QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags), m_Tags(Tags) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); m_nId = nId; connect(ui.okButton, SIGNAL(clicked()), this, SLOT(OnOK())); connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(OnCancel())); connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setTagColor())); connect(ui.lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &))); ui.okButton->setEnabled(false); if (m_nId) { std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag; Tag = m_Tags.types.find(m_nId); if (Tag != m_Tags.types.end()) { ui.lineEdit->setText(QString::fromStdString(Tag->second.first)); m_Color = QRgb(Tag->second.second); if (m_nId < RS_MSGTAGTYPE_USER) { // standard tag ui.lineEdit->setEnabled(false); } } else { // tag id not found m_Color = 0; m_nId = 0; } } else { m_Color = 0; } showColor (m_Color); }
int main(int argc, char **argv) { QApplication app(argc, argv); QColorDialog::setCustomColor(0, QRgb(0x0000FF)); QColor c = QColorDialog::getColor(QColor(0, 255, 0)); QString text; if(c.isValid()) { text.sprintf("R:%d G:%d B:%d", c.red(), c.green(), c.blue()); QMessageBox::information(0, "Get Selected Color", text, "OK", "", "", 0, 1); } else { QMessageBox::information(0,"Error message", "You cancel the color input","OK","","",0,1); } text.sprintf("%d custom colors available", QColorDialog::customCount()); QMessageBox::information(0, "Get Selected Color", text, "OK", "", "", 0, 1); return 0; }
void qt_set_color(t_colorspec* colorspec) { if (colorspec->type == TC_LT) { if (colorspec->lt <= LT_NODRAW) qt->out << GEBackgroundColor; else qt->out << GEPenColor << qt_colorList[colorspec->lt % 9 + 3]; } else if (colorspec->type == TC_FRAC) { rgb_color rgb; rgb1maxcolors_from_gray(colorspec->value, &rgb); QColor color; color.setRgbF(rgb.r, rgb.g, rgb.b); qt->out << GEPenColor << color; } else if (colorspec->type == TC_RGB) { QColor color = QRgb(colorspec->lt); int alpha = (colorspec->lt >> 24) & 0xff; if (alpha > 0) color.setAlpha(255-alpha); qt->out << GEPenColor << color; }
bool QRgbAttribute::merge(void*& parent, void* children[], bool postRead) const { QRgb firstValue = decodeInline<QRgb>(children[0]); int totalAlpha = qAlpha(firstValue); int totalRed = qRed(firstValue) * totalAlpha; int totalGreen = qGreen(firstValue) * totalAlpha; int totalBlue = qBlue(firstValue) * totalAlpha; bool allChildrenEqual = true; for (int i = 1; i < Attribute::MERGE_COUNT; i++) { QRgb value = decodeInline<QRgb>(children[i]); int alpha = qAlpha(value); totalRed += qRed(value) * alpha; totalGreen += qGreen(value) * alpha; totalBlue += qBlue(value) * alpha; totalAlpha += alpha; allChildrenEqual &= (firstValue == value); } if (totalAlpha == 0) { parent = encodeInline(QRgb()); } else { parent = encodeInline(qRgba(totalRed / totalAlpha, totalGreen / totalAlpha, totalBlue / totalAlpha, totalAlpha / MERGE_COUNT)); } return allChildrenEqual; }
void ColorPalette::draw3DPannel(QPainter &painter) { QPen pen; pen.setColor(QColor(255,255,255)); pen.setWidthF(0.01); painter.setPen(pen); float x = draw_erae_.left(); float y = draw_erae_.top(); float diff = draw_erae_.height()/1020; float l_x = draw_erae_.right(); float l_y = draw_erae_.bottom(); QRgb srgb = QRgb(0x660000); int sred = qRed(srgb); QRgb ergb = QRgb(0xff0000); int ered = qRed(ergb); int k = 0; while(k<1020) { QRectF rect = QRectF(draw_erae_.left(),draw_erae_.top() + k*diff,draw_erae_.width() - 40,diff); painter.drawRect(rect); if (k<153) { painter.fillRect(rect,QBrush(QColor(sred + k,0,0).toHsv())); } else if (k < 408 && k >= 153) { painter.fillRect(rect,QBrush(QColor(255,k - 153,0).toHsv())); } else if ( k < 663 && k >= 408) { painter.fillRect(rect,QBrush(QColor(255 - (k - 408),255,0).toHsv())); } else if (k < 918 && k>= 663) { painter.fillRect(rect,QBrush(QColor(0,255 - (k - 663),k - 663).toHsv())); } else { painter.fillRect(rect,QBrush(QColor(0,0,255- (k - 918)).toHsv())); } k++; } float temp = (point3ddeepmax_ - point3ddeepmin_) / 9; float colordiff = draw_erae_.height() / 9; QLineF line[10]; pen.setColor(QColor(0,0,0)); pen.setWidth(XCOORDINATERULERWIDTH); painter.setFont(QFont(QObject::tr("WenQuanYi"),6)); painter.setPen(pen); int num = point3ddeepmax_; for (int i = 0;i<10;i++) { line[i].setP1(QPointF(draw_erae_.left(),draw_erae_.top()+(i)*colordiff)); line[i].setP2(QPointF(draw_erae_.right() -40,draw_erae_.top() + (i)*colordiff)); QString deep = QString::number(num); float width = painter.fontMetrics().width(deep); float height = painter.fontMetrics().height(); QRectF rect; if (i == 0) { rect = QRectF(draw_erae_.right() -35,draw_erae_.top() + colordiff*(i),width,height + 5); } else if (i == 9) { rect = QRectF(draw_erae_.right() -35,draw_erae_.top()-10 + colordiff*(i),width,height + 5); } else { rect = QRectF(draw_erae_.right() -35,draw_erae_.top()-5 + colordiff*(i),width,height + 5); } painter.drawText(rect,deep); num = point3ddeepmax_ - (i+1)*temp; } painter.drawLines(line,10); }
QString Conversion::computeAutoColor(const wvWare::Word97::SHD& shd, const QString& bgColor, const QString& fontColor) { // NOTE: by definition, see // http://social.msdn.microsoft.com/Forums/en-US/os_binaryfile/thread/a02a9a24-efb6-4ba0-a187-0e3d2704882b #ifdef CONVERSION_DEBUG_SHD qDebug() << Q_FUNC_INFO; qDebug() << "bgColor:" << bgColor; qDebug() << "fontColor:" << fontColor; qDebug() << "ipat:" << shd.ipat; qDebug() << "cvBack:" << hex << shd.cvBack; qDebug() << "cvFore:" << hex << shd.cvFore; #endif if (shd.isShdAuto() || shd.isShdNil()) { return contrastColor(bgColor); } QColor foreColor; QColor backColor; if (shd.cvFore == wvWare::Word97::cvAuto) { if (fontColor.isEmpty()) { foreColor = QColor(contrastColor(bgColor)); } else { foreColor = QColor(fontColor); } } else { foreColor = QColor(QRgb(shd.cvFore)); } if (shd.cvBack == wvWare::Word97::cvAuto) { if (bgColor.isEmpty()) { backColor = QColor(Qt::white).name(); } else { backColor = QColor(bgColor); } } else { backColor = QColor(QRgb(shd.cvBack)); } int luminosity = 0; if (shd.ipat == ipatAuto) { luminosity = luma(backColor); } else if (shd.ipat == ipatSolid) { luminosity = luma(foreColor); } else if ((shd.ipat > 13) && (shd.ipat < 34)) { luminosity = 61; } else { if (SHADING_TABLE.contains(shd.ipat)) { qreal pct = SHADING_TABLE.value(shd.ipat); luminosity = yMix( luma(foreColor), luma(backColor), pct); } else { // this should not happen, but it's binary data luminosity = 61; } } #ifdef CONVERSION_DEBUG_SHD qDebug() << "ooooooooooooooooooooooooooooooo chp: oooooooooooooooo bgColor:" << bgColor; qDebug() << "fontColor:" << fontColor; qDebug() << (shd.cvFore == wvWare::Word97::cvAuto); qDebug() << (shd.cvBack == wvWare::Word97::cvAuto); qDebug() << "ipat" << shd.ipat; qDebug() << "fore" << QString::number(shd.cvFore | 0xff000000, 16).right(6) << foreColor.name(); qDebug() << "back" << QString::number(shd.cvBack | 0xff000000, 16).right(6) << backColor.name(); qDebug() << "luminosity " << luminosity; #endif if (luminosity <= 60) { // it is dark color // window background color return QColor(Qt::white).name(); } else { // window text color return QColor(Qt::black).name(); } } //computeAutoColor
// Testing get/set functions void tst_QColor::getSetCheck() { QColor obj1; // int QColor::alpha() // void QColor::setAlpha(int) obj1.setAlpha(0); QCOMPARE(obj1.alpha(), 0); obj1.setAlpha(-1); QCOMPARE(obj1.alpha(), 0); // range<0, 255> obj1.setAlpha(INT_MIN); QCOMPARE(obj1.alpha(), 0); // range<0, 255> obj1.setAlpha(255); QCOMPARE(obj1.alpha(), 255); // range<0, 255> obj1.setAlpha(INT_MAX); QCOMPARE(obj1.alpha(), 255); // range<0, 255> // qreal QColor::alphaF() // void QColor::setAlphaF(qreal) obj1.setAlphaF(0.0); QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0> obj1.setAlphaF(-0.2); QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0> obj1.setAlphaF(1.0); QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0> obj1.setAlphaF(1.1); QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0> // int QColor::red() // void QColor::setRed(int) obj1.setRed(0); QCOMPARE(obj1.red(), 0); obj1.setRed(-1); QCOMPARE(obj1.red(), 0); // range<0, 255> obj1.setRed(INT_MIN); QCOMPARE(obj1.red(), 0); // range<0, 255> obj1.setRed(255); QCOMPARE(obj1.red(), 255); // range<0, 255> obj1.setRed(INT_MAX); QCOMPARE(obj1.red(), 255); // range<0, 255> // int QColor::green() // void QColor::setGreen(int) obj1.setGreen(0); QCOMPARE(obj1.green(), 0); obj1.setGreen(-1); QCOMPARE(obj1.green(), 0); // range<0, 255> obj1.setGreen(INT_MIN); QCOMPARE(obj1.green(), 0); // range<0, 255> obj1.setGreen(255); QCOMPARE(obj1.green(), 255); // range<0, 255> obj1.setGreen(INT_MAX); QCOMPARE(obj1.green(), 255); // range<0, 255> // int QColor::blue() // void QColor::setBlue(int) obj1.setBlue(0); QCOMPARE(obj1.blue(), 0); obj1.setBlue(-1); QCOMPARE(obj1.blue(), 0); // range<0, 255> obj1.setBlue(INT_MIN); QCOMPARE(obj1.blue(), 0); // range<0, 255> obj1.setBlue(255); QCOMPARE(obj1.blue(), 255); // range<0, 255> obj1.setBlue(INT_MAX); QCOMPARE(obj1.blue(), 255); // range<0, 255> // qreal QColor::redF() // void QColor::setRedF(qreal) obj1.setRedF(0.0); QCOMPARE(obj1.redF(), qreal(0.0)); obj1.setRedF(-0.2); QCOMPARE(obj1.redF(), qreal(0.0)); // range<0.0, 1.0 obj1.setRedF(1.1); QCOMPARE(obj1.redF(), qreal(1.0)); // range<0.0, 1.0 // qreal QColor::greenF() // void QColor::setGreenF(qreal) obj1.setGreenF(0.0); QCOMPARE(obj1.greenF(), qreal(0.0)); obj1.setGreenF(-0.2); QCOMPARE(obj1.greenF(), qreal(0.0)); // range<0.0, 1.0 obj1.setGreenF(1.1); QCOMPARE(obj1.greenF(), qreal(1.0)); // range<0.0, 1.0 // qreal QColor::blueF() // void QColor::setBlueF(qreal) obj1.setBlueF(0.0); QCOMPARE(obj1.blueF(), qreal(0.0)); obj1.setBlueF(-0.2); QCOMPARE(obj1.blueF(), qreal(0.0)); // range<0.0, 1.0 obj1.setBlueF(1.1); QCOMPARE(obj1.blueF(), qreal(1.0)); // range<0.0, 1.0 // QRgb QColor::rgba() // void QColor::setRgba(QRgb) QRgb var9(qRgba(10, 20, 30, 40)); obj1.setRgba(var9); QCOMPARE(obj1.rgba(), var9); obj1.setRgba(QRgb(0)); QCOMPARE(obj1.rgba(), QRgb(0)); // QRgb QColor::rgb() // void QColor::setRgb(QRgb) QRgb var10(qRgb(10, 20, 30)); obj1.setRgb(var10); QCOMPARE(obj1.rgb(), var10); obj1.setRgb(QRgb(0)); QCOMPARE(obj1.rgb(), qRgb(0, 0, 0)); }
void ColorPalette::drawTimePannel(QPainter &painter) { painter.save(); QPen pen; pen.setColor(QColor(0,0,0)); pen.setWidthF(1); painter.setPen(pen); painter.setFont(QFont(QObject::tr("WenQuanYi"),8)); float x = draw_erae_.left(); float y = draw_erae_.top(); // float width = painter.fontMetrics().width("Time"); // painter.drawText(QRectF(x - 5,y - 15,width,15),Qt::AlignCenter|Qt::AlignTop,"Time"); float diff = (draw_erae_.width())/1020; QRgb srgb = QRgb(0x660000); int sred = qRed(srgb); int k = 1020; QRectF rect; while(k >0) { rect = QRectF(draw_erae_.left() + k * diff, draw_erae_.top(),diff,draw_erae_.height() * 0.25); //painter.drawRect(rect); if (k < 153) { painter.fillRect(rect, QBrush(QColor(sred + k, 0, 0))); } else if (k < 408 && k >= 153) { painter.fillRect(rect, QBrush(QColor(255, k - 153, 0))); } else if ( k < 663 && k >= 408) { painter.fillRect(rect, QBrush(QColor(255 - (k - 408), 255, 0))); } else if (k < 918 && k>= 663) { painter.fillRect(rect, QBrush(QColor(0, 255 - (k - 663), k - 663))); } else { painter.fillRect(rect, QBrush(QColor(0,0,255- (k - 918)))); } k--; } QRectF rects(draw_erae_.left(),draw_erae_.top(),draw_erae_.width(),draw_erae_.height()*0.25); painter.drawRect(rects); int partion = 1; int datastep = 0; if (days_ <= 7) //如果总天数小于等于7天则分成4份,否则分成6份 { partion = 4; datastep = 2; } else { partion = 6; datastep = days_ / partion; } float step = draw_erae_.width() / partion; QString tempday = ""; float line = 0; while(line < draw_erae_.width()) { if (partion == 4) { painter.drawLine(x + line,y,x + line,y + draw_erae_.height()*0.25); tempday = start_date_.toString("MM/dd"); float width = painter.fontMetrics().width(tempday); float height = painter.fontMetrics().height(); painter.drawText(QRectF(x+line-width/2,y+draw_erae_.height()*0.25+4,width,height),Qt::AlignCenter,tempday); start_date_ = start_date_.addDays(datastep); line += step; } else { line += step; if (line < draw_erae_.width()) { painter.drawLine(x + line,y,x + line,y + draw_erae_.height()*0.25); tempday = start_date_.toString("MM/dd"); float width = painter.fontMetrics().width(tempday); float height = painter.fontMetrics().height(); painter.drawText(QRectF(x+line-width/2,y+draw_erae_.height()*0.25+4,width,height),Qt::AlignCenter,tempday); start_date_ = start_date_.addDays(datastep); } } } painter.restore(); }
void ColorPalette::drawPannel(QPainter &painter) { QPen pen; pen.setColor(QColor(255,255,255)); pen.setWidthF(0.01); painter.setPen(pen); float x = draw_erae_.left(); float y = draw_erae_.top(); float diff = draw_erae_.height()/1020; float l_x = draw_erae_.right(); float l_y = draw_erae_.bottom(); QRgb srgb = QRgb(0x660000); int sred = qRed(srgb); QRgb ergb = QRgb(0xff0000); int ered = qRed(ergb); int k = 0; while(k<919) //1020) { QRectF rect = QRectF(draw_erae_.left(),draw_erae_.top() + k*diff,draw_erae_.width() - 40,diff); painter.drawRect(rect); if (k<153) { painter.fillRect(rect,QBrush(QColor(sred + k,0,0))); } else if (k < 408 && k >= 153) { painter.fillRect(rect,QBrush(QColor(255,k - 153,0))); } else if ( k < 663 && k >= 408) { painter.fillRect(rect,QBrush(QColor(255 - (k - 408),255,0))); } else if (k < 918 && k>= 663) { painter.fillRect(rect,QBrush(QColor(0,255 - (k - 663),k - 663))); } else { painter.fillRect(rect,QBrush(QColor(0,0,255- (k - 918)))); } k++; } QList<float> earthquk; for (int i = 0;i<locationpoints.size();i++) { earthquk.push_back(locationpoints.value(i).quk_level); } qSort(earthquk); //earthquk.sort(Complear); int num = earthquk.size() * 0.1; QList<float> templist; for (int i = num;i<earthquk.size() - num;i++) { templist.push_back(earthquk.value(i)); } //从1020个色彩中选出与震级幅度相同的颜色 //震级的最大值为第一个颜色,最小值为最后一个颜色 //int colordiff = 1020/templist.size(); float tempmin = earthquk.value(0); float tempmax = earthquk.value(earthquk.size() - 1); float temp = (tempmax - tempmin) / 10; float colordiff = draw_erae_.height() / 9; QLineF line[10]; pen.setColor(QColor(0,0,0)); pen.setWidth(XCOORDINATERULERWIDTH); painter.setFont(QFont(QObject::tr("WenQuanYi"),6)); painter.setPen(pen); for (int i = 0;i<10;i++) { line[i].setP1(QPointF(draw_erae_.left(),draw_erae_.top()+(i)*colordiff)); line[i].setP2(QPointF(draw_erae_.right() -40,draw_erae_.top() + (i)*colordiff)); QString str_earthquake; str_earthquake.sprintf("%0.1f",tempmax - i*temp); float width = painter.fontMetrics().width(str_earthquake); float height = painter.fontMetrics().height(); QRectF rect; if (i == 0) { rect = QRectF(draw_erae_.right() -35,draw_erae_.top() + colordiff*(i),width,height + 5); } else if (i == 9) { rect = QRectF(draw_erae_.right() -35,draw_erae_.top()-10 + colordiff*(i),width,height + 5); } else { rect = QRectF(draw_erae_.right() -35,draw_erae_.top()-5 + colordiff*(i),width,height + 5); } painter.drawText(rect,str_earthquake,QTextOption(Qt::AlignRight)); } painter.drawLines(line,10); }
QPalette FancyStyle::standardPalette() const { QPalette palette; palette.setBrush(QPalette::Disabled, QPalette::WindowText, QColor(QRgb(0xff808080))); palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(QRgb(0xffdddfe4))); palette.setBrush(QPalette::Disabled, QPalette::Light, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Disabled, QPalette::Midlight, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Disabled, QPalette::Dark, QColor(QRgb(0xff555555))); palette.setBrush(QPalette::Disabled, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(QRgb(0xffc7c7c7))); palette.setBrush(QPalette::Disabled, QPalette::BrightText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Disabled, QPalette::ButtonText, QColor(QRgb(0xff808080))); palette.setBrush(QPalette::Disabled, QPalette::Base, QColor(QRgb(0xffefefef))); palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, palette.color(QPalette::Disabled, QPalette::Base).darker(110)); palette.setBrush(QPalette::Disabled, QPalette::Window, QColor(QRgb(0xffefefef))); palette.setBrush(QPalette::Disabled, QPalette::Shadow, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(QRgb(0xff567594))); palette.setBrush(QPalette::Disabled, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Disabled, QPalette::Link, QColor(QRgb(0xff0000ee))); palette.setBrush(QPalette::Disabled, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); palette.setBrush(QPalette::Active, QPalette::WindowText, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Active, QPalette::Button, QColor(QRgb(0xffdddfe4))); palette.setBrush(QPalette::Active, QPalette::Light, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Active, QPalette::Dark, QColor(QRgb(0xff555555))); palette.setBrush(QPalette::Active, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); palette.setBrush(QPalette::Active, QPalette::Text, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Active, QPalette::BrightText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Active, QPalette::ButtonText, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Active, QPalette::Base, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Active, QPalette::AlternateBase, palette.color(QPalette::Active, QPalette::Base).darker(110)); palette.setBrush(QPalette::Active, QPalette::Window, QColor(QRgb(0xffefefef))); palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(QRgb(0xff555555))); palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(QRgb(0xff678db2))); palette.setBrush(QPalette::Active, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Active, QPalette::Link, QColor(QRgb(0xff0000ee))); palette.setBrush(QPalette::Active, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); palette.setBrush(QPalette::Inactive, QPalette::WindowText, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(QRgb(0xffdddfe4))); palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Inactive, QPalette::Dark, QColor(QRgb(0xff555555))); palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Inactive, QPalette::BrightText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Inactive, QPalette::ButtonText, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Inactive, QPalette::Base, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, palette.color(QPalette::Inactive, QPalette::Base).darker(110)); palette.setBrush(QPalette::Inactive, QPalette::Window, QColor(QRgb(0xffefefef))); palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(QRgb(0xff000000))); palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(QRgb(0xff678db2))); palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); palette.setBrush(QPalette::Inactive, QPalette::Link, QColor(QRgb(0xff0000ee))); palette.setBrush(QPalette::Inactive, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); return palette; }
SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity) : m_rootEntity(rootEntity) { // Torus shape data //! [0] m_torus = new Qt3DExtras::QTorusMesh(); m_torus->setRadius(1.0f); m_torus->setMinorRadius(0.4f); m_torus->setRings(100); m_torus->setSlices(20); //! [0] // TorusMesh Transform //! [1] Qt3DCore::QTransform *torusTransform = new Qt3DCore::QTransform(); torusTransform->setScale(2.0f); torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 25.0f)); torusTransform->setTranslation(QVector3D(5.0f, 4.0f, 0.0f)); //! [1] //! [2] Qt3DExtras::QPhongMaterial *torusMaterial = new Qt3DExtras::QPhongMaterial(); torusMaterial->setDiffuse(QColor(QRgb(0xbeb32b))); //! [2] // Torus //! [3] m_torusEntity = new Qt3DCore::QEntity(m_rootEntity); m_torusEntity->addComponent(m_torus); m_torusEntity->addComponent(torusMaterial); m_torusEntity->addComponent(torusTransform); //! [3] // Cone shape data Qt3DExtras::QConeMesh *cone = new Qt3DExtras::QConeMesh(); cone->setTopRadius(0.5); cone->setBottomRadius(1); cone->setLength(3); cone->setRings(50); cone->setSlices(20); // ConeMesh Transform Qt3DCore::QTransform *coneTransform = new Qt3DCore::QTransform(); coneTransform->setScale(1.5f); coneTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 45.0f)); coneTransform->setTranslation(QVector3D(0.0f, 4.0f, -1.5)); Qt3DExtras::QPhongMaterial *coneMaterial = new Qt3DExtras::QPhongMaterial(); coneMaterial->setDiffuse(QColor(QRgb(0x928327))); // Cone m_coneEntity = new Qt3DCore::QEntity(m_rootEntity); m_coneEntity->addComponent(cone); m_coneEntity->addComponent(coneMaterial); m_coneEntity->addComponent(coneTransform); // Cylinder shape data Qt3DExtras::QCylinderMesh *cylinder = new Qt3DExtras::QCylinderMesh(); cylinder->setRadius(1); cylinder->setLength(3); cylinder->setRings(100); cylinder->setSlices(20); // CylinderMesh Transform Qt3DCore::QTransform *cylinderTransform = new Qt3DCore::QTransform(); cylinderTransform->setScale(1.5f); cylinderTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 45.0f)); cylinderTransform->setTranslation(QVector3D(-5.0f, 4.0f, -1.5)); Qt3DExtras::QPhongMaterial *cylinderMaterial = new Qt3DExtras::QPhongMaterial(); cylinderMaterial->setDiffuse(QColor(QRgb(0x928327))); // Cylinder m_cylinderEntity = new Qt3DCore::QEntity(m_rootEntity); m_cylinderEntity->addComponent(cylinder); m_cylinderEntity->addComponent(cylinderMaterial); m_cylinderEntity->addComponent(cylinderTransform); // Cuboid shape data Qt3DExtras::QCuboidMesh *cuboid = new Qt3DExtras::QCuboidMesh(); // CuboidMesh Transform Qt3DCore::QTransform *cuboidTransform = new Qt3DCore::QTransform(); cuboidTransform->setScale(4.0f); cuboidTransform->setTranslation(QVector3D(5.0f, -4.0f, 0.0f)); Qt3DExtras::QPhongMaterial *cuboidMaterial = new Qt3DExtras::QPhongMaterial(); cuboidMaterial->setDiffuse(QColor(QRgb(0x665423))); //Cuboid m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity); m_cuboidEntity->addComponent(cuboid); m_cuboidEntity->addComponent(cuboidMaterial); m_cuboidEntity->addComponent(cuboidTransform); // Plane shape data Qt3DExtras::QPlaneMesh *planeMesh = new Qt3DExtras::QPlaneMesh(); planeMesh->setWidth(2); planeMesh->setHeight(2); // Plane mesh transform Qt3DCore::QTransform *planeTransform = new Qt3DCore::QTransform(); planeTransform->setScale(1.3f); planeTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 45.0f)); planeTransform->setTranslation(QVector3D(0.0f, -4.0f, 0.0f)); Qt3DExtras::QPhongMaterial *planeMaterial = new Qt3DExtras::QPhongMaterial(); planeMaterial->setDiffuse(QColor(QRgb(0xa69929))); // Plane m_planeEntity = new Qt3DCore::QEntity(m_rootEntity); m_planeEntity->addComponent(planeMesh); m_planeEntity->addComponent(planeMaterial); m_planeEntity->addComponent(planeTransform); // Sphere shape data Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh(); sphereMesh->setRings(20); sphereMesh->setSlices(20); sphereMesh->setRadius(2); // Sphere mesh transform Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform(); sphereTransform->setScale(1.3f); sphereTransform->setTranslation(QVector3D(-5.0f, -4.0f, 0.0f)); Qt3DExtras::QPhongMaterial *sphereMaterial = new Qt3DExtras::QPhongMaterial(); sphereMaterial->setDiffuse(QColor(QRgb(0xa69929))); // Sphere m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity); m_sphereEntity->addComponent(sphereMesh); m_sphereEntity->addComponent(sphereMaterial); m_sphereEntity->addComponent(sphereTransform); }
int main(int argc, char **argv) { QApplication app(argc, argv); Window *view = new Window(); QWidget *container = QWidget::createWindowContainer(view); QSize screenSize = view->screen()->size(); container->setMinimumSize(QSize(200, 100)); container->setMaximumSize(screenSize); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->setAlignment(Qt::AlignTop); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); widget->setWindowTitle(QStringLiteral("Basic shapes")); Qt3DCore::QAspectEngine engine; engine.registerAspect(new Qt3DRender::QRenderAspect()); Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; engine.registerAspect(input); QVariantMap data; data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(view))); data.insert(QStringLiteral("eventSource"), QVariant::fromValue(view)); engine.setData(data); // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Camera Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(rootEntity); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, 0, -20.0f)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); cameraEntity->setViewCenter(QVector3D(0, 0, 0)); input->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); Qt3DRender::QForwardRenderer *forwardRenderer = new Qt3DRender::QForwardRenderer(); forwardRenderer->setCamera(cameraEntity); forwardRenderer->setClearColor(QColor(QRgb(0x4d4d4f))); frameGraph->setActiveFrameGraph(forwardRenderer); // Setting the FrameGraph rootEntity->addComponent(frameGraph); // Scenemodifier SceneModifier *modifier = new SceneModifier(rootEntity); // Set root object of the scene engine.setRootEntity(rootEntity); // Create control widgets QCommandLinkButton *info = new QCommandLinkButton(); info->setText(QStringLiteral("Qt3D ready-made meshes")); info->setDescription(QStringLiteral("Qt3D provides several ready-made meshes, like torus, cylinder, cube and sphere.")); info->setIconSize(QSize(0,0)); QCheckBox *torusCB = new QCheckBox(widget); torusCB->setChecked(true); torusCB->setText(QStringLiteral("Torus")); QCheckBox *cylinderCB = new QCheckBox(widget); cylinderCB->setChecked(true); cylinderCB->setText(QStringLiteral("Cylinder")); QCheckBox *cuboidCB = new QCheckBox(widget); cuboidCB->setChecked(true); cuboidCB->setText(QStringLiteral("Cuboid")); QCheckBox *sphereCB = new QCheckBox(widget); sphereCB->setChecked(true); sphereCB->setText(QStringLiteral("Sphere")); vLayout->addWidget(info); vLayout->addWidget(torusCB); vLayout->addWidget(cylinderCB); vLayout->addWidget(cuboidCB); vLayout->addWidget(sphereCB); QObject::connect(torusCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableTorus); QObject::connect(cylinderCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableCylinder); QObject::connect(cuboidCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableCuboid); QObject::connect(sphereCB, &QCheckBox::stateChanged, modifier, &SceneModifier::enableSphere); torusCB->setChecked(true); cylinderCB->setChecked(true); cuboidCB->setChecked(true); sphereCB->setChecked(true); // Show window widget->show(); widget->resize(1200, 800); // Update the aspect ratio QSize widgetSize = container->size(); float aspectRatio = float(widgetSize.width()) / float(widgetSize.height()); cameraEntity->lens()->setPerspectiveProjection(45.0f, aspectRatio, 0.1f, 1000.0f); return app.exec(); }
LinkLookEditWidget::LinkLookEditWidget(KCModule *module, const QString exTitle, const QString exIcon, QWidget *parent, Qt::WFlags fl) : QWidget(parent, fl) { QLabel *label; QVBoxLayout *layout = new QVBoxLayout(this); m_italic = new QCheckBox(i18n("I&talic"), this); layout->addWidget(m_italic); m_bold = new QCheckBox(i18n("&Bold"), this); layout->addWidget(m_bold); QGridLayout *gl = new QGridLayout; layout->addLayout(gl); gl->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 1, /*2*/3); m_underlining = new KComboBox(this); m_underlining->addItem(i18n("Always")); m_underlining->addItem(i18n("Never")); m_underlining->addItem(i18n("On mouse hovering")); m_underlining->addItem(i18n("When mouse is outside")); label = new QLabel(this); label->setText(i18n("&Underline:")); label->setBuddy(m_underlining); gl->addWidget(label, 0, 0); gl->addWidget(m_underlining, 0, 1); m_color = new KColorCombo2(QRgb(), this); label = new QLabel(this); label->setText(i18n("Colo&r:")); label->setBuddy(m_color); gl->addWidget(label, 1, 0); gl->addWidget(m_color, 1, 1); m_hoverColor = new KColorCombo2(QRgb(), this); label = new QLabel(this); label->setText(i18n("&Mouse hover color:")); label->setBuddy(m_hoverColor); gl->addWidget(label, 2, 0); gl->addWidget(m_hoverColor, 2, 1); QHBoxLayout *icoLay = new QHBoxLayout(0); m_iconSize = new IconSizeCombo(this); icoLay->addWidget(m_iconSize); label = new QLabel(this); label->setText(i18n("&Icon size:")); label->setBuddy(m_iconSize); gl->addWidget(label, 3, 0); gl->addItem(icoLay, 3, 1); m_preview = new KComboBox(this); m_preview->addItem(i18n("None")); m_preview->addItem(i18n("Icon size")); m_preview->addItem(i18n("Twice the icon size")); m_preview->addItem(i18n("Three times the icon size")); m_label = new QLabel(this); m_label->setText(i18n("&Preview:")); m_label->setBuddy(m_preview); m_hLabel = new HelpLabel( i18n("You disabled preview but still see images?"), i18n("<p>This is normal because there are several type of notes.<br>" "This setting only applies to file and local link notes.<br>" "The images you see are image notes, not file notes.<br>" "File notes are generic documents, whereas image notes are pictures you can draw in.</p>" "<p>When dropping files to baskets, %1 detects their type and shows you the content of the files.<br>" "For instance, when dropping image or text files, image and text notes are created for them.<br>" "For type of files %2 does not understand, they are shown as generic file notes with just an icon or file preview and a filename.</p>" "<p>If you do not want the application to create notes depending on the content of the files you drop, " "go to the \"General\" page and uncheck \"Image or animation\" in the \"View Content of Added Files for the Following Types\" group.</p>", // TODO: Note: you can resize down maximum size of images... KGlobal::mainComponent().aboutData()->programName(), KGlobal::mainComponent().aboutData()->programName()), this); gl->addWidget(m_label, 4, 0); gl->addWidget(m_preview, 4, 1); gl->addWidget(m_hLabel, 5, 1, 1, 2); QGroupBox *gb = new QGroupBox(i18n("Example"), this); QHBoxLayout* gbLayout = new QHBoxLayout; gb->setLayout(gbLayout); m_exLook = new LinkLook; m_example = new LinkLabel(exTitle, exIcon, m_exLook, 1, 1); gbLayout->addWidget(m_example); m_example->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_example->setCursor(QCursor(Qt::PointingHandCursor)); layout->addWidget(gb); m_exTitle = exTitle; m_exIcon = exIcon; connect(m_italic, SIGNAL(stateChanged(int)), this, SLOT(slotChangeLook())); connect(m_bold, SIGNAL(stateChanged(int)), this, SLOT(slotChangeLook())); connect(m_underlining, SIGNAL(activated(int)), this, SLOT(slotChangeLook())); connect(m_color, SIGNAL(activated(int)), this, SLOT(slotChangeLook())); connect(m_hoverColor, SIGNAL(activated(int)), this, SLOT(slotChangeLook())); connect(m_iconSize, SIGNAL(activated(int)), this, SLOT(slotChangeLook())); connect(m_preview, SIGNAL(activated(int)), this, SLOT(slotChangeLook())); connect(m_italic, SIGNAL(stateChanged(int)), module, SLOT(changed())); connect(m_bold, SIGNAL(stateChanged(int)), module, SLOT(changed())); connect(m_underlining, SIGNAL(activated(int)), module, SLOT(changed())); connect(m_color, SIGNAL(activated(int)), module, SLOT(changed())); connect(m_hoverColor, SIGNAL(activated(int)), module, SLOT(changed())); connect(m_iconSize, SIGNAL(activated(int)), module, SLOT(changed())); connect(m_preview, SIGNAL(activated(int)), module, SLOT(changed())); }