QFont Colors::tickerFont() { QFont font; font.setStyleStrategy(QFont::PreferAntialias); #if defined(Q_OS_MAC) font.setPixelSize(11); font.setBold(true); font.setFamily("Arial"); #else font.setPixelSize(10); font.setBold(true); font.setFamily("sans serif"); #endif return font; }
void Font::Create(const char *faceName, int, int size, bool bold, bool italic, int flags) { Release(); QFont *f = new QFont(); QFont::StyleStrategy strategy; switch (flags & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: strategy = QFont::NoAntialias; break; case SC_EFF_QUALITY_ANTIALIASED: strategy = QFont::PreferAntialias; break; default: strategy = QFont::PreferDefault; } #if defined(Q_WS_MAC) #if QT_VERSION >= 0x040700 strategy = static_cast<QFont::StyleStrategy>(strategy | QFont::ForceIntegerMetrics); #else #warning "Correct handling of QFont metrics requires Qt v4.7.0 or later" #endif #endif f->setStyleStrategy(strategy); // If name of the font begins with a '-', assume, that it is an XLFD. if (faceName[0] == '-') { f->setRawName(faceName); } else { f->setFamily(faceName); f->setPointSize(size); f->setBold(bold); f->setItalic(italic); } fid = f; }
QFont FontHelper::fontFromFile(const QString &fontFile) { QFont font; int fontId; QStringList loadedFontFamilies; fontId = QFontDatabase::addApplicationFont(fontFile); loadedFontFamilies = QFontDatabase::applicationFontFamilies(fontId); if(!loadedFontFamilies.empty()) { font = loadedFontFamilies.at(0); } font.setStyleStrategy(QFont::PreferAntialias); return font; }
// Inspired by text-use-opengl-buffer branch: work around font problems in GUI buttons. // May be useful in other broken OpenGL font situations. RasPi necessity as of 2016-03-26. Mesa 13 (2016-11) has finally fixed this on RasPi(VC4). QPixmap getTextPixmap(const QString& str, QFont font) { // Render the text str into a QPixmap. QRect strRect = QFontMetrics(font).boundingRect(str); int w = strRect.width()+1+(int)(0.02f*strRect.width()); int h = strRect.height(); QPixmap strPixmap(w, h); strPixmap.fill(Qt::transparent); QPainter painter(&strPixmap); font.setStyleStrategy(QFont::NoAntialias); // else: font problems on RasPi20160326 painter.setFont(font); //painter.setRenderHints(QPainter::TextAntialiasing); painter.setPen(Qt::white); painter.drawText(-strRect.x(), -strRect.y(), str); return strPixmap; }
QFont Manager::codeFont() { QString fontFamily = value("IDE/editor/font/family").toString(); int fontSize = value("IDE/editor/font/size").toInt(); bool fontAntialas = value("IDE/editor/font/antialias").toBool(); QFont font = QApplication::font("QPlainTextEdit"); font.setStyleHint(QFont::TypeWriter); font.setFamily(fontFamily); if (fontSize > 0) font.setPointSize(fontSize); if (!fontAntialas) font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() | QFont::NoAntialias)); return font; }
QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts, QDeclarativeView *parent) : QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts), testscript(0), hasCompleted(false), hasFailed(false) { parent->viewport()->installEventFilter(this); parent->installEventFilter(this); QUnifiedTimer::instance()->setConsistentTiming(true); //Font antialiasing makes tests system-specific, so disable it QFont noAA = QApplication::font(); noAA.setStyleStrategy(QFont::NoAntialias); QApplication::setFont(noAA); if (options & QDeclarativeViewer::Play) this->run(); start(); }
QFont fontId2font(int fontId) { static QFont* fonts[4]; // cached values Q_ASSERT(fontId >= 0 && fontId < 4); QFont* f = fonts[fontId]; if (f == 0) { f = fonts[fontId] = new QFont(); f->setWeight(QFont::Normal); // if not set we get system default f->setItalic(false); #ifdef USE_GLYPHS qreal size = 20.0; #else qreal size = 20.0 * MScore::DPI / PPI; #endif if (fontId == 0) f->setFamily("MScore"); else if (fontId == 2) { f->setFamily("FreeSerif"); size = 8.0; // * MScore::DPI / PPI; #ifndef USE_GLYPHS size = size * MScore::DPI / PPI; #endif } else if (fontId == 3) f->setFamily("Gonville-20"); else qFatal("illegal font id %d", fontId); f->setStyleStrategy(QFont::NoFontMerging); // horizontal hinting is bad as note hooks do not attach to stems // properly at some magnifications f->setHintingPreference(QFont::PreferVerticalHinting); #ifdef USE_GLYPHS f->setPixelSize(lrint(size)); // f->setPointSizeF(size); #else f->setPixelSize(lrint(size)); #endif } return *f; }
//DragLabel::DragLabel(const QString &text, QWidget *parent,int r, int g, int b, int alpha) //DragLabel::DragLabel(Task trab, const QString &text, QWidget *parent, QColor color, int tamanho) DragLabel::DragLabel(const QString &text,QWidget *parent,QString tooltip, QColor color, float tamanho, bool tempo_setup) : QLabel(parent){ this->coordenada = QPoint(0,0); this->tempo_setup = tempo_setup; this->tamanho = tamanho; this->tooltip = tooltip; //this->trabalho = trab; this->cor = color; QFontMetrics metric(font()); QSize size = metric.size(Qt::TextSingleLine, text); //QImage image(size.width() + 12, size.height() + 12, // QImage::Format_ARGB32_Premultiplied); int height; if(!tempo_setup){ height = size.height()+12; //se trabalho for tempo_setup da maquina, desenhar label menor }else{ height = 6; } //QImage image(tamanho, size.height()+12, QImage::Format_ARGB32_Premultiplied); QImage image(tamanho, height, QImage::Format_ARGB32_Premultiplied); image.fill(qRgba(0,0,0,0)); QFont font; font.setStyleStrategy(QFont::ForceOutline); QPainter painter; painter.begin(&image); painter.setRenderHint(QPainter::Antialiasing); //Cor do background do label painter.setBrush(cor); //Especificação do desenho do label painter.drawRect(0,0,image.width(),image.height()); painter.setFont(font); //Cor do texto painter.setBrush(Qt::green); //Define texto do label painter.drawText(QRect(QPoint(6,6),size), Qt::AlignCenter,text); painter.end(); setPixmap(QPixmap::fromImage(image)); labelText = text; }
void Terminal::create_transmit_terminal() { txTerminal = new QPlainTextEdit(this); palette = txTerminal->palette(); palette.setColor(QPalette::Base, QColor(0, 0, 0)); palette.setColor(QPalette::Text, QColor(255, 255, 0)); QFont font; font.setFamily("Courier New"); font.setPointSize(10); font.setStyleStrategy(QFont::NoAntialias); txTerminal->setPalette(palette); txTerminal->setCursorWidth(0); txTerminal->setFont(font); txTerminal->setMaximumBlockCount(100); txBar = txTerminal->verticalScrollBar(); }
void Context2D::strokeText(const QString &text, qreal x, qreal y) { beginPainting(); m_painter.save(); m_painter.setPen(QPen(m_state.fillStyle,0)); m_painter.setMatrix(worldMatrix(), false); QPainterPath textPath; QFont font = m_state.font; font.setStyleStrategy(QFont::ForceOutline); m_painter.setFont(font); const QFontMetrics &metrics = m_painter.fontMetrics(); int yoffset = baseLineOffset(m_state.textBaseline, metrics); int xoffset = textAlignOffset(m_state.textAlign, metrics, text); textPath.addText(x-xoffset, y-yoffset+metrics.ascent(), font, text); m_painter.strokePath(textPath, QPen(m_state.fillStyle, m_state.lineWidth)); m_painter.restore(); endPainting(); scheduleChange(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); //支持Tr中文 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));//支持中文文件名显示 QFont font; font.setStyleStrategy(QFont::PreferDefault); //font.setPointSize(160);//实际上是16的字号,但设成16却不行 //font.setFamily(("wenquanyi")); //font.setBold(false); a.setFont(font); MyDialog *w = new MyDialog; //w->showMaximized();//最大化显示 w->setWindowTitle("GPS评估程序"); w->show(); return a.exec(); }
void MainWindow::fontChanged() { QFont f = preview->font(); f.setStyleStrategy(QFont::NoFontMerging); f.setPixelSize(pixelSize->value()); f.setFamily(fontComboBox->currentFont().family()); f.setItalic(italic->isChecked()); f.setWeight(weightCombo->itemData(weightCombo->currentIndex()).toInt()); if (!preview->isModified()) { QFontDatabase db; QFontDatabase::WritingSystem ws = db.writingSystems(f.family()).value(0, QFontDatabase::Any); QString sample = db.writingSystemSample(ws); preview->setText(sample); preview->setModified(false); } fileName->setText(QPF::fileNameForFont(f)); preview->setFont(f); }
void SGI_NetLine::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); bool highlight = mNetLine.isSelected() || mNetLine.getNetSignal().isHighlighted(); // draw line if (mLayer->isVisible()) { QPen pen(mLayer->getColor(highlight), mNetLine.getWidth().toPx(), Qt::SolidLine, Qt::RoundCap); painter->setPen(pen); painter->drawLine(mLineF); } #ifdef QT_DEBUG SchematicLayer* layer = getSchematicLayer(SchematicLayer::LayerID::DEBUG_NetLinesNetSignalNames); Q_ASSERT(layer); if (layer->isVisible()) { // draw net signal name QFont font; font.setStyleStrategy(QFont::StyleStrategy(QFont::OpenGLCompatible | QFont::PreferQuality)); font.setStyleHint(QFont::TypeWriter); font.setFamily("Monospace"); font.setPixelSize(3); painter->setFont(font); painter->setPen(QPen(layer->getColor(highlight), 0)); painter->drawText(mLineF.pointAt((qreal)0.5), mNetLine.getNetSignal().getName()); } layer = getSchematicLayer(SchematicLayer::LayerID::DEBUG_GraphicsItemsBoundingRect); Q_ASSERT(layer); if (layer->isVisible()) { // draw bounding rect painter->setPen(QPen(layer->getColor(highlight), 0)); painter->setBrush(Qt::NoBrush); painter->drawRect(mBoundingRect); } #endif }
FontPropertyManager::ValueChangedResult FontPropertyManager::valueChanged(QtVariantPropertyManager *vm, QtProperty *property, const QVariant &value) { QtProperty *antialiasingProperty = m_antialiasingToProperty.value(property, 0); if (!antialiasingProperty) { if (m_propertyToFontSubProperties.contains(property)) { updateModifiedState(property, value); } return NoMatch; } QtVariantProperty *fontProperty = vm->variantProperty(antialiasingProperty); const QFont::StyleStrategy newValue = indexToAntialiasing(value.toInt()); QFont font = qVariantValue<QFont>(fontProperty->value()); const QFont::StyleStrategy oldValue = font.styleStrategy(); if (newValue == oldValue) return Unchanged; font.setStyleStrategy(newValue); fontProperty->setValue(qVariantFromValue(font)); return Changed; }
//! [0] DragLabel::DragLabel(const QString &text, QWidget *parent) : QLabel(parent) { QFontMetrics metric(font()); QSize size = metric.size(Qt::TextSingleLine, text); QImage image(size.width() + 12, size.height() + 12, QImage::Format_ARGB32_Premultiplied); image.fill(qRgba(0, 0, 0, 0)); QFont font; font.setStyleStrategy(QFont::ForceOutline); //! [0] //! [1] QLinearGradient gradient(0, 0, 0, image.height()-1); gradient.setColorAt(0.0, Qt::white); gradient.setColorAt(0.2, QColor(200, 200, 255)); gradient.setColorAt(0.8, QColor(200, 200, 255)); gradient.setColorAt(1.0, QColor(127, 127, 200)); QPainter painter; painter.begin(&image); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(gradient); painter.drawRoundedRect(QRectF(0.5, 0.5, image.width()-1, image.height()-1), 25, 25, Qt::RelativeSize); painter.setFont(font); painter.setBrush(Qt::black); painter.drawText(QRect(QPoint(6, 6), size), Qt::AlignCenter, text); painter.end(); //! [1] //! [2] setPixmap(QPixmap::fromImage(image)); m_labelText = text; }
QPixmap FixedWidthTableView::getDragPixmap(QString text) { // From the "Fridge Magnets" example QFontMetrics metric(font()); QSize size = metric.size(Qt::TextSingleLine, text); QImage image(size.width() + 12, size.height() + 12, QImage::Format_ARGB32_Premultiplied); image.fill(qRgba(0, 0, 0, 0)); QFont font; font.setStyleStrategy(QFont::ForceOutline); QPainter painter; painter.begin(&image); painter.setRenderHint(QPainter::Antialiasing); painter.setFont(font); painter.setBrush(Qt::black); painter.drawText(QRect(QPoint(6, 6), size), Qt::AlignCenter, text); painter.end(); return QPixmap::fromImage(image); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationVersion(APP_VERSION); // activate anti-aliasing on all fonts: QFont font = QApplication::font(); font.setStyleStrategy(QFont::PreferAntialias); a.setFont(font); // retrieve and apply factory Stylesheet: QFile ss(":/ferocious.css"); if(ss.open(QIODevice::ReadOnly | QIODevice::Text)) { a.setStyleSheet(ss.readAll()); ss.close(); } else { qDebug() << QString{"Couldn't open stylesheet resource: %1"}.arg(ss.fileName()); } MainWindow w; w.show(); return a.exec(); }
Ui::NameWidget::NameWidget(QWidget* _parent, int _nameBaseline) : QWidget(_parent) , name_(NULL) { setContentsMargins(0, 0, 0, 0); QHBoxLayout* rootLayout = Utils::emptyHLayout(); rootLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); setLayout(rootLayout); rootLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); QFont font = QApplication::font(); font.setStyleStrategy(QFont::PreferAntialias); name_ = new voipTools::BoundBox<ShadowedWidget<TextEmojiLabel> >(this); name_->setFont(font); name_->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); name_->setSizeToBaseline(_nameBaseline); // SORRY, MANKIND!!! THIS IS NECCESSARY EVIL BECAUSE TextEmojiLabel IS TERRIBLE!!! rootLayout->addWidget(name_); rootLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); }
FontPlatformData::FontPlatformData(const FontDescription& description, const AtomicString& familyName, int wordSpacing, int letterSpacing) : m_data(adoptRef(new FontPlatformDataPrivate())) { QFont font; int requestedSize = description.computedPixelSize(); font.setFamily(familyName); if (requestedSize) font.setPixelSize(requestedSize); font.setItalic(description.italic()); font.setWeight(toQFontWeight(description.weight())); font.setWordSpacing(wordSpacing); font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing); if (description.fontSmoothing() == NoSmoothing || (description.fontSmoothing() == AutoSmoothing && !Font::shouldUseSmoothing())) font.setStyleStrategy(QFont::NoAntialias); m_data->bold = font.bold(); // WebKit allows font size zero but QFont does not. We will return // m_data->size if a font size of zero is requested and pixelSize() // otherwise. m_data->size = (!requestedSize) ? requestedSize : font.pixelSize(); m_data->rawFont = QRawFont::fromFont(font, QFontDatabase::Any); }
CustomTable::CustomTable(ScreensContainer::ScreenId id, ScreensContainer *parent, TableGuiHandler * guiHandler) : Screen(id, guiHandler, parent) { m_screenTitle = new QLabel(this); m_screenTitle->setObjectName("screenLabel"); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sizePolicy.setHeightForWidth(m_screenTitle->sizePolicy().hasHeightForWidth()); m_screenTitle->setSizePolicy(sizePolicy); m_screenTitle->setMinimumSize(QSize(800, 50)); m_screenTitle->setMaximumSize(QSize(1600, 100)); QPalette palette1; QBrush brush2(QColor(0,141,210)); brush2.setStyle(Qt::SolidPattern); palette1.setBrush(QPalette::Active, QPalette::WindowText, brush2); palette1.setBrush(QPalette::Active, QPalette::Text, brush2); palette1.setBrush(QPalette::Inactive, QPalette::WindowText, brush2); palette1.setBrush(QPalette::Inactive, QPalette::Text, brush2); QBrush brush3(QColor(0,141,210)); brush3.setStyle(Qt::SolidPattern); palette1.setBrush(QPalette::Disabled, QPalette::WindowText, brush3); palette1.setBrush(QPalette::Disabled, QPalette::Text, brush3); m_screenTitle->setPalette(palette1); m_screenTitle->setAutoFillBackground(true); QFont font; font.setPointSize(28); font.setBold(true); font.setWeight(75); font.setStyleStrategy(QFont::PreferAntialias); m_screenTitle->setFont(font); m_screenTitle->setLineWidth(0); m_screenTitle->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); m_screenTitle->setMargin(10); m_mainGrid->addWidget(m_screenTitle, 0, 0, 1, 1); }
// Based on kconfigbase.cpp static QFont Str2Font(const QString &aValue) { uint nFontBits; QFont aRetFont; QString chStr; QStringList sl = QStringList::split(QString::fromLatin1(","), aValue); if(sl.count() == 1) { /* X11 font spec */ aRetFont = QFont(aValue); aRetFont.setRawMode(true); } else if(sl.count() == 10) { /* qt3 font spec */ aRetFont.fromString(aValue); } else if(sl.count() == 6) { /* backward compatible kde2 font spec */ aRetFont = QFont(sl[0], sl[1].toInt(), sl[4].toUInt()); aRetFont.setStyleHint((QFont::StyleHint)sl[2].toUInt()); nFontBits = sl[5].toUInt(); aRetFont.setItalic((nFontBits & 0x01) != 0); aRetFont.setUnderline((nFontBits & 0x02) != 0); aRetFont.setStrikeOut((nFontBits & 0x04) != 0); aRetFont.setFixedPitch((nFontBits & 0x08) != 0); aRetFont.setRawMode((nFontBits & 0x20) != 0); } aRetFont.setStyleStrategy((QFont::StyleStrategy)(QFont::PreferMatch | (_antiAliasing ? QFont::PreferAntialias : QFont::NoAntialias))); return aRetFont; }
void BlockDrawItem::build() { resize(100,40); QFont font; font.setStyleStrategy(QFont::PreferAntialias); setFont(font); blockLayout = new QHBoxLayout(this); setLayout(blockLayout); blockLayout->setMargin(0); label = new QLabel(); label->setFont(font); label->setFrameShape(QFrame::StyledPanel); label->setFrameShadow(QFrame::Plain); label->setLineWidth(3); label->setScaledContents(false); label->setAlignment(Qt::AlignCenter); label->setMargin(5); blockLayout->addWidget(label); }
MainWindow::MainWindow(QApplication* app) : main_page_(nullptr) , login_page_(nullptr) #ifdef __APPLE__ , accounts_page_(nullptr) #endif //_APPLE__ , app_(app) , event_filter_(new TitleWidgetEventFilter(this)) , tray_icon_(new TrayIcon(this)) , backgroundPixmap_(QPixmap()) , Shadow_(0) , SkipRead_(false) , TaskBarIconHidden_(false) , liveChats_(new LiveChats(this)) { Utils::InterConnector::instance().setMainWindow(this); #ifdef _WIN32 Utils::init_crash_handlers_in_core(); core::dump::crash_handler chandler; chandler.set_process_exception_handlers(); chandler.set_thread_exception_handlers(); #endif //_WIN32 setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true)); #ifdef __APPLE__ mac_support_ = new MacSupport(this); mac_support_->enableMacCrashReport(); #endif app_->installNativeEventFilter(this); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_window")); this->resize(329, 331); QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); this->setSizePolicy(sizePolicy); this->setLayoutDirection(Qt::LeftToRight); this->setAutoFillBackground(false); main_widget_ = new QWidget(this); main_widget_->setObjectName(QStringLiteral("main_widget")); sizePolicy.setHeightForWidth(main_widget_->sizePolicy().hasHeightForWidth()); main_widget_->setSizePolicy(sizePolicy); vertical_layout_ = new QVBoxLayout(main_widget_); vertical_layout_->setSpacing(0); vertical_layout_->setObjectName(QStringLiteral("verticalLayout_9")); vertical_layout_->setSizeConstraint(QLayout::SetDefaultConstraint); vertical_layout_->setContentsMargins(0, 0, 0, 0); title_widget_ = new QWidget(main_widget_); title_widget_->setObjectName(QStringLiteral("title_widget")); QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(title_widget_->sizePolicy().hasHeightForWidth()); title_widget_->setSizePolicy(sizePolicy1); title_widget_->setProperty("TitleWidget", QVariant(true)); horizontal_layout_ = new QHBoxLayout(title_widget_); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); logo_ = new QPushButton(title_widget_); logo_->setObjectName(QStringLiteral("logo")); QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy2.setHorizontalStretch(0); sizePolicy2.setVerticalStretch(0); sizePolicy2.setHeightForWidth(logo_->sizePolicy().hasHeightForWidth()); logo_->setSizePolicy(sizePolicy2); logo_->setProperty("WindowIcon", QVariant(true)); horizontal_layout_->addWidget(logo_); title_ = new QLabel(title_widget_); title_->setObjectName(QStringLiteral("title")); title_->setProperty("Title", QVariant(true)); horizontal_layout_->addWidget(title_); horizontal_spacer_ = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontal_layout_->addItem(horizontal_spacer_); hide_button_ = new QPushButton(title_widget_); hide_button_->setObjectName(QStringLiteral("hide_button")); hide_button_->setProperty("HideButton", QVariant(true)); horizontal_layout_->addWidget(hide_button_); maximize_button_ = new QPushButton(title_widget_); maximize_button_->setObjectName(QStringLiteral("maximize_button")); sizePolicy2.setHeightForWidth(maximize_button_->sizePolicy().hasHeightForWidth()); maximize_button_->setSizePolicy(sizePolicy2); maximize_button_->setProperty("MaximizeButton", QVariant(true)); horizontal_layout_->addWidget(maximize_button_); close_button_ = new QPushButton(title_widget_); close_button_->setObjectName(QStringLiteral("close_button")); sizePolicy2.setHeightForWidth(close_button_->sizePolicy().hasHeightForWidth()); close_button_->setSizePolicy(sizePolicy2); close_button_->setProperty("CloseButton", QVariant(true)); horizontal_layout_->addWidget(close_button_); vertical_layout_->addWidget(title_widget_); stacked_widget_ = new BackgroundWidget(main_widget_, ""); stacked_widget_->setObjectName(QStringLiteral("stacked_widget")); QPixmap p(":/resources/main_window/pat_100.png"); setBackgroundPixmap(p, true); //Utils::InterConnector::instance().setMainWindow(this); get_qt_theme_settings()->setOrLoadDefaultTheme(); vertical_layout_->addWidget(stacked_widget_); this->setCentralWidget(main_widget_); logo_->setText(QString()); hide_button_->setText(QString()); maximize_button_->setText(QString()); close_button_->setText(QString()); stacked_widget_->setCurrentIndex(-1); QMetaObject::connectSlotsByName(this); if (!get_gui_settings()->get_value(settings_keep_logged_in, true))// || !get_gui_settings()->contains_value(settings_keep_logged_in)) { showLoginPage(); } else { showMainPage(); } title_widget_->installEventFilter(event_filter_); title_->setText("ICQ"); title_->setAttribute(Qt::WA_TransparentForMouseEvents); logo_->setAttribute(Qt::WA_TransparentForMouseEvents); setWindowTitle("ICQ"); #ifdef _WIN32 setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowMinimizeButtonHint); fake_parent_window_ = Utils::create_fake_parent_window(); #else title_widget_->hide(); #endif title_->setMouseTracking(true); connect(hide_button_, SIGNAL(clicked()), this, SLOT(minimize()), Qt::QueuedConnection); connect(maximize_button_, SIGNAL(clicked()), this, SLOT(maximize()), Qt::QueuedConnection); connect(close_button_, SIGNAL(clicked()), this, SLOT(hideWindow()), Qt::QueuedConnection); hide_button_->setCursor(Qt::PointingHandCursor); maximize_button_->setCursor(Qt::PointingHandCursor); close_button_->setCursor(Qt::PointingHandCursor); connect(event_filter_, SIGNAL(doubleClick()), this, SLOT(maximize()), Qt::QueuedConnection); connect(event_filter_, SIGNAL(moveRequest(QPoint)), this, SLOT(moveRequest(QPoint)), Qt::QueuedConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipResetComplete()), this, SLOT(onVoipResetComplete()), Qt::QueuedConnection); connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(showLoginPage()), Qt::DirectConnection); connect(&Utils::InterConnector::instance(), SIGNAL(showIconInTaskbar(bool)), this, SLOT(showIconInTaskbar(bool)), Qt::QueuedConnection); connect(this, SIGNAL(needActivate()), this, SLOT(activate()), Qt::QueuedConnection); connect(get_gui_settings(), SIGNAL(changed(QString)), this, SLOT(guiSettingsChanged(QString)), Qt::QueuedConnection); QFont f = QApplication::font(); f.setStyleStrategy(QFont::PreferAntialias); QApplication::setFont(f); if (platform::is_windows()) { int shadowWidth = get_gui_settings()->get_shadow_width(); QBrush b = stacked_widget_->palette().background(); QMatrix m; m.translate(shadowWidth, title_widget_->height() + shadowWidth); b.setMatrix(m); Shadow_ = new ShadowWindow(b, shadowWidth); QPoint pos = mapToGlobal(QPoint(rect().x(), rect().y())); Shadow_->move(pos.x(), pos.y()); Shadow_->resize(rect().width(), rect().height()); Shadow_->setActive(true); Shadow_->show(); } initSettings(); #ifdef _WIN32 DragAcceptFiles((HWND)winId(), TRUE); #endif //_WIN32 if (!get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true)) hide_taskbar_icon(); #ifdef __APPLE__ mac_support_->enableMacUpdater(); mac_support_->enableMacPreview(this->winId()); #endif }
Ui::VideoPanelHeader::VideoPanelHeader(QWidget* parent, int items) : MoveablePanel(parent) , _callName(NULL) , _lowWidget(NULL) , _callTime(NULL) , _btnMin(NULL) , _secureCallEnabled(false) , _btnMax(NULL) , _btnClose(NULL) , _callNameSpacer(NULL) , _callTimeSpacer(NULL) , _items_to_show(items) { setProperty("VideoPanelHeader", true); setContentsMargins(0, 0, 0, 0); QHBoxLayout* layout = new QHBoxLayout(); _lowWidget = new QWidget(this); { // low widget. it makes background panel coloured _lowWidget->setContentsMargins(DEFAULT_BORDER, 0, 0, 0); _lowWidget->setProperty("VideoPanelHeader", true); _lowWidget->setLayout(layout); QVBoxLayout* vLayoutParent = new QVBoxLayout(); vLayoutParent->setContentsMargins(0, 0, 0, 0); vLayoutParent->setSpacing(0); vLayoutParent->setAlignment(Qt::AlignVCenter); vLayoutParent->addWidget(_lowWidget); setLayout(vLayoutParent); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(Qt::AlignVCenter); //layout->addSpacing(DEFAULT_BORDER); } auto __addWidget = [] (QWidget* parent) { QWidget* w = new QWidget(parent); w->setContentsMargins(0, 0, 0, 0); w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); if (parent) { parent->layout()->addWidget(w); } return w; }; auto __addLayout = [] (QWidget* w, Qt::Alignment align) { assert(w); if (w) { QHBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(align); w->setLayout(layout); } }; QWidget* leftWidg = __addWidget(_lowWidget); QWidget* centerWidg = __addWidget(_lowWidget); QWidget* rightWidg = __addWidget(_lowWidget); __addLayout(leftWidg, Qt::AlignLeft | Qt::AlignVCenter); __addLayout(centerWidg, Qt::AlignCenter); __addLayout(rightWidg, Qt::AlignRight | Qt::AlignVCenter); QFont font = QApplication::font(); font.setStyleStrategy(QFont::PreferAntialias); if (_items_to_show & kVPH_ShowName) { _callName = new NameWidget(leftWidg, Utils::scale_value(15)); _callName->setFont(font); _callName->layout()->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); _callName->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); _callName->setNameProperty("VideoPanelHeaderText", true); leftWidg->layout()->addWidget(_callName); //leftWidg->layout()->addSpacing(DEFAULT_BORDER << 1); } if (_items_to_show & kVPH_ShowTime) { _callTime = new voipTools::BoundBox<PushButton_t>(centerWidg); _callTime->setPostfixColor(QColor(255, 255, 255, 255)); _callTime->setFont(font); _callTime->setEnabled(false); _callTime->setAlignment(Qt::AlignCenter); _callTime->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); _callTime->setFixedWidth(SECURE_BTN_TEXT_W); _callTime->setIconSize(SECURE_BTN_ICON_W, SECURE_BTN_ICON_H); QObject::connect(_callTime, SIGNAL(clicked()), this, SLOT(_onSecureCallClicked()), Qt::QueuedConnection); Utils::ApplyStyle(_callTime, secureCallButton); centerWidg->layout()->addWidget(_callTime); //layout->addSpacing(DEFAULT_BORDER * 3); } QWidget* parentWidget = rightWidg; auto __addButton = [this, parentWidget] (const QString& propertyName, const char* slot)->QPushButton* { QPushButton* btn = new voipTools::BoundBox<QPushButton>(parentWidget); Utils::ApplyStyle(btn, propertyName); btn->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); btn->setCursor(QCursor(Qt::PointingHandCursor)); btn->setFlat(true); parentWidget->layout()->addWidget(btn); connect(btn, SIGNAL(clicked()), this, slot, Qt::QueuedConnection); return btn; }; bool spacerBetweenBtnsAndTimeAdded = false; if (_items_to_show & kVPH_ShowMin) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnMin = __addButton(minButtonStyle, SLOT(_onMinimize())); } if (_items_to_show & kVPH_ShowMax) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnMax = __addButton(maxButtonStyle, SLOT(_onMaximize())); } if (_items_to_show & kVPH_ShowClose) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnClose = __addButton(closeButtonStyle, SLOT(_onClose())); } //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} }
QT_END_NAMESPACE int main(int argc, char **argv) { QT_USE_NAMESPACE QApplication app(argc, argv); app.setOrganizationName(QLatin1String("QtProject")); app.setApplicationName(QLatin1String("MakeQPF")); const QStringList arguments = app.arguments(); if (arguments.count() <= 1) { return gui(); } else if (arguments.count() == 2 && QFile::exists(arguments.at(1))) { return gui(arguments.at(1)); } const QString &firstArg = arguments.at(1); if (firstArg == QLatin1String("-h") || firstArg == QLatin1String("--help")) help(); if (firstArg == QLatin1String("-dump")) { QString file; for (int i = 2; i < arguments.count(); ++i) { if (arguments.at(i).startsWith(QLatin1String("-v"))) QPF::debugVerbosity += arguments.at(i).length() - 1; else if (file.isEmpty()) file = arguments.at(i); else help(); } if (file.isEmpty()) help(); QFile f(file); if (!f.open(QIODevice::ReadOnly)) { printf("cannot open %s\n", qPrintable(file)); exit(1); } QByteArray qpf = f.readAll(); f.close(); QPF::dump(qpf); return 0; } if (arguments.count() < 3) help(); QFont font; QString fontName = firstArg; if (QFile::exists(fontName)) { int id = QFontDatabase::addApplicationFont(fontName); if (id == -1) { printf("cannot open font %s", qPrintable(fontName)); help(); } QStringList families = QFontDatabase::applicationFontFamilies(id); if (families.isEmpty()) { printf("cannot find any font families in %s", qPrintable(fontName)); help(); } fontName = families.first(); } font.setFamily(fontName); bool ok = false; int pixelSize = arguments.at(2).toInt(&ok); if (!ok) help(); font.setPixelSize(pixelSize); int generationOptions = QPF::IncludeCMap | QPF::RenderGlyphs; for (int i = 3; i < arguments.count(); ++i) { const QString &arg = arguments.at(i); if (arg == QLatin1String("italic")) { font.setItalic(true); } else if (arg == QLatin1String("bold")) { font.setBold(true); } else if (arg == QLatin1String("--exclude-cmap")) { generationOptions &= ~QPF::IncludeCMap; } else if (arg == QLatin1String("--exclude-glyphs")) { generationOptions &= ~QPF::RenderGlyphs; } else if (arg == QLatin1String("-v")) { ++QPF::debugVerbosity; } else { printf("unknown option %s\n", qPrintable(arg)); help(); } } font.setStyleStrategy(QFont::NoFontMerging); QList<QPF::CharacterRange> ranges; ranges.append(QPF::CharacterRange()); // default range from 0 to 0xffff QString origFont; QByteArray qpf = QPF::generate(font, generationOptions, ranges, &origFont); QString fileName = QPF::fileNameForFont(font); QFile f(fileName); f.open(QIODevice::WriteOnly | QIODevice::Truncate); f.write(qpf); f.close(); if (generationOptions & QPF::IncludeCMap) { printf("Created %s from %s\n", qPrintable(fileName), qPrintable(origFont)); } else { printf("Created %s from %s excluding the character-map\n", qPrintable(fileName), qPrintable(origFont)); printf("The TrueType font file is therefore required for the font to work\n"); } return 0; }
void Document::loadTheme(const Theme& theme) { m_text->document()->blockSignals(true); m_block_default_format.clear(); for(int i=0;i<theme.definedDefaultFormatsForBlocks().length();i++) m_block_default_format.insert(theme.definedDefaultFormatsForBlocks()[i],theme.defaultFormatForBlock(theme.definedDefaultFormatsForBlocks()[i])); // Update colors QString contrast = (qGray(theme.textColor().rgb()) > 127) ? "black" : "white"; QColor color = theme.foregroundColor(); color.setAlpha(theme.foregroundOpacity() * 2.55f); m_text->setStyleSheet( QString("Editor { background: rgba(%1, %2, %3, %4); color: %5; selection-background-color: %6; selection-color: %7; padding: %8px; border-radius: %9px; }") .arg(color.red()) .arg(color.green()) .arg(color.blue()) .arg(color.alpha()) .arg(theme.textColor().name()) .arg(theme.textColor().name()) .arg(contrast) .arg(theme.foregroundPadding()) .arg(theme.foregroundRounding()) ); if (m_highlighter->misspelledColor() != theme.misspelledColor()) { m_highlighter->setMisspelledColor(theme.misspelledColor()); } // Update text QFont font = theme.textFont(); font.setStyleStrategy(m_text->font().styleStrategy()); if (m_text->font() != font) { m_text->setFont(font); } m_text->setCursorWidth(!m_block_cursor ? 1 : m_text->fontMetrics().averageCharWidth()); int margin = theme.foregroundMargin(); m_layout->setColumnMinimumWidth(0, margin); m_layout->setColumnMinimumWidth(2, margin); if (theme.foregroundPosition() < 3) { m_text->setFixedWidth(theme.foregroundWidth()); switch (theme.foregroundPosition()) { case 0: m_layout->setColumnStretch(0, 0); m_layout->setColumnStretch(2, 1); break; case 2: m_layout->setColumnStretch(0, 1); m_layout->setColumnStretch(2, 0); break; case 1: default: m_layout->setColumnStretch(0, 1); m_layout->setColumnStretch(2, 1); break; }; } else { m_text->setMinimumWidth(theme.foregroundWidth()); m_text->setMaximumWidth(maximumSize().height()); m_layout->setColumnStretch(0, 0); m_layout->setColumnStretch(2, 0); } cleanUpDocument(false); centerCursor(true); m_text->document()->blockSignals(false); m_highlighter->rehighlight(); }
QtnPropertyDelegateQFont::QtnPropertyDelegateQFont(QtnPropertyQFontBase& owner) : QtnPropertyDelegateTypedEx<QtnPropertyQFontBase>(owner) { QtnPropertyQStringCallback* propertyFamily = new QtnPropertyQStringCallback(0); addSubProperty(propertyFamily); propertyFamily->setName(owner.tr("Family")); propertyFamily->setDescription(owner.tr("Font Family for %1.").arg(owner.name())); propertyFamily->setCallbackValueGet([&owner]()->QString { return owner.value().family(); }); propertyFamily->setCallbackValueSet([&owner](QString value) { QFont font = owner.value(); font.setFamily(value); owner.setValue(font); }); QtnPropertyDelegateInfo delegate; delegate.name = "List"; QFontDatabase fDB; delegate.attributes["items"] = fDB.families(); propertyFamily->setDelegate(delegate); QtnPropertyUIntCallback* propertyPointSize = new QtnPropertyUIntCallback(0); addSubProperty(propertyPointSize); propertyPointSize->setName(owner.tr("PointSize")); propertyPointSize->setDescription(owner.tr("Point size for %1.").arg(owner.name())); propertyPointSize->setCallbackValueGet([&owner]()->quint32 { int ps = owner.value().pointSize(); return ps != -1 ? ps : 1; }); propertyPointSize->setCallbackValueSet([&owner](quint32 value) { QFont font = owner.value(); font.setPointSize((int)value); owner.setValue(font); }); propertyPointSize->setMinValue(1); propertyPointSize->setMaxValue((quint32)std::numeric_limits<int>::max()); QtnPropertyBoolCallback* propertyBold = new QtnPropertyBoolCallback(0); addSubProperty(propertyBold); propertyBold->setName(owner.tr("Bold")); propertyBold->setDescription(owner.tr("Bold flag for %1").arg(owner.name())); propertyBold->setCallbackValueGet([&owner]()->bool { return owner.value().bold(); }); propertyBold->setCallbackValueSet([&owner](bool value) { QFont font = owner.value(); font.setBold(value); owner.setValue(font); }); QtnPropertyBoolCallback* propertyItalic = new QtnPropertyBoolCallback(0); addSubProperty(propertyItalic); propertyItalic->setName(owner.tr("Italic")); propertyItalic->setDescription(owner.tr("Italic flag for %1").arg(owner.name())); propertyItalic->setCallbackValueGet([&owner]()->bool { return owner.value().italic(); }); propertyItalic->setCallbackValueSet([&owner](bool value) { QFont font = owner.value(); font.setItalic(value); owner.setValue(font); }); QtnPropertyBoolCallback* propertyUnderline = new QtnPropertyBoolCallback(0); addSubProperty(propertyUnderline); propertyUnderline->setName(owner.tr("Underline")); propertyUnderline->setDescription(owner.tr("Underline flag for %1").arg(owner.name())); propertyUnderline->setCallbackValueGet([&owner]()->bool { return owner.value().underline(); }); propertyUnderline->setCallbackValueSet([&owner](bool value) { QFont font = owner.value(); font.setUnderline(value); owner.setValue(font); }); QtnPropertyBoolCallback* propertyStrikeout = new QtnPropertyBoolCallback(0); addSubProperty(propertyStrikeout); propertyStrikeout->setName(owner.tr("Strikeout")); propertyStrikeout->setDescription(owner.tr("Strikeout flag for %1").arg(owner.name())); propertyStrikeout->setCallbackValueGet([&owner]()->bool { return owner.value().strikeOut(); }); propertyStrikeout->setCallbackValueSet([&owner](bool value) { QFont font = owner.value(); font.setStrikeOut(value); owner.setValue(font); }); QtnPropertyBoolCallback* propertyKerning = new QtnPropertyBoolCallback(0); addSubProperty(propertyKerning); propertyKerning->setName(owner.tr("Kerning")); propertyKerning->setDescription(owner.tr("Kerning flag for %1").arg(owner.name())); propertyKerning->setCallbackValueGet([&owner]()->bool { return owner.value().kerning(); }); propertyKerning->setCallbackValueSet([&owner](bool value) { QFont font = owner.value(); font.setKerning(value); owner.setValue(font); }); QtnPropertyEnumCallback* propertyAntialiasing = new QtnPropertyEnumCallback(0); addSubProperty(propertyAntialiasing); propertyAntialiasing->setName(owner.tr("Antialiasing")); propertyAntialiasing->setDescription(owner.tr("Antialiasing flag for %1.").arg(owner.name())); propertyAntialiasing->setEnumInfo(styleStrategyEnum()); propertyAntialiasing->setCallbackValueGet([&owner]()->QtnEnumValueType { return owner.value().styleStrategy(); }); propertyAntialiasing->setCallbackValueSet([&owner](QtnEnumValueType value) { QFont font = owner.value(); font.setStyleStrategy((QFont::StyleStrategy)value); owner.setValue(font); }); }
void Document::loadTheme(const Theme& theme) { m_text->document()->blockSignals(true); // Update colors QColor color = theme.foregroundColor(); color.setAlpha(theme.foregroundOpacity() * 2.55f); m_text->setStyleSheet( QString("QTextEdit { background: rgba(%1, %2, %3, %4); color: %5; selection-background-color: %6; selection-color: %7; padding: %8px; }") .arg(color.red()) .arg(color.green()) .arg(color.blue()) .arg(color.alpha()) .arg(theme.textColor().name()) .arg(theme.textColor().name()) .arg(theme.foregroundColor().name()) .arg(theme.foregroundPadding()) ); if (m_highlighter->misspelledColor() != theme.misspelledColor()) { m_highlighter->setMisspelledColor(theme.misspelledColor()); } // Update text QFont font = theme.textFont(); font.setStyleStrategy(m_text->font().styleStrategy()); if (m_text->font() != font) { m_text->setFont(font); } m_text->setCursorWidth(!m_block_cursor ? 1 : m_text->fontMetrics().averageCharWidth()); int margin = theme.foregroundMargin(); m_layout->setColumnMinimumWidth(0, margin); m_layout->setColumnMinimumWidth(2, margin); if (theme.foregroundPosition() < 3) { m_text->setFixedWidth(theme.foregroundWidth()); switch (theme.foregroundPosition()) { case 0: m_layout->setColumnStretch(0, 0); m_layout->setColumnStretch(2, 1); break; case 2: m_layout->setColumnStretch(0, 1); m_layout->setColumnStretch(2, 0); break; case 1: default: m_layout->setColumnStretch(0, 1); m_layout->setColumnStretch(2, 1); break; }; } else { m_text->setMinimumWidth(theme.foregroundWidth()); m_text->setMaximumWidth(maximumSize().height()); m_layout->setColumnStretch(0, 0); m_layout->setColumnStretch(2, 0); } centerCursor(true); m_text->document()->blockSignals(false); }
// Convert simple DOM types QVariant domPropertyToVariant(const DomProperty *p) { // requires non-const virtual nameToIcon, etc. switch(p->kind()) { case DomProperty::Bool: return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue); case DomProperty::Cstring: return QVariant(p->elementCstring().toUtf8()); case DomProperty::Point: { const DomPoint *point = p->elementPoint(); return QVariant(QPoint(point->elementX(), point->elementY())); } case DomProperty::PointF: { const DomPointF *pointf = p->elementPointF(); return QVariant(QPointF(pointf->elementX(), pointf->elementY())); } case DomProperty::Size: { const DomSize *size = p->elementSize(); return QVariant(QSize(size->elementWidth(), size->elementHeight())); } case DomProperty::SizeF: { const DomSizeF *sizef = p->elementSizeF(); return QVariant(QSizeF(sizef->elementWidth(), sizef->elementHeight())); } case DomProperty::Rect: { const DomRect *rc = p->elementRect(); const QRect g(rc->elementX(), rc->elementY(), rc->elementWidth(), rc->elementHeight()); return QVariant(g); } case DomProperty::RectF: { const DomRectF *rcf = p->elementRectF(); const QRectF g(rcf->elementX(), rcf->elementY(), rcf->elementWidth(), rcf->elementHeight()); return QVariant(g); } case DomProperty::String: return QVariant(p->elementString()->text()); case DomProperty::Number: return QVariant(p->elementNumber()); case DomProperty::UInt: return QVariant(p->elementUInt()); case DomProperty::LongLong: return QVariant(p->elementLongLong()); case DomProperty::ULongLong: return QVariant(p->elementULongLong()); case DomProperty::Double: return QVariant(p->elementDouble()); case DomProperty::Char: { const DomChar *character = p->elementChar(); const QChar c(character->elementUnicode()); return QVariant::fromValue(c); } case DomProperty::Color: { const DomColor *color = p->elementColor(); QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); if (color->hasAttributeAlpha()) c.setAlpha(color->attributeAlpha()); return QVariant::fromValue(c); } case DomProperty::Font: { const DomFont *font = p->elementFont(); QFont f; if (font->hasElementFamily() && !font->elementFamily().isEmpty()) f.setFamily(font->elementFamily()); if (font->hasElementPointSize() && font->elementPointSize() > 0) f.setPointSize(font->elementPointSize()); if (font->hasElementWeight() && font->elementWeight() > 0) f.setWeight(font->elementWeight()); if (font->hasElementItalic()) f.setItalic(font->elementItalic()); if (font->hasElementBold()) f.setBold(font->elementBold()); if (font->hasElementUnderline()) f.setUnderline(font->elementUnderline()); if (font->hasElementStrikeOut()) f.setStrikeOut(font->elementStrikeOut()); if (font->hasElementKerning()) f.setKerning(font->elementKerning()); if (font->hasElementAntialiasing()) f.setStyleStrategy(font->elementAntialiasing() ? QFont::PreferDefault : QFont::NoAntialias); if (font->hasElementStyleStrategy()) { f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1())); } return QVariant::fromValue(f); } case DomProperty::Date: { const DomDate *date = p->elementDate(); return QVariant(QDate(date->elementYear(), date->elementMonth(), date->elementDay())); } case DomProperty::Time: { const DomTime *t = p->elementTime(); return QVariant(QTime(t->elementHour(), t->elementMinute(), t->elementSecond())); } case DomProperty::DateTime: { const DomDateTime *dateTime = p->elementDateTime(); const QDate d(dateTime->elementYear(), dateTime->elementMonth(), dateTime->elementDay()); const QTime tm(dateTime->elementHour(), dateTime->elementMinute(), dateTime->elementSecond()); return QVariant(QDateTime(d, tm)); } case DomProperty::Url: { const DomUrl *url = p->elementUrl(); return QVariant(QUrl(url->elementString()->text())); } #ifndef QT_NO_CURSOR case DomProperty::Cursor: return QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor()))); case DomProperty::CursorShape: return QVariant::fromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1()))); #endif case DomProperty::Locale: { const DomLocale *locale = p->elementLocale(); return QVariant::fromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()), enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1()))); } case DomProperty::SizePolicy: { const DomSizePolicy *sizep = p->elementSizePolicy(); QSizePolicy sizePolicy; sizePolicy.setHorizontalStretch(sizep->elementHorStretch()); sizePolicy.setVerticalStretch(sizep->elementVerStretch()); const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType"); if (sizep->hasElementHSizeType()) { sizePolicy.setHorizontalPolicy((QSizePolicy::Policy) sizep->elementHSizeType()); } else if (sizep->hasAttributeHSizeType()) { const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeHSizeType().toLatin1()); sizePolicy.setHorizontalPolicy(sp); } if (sizep->hasElementVSizeType()) { sizePolicy.setVerticalPolicy((QSizePolicy::Policy) sizep->elementVSizeType()); } else if (sizep->hasAttributeVSizeType()) { const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeVSizeType().toLatin1()); sizePolicy.setVerticalPolicy(sp); } return QVariant::fromValue(sizePolicy); } case DomProperty::StringList: return QVariant(p->elementStringList()->elementString()); default: uiLibWarning(QCoreApplication::translate("QFormBuilder", "Reading properties of the type %1 is not supported yet.").arg(p->kind())); break; } return QVariant(); }
void Font::Create(const FontParameters &fp) { Release(); QFont *f = new QFont(); QFont::StyleStrategy strategy; switch (fp.extraFontFlag & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: strategy = QFont::NoAntialias; break; case SC_EFF_QUALITY_ANTIALIASED: strategy = QFont::PreferAntialias; break; default: strategy = QFont::PreferDefault; } #if defined(Q_OS_MAC) #if QT_VERSION >= 0x040700 strategy = static_cast<QFont::StyleStrategy>(strategy | QFont::ForceIntegerMetrics); #else #warning "Correct handling of QFont metrics requires Qt v4.7.0 or later" #endif #endif f->setStyleStrategy(strategy); // If name of the font begins with a '-', assume, that it is an XLFD. if (fp.faceName[0] == '-') { f->setRawName(fp.faceName); } else { f->setFamily(fp.faceName); f->setPointSize(fp.size); // See if the Qt weight has been passed via the back door. Otherwise // map Scintilla weights to Qt weights ensuring that the SC_WEIGHT_* // values get mapped to the correct QFont::Weight values. int qt_weight; if (fp.weight < 0) qt_weight = -fp.weight; else if (fp.weight <= 200) qt_weight = QFont::Light; else if (fp.weight <= QsciScintillaBase::SC_WEIGHT_NORMAL) qt_weight = QFont::Normal; else if (fp.weight <= 600) qt_weight = QFont::DemiBold; else if (fp.weight <= 850) qt_weight = QFont::Bold; else qt_weight = QFont::Black; f->setWeight(qt_weight); f->setItalic(fp.italic); } fid = f; }