Extract the styled painting of the find bar to utils widget.

This commit is contained in:
con
2009-07-15 12:38:45 +02:00
parent d476c9967e
commit db8507c4a0
16 changed files with 28 additions and 77 deletions

View File

@@ -30,7 +30,7 @@
#ifndef STYLEHELPER_H #ifndef STYLEHELPER_H
#define STYLEHELPER_H #define STYLEHELPER_H
#include "core_global.h" #include "utils_global.h"
#include <QtCore/QRect> #include <QtCore/QRect>
#include <QtGui/QPainter> #include <QtGui/QPainter>
@@ -40,7 +40,7 @@
// Helper class holding all custom color values // Helper class holding all custom color values
class CORE_EXPORT StyleHelper class QTCREATOR_UTILS_EXPORT StyleHelper
{ {
public: public:
// Height of the project explorer navigation bar // Height of the project explorer navigation bar

View File

@@ -30,7 +30,8 @@ SOURCES += reloadpromptutils.cpp \
parameteraction.cpp \ parameteraction.cpp \
treewidgetcolumnstretcher.cpp \ treewidgetcolumnstretcher.cpp \
checkablemessagebox.cpp \ checkablemessagebox.cpp \
styledbar.cpp styledbar.cpp \
stylehelper.cpp
win32 { win32 {
SOURCES += abstractprocess_win.cpp \ SOURCES += abstractprocess_win.cpp \
@@ -69,7 +70,8 @@ HEADERS += utils_global.h \
treewidgetcolumnstretcher.h \ treewidgetcolumnstretcher.h \
checkablemessagebox.h \ checkablemessagebox.h \
qtcassert.h \ qtcassert.h \
styledbar.h styledbar.h \
stylehelper.h
FORMS += filewizardpage.ui \ FORMS += filewizardpage.ui \
projectintropage.ui \ projectintropage.ui \

View File

@@ -65,7 +65,6 @@ SOURCES += mainwindow.cpp \
coreimpl.cpp \ coreimpl.cpp \
basefilewizard.cpp \ basefilewizard.cpp \
plugindialog.cpp \ plugindialog.cpp \
stylehelper.cpp \
inavigationwidgetfactory.cpp \ inavigationwidgetfactory.cpp \
navigationwidget.cpp \ navigationwidget.cpp \
manhattanstyle.cpp \ manhattanstyle.cpp \
@@ -150,7 +149,6 @@ HEADERS += mainwindow.h \
coreimpl.h \ coreimpl.h \
basefilewizard.h \ basefilewizard.h \
plugindialog.h \ plugindialog.h \
stylehelper.h \
inavigationwidgetfactory.h \ inavigationwidgetfactory.h \
navigationwidget.h \ navigationwidget.h \
manhattanstyle.h \ manhattanstyle.h \

View File

@@ -28,7 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "fancytabwidget.h" #include "fancytabwidget.h"
#include "stylehelper.h" #include <utils/stylehelper.h>
#include <QDebug> #include <QDebug>

View File

@@ -29,8 +29,8 @@
#include "generalsettings.h" #include "generalsettings.h"
#include "stylehelper.h" #include <utils/stylehelper.h>
#include "utils/qtcolorbutton.h" #include <utils/qtcolorbutton.h>
#include <utils/consoleprocess.h> #include <utils/consoleprocess.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>

View File

@@ -51,7 +51,6 @@
#include "scriptmanager_p.h" #include "scriptmanager_p.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "stylehelper.h"
#include "variablemanager.h" #include "variablemanager.h"
#include "versiondialog.h" #include "versiondialog.h"
#include "viewmanager.h" #include "viewmanager.h"
@@ -68,6 +67,7 @@
#include <coreplugin/findplaceholder.h> #include <coreplugin/findplaceholder.h>
#include <coreplugin/settingsdatabase.h> #include <coreplugin/settingsdatabase.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/stylehelper.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>

View File

@@ -29,12 +29,14 @@
#include "manhattanstyle.h" #include "manhattanstyle.h"
#include "stylehelper.h"
#include "styleanimator.h" #include "styleanimator.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QLibrary> #include <QtCore/QLibrary>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QDialog> #include <QtGui/QDialog>
@@ -56,8 +58,6 @@
#include <QtGui/QToolBar> #include <QtGui/QToolBar>
#include <QtGui/QToolButton> #include <QtGui/QToolButton>
#include <utils/qtcassert.h>
// We define a currently unused state for indicating animations // We define a currently unused state for indicating animations
#define State_Animating 0x00000040 #define State_Animating 0x00000040

View File

@@ -28,7 +28,8 @@
**************************************************************************/ **************************************************************************/
#include "minisplitter.h" #include "minisplitter.h"
#include "stylehelper.h"
#include <utils/stylehelper.h>
#include <QtGui/QPaintEvent> #include <QtGui/QPaintEvent>
#include <QtGui/QPainter> #include <QtGui/QPainter>

View File

@@ -28,7 +28,8 @@
**************************************************************************/ **************************************************************************/
#include "progresspie.h" #include "progresspie.h"
#include "stylehelper.h"
#include <utils/stylehelper.h>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QtGui/QFont> #include <QtGui/QFont>

View File

@@ -1 +1,2 @@
include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/utils/utils.pri)

View File

@@ -32,15 +32,13 @@
#include "textfindconstants.h" #include "textfindconstants.h"
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/stylehelper.h>
#include <coreplugin/findplaceholder.h> #include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/stylehelper.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/stylehelper.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QSettings> #include <QtCore/QSettings>
@@ -76,7 +74,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
{ {
//setup ui //setup ui
m_ui.setupUi(this); m_ui.setupUi(this);
setProperty("panelwidget", true);
setFocusProxy(m_ui.findEdit); setFocusProxy(m_ui.findEdit);
setProperty("topBorder", true); setProperty("topBorder", true);
m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false); m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
@@ -230,56 +227,6 @@ FindToolBar::~FindToolBar()
{ {
} }
void FindToolBar::paintEvent(QPaintEvent *event)
{
// Currently from the style
// Goal should be to migrate that into a Utils::StyledWidget class
Q_UNUSED(event)
QPainter painter(this);
QRect selfRect = rect();
QString key;
key.sprintf("mh_toolbar %d %d %d", selfRect.width(), selfRect.height(), StyleHelper::baseColor().rgb());;
QPixmap pixmap;
QPainter *p = &painter;
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(selfRect.size());
p = new QPainter(&pixmap);
selfRect = QRect(0, 0, selfRect.width(), selfRect.height());
}
// Map offset for global window gradient
QPoint offset = window()->mapToGlobal(selfRect.topLeft()) -
mapToGlobal(selfRect.topLeft());
QRect gradientSpan;
gradientSpan = QRect(offset, window()->size());
StyleHelper::horizontalGradient(p, gradientSpan, selfRect);
p->setPen(StyleHelper::borderColor());
// Note: This is a hack to determine if the
// toolbar should draw the top or bottom outline
// (needed for the find toolbar for instance)
QColor lighter(255, 255, 255, 40);
if (property("topBorder").toBool()) {
p->drawLine(selfRect.topLeft(), selfRect.topRight());
p->setPen(lighter);
p->drawLine(selfRect.topLeft() + QPoint(0, 1), selfRect.topRight() + QPoint(0, 1));
} else {
p->drawLine(selfRect.bottomLeft(), selfRect.bottomRight());
p->setPen(lighter);
p->drawLine(selfRect.topLeft(), selfRect.topRight());
}
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
painter.drawPixmap(selfRect.topLeft(), pixmap);
p->end();
delete p;
QPixmapCache::insert(key, pixmap);
}
}
bool FindToolBar::eventFilter(QObject *obj, QEvent *event) bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
{ {
if ((obj == m_ui.findEdit || obj == m_findCompleter->popup()) if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
@@ -320,7 +267,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
m_currentDocumentFind->clearFindScope(); m_currentDocumentFind->clearFindScope();
} }
} }
return QWidget::eventFilter(obj, event); return Core::Utils::StyledBar::eventFilter(obj, event);
} }
void FindToolBar::updateActions() void FindToolBar::updateActions()
@@ -596,7 +543,7 @@ bool FindToolBar::focusNextPrevChild(bool next)
else if (!next && m_ui.findEdit->hasFocus()) else if (!next && m_ui.findEdit->hasFocus())
m_ui.replaceAllButton->setFocus(Qt::TabFocusReason); m_ui.replaceAllButton->setFocus(Qt::TabFocusReason);
else else
return QWidget::focusNextPrevChild(next); return Core::Utils::StyledBar::focusNextPrevChild(next);
return true; return true;
} }

