Exemple #1
0
bool K3b::TitleLabel::event( QEvent* event )
{
    if ( event->type() == QEvent::ToolTip ) {
        QHelpEvent* he = ( QHelpEvent* )event;
        QPoint pos = he->pos();

        const QRect rect = contentsRect().adjusted( d->margin, d->margin, -d->margin, -d->margin );
        const QRect titleRect = d->titleRect( rect );
        const QRect subTitleRect = d->subTitleRect( rect, titleRect );
        const QRect actualTitleRect = QStyle::visualRect( layoutDirection(), rect, titleRect );
        const QRect actualSubTitleRect = QStyle::visualRect( layoutDirection(), rect, subTitleRect );

        if( actualTitleRect.contains( pos ) && d->displayTitle != d->title ) {
            QToolTip::showText( he->globalPos(), d->title, this, actualTitleRect );
        }
        else if( actualSubTitleRect.contains( pos ) && d->displaySubTitle != d->subTitle ) {
            QToolTip::showText( he->globalPos(), d->subTitle, this, actualSubTitleRect );
        }

        event->accept();

        return true;
    }

    return QFrame::event( event );
}
Exemple #2
0
void K3b::TitleLabel::paintEvent( QPaintEvent* e )
{
    QPainter p( this );
    p.eraseRect( e->rect() );
    p.setLayoutDirection( layoutDirection() );

    const QRect rect = e->rect().adjusted( d->margin, d->margin, -d->margin, -d->margin );
    const QRect titleRect = d->titleRect( rect );

    QFont f( font() );
    f.setBold(true);
    f.setPointSize( f.pointSize() + 2 );

    // paint title
    p.setFont(f);
    p.drawText( QStyle::visualRect( layoutDirection(), rect, titleRect ),
                QStyle::visualAlignment( layoutDirection(), d->alignment ),
                d->displayTitle );

    if( !d->subTitle.isEmpty() ) {
        f.setBold(false);
        f.setPointSize( f.pointSize() - 4 );
        p.setFont(f);
        const QRect subTitleRect = d->subTitleRect( rect, titleRect );
        p.drawText( QStyle::visualRect( layoutDirection(), rect, subTitleRect ),
                    QStyle::visualAlignment( layoutDirection(), d->alignment ),
                    d->displaySubTitle );
    }
}
Exemple #3
0
void OsdWidget::paintEvent(QPaintEvent *)
{
	if (osdObject == NULL) {
		if (layoutDirection() == Qt::LeftToRight) {
			QPainter(this).drawPixmap(20, 20, pixmap);
			rect.moveTo(20, 20);
		} else {
			int x = width() - pixmap.width() - 20;
			QPainter(this).drawPixmap(x, 20, pixmap);
			rect.moveTo(x, 20);
		}
	} else {
		rect = QWidget::rect();
		rect.adjust(0, 0, -40, -60);
		pixmap = osdObject->paintOsd(rect, font(), layoutDirection());

		int y = (4 * height()) / 5 - rect.height();

		if (y < 30) {
			y = 30;
		}

		rect.moveTo(20, y);
		QPainter(this).drawPixmap(rect.left(), rect.top(), pixmap);
	}

	setMask(rect);
}
void MessageOverlay::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    QRect r(rect());
    QRectF rf(r.x()+0.5, r.y()+0.5, r.width()-1, r.height()-1);
    QColor borderCol=palette().color(QPalette::Highlight).darker(120);
    QColor col=palette().color(QPalette::Window);
    QPainterPath path=Utils::buildPath(rf, r.height()/4.0);
    col.setAlphaF(0.8);
    p.setRenderHint(QPainter::Antialiasing, true);
    p.fillPath(path, col);
    p.setPen(QPen(borderCol, qMax(2, r.height()/16)));
    p.drawPath(path);

    int pad=r.height()/4;
    if (cancelButton->isVisible()) {
        if (Qt::LeftToRight==layoutDirection() && !closeOnLeft) {
            rf.adjust(pad, pad, -((pad*2)+cancelButton->width()), -pad);
        } else {
            rf.adjust(((pad*2)+cancelButton->width()), pad, -pad, -pad);
        }
    } else {
        rf.adjust(pad, pad, -pad, -pad);
    }
    QFont fnt(QApplication::font());
    fnt.setBold(true);
    QFontMetrics fm(fnt);
    col=palette().color(QPalette::WindowText);

    p.setPen(col);
    p.setFont(fnt);
    p.drawText(rf, fm.elidedText(text, Qt::ElideRight, r.width(), QPalette::WindowText), QTextOption(Qt::LeftToRight==layoutDirection() ? Qt::AlignLeft : Qt::AlignRight));
    p.end();
}
Exemple #5
0
void BarGraph::drawContents( QPainter *p )
{
    int h = contentsRect().height();
    int y = contentsRect().top();

    int total = 0;
    for ( int i = 0; i < data->count(); i++ )
        total += data->value(i);

    int pos = 0;
    p->setPen(Qt::NoPen);
    QRect r = contentsRect();
    for ( int i = 0; i < data->count(); i++ ) {
        int len;
        if ( i == data->count() - 1 || !total )
            len = r.width() - pos;
        else
            len = (uint)data->value(i) * r.width() / total;
        QColor col;
        col.setHsv( i * 360 / data->count(), 255, 255 );
        if ( layoutDirection() == Qt::LeftToRight )
            drawSegment( p, QRect(r.x() + pos, y, len, h), col );
        else
            drawSegment( p, QRect(r.width()+ r.x()-pos-len ,y,len,h), col );
        pos += len;
    }
}
Exemple #6
0
LineEdit::LineEdit(QWidget* parent)
    : QLineEdit(parent)
    , m_clearButton(new QToolButton(this))
{
    m_clearButton->setObjectName("clearButton");

    QIcon icon;
    QString iconNameDirected = QString("edit-clear-locationbar-").append(
                (layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr");
    icon = QIcon::fromTheme(iconNameDirected);
    if (icon.isNull()) {
        icon = QIcon::fromTheme("edit-clear");
        if (icon.isNull()) {
            icon = filePath()->icon("actions", iconNameDirected, false);
        }
    }

    m_clearButton->setIcon(icon);
    m_clearButton->setCursor(Qt::ArrowCursor);
    m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    m_clearButton->hide();
    connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateCloseButton(QString)));
    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    setStyleSheet(QString("QLineEdit { padding-right: %1px; } ")
                  .arg(m_clearButton->sizeHint().width() + frameWidth + 1));
    QSize msz = minimumSizeHint();
    setMinimumSize(qMax(msz.width(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2),
                   qMax(msz.height(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
void KonqCombo::paintEvent( QPaintEvent *pe )
{
    QComboBox::paintEvent( pe );

    QLineEdit *edit = lineEdit();

    QStyleOptionComboBox comboOpt;
    getStyleOption(&comboOpt);
    QRect re = style()->subControlRect( QStyle::CC_ComboBox, &comboOpt,
                                        QStyle::SC_ComboBoxEditField, this );
    re = QStyle::visualRect(layoutDirection(), rect(), re);

    if (m_pageSecurity!= KonqMainWindow::NotCrypted) {
        QPainter p( this );
        p.setClipRect( re );

        QPixmap pix = SmallIcon(QLatin1String(m_pageSecurity == KonqMainWindow::Encrypted ? "security-high" : "security-medium"));

        QRect r = edit->geometry();
        r.setRight( re.right() - pix.width() - 2 );
        if ( r != edit->geometry() )
            edit->setGeometry( r );

        p.drawPixmap( re.right() - pix.width() -1 , re.y() + ( re.height() - pix.height() ) / 2, pix );
        p.setClipping( false );
    } else {
        QRect r = edit->geometry();
        r.setRight( re.right() );
        if ( r != edit->geometry() )
            edit->setGeometry( r );
    }
}
void KonqCombo::mousePressEvent( QMouseEvent *e )
{
    m_dragStart = QPoint(); // null QPoint

    if ( e->button() == Qt::LeftButton && !itemIcon( currentIndex()).isNull() ) {
        // check if the pixmap was clicked
        int x = e->pos().x();
        QStyleOptionComboBox comboOpt;
        getStyleOption(&comboOpt);
        int x0 = QStyle::visualRect( layoutDirection(), rect(),
            style()->subControlRect( QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxEditField,
                                     this ) ).x();

        if ( x > x0 + 2 && x < lineEdit()->x() ) {
            m_dragStart = e->pos();
            return; // don't call KComboBox::mousePressEvent!
        }
    }

    QStyleOptionComboBox optCombo;
    optCombo.initFrom(this);
    if ( e->button() == Qt::LeftButton && m_pageSecurity != KonqMainWindow::NotCrypted &&
         style()->subElementRect( QStyle::SE_ComboBoxFocusRect, &optCombo, this ).contains( e->pos() ) )
        emit showPageSecurity();

    KComboBox::mousePressEvent( e );
}
SqueezedTextLabel::SqueezedTextLabel(QWidget *p)
    : QLabel(p) {
    bool rtl = Qt::RightToLeft == layoutDirection();

    setTextElideMode(rtl ? Qt::ElideLeft : Qt::ElideRight);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
void MainWindow::switchLayoutDirection()
{
    if (layoutDirection() == Qt::LeftToRight)
        qApp->setLayoutDirection(Qt::RightToLeft);
    else
        qApp->setLayoutDirection(Qt::LeftToRight);
}
Exemple #11
0
void pLineEdit::paintEvent( QPaintEvent* event )
{
	QLineEdit::paintEvent( event );
	
	if ( !mPromptText.isEmpty() && text().isEmpty() && isEnabled() ) {
		QStyleOptionFrameV3 option;
		initStyleOption( &option );
		
		int left;
		int top;
		int right;
		int bottom;
		
		getTextMargins( &left, &top, &right, &bottom );
		
		const Qt::Alignment va = style()->visualAlignment( layoutDirection(), alignment() );
		const QRect rect = style()->subElementRect( QStyle::SE_LineEditContents, &option, this ).adjusted( 2, 0, 0, 0 ).adjusted( left, top, -right, -bottom );
		const QFontMetrics fm( font() );
		const QString text = fm.elidedText( mPromptText, Qt::ElideRight, rect.width() );
		QPainter painter( this );
		
		painter.setPen( palette().color( QPalette::Disabled, QPalette::Text ) );
		painter.drawText( rect, va, text );
	}
}
void MainWindow::switchLayoutDirection()
{
    if (layoutDirection() == Qt::LeftToRight)
        QApplication::setLayoutDirection(Qt::RightToLeft);
    else
        QApplication::setLayoutDirection(Qt::LeftToRight);
}
void FancyLineEdit::setSide(Side side)
{
    m_d->m_side = side;

    Side iconpos = side;
    if (layoutDirection() == Qt::RightToLeft)
        iconpos = (side == Left ? Right : Left);

    // Make room for icon

    // Let the style determine minimum height for our widget
    QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2);

    // Note KDE does not reserve space for the highlight color
    if (style()->inherits("OxygenStyle")) {
        size = size.expandedTo(QSize(24, 0));
    }

    QMargins margins;
    if (iconpos == Right)
        margins.setRight(size.width());
    else
        margins.setLeft(size.width());

    setTextMargins(margins);
}
Exemple #14
0
void GraphLegend::paintEvent( QPaintEvent *)
{
    QPainter p(this);

    int total = 0;
    for ( int i = 0; i < data->count(); i++ )
        total += data->value(i);

    int tw = width()/data->count()-1;
    int th = height()/(horz ? 1 : data->count());
    if ( th > p.fontMetrics().height() )
        th = p.fontMetrics().height();
    int x = 0;
    int y = 0;
    for ( int i = 0; i < data->count(); i++ ) {
        QColor col;
        col.setHsv( i * 360 / data->count(), 255, 255 );

        p.setBrush( col );
        if ( layoutDirection() == Qt::LeftToRight ) {
            p.drawRect( x+1, y+1, th - 2, th - 2 );
            p.drawText( x+th + 1, y + p.fontMetrics().ascent()+1, data->name(i) );
        } else {
            p.drawRect( width()-(th-2)-1, y+1, th-2, th-2 );
            p.drawText( x+1, y + 1,
                    width()-(th-2)-3, p.fontMetrics().ascent()+1,
                    Qt::AlignLeft, data->name(i) );
        }
        if ( horz ) {
            x += tw;
        } else {
            y += th;
        }
    }
}
Exemple #15
0
void QVistaBackButton::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    QRect r = rect();
    HANDLE theme = pOpenThemeData(0, L"Navigation");
    //RECT rect;
    QPoint origin;
    const HDC hdc = QVistaHelper::backingStoreDC(parentWidget(), &origin);
    RECT clipRect;
    int xoffset = origin.x() + QWidget::mapToParent(r.topLeft()).x() - 1;
    int yoffset = origin.y() + QWidget::mapToParent(r.topLeft()).y() - 1;
    const int dpr = devicePixelRatio();
    const QRect rDp = QRect(r.topLeft() * dpr, r.size() * dpr);
    const int xoffsetDp = xoffset * dpr;
    const int yoffsetDp = yoffset * dpr;

    clipRect.top = rDp.top() + yoffsetDp;
    clipRect.bottom = rDp.bottom() + yoffsetDp;
    clipRect.left = rDp.left() + xoffsetDp;
    clipRect.right = rDp.right()  + xoffsetDp;

    int state = WIZ_NAV_BB_NORMAL;
    if (!isEnabled())
        state = WIZ_NAV_BB_DISABLED;
    else if (isDown())
        state = WIZ_NAV_BB_PRESSED;
    else if (underMouse())
        state = WIZ_NAV_BB_HOT;

    WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight
                                      ? WIZ_NAV_BACKBUTTON
                                      : WIZ_NAV_FORWARDBUTTON);

    pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect);
}
Exemple #16
0
// ------------------- FilterWidget
FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm)  :
    QWidget(parent),
    m_editor(new HintLineEdit(this)),
    m_button(new IconButton(m_editor)),
    m_buttonwidth(0)
{
    m_editor->setPlaceholderText(tr("Filter"));

    // Let the style determine minimum height for our widget
    QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2);

    // Note KDE does not reserve space for the highlight color
    if (style()->inherits("OxygenStyle")) {
        size = size.expandedTo(QSize(24, 0));
    }

    // Make room for clear icon
    QMargins margins = m_editor->textMargins();
    if (layoutDirection() == Qt::LeftToRight)
        margins.setRight(size.width());
    else
        margins.setLeft(size.width());

    m_editor->setTextMargins(margins);

    QHBoxLayout *l = new QHBoxLayout(this);
    l->setMargin(0);
    l->setSpacing(0);
    if (lm == LayoutAlignRight)
        l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));

    l->addWidget(m_editor);

    // KDE has custom icons for this. Notice that icon namings are counter intuitive
    // If these icons are not avaiable we use the freedesktop standard name before
    // falling back to a bundled resource
    QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ?
                     QLatin1String("edit-clear-locationbar-rtl") :
                     QLatin1String("edit-clear-locationbar-ltr"),
                     QIcon::fromTheme("edit-clear", createIconSet(QLatin1String("cleartext.png"))));

    m_button->setIcon(icon);
    m_button->setToolTip(tr("Clear text"));
    connect(m_button, SIGNAL(clicked()), this, SLOT(reset()));
    connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(checkButton(QString)));
    connect(m_editor, SIGNAL(textEdited(QString)), this, SIGNAL(filterChanged(QString)));
}
Exemple #17
0
void MarkdownEditor::resizeEvent(QResizeEvent *event)
{
    QPlainTextEdit::resizeEvent(event);

    QRect cr = contentsRect();
    lineNumberArea->setGeometry(QStyle::visualRect(layoutDirection(), cr,
                                QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())));
}
Exemple #18
0
TitleWidget::TitleWidget(QWidget *p)
    : QWidget(p)
    , controls(0)
{
    QGridLayout *layout=new QGridLayout(this);
    QVBoxLayout *textLayout=new QVBoxLayout(0);
    image=new QLabel(this);
    mainText=new SqueezedTextLabel(this);
    subText=new SqueezedTextLabel(this);
    QLabel *chevron=new QLabel(QChar(Qt::RightToLeft==layoutDirection() ? 0x203A : 0x2039), this);
    QFont f=mainText->font();
    subText->setFont(Utils::smallFont(f));
    f.setBold(true);
    mainText->setFont(f);
    if (f.pixelSize()>0) {
        f.setPixelSize(f.pixelSize()*2);
    } else {
        f.setPointSizeF(f.pointSizeF()*2);
    }
    f.setBold(false);
    chevron->setFont(f);
    int spacing=Utils::layoutSpacing(this);
    mainText->ensurePolished();
    subText->ensurePolished();
    int size=mainText->sizeHint().height()+subText->sizeHint().height()+spacing;
    if (size<72) {
        size=Icon::stdSize(size);
    }
    size=Utils::scaleForDpi(qMax(size, 48));
    image->setFixedSize(size, size);
    setToolTip(i18n("Click to go back"));
    spacing=qMin(4, spacing-1);
    layout->addItem(new QSpacerItem(spacing, spacing), 0, 0, 2, 1);
    layout->addWidget(chevron, 0, 1, 2, 1);
    layout->addWidget(image, 0, 2, 2, 1);
    textLayout->addWidget(mainText);
    textLayout->addWidget(subText);
    layout->addItem(textLayout, 0, 3, 2, 1);
    mainText->installEventFilter(this);
    subText->installEventFilter(this);
    image->installEventFilter(this);
    installEventFilter(this);
    setAttribute(Qt::WA_Hover);
    connect(Covers::self(), SIGNAL(cover(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString)));
    connect(Covers::self(), SIGNAL(coverUpdated(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString)));
    connect(Covers::self(), SIGNAL(artistImage(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString)));
    layout->setContentsMargins(1, 4, 1, 4);
    layout->setSpacing(spacing);
    textLayout->setMargin(0);
    textLayout->setSpacing(spacing);
    mainText->setAlignment(Qt::AlignBottom);
    subText->setAlignment(Qt::AlignTop);
    image->setAlignment(Qt::AlignCenter);
    chevron->setAlignment(Qt::AlignCenter);
    chevron->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
}
Exemple #19
0
void BookDock::handleLayoutDirection()
{
    if (layoutDirection() == Qt::RightToLeft) {
        m_backButton->setIcon(QPixmap(":/book_forward.png"));
        m_forwardButton->setIcon(QPixmap(":/book_back.png"));
    } else {
        m_backButton->setIcon(QPixmap(":/book_back.png"));
        m_forwardButton->setIcon(QPixmap(":/book_forward.png"));
    }
}
Exemple #20
0
void MarbleLineEdit::setDecorator(const QPixmap &decorator)
{
    d->m_decoratorPixmap = decorator;
    d->m_decoratorButton->setPixmap( d->m_decoratorPixmap );
    int const padding = 2 + d->m_decoratorPixmap.width();

    QString const prefixDirection = layoutDirection() == Qt::LeftToRight ? "left" : "right";
    QString decoratorStyleSheet;
    if ( !d->m_decoratorPixmap.isNull() ) {
        decoratorStyleSheet = QString( "; padding-%1: %2" ).arg( prefixDirection ).arg( padding );
    }
    // Padding for clear button to avoid text underflow
    QString const postfixDirection  = layoutDirection() == Qt::LeftToRight ? "right" : "left";
    QString styleSheet = QString( ":enabled { padding-%1: %2; %3}").arg( postfixDirection ).arg( padding ).arg( decoratorStyleSheet );

    if ( !MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
        setStyleSheet( styleSheet );
    }
}
Exemple #21
0
void DDateTable::paintEvent(QPaintEvent *e)
{
    QPainter p(this);
    const QRect& rectToUpdate = e->rect();
    double cellWidth          = width() / (double) d->numDayColumns;
    double cellHeight         = height() / (double) d->numWeekRows;
    int leftCol               = (int)std::floor(rectToUpdate.left() / cellWidth);
    int topRow                = (int)std::floor(rectToUpdate.top() / cellHeight);
    int rightCol              = (int)std::ceil(rectToUpdate.right() / cellWidth);
    int bottomRow             = (int)std::ceil(rectToUpdate.bottom() / cellHeight);
    bottomRow                 = qMin(bottomRow, d->numWeekRows - 1);
    rightCol                  = qMin(rightCol, d->numDayColumns - 1);

    if (layoutDirection() == Qt::RightToLeft)
    {
        p.translate((d->numDayColumns - leftCol - 1) * cellWidth, topRow * cellHeight);
    }
    else
    {
        p.translate(leftCol * cellWidth, topRow * cellHeight);
    }

    for (int i = leftCol; i <= rightCol; ++i)
    {
        for (int j = topRow; j <= bottomRow; ++j)
        {
            paintCell(&p, j, i);
            p.translate(0, cellHeight);
        }

        if (layoutDirection() == Qt::RightToLeft)
        {
            p.translate(-cellWidth, 0);
        }
        else
        {
            p.translate(cellWidth, 0);
        }

        p.translate(0, -cellHeight * (bottomRow - topRow + 1));
    }
}
Exemple #22
0
void FilterWidget::resizeEvent(QResizeEvent *)
{
    QRect contentRect = m_editor->rect();
    if (layoutDirection() == Qt::LeftToRight) {
        const int iconoffset = m_editor->textMargins().right() + 4;
        m_button->setGeometry(contentRect.adjusted(m_editor->width() - iconoffset, 0, 0, 0));
    } else {
        const int iconoffset = m_editor->textMargins().left() + 4;
        m_button->setGeometry(contentRect.adjusted(0, 0, -m_editor->width() + iconoffset, 0));
    }
}
Exemple #23
0
void AdjustingScrollArea::resizeEvent(QResizeEvent* ev)
{
    int scrollBarWidth =
        verticalScrollBar()->isVisible() ? verticalScrollBar()->sizeHint().width() : 0;

    if (layoutDirection() == Qt::RightToLeft)
        setViewportMargins(-scrollBarWidth, 0, 0, 0);

    updateGeometry();
    QScrollArea::resizeEvent(ev);
}
 void mousePressEvent(QMouseEvent *event)
 {
     int rr= event->x();
     if (layoutDirection() == Qt::LeftToRight)
         rr = viewport()->width() - event->x();
     if (rr < pixmapWidth) {
         model->removeRow(indexAt(event->pos()).row());
         return;
     }
     QListView::mousePressEvent(event);
 }
