diff --git a/interfaces/iassistant.cpp b/interfaces/iassistant.cpp index 2ff26ff086..1c3830c09d 100644 --- a/interfaces/iassistant.cpp +++ b/interfaces/iassistant.cpp @@ -1,95 +1,102 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 "iassistant.h" #include #include +#include using namespace KDevelop; Q_DECLARE_METATYPE(KSharedPtr) +// Very slow and ugly, but very secure +static QString removeHtmlFromString(QString string) +{ + return QTextEdit(string).toPlainText(); +} + KAction* KDevelop::IAssistantAction::toKAction() const { - KAction* ret = new KAction(KIcon(icon()), description(), 0); + KAction* ret = new KAction(KIcon(icon()), removeHtmlFromString(description()), 0); ret->setToolTip(toolTip()); qRegisterMetaType >("KSharedPtr()"); //Add the data as a KSharedPtr to the action, so this assistant stays alive at least as long as the KAction ret->setData(QVariant::fromValue(KSharedPtr(const_cast(this)))); connect(ret, SIGNAL(triggered(bool)), SLOT(execute()), Qt::QueuedConnection); return ret; } KDevelop::IAssistant::~IAssistant() { } KDevelop::IAssistantAction::IAssistantAction() : KSharedObject(*(QObject*)this) { } KDevelop::IAssistantAction::~IAssistantAction() { } QIcon KDevelop::IAssistantAction::icon() const { return QIcon(); } QString KDevelop::IAssistantAction::toolTip() const { return QString(); } KDevelop::IAssistant::IAssistant() : KSharedObject(*(QObject*)this) { } QIcon KDevelop::IAssistant::icon() const { return QIcon(); } QString KDevelop::IAssistant::title() const { return QString(); } void KDevelop::IAssistant::doHide() { emit hide(); } QList< KDevelop::IAssistantAction::Ptr > KDevelop::IAssistant::actions() const { return m_actions; } void KDevelop::IAssistant::addAction(KDevelop::IAssistantAction::Ptr action) { m_actions << action; } void KDevelop::IAssistant::clearActions() { m_actions.clear(); } QString KDevelop::DummyAssistantAction::description() const { return m_description; } KDevelop::DummyAssistantAction::DummyAssistantAction(QString desc) : m_description(desc) { } void KDevelop::DummyAssistantAction::execute() { } #include "iassistant.moc" diff --git a/interfaces/iassistant.h b/interfaces/iassistant.h index 9939376c5c..d3c9b30947 100644 --- a/interfaces/iassistant.h +++ b/interfaces/iassistant.h @@ -1,113 +1,115 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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. */ #ifndef KDEVELOP_IASSISTANT_H #define KDEVELOP_IASSISTANT_H #include #include #include #include "interfacesexport.h" #include class KAction; namespace KDevelop { ///Represents a single assistant action. ///Subclass it to create your own actions. class KDEVPLATFORMINTERFACES_EXPORT IAssistantAction : public QObject, public KSharedObject { Q_OBJECT public: IAssistantAction(); typedef KSharedPtr Ptr; virtual ~IAssistantAction(); ///Creates a KAction that represents this exact assistant action. ///The caller owns the action, and is responsible for deleting it. virtual KAction* toKAction() const; ///Should return a short description of the action. ///It may contain simple HTML formatting. ///Must be very short, so it nicely fits into the assistant popups. virtual QString description() const = 0; ///May return additional tooltip hover information. ///The default implementation returns an empty string. virtual QString toolTip() const; ///May return an icon for this action. ///The default implementation returns an invalid icon, which means that no icon is shown. virtual QIcon icon() const; public Q_SLOTS: ///Execute this action. virtual void execute() = 0; }; ///For testing purposes: This action just shows the given string, and does nothing on execution. class KDEVPLATFORMINTERFACES_EXPORT DummyAssistantAction : public IAssistantAction { public: DummyAssistantAction(QString desc); virtual void execute(); virtual QString description() const; private: QString m_description; }; ///Represents a single assistant popup. ///Subclass it to create your own assistants. class KDEVPLATFORMINTERFACES_EXPORT IAssistant : public QObject, public KSharedObject { Q_OBJECT public: IAssistant(); virtual ~IAssistant(); typedef KSharedPtr Ptr; ///Returns the stored list of actions, or can be overridden to return an own set. virtual QList actions() const; ///Adds the given action to the list of actions. ///Does not emit actionsChanged(), you have to do that when you're ready. virtual void addAction(IAssistantAction::Ptr action); ///Clears the stored list of actions. ///Does not emit actionsChanged(), you have to do that when you're ready. virtual void clearActions(); ///May return an icon for this assistant virtual QIcon icon() const; ///May return the title of this assistant + ///The text may be html formatted. If it can be confused with HTML, + ///use Qt::escape(..). virtual QString title() const; public Q_SLOTS: ///Emits hide(), which causes this assistant to be hidden virtual void doHide(); Q_SIGNALS: ///Can be emitted by the assistant when it should be hidden void hide(); ///Can be emitted by the assistant when its actions have changed and should be re-read void actionsChanged(); private: QList m_actions; }; } #endif // KDEVELOP_IASSISTANT_H diff --git a/language/duchain/navigation/problemnavigationcontext.cpp b/language/duchain/navigation/problemnavigationcontext.cpp index ea75b23ab5..10355bb097 100644 --- a/language/duchain/navigation/problemnavigationcontext.cpp +++ b/language/duchain/navigation/problemnavigationcontext.cpp @@ -1,94 +1,94 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 "problemnavigationcontext.h" #include #include #include #include #include #include #include #include -#include +#include using namespace KDevelop; ProblemNavigationContext::ProblemNavigationContext(ProblemPointer problem): m_problem(problem) { m_widget = 0; KSharedPtr< IAssistant > solution = problem->solutionAssistant(); if(solution) { m_widget = new QWidget; QHBoxLayout* layout = new QHBoxLayout(m_widget); - QPushButton* button = new QPushButton; + RichTextPushButton* button = new RichTextPushButton; // button->setPopupMode(QToolButton::InstantPopup); - button->setText(i18n("Solve")); + button->setHtml(i18n("Solve")); if(!solution->title().isEmpty()) - button->setText(i18n("Solve: %1", solution->title())); + button->setHtml(i18n("Solve: %1", solution->title())); QMenu* menu = new QMenu; menu->setFocusPolicy(Qt::NoFocus); foreach(IAssistantAction::Ptr action, solution->actions()) { menu->addAction(action->toKAction()); kDebug() << "adding action" << action->description(); } button->setMenu(menu); layout->addWidget(button); layout->setAlignment(button, Qt::AlignLeft); m_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); } } ProblemNavigationContext::~ProblemNavigationContext() { delete m_widget; } QWidget* ProblemNavigationContext::widget() const { return m_widget; } bool ProblemNavigationContext::isWidgetMaximized() const { return false; } QString ProblemNavigationContext::name() const { return i18n("Problem"); } QString ProblemNavigationContext::html(bool shorten) { clear(); m_shorten = shorten; modifyHtml() += "

