forked from qt-creator/qt-creator
Work around wrong click area of output buttons on Mac.
For some reason using push buttons in the status bar will make the clickable area of the buttons too small (half of the button isn't clickable). Using QToolButtons instead. Task-number: QTCREATORBUG-4513 Change-Id: I8b0f97552ec9b2471d570d577522b7ce5f382fb9 Reviewed-on: http://codereview.qt.nokia.com/2193 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com> Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
@@ -103,6 +103,7 @@
|
|||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QtGui/QMenuBar>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ void OutputPaneManager::init()
|
|||||||
|
|
||||||
if (outPane->priorityInStatusBar() != -1) {
|
if (outPane->priorityInStatusBar() != -1) {
|
||||||
cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
|
cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
|
||||||
QPushButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
|
QToolButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
|
||||||
cmd->action());
|
cmd->action());
|
||||||
++shortcutNumber;
|
++shortcutNumber;
|
||||||
m_buttonsWidget->layout()->addWidget(button);
|
m_buttonsWidget->layout()->addWidget(button);
|
||||||
@@ -339,8 +339,8 @@ void OutputPaneManager::slotMinMax()
|
|||||||
|
|
||||||
void OutputPaneManager::buttonTriggered()
|
void OutputPaneManager::buttonTriggered()
|
||||||
{
|
{
|
||||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
QToolButton *button = qobject_cast<QToolButton *>(sender());
|
||||||
QMap<int, QPushButton *>::const_iterator it, end;
|
QMap<int, QToolButton *>::const_iterator it, end;
|
||||||
end = m_buttons.constEnd();
|
end = m_buttons.constEnd();
|
||||||
for (it = m_buttons.begin(); it != end; ++it) {
|
for (it = m_buttons.begin(); it != end; ++it) {
|
||||||
if (it.value() == button)
|
if (it.value() == button)
|
||||||
@@ -514,22 +514,24 @@ void OutputPaneManager::clearPage()
|
|||||||
|
|
||||||
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
||||||
QAction *action, QWidget *parent)
|
QAction *action, QWidget *parent)
|
||||||
: QPushButton(parent)
|
: QToolButton(parent)
|
||||||
, m_number(QString::number(number))
|
, m_number(QString::number(number))
|
||||||
, m_text(text)
|
, m_text(text)
|
||||||
, m_action(action)
|
, m_action(action)
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
setCheckable(true);
|
setCheckable(true);
|
||||||
|
QFont fnt = QApplication::font();
|
||||||
|
setFont(fnt);
|
||||||
setStyleSheet(
|
setStyleSheet(
|
||||||
"QPushButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
"QToolButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
||||||
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
||||||
"QPushButton:checked { border-image: url(:/core/images/panel_button_checked.png) 2 2 2 19 } "
|
"QToolButton:checked { border-image: url(:/core/images/panel_button_checked.png) 2 2 2 19 } "
|
||||||
"QPushButton::menu-indicator { width:0; height:0 }"
|
"QToolButton::menu-indicator { width:0; height:0 }"
|
||||||
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
||||||
"QPushButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
"QToolButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
||||||
"QPushButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
"QToolButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
||||||
"QPushButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } "
|
"QToolButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } "
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (m_action)
|
if (m_action)
|
||||||
@@ -558,7 +560,7 @@ QSize OutputPaneToggleButton::sizeHint() const
|
|||||||
void OutputPaneToggleButton::paintEvent(QPaintEvent *event)
|
void OutputPaneToggleButton::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
// For drawing the style sheet stuff
|
// For drawing the style sheet stuff
|
||||||
QPushButton::paintEvent(event);
|
QToolButton::paintEvent(event);
|
||||||
|
|
||||||
const QFontMetrics fm = fontMetrics();
|
const QFontMetrics fm = fontMetrics();
|
||||||
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
||||||
|
|||||||
@@ -34,12 +34,11 @@
|
|||||||
#define OUTPUTPANEMANAGER_H
|
#define OUTPUTPANEMANAGER_H
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QToolButton;
|
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -118,14 +117,14 @@ private:
|
|||||||
QStackedWidget *m_outputWidgetPane;
|
QStackedWidget *m_outputWidgetPane;
|
||||||
QStackedWidget *m_opToolBarWidgets;
|
QStackedWidget *m_opToolBarWidgets;
|
||||||
QWidget *m_buttonsWidget;
|
QWidget *m_buttonsWidget;
|
||||||
QMap<int, QPushButton *> m_buttons;
|
QMap<int, QToolButton *> m_buttons;
|
||||||
QMap<QAction *, int> m_actions;
|
QMap<QAction *, int> m_actions;
|
||||||
QPixmap m_minimizeIcon;
|
QPixmap m_minimizeIcon;
|
||||||
QPixmap m_maximizeIcon;
|
QPixmap m_maximizeIcon;
|
||||||
bool m_maximised;
|
bool m_maximised;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OutputPaneToggleButton : public QPushButton
|
class OutputPaneToggleButton : public QToolButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user