forked from mirror/openmw-tes3mp
toolbar tooltip system
This commit is contained in:
parent
67ad7d5b0e
commit
32e48edb83
4 changed files with 32 additions and 8 deletions
|
@ -4,6 +4,20 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
void CSVWidget::PushButton::setExtendedToolTip (const std::string& text)
|
||||||
|
{
|
||||||
|
std::string tooltip = text;
|
||||||
|
|
||||||
|
if (tooltip.empty())
|
||||||
|
tooltip = "(Tool tip not implemented yet)";
|
||||||
|
|
||||||
|
if (!mPush)
|
||||||
|
tooltip +=
|
||||||
|
"<p>(left click to activate,<br>shift-left click to activate and keep panel open)";
|
||||||
|
|
||||||
|
setToolTip (QString::fromUtf8 (tooltip.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event)
|
void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (event->key()!=Qt::Key_Shift)
|
if (event->key()!=Qt::Key_Shift)
|
||||||
|
@ -29,16 +43,19 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
|
||||||
QPushButton::mouseReleaseEvent (event);
|
QPushButton::mouseReleaseEvent (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, QWidget *parent)
|
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, const std::string& tooltip,
|
||||||
: QPushButton (icon, "", parent), mKeepOpen (false)
|
QWidget *parent)
|
||||||
|
: QPushButton (icon, "", parent), mKeepOpen (false), mPush (push)
|
||||||
{
|
{
|
||||||
setCheckable (!push);
|
setCheckable (!push);
|
||||||
|
setExtendedToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWidget::PushButton::PushButton (bool push, QWidget *parent)
|
CSVWidget::PushButton::PushButton (bool push, const std::string& tooltip, QWidget *parent)
|
||||||
: QPushButton (parent), mKeepOpen (false)
|
: QPushButton (parent), mKeepOpen (false), mPush (push)
|
||||||
{
|
{
|
||||||
setCheckable (!push);
|
setCheckable (!push);
|
||||||
|
setExtendedToolTip (tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVWidget::PushButton::hasKeepOpen() const
|
bool CSVWidget::PushButton::hasKeepOpen() const
|
||||||
|
|
|
@ -10,6 +10,11 @@ namespace CSVWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
bool mKeepOpen;
|
bool mKeepOpen;
|
||||||
|
bool mPush;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void setExtendedToolTip (const std::string& text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -22,10 +27,12 @@ namespace CSVWidget
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// \param push Do not maintain a toggle state
|
/// \param push Do not maintain a toggle state
|
||||||
PushButton (const QIcon& icon, bool push = false, QWidget *parent = 0);
|
PushButton (const QIcon& icon, bool push = false, const std::string& tooltip = "",
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
/// \param push Do not maintain a toggle state
|
/// \param push Do not maintain a toggle state
|
||||||
PushButton (bool push = false, QWidget *parent = 0);
|
PushButton (bool push = false, const std::string& tooltip = "",
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
bool hasKeepOpen() const;
|
bool hasKeepOpen() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
#include "scenetoolbar.hpp"
|
||||||
|
|
||||||
CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, parent)
|
CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, "", parent)
|
||||||
{
|
{
|
||||||
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
setIconSize (QSize (parent->getIconSize(), parent->getIconSize()));
|
setIconSize (QSize (parent->getIconSize(), parent->getIconSize()));
|
||||||
|
|
|
@ -31,7 +31,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position)
|
||||||
|
|
||||||
void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id)
|
void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id)
|
||||||
{
|
{
|
||||||
PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, mPanel);
|
PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, "", mPanel);
|
||||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
button->setIconSize (QSize (mIconSize, mIconSize));
|
button->setIconSize (QSize (mIconSize, mIconSize));
|
||||||
button->setFixedSize (mButtonSize, mButtonSize);
|
button->setFixedSize (mButtonSize, mButtonSize);
|
||||||
|
|
Loading…
Reference in a new issue