예제 #1
0
void Plotter::setPlotCount(int count)
{
    for (int i = 0; i < m_plotCount; ++i) {
        m_plotter->removePlot(0);
    }
    m_plotCount = count;
    Plasma::Theme* theme = Plasma::Theme::defaultTheme();
    QColor text = theme->color(Plasma::Theme::TextColor);
    QColor bg = theme->color(Plasma::Theme::BackgroundColor);
    for (int i = 0; i < m_plotCount; ++i) {
        QColor color = KColorUtils::tint(text, bg, 0.4 + ((double)i / 2.5));
        m_plotter->addPlot(color);
    }
}
예제 #2
0
파일: options.cpp 프로젝트: f0x/kcd
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);
}
예제 #3
0
void ShellRunner::createRunOptions(QWidget *parent)
{
    //TODO: for multiple runners?
    //TODO: sync palette on theme changes
    ShellConfig *configWidget = new ShellConfig(config(), parent);

    QPalette pal = configWidget->palette();
    Plasma::Theme *theme = new Plasma::Theme(this);
    pal.setColor(QPalette::Normal, QPalette::Window, theme->color(Plasma::Theme::BackgroundColor));
    pal.setColor(QPalette::Normal, QPalette::WindowText, theme->color(Plasma::Theme::TextColor));
    configWidget->setPalette(pal);

    connect(configWidget->m_ui.cbRunAsOther, SIGNAL(clicked(bool)), this, SLOT(setRunAsOtherUser(bool)));
    connect(configWidget->m_ui.cbRunInTerminal, SIGNAL(clicked(bool)), this, SLOT(setRunInTerminal(bool)));
    connect(configWidget->m_ui.leUsername, SIGNAL(textChanged(QString)), this, SLOT(setUsername(QString)));
    connect(configWidget->m_ui.lePassword, SIGNAL(textChanged(QString)), this, SLOT(setPassword(QString)));
}
예제 #4
0
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));
        }
    }
