diff --git a/CMakeLists.txt b/CMakeLists.txt index eccbb165c..24557886f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,7 @@ set(plasma_LIB_SRCS private/qtjolie-branch/qtjolie/serverthread.cpp #FIXME: all these must move into the qgv library + private/themedwidgetinterface.cpp widgets/iconwidget.cpp ) diff --git a/data/services/plasma.protocol b/data/services/plasma.protocol index 630216ee8..1cb84bd84 100644 --- a/data/services/plasma.protocol +++ b/data/services/plasma.protocol @@ -39,6 +39,7 @@ Description[pt]=Um protocolo para os serviços do Plasma Description[pt_BR]=Protocolo para os serviços do Plasma Description[ro]=Un protocol pentru servicii Plasma Description[ru]=Протокол для служб Plasma +Description[se]=Protokolla Plasma-bálvalusaid várás Description[sk]=Protokol pre Plasma služby Description[sr]=Протокол за плазма сервисе Description[sr@ijekavian]=Протокол за плазма сервисе diff --git a/data/servicetypes/plasma-service.desktop b/data/servicetypes/plasma-service.desktop index cfb80feb8..db21604e7 100644 --- a/data/servicetypes/plasma-service.desktop +++ b/data/servicetypes/plasma-service.desktop @@ -38,6 +38,7 @@ Comment[pt]=Serviço do Plasma Comment[pt_BR]=Serviço do Plasma Comment[ro]=Servicu Plasma Comment[ru]=Служба Plasma +Comment[se]=Plasma-bálvalus Comment[si]=ප්ලස්මා සේවා Comment[sk]=Služba Plasma Comment[sr]=Плазма сервис diff --git a/packagestructure.cpp b/packagestructure.cpp index 091fdf9ae..627b8b5b8 100644 --- a/packagestructure.cpp +++ b/packagestructure.cpp @@ -57,3 +57,5 @@ bool PackageStructure::uninstallPackage(Package *package, const QString &package } +#include "packagestructure.moc" + diff --git a/popupapplet.cpp b/popupapplet.cpp index 82d8f7bd6..27f9d1f76 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -413,7 +413,6 @@ QSizeF PopupApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) cons case Horizontal: { const int size = IconSize(KIconLoader::Panel); return QSizeF(size, size); - break; } default: break; diff --git a/private/associatedapplicationmanager.cpp b/private/associatedapplicationmanager.cpp index cf8bbe5fc..9da0fd2ce 100644 --- a/private/associatedapplicationmanager.cpp +++ b/private/associatedapplicationmanager.cpp @@ -100,9 +100,6 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const QString AssociatedApplicationManager::application(const Plasma::Applet *applet) const { return d->applicationNames.value(applet); - if (!d->applicationNames.contains(applet)) { - connect(applet, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupApplet(QObject *))); - } } void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const KUrl::List &urls) diff --git a/private/packages.cpp b/private/packages.cpp index 1762cdd74..7bcfcd787 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -22,6 +22,7 @@ #include #include // FLT_MAX +#include #include #include diff --git a/private/style.cpp b/private/style.cpp index e3449f532..adfa9bdee 100644 --- a/private/style.cpp +++ b/private/style.cpp @@ -303,12 +303,13 @@ QRect Style::subControlRect(ComplexControl control, const QStyleOptionComplex *o rect.moveCenter(QPoint(option->rect.center().x(), rect.center().y())); } } - return rect; break; } default: - return rect; + break; } + return rect; + } int Style::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const diff --git a/private/themedwidgetinterface.cpp b/private/themedwidgetinterface.cpp new file mode 100644 index 000000000..399033c55 --- /dev/null +++ b/private/themedwidgetinterface.cpp @@ -0,0 +1,85 @@ +/****************************************************************************** +* Copyright 2011 by Aaron Seigo * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Library General Public * +* License as published by the Free Software Foundation; either * +* version 2 of the License, or (at your option) any later version. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * +* Library General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public License * +* along with this library; see the file COPYING.LIB. If not, write to * +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * +* Boston, MA 02110-1301, USA. * +*******************************************************************************/ + +#include "themedwidgetinterface_p.h" + +#include "theme.h" + +namespace Plasma +{ + +PaletteHelper *PaletteHelper::s_paletteHelper = 0; + +PaletteHelper::PaletteHelper() + : QObject() +{ + generatePalettes(); + connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(generatePalettes())); + connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(generatePalettes())); +} + +PaletteHelper *PaletteHelper::self() +{ + if (!s_paletteHelper) { + s_paletteHelper = new PaletteHelper; + } + + return s_paletteHelper; +} + +void PaletteHelper::generatePalettes() +{ + Theme *theme = Theme::defaultTheme(); + + QColor color = theme->color(Theme::TextColor); + palette = qApp->palette(); + palette.setColor(QPalette::Normal, QPalette::WindowText, color); + palette.setColor(QPalette::Inactive, QPalette::WindowText, color); + + palette.setColor(QPalette::Normal, QPalette::Link, theme->color(Theme::LinkColor)); + palette.setColor(QPalette::Normal, QPalette::LinkVisited, theme->color(Theme::VisitedLinkColor)); + + qreal alpha = color.alphaF(); + color.setAlphaF(0.6); + palette.setColor(QPalette::Disabled, QPalette::WindowText, color); + color.setAlphaF(alpha); + + palette.setColor(QPalette::Normal, QPalette::Text, color); + palette.setColor(QPalette::Inactive, QPalette::Text, color); + + const QColor buttonColor = Theme::defaultTheme()->color(Theme::ButtonTextColor); + palette.setColor(QPalette::Normal, QPalette::ButtonText, buttonColor); + palette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonColor); + + //FIXME: hardcoded colors .. looks incorrect + palette.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); + palette.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); + + buttonPalette = palette; + buttonPalette.setColor(QPalette::Normal, QPalette::Text, buttonColor); + buttonPalette.setColor(QPalette::Inactive, QPalette::Text, buttonColor); + + emit palettesUpdated(); +} + + +} // namespace Plasma + +#include "themedwidgetinterface_p.moc" + diff --git a/private/themedwidgetinterface_p.h b/private/themedwidgetinterface_p.h index 624e2f7cb..ac2eeec3b 100644 --- a/private/themedwidgetinterface_p.h +++ b/private/themedwidgetinterface_p.h @@ -28,6 +28,28 @@ namespace Plasma { +class PaletteHelper : public QObject +{ + Q_OBJECT +public: + static PaletteHelper *self(); + +public Q_SLOTS: + void generatePalettes(); + +Q_SIGNALS: + void palettesUpdated(); + +public: + QPalette palette; + QPalette buttonPalette; + +private: + PaletteHelper(); + static PaletteHelper *s_paletteHelper; +}; + + template class ThemedWidgetInterface { @@ -36,10 +58,10 @@ public: : q(publicClass), customPalette(false), customFont(false), - buttonColorForText(false) + buttonColorForText(false), + internalPaletteChange(false) { - QObject::connect(Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(setPalette())); - QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(setPalette())); + QObject::connect(PaletteHelper::self(), SIGNAL(palettesUpdated()), q, SLOT(setPalette())); } void initTheming() @@ -52,33 +74,10 @@ public: void setPalette() { if (!customPalette) { - QColor color = Theme::defaultTheme()->color(Theme::TextColor); - QPalette p = q->palette(); - p.setColor(QPalette::Normal, QPalette::WindowText, color); - p.setColor(QPalette::Inactive, QPalette::WindowText, color); - - p.setColor(QPalette::Normal, QPalette::Link, Theme::defaultTheme()->color(Theme::LinkColor)); - p.setColor(QPalette::Normal, QPalette::LinkVisited, Theme::defaultTheme()->color(Theme::VisitedLinkColor)); - - - qreal alpha = color.alphaF(); - color.setAlphaF(0.6); - p.setColor(QPalette::Disabled, QPalette::WindowText, color); - color.setAlphaF(alpha); - - const QColor buttonColor = Theme::defaultTheme()->color(Theme::ButtonTextColor); - p.setColor(QPalette::Normal, QPalette::Text, buttonColorForText ? buttonColor : color); - p.setColor(QPalette::Inactive, QPalette::Text, buttonColorForText ? buttonColor : color); - - p.setColor(QPalette::Normal, QPalette::ButtonText, buttonColor); - p.setColor(QPalette::Inactive, QPalette::ButtonText, buttonColor); - - //FIXME: hardcoded colors .. looks incorrect - p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); - p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); - - q->setPalette(p); - customPalette = false; + internalPaletteChange = true; + q->setPalette((buttonColorForText ? PaletteHelper::self()->buttonPalette + : PaletteHelper::self()->palette)); + internalPaletteChange = false; } if (!customFont) { @@ -95,7 +94,10 @@ public: break; case QEvent::PaletteChange: - customPalette = true; + if (!internalPaletteChange && + q->palette() != (buttonColorForText ? PaletteHelper::self()->buttonPalette : PaletteHelper::self()->palette)) { + customPalette = true; + } break; default: @@ -103,6 +105,13 @@ public: } } + void setWidget(QWidget *widget) + { + internalPaletteChange = true; + q->setWidget(widget); + internalPaletteChange = false; + } + void event(QEvent *event) { if (event->type() == QEvent::Show) { @@ -114,6 +123,7 @@ public: bool customPalette : 1; bool customFont : 1; bool buttonColorForText : 1; + bool internalPaletteChange : 1; }; } // namespace Plasma diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index 00cce9da5..e5839a498 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -248,6 +248,11 @@ void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &d //look if the data prefers aother graphicswidget, otherwise use the one used as event catcher QGraphicsWidget *referenceWidget = data.graphicsWidget() ? data.graphicsWidget() : widget; Corona *corona = qobject_cast(referenceWidget->scene()); + if (!corona) { + // fallback to the corona we were given + corona = m_corona; + } + if (corona) { d->tipWidget->moveTo(corona->popupPosition(referenceWidget, d->tipWidget->size(), Qt::AlignCenter)); } @@ -403,6 +408,11 @@ void ToolTipManagerPrivate::showToolTip() tipWidget->prepareShowing(); QGraphicsWidget *referenceWidget = tooltip.value().graphicsWidget() ? tooltip.value().graphicsWidget() : currentWidget; Corona *corona = qobject_cast(referenceWidget->scene()); + if (!corona) { + // fallback to the corona we were given + corona = q->m_corona; + } + if (corona) { tipWidget->moveTo(corona->popupPosition(referenceWidget, tipWidget->size(), Qt::AlignCenter)); } diff --git a/widgets/checkbox.cpp b/widgets/checkbox.cpp index 98a2fa5de..e37405454 100644 --- a/widgets/checkbox.cpp +++ b/widgets/checkbox.cpp @@ -87,7 +87,7 @@ CheckBox::CheckBox(QGraphicsWidget *parent) { QCheckBox *native = new QCheckBox; connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/combobox.cpp b/widgets/combobox.cpp index 48a492346..d52eb0ab7 100644 --- a/widgets/combobox.cpp +++ b/widgets/combobox.cpp @@ -166,7 +166,7 @@ void ComboBox::setNativeWidget(KComboBox *nativeWidget) connect(nativeWidget, SIGNAL(currentIndexChanged(const QString &)), this, SIGNAL(textChanged(const QString &))); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setWindowIcon(QIcon()); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/groupbox.cpp b/widgets/groupbox.cpp index 4b8379c7f..0abc2ca61 100644 --- a/widgets/groupbox.cpp +++ b/widgets/groupbox.cpp @@ -50,7 +50,7 @@ GroupBox::GroupBox(QGraphicsWidget *parent) d(new GroupBoxPrivate(this)) { QGroupBox *native = new QGroupBox; - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); d->initTheming(); diff --git a/widgets/label.cpp b/widgets/label.cpp index b73aacb57..a216c6bd7 100644 --- a/widgets/label.cpp +++ b/widgets/label.cpp @@ -105,7 +105,7 @@ Label::Label(QGraphicsWidget *parent) connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString))); connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString))); - setWidget(native); + d->setWidget(native); d->initTheming(); } diff --git a/widgets/lineedit.cpp b/widgets/lineedit.cpp index 708ef3a70..d000439bf 100644 --- a/widgets/lineedit.cpp +++ b/widgets/lineedit.cpp @@ -130,7 +130,7 @@ void LineEdit::setNativeWidget(KLineEdit *nativeWidget) nativeWidget->setWindowFlags(nativeWidget->windowFlags()|Qt::BypassGraphicsProxyWidget); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setWindowIcon(QIcon()); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/radiobutton.cpp b/widgets/radiobutton.cpp index dd9952b18..67e08288c 100644 --- a/widgets/radiobutton.cpp +++ b/widgets/radiobutton.cpp @@ -77,7 +77,7 @@ RadioButton::RadioButton(QGraphicsWidget *parent) { QRadioButton *native = new QRadioButton; connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); d->initTheming(); diff --git a/widgets/signalplotter.cpp b/widgets/signalplotter.cpp index 87df376e6..fdf3ab5d7 100644 --- a/widgets/signalplotter.cpp +++ b/widgets/signalplotter.cpp @@ -941,7 +941,7 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal qMax(prev_prev_datapoints[j], prev_prev_prev_datapoints[j]))); double current_minvalue = - qMin(datapoints[j], + qMin(datapoints[j], qMin(prev_datapoints[j], qMin(prev_prev_datapoints[j], prev_prev_prev_datapoints[j]))); diff --git a/widgets/spinbox.cpp b/widgets/spinbox.cpp index bacdabdca..9c1c3fe66 100644 --- a/widgets/spinbox.cpp +++ b/widgets/spinbox.cpp @@ -67,7 +67,7 @@ SpinBox::SpinBox(QGraphicsWidget *parent) d->focusIndicator = new FocusIndicator(this, "widgets/lineedit"); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); native->setAutoFillBackground(false); diff --git a/widgets/textbrowser.cpp b/widgets/textbrowser.cpp index 8e35ab5ce..870d570e0 100644 --- a/widgets/textbrowser.cpp +++ b/widgets/textbrowser.cpp @@ -40,7 +40,6 @@ class TextBrowserPrivate : public ThemedWidgetInterface public: TextBrowserPrivate(TextBrowser *browser) : ThemedWidgetInterface(browser), - native(0), savedMinimumHeight(0), savedMaximumHeight(QWIDGETSIZE_MAX), wasNotFixed(true) @@ -49,7 +48,8 @@ public: void setFixedHeight() { - if (native && native->document() && + KTextBrowser *native = q->nativeWidget(); + if (native->document() && q->sizePolicy().verticalPolicy() == QSizePolicy::Fixed && native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { native->document()->setTextWidth(q->size().width()); @@ -84,7 +84,7 @@ TextBrowser::TextBrowser(QGraphicsWidget *parent) connect(native, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(native, SIGNAL(textChanged()), this, SLOT(setFixedHeight())); native->setWindowIcon(QIcon()); - setWidget(native); + d->setWidget(native); d->native = native; native->setAttribute(Qt::WA_NoSystemBackground); native->setFrameShape(QFrame::NoFrame); @@ -114,12 +114,12 @@ QString TextBrowser::text() const void TextBrowser::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy) { - d->native->setHorizontalScrollBarPolicy(policy); + nativeWidget()->setHorizontalScrollBarPolicy(policy); } void TextBrowser::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy) { - d->native->setVerticalScrollBarPolicy(policy); + nativeWidget()->setVerticalScrollBarPolicy(policy); } void TextBrowser::setStyleSheet(const QString &stylesheet) @@ -173,8 +173,8 @@ void TextBrowser::resizeEvent(QGraphicsSceneResizeEvent *event) void TextBrowser::wheelEvent(QGraphicsSceneWheelEvent *event) { - if (d->native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff && - d->native->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { + if (nativeWidget()->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff && + nativeWidget()->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { event->ignore(); } else { QGraphicsProxyWidget::wheelEvent(event); diff --git a/widgets/textedit.cpp b/widgets/textedit.cpp index 633aec694..271f6cbfc 100644 --- a/widgets/textedit.cpp +++ b/widgets/textedit.cpp @@ -108,7 +108,7 @@ void TextEdit::setNativeWidget(KTextEdit *nativeWidget) connect(nativeWidget, SIGNAL(textChanged()), this, SIGNAL(textChanged())); nativeWidget->setWindowIcon(QIcon()); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); nativeWidget->setFrameShape(QFrame::NoFrame);