View File

@@ -34,6 +34,8 @@
#include "ifindfilter.h" #include "ifindfilter.h"
#include "currentdocumentfind.h" #include "currentdocumentfind.h"
#include <utils/styledbar.h>
#include <QtGui/QStringListModel> #include <QtGui/QStringListModel>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QToolBar> #include <QtGui/QToolBar>
@@ -44,14 +46,13 @@ namespace Internal {
class FindPlugin; class FindPlugin;
class FindToolBar : public QWidget class FindToolBar : public Core::Utils::StyledBar
{ {
Q_OBJECT Q_OBJECT
public: public:
FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind); FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind);
~FindToolBar(); ~FindToolBar();
void paintEvent(QPaintEvent *event);
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();

View File

@@ -29,7 +29,7 @@
#include "buildprogress.h" #include "buildprogress.h"
#include <coreplugin/stylehelper.h> #include <utils/stylehelper.h>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout> #include <QtGui/QHBoxLayout>

View File

@@ -30,12 +30,12 @@
#include "basefilefind.h" #include "basefilefind.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/stylehelper.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <find/textfindconstants.h> #include <find/textfindconstants.h>
#include <texteditor/itexteditor.h> #include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <utils/stylehelper.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDirIterator> #include <QtCore/QDirIterator>

View File

@@ -39,14 +39,14 @@
#include "codecselector.h" #include "codecselector.h"
#ifndef TEXTEDITOR_STANDALONE #ifndef TEXTEDITOR_STANDALONE
#include <aggregation/aggregate.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/manhattanstyle.h> #include <coreplugin/manhattanstyle.h>
#include <coreplugin/stylehelper.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <find/basetextfind.h> #include <find/basetextfind.h>
#include <utils/stylehelper.h>
#include <aggregation/aggregate.h>
#endif #endif
#include <utils/linecolumnlabel.h> #include <utils/linecolumnlabel.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>