예제 #5
0
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);
}
예제 #7
0
IconModel::IconModel(QObject *parent) :
    QAbstractListModel(parent),
    m_theme(QStringLiteral("breeze"))
    , m_loading(false)
{
    m_roleNames.insert(FileName, "fileName");
    m_roleNames.insert(IconName, "iconName");
    m_roleNames.insert(Icon, "icon");
    m_roleNames.insert(FullPath, "fullPath");
    m_roleNames.insert(Category, "category");
    m_roleNames.insert(Scalable, "scalable");
    m_roleNames.insert(Sizes, "sizes");
    m_roleNames.insert(Theme, "iconTheme");
    m_roleNames.insert(Type, "type");

    connect(this, &IconModel::categoryChanged, this, &IconModel::load);
    KConfigGroup cg(KSharedConfig::openConfig("cuttlefishrc"), "CuttleFish");
    const QString themeName = cg.readEntry("theme", "default");

    Plasma::Theme theme;
//     qDebug() << "Setting Plasma theme" << themeName;
    theme.setUseGlobalSettings(false);
    theme.setThemeName(themeName); // needs to happen after setUseGlobalSettings, since that clears themeName

    QList<KPluginMetaData> themepackages = KPackage::PackageLoader::self()->listPackages(QString(), "plasma/desktoptheme");
    foreach (const KPluginMetaData &pkg, themepackages) {
        m_plasmathemes << pkg.pluginId();
    }

    m_svgIcons[QStringLiteral("amarok")] = QStringList() << "amarok";
    m_svgIcons[QStringLiteral("audio")] = QStringList() << "audio-volume-muted"
                                                        << "audio-volume-low"
                                                        << "audio-volume-medium"
                                                        << "audio-volume-high" ;

    m_svgIcons[QStringLiteral("battery")] = QStringList() << "Battery"
                                                        << "Acadapter"
                                                        << "Unavailable"
                                                        << "Fill10"
                                                        << "Fill20"
                                                        << "Fill30"
                                                        << "Fill40"
                                                        << "Fill50"
                                                        << "Fill60"
                                                        << "Fill70"
                                                        << "Fill80"
                                                        << "Fill90"
                                                        << "Fill100";
    m_svgIcons[QStringLiteral("device")] = QStringList() << "device-notfier";
    m_svgIcons[QStringLiteral("juk")] = QStringList() << "juk";
    m_svgIcons[QStringLiteral("kget")] = QStringList() << "kget";
    m_svgIcons[QStringLiteral("klippper")] = QStringList() << "klippper";
    m_svgIcons[QStringLiteral("konversation")] = QStringList() << "konversation";
    m_svgIcons[QStringLiteral("kopete")] = QStringList() << "konversation"
                                                         << "kopete-offline";
    m_svgIcons[QStringLiteral("korgac")] = QStringList() << "korgac";
    m_svgIcons[QStringLiteral("ktorrent")] = QStringList() << "ktorrent";
    m_svgIcons[QStringLiteral("kget")] = QStringList() << "kget";

    m_svgIcons[QStringLiteral("battery")] = QStringList() << "Battery"
                                                        << "Acadapter"
                                                        << "Unavailable"
                                                        << "Fill10"
                                                        << "Fill20"
                                                        << "Fill30"
                                                        << "Fill40"
                                                        << "Fill50"
                                                        << "Fill60"
                                                        << "Fill70"
                                                        << "Fill80"
                                                        << "Fill90"
                                                        << "Fill100";
    m_svgIcons[QStringLiteral("message-indicator")] = QStringList() << "normal"
                                                         << "new";

    m_svgIcons[QStringLiteral("nepomuk")] = QStringList() << "nepomuk";
    m_svgIcons[QStringLiteral("network")] = QStringList() << "network-wired-activated"
                                                        << "network-wired"
                                                        << "network-wireless-available"
                                                        << "network-wireless-disconnected"
                                                        << "flightmode-off"
                                                        << "flightmode-on"
                                                        << "network-wireless-0"
                                                        << "network-wireless-20"
                                                        << "network-wireless-25"
                                                        << "network-wireless-40"
                                                        << "network-wireless-50"
                                                        << "network-wireless-60"
                                                        << "network-wireless-75"
                                                        << "network-wireless-80"
                                                        << "network-wireless-100"
                                                        << "network-mobile-20"
                                                        << "network-mobile-40"
                                                        << "network-mobile-60"
                                                        << "network-mobile-80"
                                                        << "network-mobile-100";
    m_svgIcons[QStringLiteral("preferences")] = QStringList() << "preferences-system-bluetooth"
                                                        << "preferences-system-bluetooth-inactive"
                                                        << "preferences-desktop-texttospeach"
                                                        << "preferences-desktop-display-randr"
                                                        << "preferences-activities";
    m_svgIcons[QStringLiteral("printer")] = QStringList() << "printer";
    m_svgIcons[QStringLiteral("quassel")] = QStringList() << "quassel"
                                                        << "quassel_inactive"
                                                        << "quassel_message";
    m_svgIcons[QStringLiteral("wallet")] = QStringList() << "wallet"
                                                        << "wallet-open"
                                                        << "wallet-closed";

    m_categories = QStringList() << "all" \
        << "actions"
        << "animations"
        << "apps"
        << "categories"
        << "devices"
        << "emblems"
        << "emotes"
        << "filesystems"
        << "international"
        << "mimetypes"
        << "places"
        << "status";

    /*
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/hicolor/24x24/apps/gnome-cpu-frequency-applet.png");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/hicolor/24x24/apps/gnome-cpu-frequency-applet.png");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/hicolor/256x256/mimetypes/libreoffice-oasis-text.png");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/hicolor/scalable/places/gnome-flashback-compiz_badge-symbolic.svg");
    qDebug() << "XX: " << categoryFromPath("/home/sebas/kf5/install/share/icons/breeze/apps/preferences/preferences-desktop-peripherals.svgz");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/breeze/actions/scalable/irc-unvoice.svgz");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/breeze/actions/toolbar-small/edit-clear.svg");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/breeze/categories/scalable/preferences-desktop.svg");
    qDebug() << "XX: " << categoryFromPath("/usr/share/icons/breeze/status/im-status/user-online.svg");
    */
    load();
    //qDebug() << m_roleNames;
}
예제 #8
0
파일: flags.cpp 프로젝트: KDE/kde-workspace
void Flags::drawLabel(QPainter& painter, const QString& layoutText, bool flagShown)
{
    QFont font = painter.font();

    QRect rect = painter.window();
//	int fontSize = layoutText.length() == 2
//			? height * 7 / 10
//			: height * 5 / 10;

    int fontSize = rect.height();// * 7 /10;

    font.setPixelSize(fontSize);
    font.setWeight(QFont::DemiBold);

    QFontMetrics fm = painter.fontMetrics();
    int width = fm.width(layoutText);

    if( width > rect.width() * 2 / 3 ) {
        fontSize = round( (double)fontSize * ((double)rect.width()*2/3) / width );
    }

    int smallestReadableSize = KGlobalSettings::smallestReadableFont().pixelSize();
    if( fontSize < smallestReadableSize ) {
        fontSize = smallestReadableSize;
    }
    font.setPixelSize(fontSize);

#ifdef DONT_USE_PLASMA
    painter.setFont(font);
    painter.setPen(Qt::white);
    painter.drawText(QRect(rect).adust(1,1,0,0), Qt::AlignCenter | Qt::AlignHCenter, layoutText);
    painter.setPen(Qt::black);
    painter.drawText(rect, Qt::AlignCenter | Qt::AlignHCenter, layoutText);
#else
    // we init svg so that we get notification about theme change
    getSvg();

    Plasma::Theme theme;
    QColor textColor = flagShown ? Qt::black : theme.color(Plasma::Theme::TextColor);
    QPoint offset = QPoint(0, 0);

    auto shadowText = [&font, &textColor, &offset](QString text) {
        //don't try to paint stuff on a future null pixmap because the text is empty
        if (text.isEmpty()) {
            return QPixmap();
        }

        // Draw text
        QFontMetrics fm(font);
        QRect textRect = fm.boundingRect(text);
        QPixmap textPixmap(textRect.width(), fm.height());
        textPixmap.fill(Qt::transparent);
        QPainter p(&textPixmap);
        p.setPen(textColor);
        p.setFont(font);
        // FIXME: the center alignment here is odd: the rect should be the size needed by
        //        the text, but for some fonts and configurations this is off by a pixel or so
        //        and "centering" the text painting 'fixes' that. Need to research why
        //        this is the case and determine if we should be painting it differently here,
        //        doing soething different with the boundingRect call or if it's a problem
        //        in Qt itself
        p.drawText(textPixmap.rect(), Qt::AlignCenter, text);
        p.end();

        return textPixmap;
    };

    //    QPixmap pixmap = Plasma::PaintUtils::texturedText(layoutText, font, svg);
    QPixmap labelPixmap = shadowText(layoutText);

    int y = round((rect.height() - labelPixmap.height()) / 2.0);
    int x = round((rect.width() - labelPixmap.width()) / 2.0);
    painter.drawPixmap(QPoint(x, y), labelPixmap);
#endif
}