diff options
author | con <[email protected]> | 2009-07-16 15:57:59 +0200 |
---|---|---|
committer | con <[email protected]> | 2009-07-16 18:06:38 +0200 |
commit | bb44837d7c7e1a1ac33d029b3613252b9d4b9f58 (patch) | |
tree | e0b9be4dd979f613f8d77daaea13ce77cab743cf /src | |
parent | cb1cd84c5a61d041ed9e8c343581b7b72b470598 (diff) |
Remove usage of QToolBar from debugger tool bar.
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/utils/styledbar.cpp | 26 | ||||
-rw-r--r-- | src/libs/utils/styledbar.h | 8 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 45 |
3 files changed, 58 insertions, 21 deletions
diff --git a/src/libs/utils/styledbar.cpp b/src/libs/utils/styledbar.cpp index f647829b07c..99a86437d06 100644 --- a/src/libs/utils/styledbar.cpp +++ b/src/libs/utils/styledbar.cpp @@ -5,6 +5,7 @@ #include <QtCore/QVariant> #include <QtGui/QPainter> #include <QtGui/QPixmapCache> +#include <QtGui/QStyle> using namespace Core::Utils; @@ -27,8 +28,6 @@ bool StyledBar::isSingleRow() const void StyledBar::paintEvent(QPaintEvent *event) { - // Currently from the style - // Goal should be to migrate that into a Utils::StyledWidget class Q_UNUSED(event) QPainter painter(this); @@ -74,3 +73,26 @@ void StyledBar::paintEvent(QPaintEvent *event) QPixmapCache::insert(key, pixmap); } } + +StyledSeparator::StyledSeparator(QWidget *parent) + : QWidget(parent) +{ + setFixedWidth(10); +} + +void StyledSeparator::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + QPainter painter(this); + QRect selfRect = rect(); + + QColor separatorColor = StyleHelper::borderColor(); + separatorColor.setAlpha(100); + painter.setPen(separatorColor); + const int margin = 6; + const int offset = selfRect.width()/2; + painter.drawLine(selfRect.bottomLeft().x() + offset, + selfRect.bottomLeft().y() - margin, + selfRect.topLeft().x() + offset, + selfRect.topLeft().y() + margin); +} diff --git a/src/libs/utils/styledbar.h b/src/libs/utils/styledbar.h index 8a86fad0c19..2e8964b8f2f 100644 --- a/src/libs/utils/styledbar.h +++ b/src/libs/utils/styledbar.h @@ -18,6 +18,14 @@ protected: void paintEvent(QPaintEvent *event); }; +class QTCREATOR_UTILS_EXPORT StyledSeparator : public QWidget +{ +public: + StyledSeparator(QWidget *parent = 0); +protected: + void paintEvent(QPaintEvent *event); +}; + } // Utils } // Core diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 904e548188b..33c204355b1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -70,6 +70,7 @@ #include <texteditor/texteditorconstants.h> #include <utils/qtcassert.h> +#include <utils/styledbar.h> #include <QtCore/QDebug> #include <QtCore/QObject> @@ -162,6 +163,13 @@ static QSettings *settings() return ICore::instance()->settings(); } +static QToolButton *toolButton(QAction *action) +{ + QToolButton *button = new QToolButton; + button->setDefaultAction(action); + return button; +} + /////////////////////////////////////////////////////////////////////// // // DebugMode @@ -821,33 +829,32 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess m_debugMode->setWidget(splitter2); - QToolBar *debugToolBar = new QToolBar; + Core::Utils::StyledBar *debugToolBar = new Core::Utils::StyledBar; debugToolBar->setProperty("topBorder", true); - debugToolBar->addAction(am->command(ProjectExplorer::Constants::DEBUG)->action()); - debugToolBar->addAction(am->command(Constants::INTERRUPT)->action()); - debugToolBar->addAction(am->command(Constants::NEXT)->action()); - debugToolBar->addAction(am->command(Constants::STEP)->action()); - debugToolBar->addAction(am->command(Constants::STEPOUT)->action()); - debugToolBar->addSeparator(); - debugToolBar->addAction(am->command(Constants::STEPI)->action()); - debugToolBar->addAction(am->command(Constants::NEXTI)->action()); + QHBoxLayout *debugToolBarLayout = new QHBoxLayout(debugToolBar); + debugToolBarLayout->setMargin(0); + debugToolBarLayout->setSpacing(0); + debugToolBarLayout->addWidget(toolButton(am->command(ProjectExplorer::Constants::DEBUG)->action())); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::INTERRUPT)->action())); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::NEXT)->action())); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEP)->action())); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEPOUT)->action())); + debugToolBarLayout->addWidget(new Core::Utils::StyledSeparator); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEPI)->action())); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::NEXTI)->action())); #ifdef USE_REVERSE_DEBUGGING - debugToolBar->addSeparator(); - debugToolBar->addAction(am->command(Constants::REVERSE)->action()); + debugToolBarLayout->addWidget(new Core::Utils::StyledSeparator); + debugToolBarLayout->addWidget(toolButton(am->command(Constants::REVERSE)->action())); #endif - debugToolBar->addSeparator(); - debugToolBar->addWidget(new QLabel(tr("Threads:"))); + debugToolBarLayout->addWidget(new Core::Utils::StyledSeparator); + debugToolBarLayout->addWidget(new QLabel(tr("Threads:"))); QComboBox *threadBox = new QComboBox; threadBox->setModel(m_manager->threadsModel()); connect(threadBox, SIGNAL(activated(int)), m_manager->threadsWindow(), SIGNAL(threadSelected(int))); - debugToolBar->addWidget(threadBox); - debugToolBar->addWidget(m_manager->statusLabel()); - - QWidget *stretch = new QWidget; - stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - debugToolBar->addWidget(stretch); + debugToolBarLayout->addWidget(threadBox); + debugToolBarLayout->addWidget(m_manager->statusLabel(), 10); QBoxLayout *toolBarAddingLayout = new QVBoxLayout(centralWidget); toolBarAddingLayout->setMargin(0); |