"; modifyHtml() += i18n("Problem in %1:
", m_problem->sourceString()); modifyHtml() += Qt::escape(m_problem->description()); modifyHtml() += "
"; modifyHtml() += "" + m_problem->explanation() + ""; modifyHtml() += "

"; return currentHtml(); } diff --git a/shell/assistantpopup.cpp b/shell/assistantpopup.cpp index ea00cf3da3..4ce05b2069 100644 --- a/shell/assistantpopup.cpp +++ b/shell/assistantpopup.cpp @@ -1,81 +1,90 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 "assistantpopup.h" #include -#include #include #include #include #include +#include const int SPACING_FROM_PARENT_BOTTOM = 5; void AssistantPopup::updateActions() { QPalette palette = QApplication::palette(); palette.setBrush(QPalette::Background, palette.toolTipBase()); setPalette(palette); m_assistantActions = m_assistant->actions(); + bool haveTitle = false; if (!m_assistant->title().isEmpty()) { + haveTitle = true; QLabel* title = new QLabel("" + m_assistant->title() + ":"); title->setTextFormat(Qt::RichText); addWidget(title); } + ///@todo Add some intelligent layouting to make sure the widget doesn't become too wide foreach(KDevelop::IAssistantAction::Ptr action, m_assistantActions) + { + if(haveTitle || action != m_assistantActions.first()) + addSeparator(); addWidget(widgetForAction(action)); + } addSeparator(); addWidget(widgetForAction(KDevelop::IAssistantAction::Ptr())); resize(sizeHint()); move((parentWidget()->width() - width())/2, parentWidget()->height() - height() - SPACING_FROM_PARENT_BOTTOM); } AssistantPopup::AssistantPopup(QWidget* parent, KDevelop::IAssistant::Ptr assistant) : QToolBar(parent), m_assistant(assistant) { Q_ASSERT(assistant); setAutoFillBackground(true); updateActions(); } QWidget* AssistantPopup::widgetForAction(KDevelop::IAssistantAction::Ptr action) { - QToolButton* button = new QToolButton; + KDevelop::RichTextToolButton* button = new KDevelop::RichTextToolButton; KAction* realAction; QString buttonText; int index = m_assistantActions.indexOf(action); if(index == -1) { realAction = new KAction(button); - buttonText = "&0 - " + i18n("Hide"); + buttonText = "0 - " + i18n("Hide"); } else { realAction = action->toKAction(); - buttonText = QString("&%1 - ").arg(index+1) + action->description(); + buttonText = QString("%1 - ").arg(index+1) + action->description(); } realAction->setParent(button); connect(realAction, SIGNAL(triggered(bool)), SLOT(executeHideAction())); button->setDefaultAction(realAction); - button->setText(buttonText); + + button->setText(QString("&%1").arg(index+1)); // Let the button care about the shortcut + button->setHtml(buttonText); return button; } void AssistantPopup::executeHideAction() { m_assistant->doHide(); } KSharedPtr< KDevelop::IAssistant > AssistantPopup::assistant() const { return m_assistant; } #include "assistantpopup.moc" diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 7af253f359..e83e2f6081 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -1,74 +1,78 @@ add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9508 ) ########### next target ############### set(kdevplatformutil_LIB_SRCS + richtextpushbutton.cpp + richtexttoolbutton.cpp kdevstringhandler.cpp focusedtreeview.cpp processlinemaker.cpp commandexecutor.cpp environmentconfigurebutton.cpp environmentselectionwidget.cpp environmentgrouplist.cpp activetooltip.cpp executecompositejob.cpp ) set (kdevplatformutil_LIB_UI runoptions.ui ) add_subdirectory(duchainify) add_subdirectory(tests) kde4_add_ui_files(kdevplatformutil_LIB_SRCS ${kdevplatformutil_LIB_US}) kde4_add_library(kdevplatformutil SHARED ${kdevplatformutil_LIB_SRCS}) target_link_libraries(kdevplatformutil ${KDE4_KDEUI_LIBS} ${KDE4_KCMUTILS_LIBRARY} kdevplatforminterfaces ) # Might want to add kdevplatform* when they're exported targets target_link_libraries(kdevplatformutil LINK_INTERFACE_LIBRARIES ${KDE4_KDEUI_LIBS}) set_target_properties(kdevplatformutil PROPERTIES VERSION ${KDEVPLATFORM_LIB_VERSION} SOVERSION ${KDEVPLATFORM_LIB_SOVERSION}) install(TARGETS kdevplatformutil EXPORT KDevPlatformTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### install( FILES + richtextpushbutton.h + richtexttoolbutton.h kdevstringhandler.h ksharedobject.h focusedtreeview.h activetooltip.h processlinemaker.h commandexecutor.h utilexport.h environmentconfigurebutton.h environmentselectionwidget.h environmentgrouplist.h pushvalue.h kdevvarlengtharray.h embeddedfreetree.h executecompositejob.h convenientfreelist.h spinlock.h DESTINATION ${INCLUDE_INSTALL_DIR}/kdevplatform/util COMPONENT Devel) install( FILES google/dense_hash_map google/dense_hash_set google/sparse_hash_map google/sparse_hash_set google/sparsetable google/type_traits.h google/hash_fun.h DESTINATION ${INCLUDE_INSTALL_DIR}/kdevplatform/util/google COMPONENT Devel) install( FILES google/sparsehash/densehashtable.h google/sparsehash/sparseconfig.h google/sparsehash/sparseconfig_windows.h google/sparsehash/sparsehashtable.h DESTINATION ${INCLUDE_INSTALL_DIR}/kdevplatform/util/google/sparsehash COMPONENT Devel) diff --git a/util/richtextpushbutton.cpp b/util/richtextpushbutton.cpp new file mode 100644 index 0000000000..1d6bbe863b --- /dev/null +++ b/util/richtextpushbutton.cpp @@ -0,0 +1,128 @@ +/* + Copyright 2010 Unknown Author (Qt Centre) + Copyright 2010 David Nolden + + 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 "richtexttoolbutton.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace KDevelop; + +RichTextToolButton::RichTextToolButton(QWidget *parent) : + QToolButton(parent) +{ +} + +void RichTextToolButton::setHtml(const QString &text) +{ + htmlText = text; + isRichText = true; + + QPalette palette; + palette.setBrush(QPalette::ButtonText, Qt::transparent); + setPalette(palette); +} + +void RichTextToolButton::setText(const QString &text) +{ + isRichText = false; + QToolButton::setText(text); +} + + +QString RichTextToolButton::text() const +{ + if (isRichText) { + QTextDocument richText; + richText.setHtml(htmlText); + return richText.toPlainText(); + } else + return QToolButton::text(); +} + +QSize RichTextToolButton::sizeHint() const +{ + if(!isRichText) { + return QToolButton::sizeHint(); + } else{ + QTextDocument richTextLabel; + richTextLabel.setHtml(htmlText); + return richTextLabel.size().toSize(); + } +} + +void RichTextToolButton::paintEvent(QPaintEvent *event) +{ + if (isRichText) { + QStylePainter p(this); + + QRect buttonRect = rect(); + QPoint point; + + QTextDocument richTextLabel; + richTextLabel.setHtml(htmlText); + + QPixmap richTextPixmap(richTextLabel.size().width(), richTextLabel.size().height()); + richTextPixmap.fill(Qt::transparent); + QPainter richTextPainter(&richTextPixmap); + richTextLabel.drawContents(&richTextPainter, richTextPixmap.rect()); + + if (!icon().isNull()) + point = QPoint(buttonRect.x() + buttonRect.width() / 2 + iconSize().width() / 2 + 2, buttonRect.y() + buttonRect.height() / 2); + else + point = QPoint(buttonRect.x() + buttonRect.width() / 2 - 1, buttonRect.y() + buttonRect.height() / 2); + + buttonRect.translate(point.x() - richTextPixmap.width() / 2, point.y() - richTextPixmap.height() / 2); + + p.drawControl(QStyle::CE_PushButton, getStyleOption()); + p.drawPixmap(buttonRect.left(), buttonRect.top(), richTextPixmap.width(), richTextPixmap.height(),richTextPixmap); + } else + QToolButton::paintEvent(event); +} + +QStyleOptionButton RichTextToolButton::getStyleOption() const +{ + QStyleOptionButton opt; + + opt.initFrom(this); + opt.features = QStyleOptionButton::None; + if (menu()) + opt.features |= QStyleOptionButton::HasMenu; + if (isDown() || (menu() && menu()->isVisible())) + opt.state |= QStyle::State_Sunken; + if (isChecked()) + opt.state |= QStyle::State_On; + if (!isDown()) + { + if(opt.state & QStyle::State_MouseOver) + opt.state |= QStyle::State_Raised; + else + opt.features |= QStyleOptionButton::Flat; + } + opt.text = text(); + opt.icon = icon(); + opt.iconSize = iconSize(); + return opt; +} diff --git a/util/richtextpushbutton.h b/util/richtextpushbutton.h new file mode 100644 index 0000000000..6a91ca0c70 --- /dev/null +++ b/util/richtextpushbutton.h @@ -0,0 +1,57 @@ +/* + Copyright 2010 Unknown Author (Qt Centre) + Copyright 2010 David Nolden + + 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. +*/ + +#ifndef RICHTEXTPUSHBUTTON_H +#define RICHTEXTPUSHBUTTON_H + +#include +#include +#include +#include "utilexport.h" + +namespace KDevelop { +class KDEVPLATFORMUTIL_EXPORT RichTextPushButton : public QPushButton +{ +Q_OBJECT +public: + explicit RichTextPushButton(QWidget *parent = 0); + + void setHtml(const QString &text); + void setText(const QString &text); + QString text() const; + + virtual QSize sizeHint() const; +signals: + +public slots: + +protected: + void paintEvent(QPaintEvent *); + +private: + QString htmlText; + bool isRichText; + + QStyleOptionButton getStyleOption() const; +}; + +} + +#endif // RICHTEXTPUSHBUTTON_H diff --git a/util/richtexttoolbutton.cpp b/util/richtexttoolbutton.cpp new file mode 100644 index 0000000000..fa59879346 --- /dev/null +++ b/util/richtexttoolbutton.cpp @@ -0,0 +1,128 @@ +/* + Copyright 2010 Unknown Author (Qt Centre) + Copyright 2010 David Nolden + + 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 "richtextpushbutton.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace KDevelop; + +RichTextPushButton::RichTextPushButton(QWidget *parent) : + QPushButton(parent) +{ +} + +void RichTextPushButton::setHtml(const QString &text) +{ + htmlText = text; + isRichText = true; + + QPalette palette; + palette.setBrush(QPalette::ButtonText, Qt::transparent); + setPalette(palette); +} + +void RichTextPushButton::setText(const QString &text) +{ + isRichText = false; + QPushButton::setText(text); +} + + +QString RichTextPushButton::text() const +{ + if (isRichText) { + QTextDocument richText; + richText.setHtml(htmlText); + return richText.toPlainText(); + } else + return QPushButton::text(); +} + +QSize RichTextPushButton::sizeHint() const +{ + if(!isRichText) { + return QPushButton::sizeHint(); + } else{ + QTextDocument richTextLabel; + richTextLabel.setHtml(htmlText); + return richTextLabel.size().toSize(); + } +} + +void RichTextPushButton::paintEvent(QPaintEvent *event) +{ + if (isRichText) { + QStylePainter p(this); + + QRect buttonRect = rect(); + QPoint point; + + QTextDocument richTextLabel; + richTextLabel.setHtml(htmlText); + + QPixmap richTextPixmap(richTextLabel.size().width(), richTextLabel.size().height()); + richTextPixmap.fill(Qt::transparent); + QPainter richTextPainter(&richTextPixmap); + richTextLabel.drawContents(&richTextPainter, richTextPixmap.rect()); + + if (!icon().isNull()) + point = QPoint(buttonRect.x() + buttonRect.width() / 2 + iconSize().width() / 2 + 2, buttonRect.y() + buttonRect.height() / 2); + else + point = QPoint(buttonRect.x() + buttonRect.width() / 2 - 1, buttonRect.y() + buttonRect.height() / 2); + + buttonRect.translate(point.x() - richTextPixmap.width() / 2, point.y() - richTextPixmap.height() / 2); + + p.drawControl(QStyle::CE_PushButton, getStyleOption()); + p.drawPixmap(buttonRect.left(), buttonRect.top(), richTextPixmap.width(), richTextPixmap.height(),richTextPixmap); + } else + QPushButton::paintEvent(event); +} + +QStyleOptionButton RichTextPushButton::getStyleOption() const +{ + QStyleOptionButton opt; + opt.initFrom(this); + opt.features = QStyleOptionButton::None; + if (isFlat()) + opt.features |= QStyleOptionButton::Flat; + if (menu()) + opt.features |= QStyleOptionButton::HasMenu; + if (autoDefault() || isDefault()) + opt.features |= QStyleOptionButton::AutoDefaultButton; + if (isDefault()) + opt.features |= QStyleOptionButton::DefaultButton; + if (isDown() || (menu() && menu()->isVisible())) + opt.state |= QStyle::State_Sunken; + if (isChecked()) + opt.state |= QStyle::State_On; + if (!isFlat() && !isDown()) + opt.state |= QStyle::State_Raised; + opt.text = text(); + opt.icon = icon(); + opt.iconSize = iconSize(); + return opt; +} diff --git a/util/richtexttoolbutton.h b/util/richtexttoolbutton.h new file mode 100644 index 0000000000..51ab013c5c --- /dev/null +++ b/util/richtexttoolbutton.h @@ -0,0 +1,57 @@ +/* + Copyright 2010 Unknown Author (Qt Centre) + Copyright 2010 David Nolden + + 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. +*/ + +#ifndef RICHTEXTTOOLBUTTON_H +#define RICHTEXTTOOLBUTTON_H + +#include +#include +#include +#include "utilexport.h" + +namespace KDevelop { +class KDEVPLATFORMUTIL_EXPORT RichTextToolButton : public QToolButton +{ +Q_OBJECT +public: + explicit RichTextToolButton(QWidget *parent = 0); + + void setHtml(const QString &text); + void setText(const QString &text); + QString text() const; + + virtual QSize sizeHint() const; +signals: + +public slots: + +protected: + void paintEvent(QPaintEvent *); + +private: + QString htmlText; + bool isRichText; + + QStyleOptionButton getStyleOption() const; +}; + +} + +#endif // RICHTEXTPUSHBUTTON_H