void Options::updateAlbumTitle(QString title) { Plasma::Theme *theme = Plasma::Theme::defaultTheme(); QFont font = theme->font(Plasma::Theme::DefaultFont); QFontMetricsF fm(font); kDebug() << title; m_albumText->setText(fm.elidedText(title, Qt::ElideMiddle, m_albumText->size().width())); font.setBold(true); font.setItalic(true); font.setStretch(110); m_albumText->nativeWidget()->setFont(font); //m_albumText->setText(title); }
void MeterPrivate::setSizePolicyAndPreferredSize() { switch (meterType) { case Meter::BarMeterHorizontal: meter->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); break; case Meter::BarMeterVertical: meter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); break; case Meter::AnalogMeter: default: meter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); break; } if (image) { //set a sane preferredSize. We can't just use the svg's native size, since that way //letters get cut off if the user uses a font larger then usual. Check how many rows of //labels we have, add 1 (the progress bar), and multiply by the font height to get a //somewhat sane size height. This is not perfect but work well enough for 4.2. I suggest //we look into alternatives for 4.3. uint i = 0; uint rows = 0; qreal prevY = -1; QString labelName = "label0"; while (image->hasElement(labelName)) { if (image->elementRect(labelName).y() > prevY) { prevY = image->elementRect(labelName).y(); rows++; } i++; labelName = QString("label%0").arg(i); } Plasma::Theme *theme = Plasma::Theme::defaultTheme(); QFont font = theme->font(Plasma::Theme::DefaultFont); QFontMetrics fm(font); meter->setPreferredHeight((rows + 1) * fm.height()); } else { meter->setPreferredSize(QSizeF(30, 30)); } }
void Hdd::applyTheme(Plasma::Meter *w) { if (!w) { return; } Plasma::Theme* theme = Plasma::Theme::defaultTheme(); QColor text = theme->color(Plasma::Theme::TextColor); QColor bg = theme->color(Plasma::Theme::BackgroundColor); QColor darkerText = KColorUtils::tint(text, bg, 0.4); w->setLabelColor(0, text); w->setLabelColor(1, darkerText); w->setLabelColor(2, darkerText); QFont font = theme->font(Plasma::Theme::DefaultFont); font.setPointSize(9); w->setLabelFont(0, font); font.setPointSizeF(7.5); w->setLabelFont(1, font); w->setLabelFont(2, font); }
void EmergingPlasmoid::themeChanged() { Plasma::Theme * theme = Plasma::Theme::defaultTheme(); QColor text = theme->color(Plasma::Theme::TextColor); QColor bg = theme->color(Plasma::Theme::BackgroundColor); QColor darkerText = KColorUtils::tint(text, bg, 0.4); totalJobMeter.setLabelColor(0, text); totalJobMeter.setLabelColor(1, darkerText); currentJobMeter.setLabelColor(0, text); currentJobMeter.setLabelColor(1, darkerText); QFont font = theme->font(Plasma::Theme::DefaultFont); font.setPointSizeF(9.0); totalJobMeter.setLabelFont(0, font); currentJobMeter.setLabelFont(0, font); font.setPointSizeF(7.5); totalJobMeter.setLabelFont(1, font); currentJobMeter.setLabelFont(1, font); }