示例#1
0
// Updates the dialog box using values in global Config()
void OptionsDialog::updateDialogFromConfig()
{
    std::shared_ptr<Configuration> config =
        Persistent<Configuration>( "settings" );

    // Main font
    QFontInfo fontInfo = QFontInfo( config->mainFont() );

    int familyIndex = fontFamilyBox->findText( fontInfo.family() );
    if ( familyIndex != -1 )
        fontFamilyBox->setCurrentIndex( familyIndex );

    int sizeIndex = fontSizeBox->findText( QString::number(fontInfo.pointSize()) );
    if ( sizeIndex != -1 )
        fontSizeBox->setCurrentIndex( sizeIndex );

    // Regexp types
    mainSearchBox->setCurrentIndex(
            getRegexpIndex( config->mainRegexpType() ) );
    quickFindSearchBox->setCurrentIndex(
            getRegexpIndex( config->quickfindRegexpType() ) );

    incrementalCheckBox->setChecked( config->isQuickfindIncremental() );

    // Polling
    pollingCheckBox->setChecked( config->pollingEnabled() );
    pollIntervalLineEdit->setText( QString::number( config->pollIntervalMs() ) );
}
示例#2
0
ClusterPalette::ClusterPalette(QColor backgroundColor,QWidget* parent,KStatusBar * statusBar, const char* name, WFlags fl )
    : QVBox( parent, name, fl ),doc(0L),mode(IMMEDIATE),isInSelectItems(false),isUpToDate(true),backgroundColor(backgroundColor),statusBar(statusBar),isInUserClusterInfoMode(false)
{
    //Set the palette color

    setPaletteBackgroundColor(backgroundColor);
    setPaletteForegroundColor(white);

    iconView = new QIconView(this, "ClusterPalette");
    QFont font( "Helvetica",8);
    iconView->setFont(font);
    iconView->setFrameStyle(QFrame::NoFrame);
    iconView->setArrangement(QIconView::LeftToRight);
    iconView->setResizeMode(QIconView::Adjust);
    iconView->setPaletteBackgroundColor(backgroundColor);
    iconView->setHScrollBarMode(QScrollView::AlwaysOff);
    iconView->setVScrollBarMode(QScrollView::AlwaysOff);

    int h;
    int s;
    int v;
    backgroundColor.hsv(&h,&s,&v);
    if(s <= 80 && v >= 240 || (s <= 40 && v >= 220)) iconView->setPaletteForegroundColor(black);
    else iconView->setPaletteForegroundColor(white);

    iconView->setSelectionMode(QIconView::Extended);
    iconView->setItemsMovable(false);
    iconView->setSpacing(4);
    QFontInfo fontInfo = QFontInfo(QFont());
    iconView->setGridX(fontInfo.pixelSize() * 2);
    iconView->setGridY(15);
    iconView->arrangeItemsInGrid();


    //Deal with the sizes
    setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,(QSizePolicy::SizeType)5));

    //Set the legend in the good language
    languageChange();

    //Signal and slot connection
    connect(iconView,SIGNAL(contextMenuRequested(QIconViewItem* ,const QPoint&)),this, SLOT(slotRightPressed(QIconViewItem*)));
    connect(iconView,SIGNAL(selectionChanged()),this, SLOT(slotClickRedraw()));
    connect(iconView,SIGNAL(mouseButtonPressed(int,QIconViewItem* ,const QPoint&)),this, SLOT(slotMousePressed(int,QIconViewItem*)));

    connect(iconView,SIGNAL(onItem(QIconViewItem*)),this, SLOT(slotOnItem(QIconViewItem*)));
}
示例#3
0
void ClusterPalette::hideUserClusterInformation() {
    //update the flag
    isInUserClusterInfoMode = false;

    iconView->setItemTextPos(QIconView::Bottom);
    //Let's go back to normal
    QFontInfo fontInfo = QFontInfo(QFont());
    iconView->setGridX(fontInfo.pixelSize() * 2);
    iconView->setGridY(15);
    iconView->arrangeItemsInGrid();

    ItemColors& clusterColors = doc->clusterColors();
    int clusterId;

    for(QIconViewItem* item = iconView->firstItem(); item; item = item->nextItem()) {
        clusterId = clusterColors.itemId(item->index());
        item->setText(QString("%1").arg(clusterId));
    }

    iconView->setWordWrapIconText(true);
    iconView->resize(this->width(),this->height());
}
示例#4
0
bool QgsFontUtils::fontMatchOnSystem( const QFont& f )
{
  QFontInfo fi = QFontInfo( f );
  return fi.exactMatch();
}
示例#5
0
wxString wxFont::GetFaceName() const
{
    // use font info to get the matched face name (not the family given)
    QFontInfo info = QFontInfo(M_FONTDATA);
    return wxQtConvertString(info.family());
}
示例#6
0
wxString wxNativeFontInfo::GetFaceName() const
{
    // use font info to get the matched face name (not the family given)
    QFontInfo info = QFontInfo(m_qtFont);
    return wxQtConvertString(info.family());
}
QString htmlizedTextPart(const QModelIndex &partIndex, const QFontInfo &font, const QColor &backgroundColor, const QColor &textColor,
                         const QColor &linkColor, const QColor &visitedLinkColor)
{
    static const QString defaultStyle = QString::fromUtf8(
        "pre{word-wrap: break-word; white-space: pre-wrap;}"
        // The following line, sadly, produces a warning "QFont::setPixelSize: Pixel size <= 0 (0)".
        // However, if it is not in place or if the font size is set higher, even to 0.1px, WebKit reserves space for the
        // quotation characters and therefore a weird white area appears. Even width: 0px doesn't help, so it looks like
        // we will have to live with this warning for the time being.
        ".quotemarks{color:transparent;font-size:0px;}"

        // Cannot really use the :dir(rtl) selector for putting the quote indicator to the "correct" side.
        // It's CSS4 and it isn't supported yet.
        "blockquote{font-size:90%; margin: 4pt 0 4pt 0; padding: 0 0 0 1em; border-left: 2px solid %1; unicode-bidi: -webkit-plaintext}"

        // Stop the font size from getting smaller after reaching two levels of quotes
        // (ie. starting on the third level, don't make the size any smaller than what it already is)
        "blockquote blockquote blockquote {font-size: 100%}"
        ".signature{opacity: 0.6;}"

        // Dynamic quote collapsing via pure CSS, yay
        "input {display: none}"
        "input ~ span.full {display: block}"
        "input ~ span.short {display: none}"
        "input:checked ~ span.full {display: none}"
        "input:checked ~ span.short {display: block}"
        "label {border: 1px solid %2; border-radius: 5px; padding: 0px 4px 0px 4px; white-space: nowrap}"
        // BLACK UP-POINTING SMALL TRIANGLE (U+25B4)
        // BLACK DOWN-POINTING SMALL TRIANGLE (U+25BE)
        "span.full > blockquote > label:before {content: \"\u25b4\"}"
        "span.short > blockquote > label:after {content: \" \u25be\"}"
        "span.shortquote > blockquote > label {display: none}"
    );

    QString fontSpecification(QStringLiteral("pre{"));
    if (font.italic())
        fontSpecification += QLatin1String("font-style: italic; ");
    if (font.bold())
        fontSpecification += QLatin1String("font-weight: bold; ");
    fontSpecification += QStringLiteral("font-size: %1px; font-family: \"%2\", monospace }").arg(
                QString::number(font.pixelSize()), font.family());

    QString textColors = QString::fromUtf8("body { background-color: %1; color: %2 }"
                                           "a:link { color: %3 } a:visited { color: %4 } a:hover { color: %3 }").arg(
                backgroundColor.name(), textColor.name(), linkColor.name(), visitedLinkColor.name());
    // looks like there's no special color for hovered links in Qt

    // build stylesheet and html header
    QColor tintForQuoteIndicator = backgroundColor;
    tintForQuoteIndicator.setAlpha(0x66);
    static QString stylesheet = defaultStyle.arg(linkColor.name(),
                                                 tintColor(textColor, tintForQuoteIndicator).name());
    static QFile file(Common::writablePath(Common::LOCATION_DATA) + QLatin1String("message.css"));
    static QDateTime lastVersion;
    QDateTime lastTouched(file.exists() ? QFileInfo(file).lastModified() : QDateTime());
    if (lastVersion < lastTouched) {
        stylesheet = defaultStyle;
        if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            const QString userSheet = QString::fromLocal8Bit(file.readAll().data());
            lastVersion = lastTouched;
            stylesheet += QLatin1Char('\n') + userSheet;
            file.close();
        }
    }

    // The dir="auto" is required for WebKit to treat all paragraphs as entities with possibly different text direction.
    // The individual paragraphs unfortunately share the same text alignment, though, as per
    // https://bugs.webkit.org/show_bug.cgi?id=71194 (fixed in Blink already).
    QString htmlHeader(QLatin1String("<html><head><style type=\"text/css\"><!--") + textColors + fontSpecification + stylesheet +
                       QLatin1String("--></style></head><body><pre dir=\"auto\">"));
    static QString htmlFooter(QStringLiteral("\n</pre></body></html>"));


    // We cannot rely on the QWebFrame's toPlainText because of https://bugs.kde.org/show_bug.cgi?id=321160
    QString markup = plainTextToHtml(partIndex.data(Imap::Mailbox::RolePartUnicodeText).toString(), flowedFormatForPart(partIndex));

    return htmlHeader + markup + htmlFooter;
}