Exemple #25
0
void WSearchLineEdit::resizeEvent(QResizeEvent* e) {
    QLineEdit::resizeEvent(e);
    QSize sz = m_clearButton->sizeHint();
    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    int height = (rect().bottom() + 1 - sz.height())/2;
    if (layoutDirection() == Qt::LeftToRight) {
        m_clearButton->move(rect().right() - frameWidth - sz.width() - 1,
                            height);
    } else {
        m_clearButton->move(frameWidth + 1, height);
    }
}
Exemple #26
0
void MarbleLineEdit::updateClearButtonIcon( const QString& text )
{
    d->m_clearButton->setVisible( text.length() > 0 );
    if ( d->m_clearButton->pixmap() && !d->m_clearButton->pixmap()->isNull() ) {
        return;
    }

    QString const direction = layoutDirection() == Qt::LeftToRight ? "rtl" : "ltr";
    int const size = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ? 32 : 16;
    QPixmap pixmap = QPixmap( QString( ":/icons/%1x%1/edit-clear-locationbar-%2.png").arg( size ).arg( direction ) );
    d->m_clearButton->setPixmap( pixmap );
}
EmbeddedDialog::EmbeddedDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::EmbeddedDialog)
{
    ui->setupUi(this);
    ui->layoutDirection->setCurrentIndex(layoutDirection() != Qt::LeftToRight);

    foreach (QString styleName, QStyleFactory::keys()) {
        ui->style->addItem(styleName);
        if (style()->objectName().toLower() == styleName.toLower())
            ui->style->setCurrentIndex(ui->style->count() - 1);
    }
    SearchEdit(QWidget *parent = 0)
        : Utils::FancyLineEdit(parent)
    {
        QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ?
                         QLatin1String("edit-clear-locationbar-rtl") :
                         QLatin1String("edit-clear-locationbar-ltr"),
                         QIcon::fromTheme(QLatin1String("edit-clear"), QIcon(QLatin1String("icon:images/editclear.png"))));

        setButtonPixmap(Right, icon.pixmap(16));
        setPlaceholderText(tr("Search"));
        setButtonToolTip(Right, tr("Stop Search"));
    }
Exemple #29
0
void RoutingLineEdit::updateClearButton()
{
    const QSize geom = size();
    const int frameWidth = style()->pixelMetric( QStyle::PM_DefaultFrameWidth, 0, this );
    const int pixmapSize = d->m_clearButton->pixmap()->width();

    int y = ( geom.height() - pixmapSize ) / 2;
    if ( layoutDirection() == Qt::LeftToRight ) {
        d->m_clearButton->move( geom.width() - frameWidth - pixmapSize - 1, y );
    } else {
        d->m_clearButton->move( frameWidth + 1, y );
    }
}
Exemple #30
0
RoutingLineEdit::RoutingLineEdit( QWidget *parent ) :
        QLineEdit( parent ), d( new RoutingLineEditPrivate( this ) )
{
    updateClearButtonIcon( text() );
    updateClearButton();

    // Padding for clear button to avoid text underflow
    QString const direction = layoutDirection() == Qt::LeftToRight ? "right" : "left";
    if ( !MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
        setStyleSheet( QString( ":enabled { padding-%1: %2; }").arg( direction).arg( 18 ) );
    }

    connect( this, SIGNAL( textChanged( QString ) ), SLOT( updateClearButtonIcon( QString ) ) );
}