mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 20:15:33 +00:00
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 <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)
|
||||
{
|
||||
if (event->key()!=Qt::Key_Shift)
|
||||
|
@ -29,16 +43,19 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
|
|||
QPushButton::mouseReleaseEvent (event);
|
||||
}
|
||||
|
||||
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, QWidget *parent)
|
||||
: QPushButton (icon, "", parent), mKeepOpen (false)
|
||||
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, const std::string& tooltip,
|
||||
QWidget *parent)
|
||||
: QPushButton (icon, "", parent), mKeepOpen (false), mPush (push)
|
||||
{
|
||||
setCheckable (!push);
|
||||
setExtendedToolTip (tooltip);
|
||||
}
|
||||
|
||||
CSVWidget::PushButton::PushButton (bool push, QWidget *parent)
|
||||
: QPushButton (parent), mKeepOpen (false)
|
||||
CSVWidget::PushButton::PushButton (bool push, const std::string& tooltip, QWidget *parent)
|
||||
: QPushButton (parent), mKeepOpen (false), mPush (push)
|
||||
{
|
||||
setCheckable (!push);
|
||||
setExtendedToolTip (tooltip);
|
||||
}
|
||||
|
||||
bool CSVWidget::PushButton::hasKeepOpen() const
|
||||
|
|
|
@ -10,6 +10,11 @@ namespace CSVWidget
|
|||
Q_OBJECT
|
||||
|
||||
bool mKeepOpen;
|
||||
bool mPush;
|
||||
|
||||
private:
|
||||
|
||||
void setExtendedToolTip (const std::string& text);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -22,10 +27,12 @@ namespace CSVWidget
|
|||
public:
|
||||
|
||||
/// \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
|
||||
PushButton (bool push = false, QWidget *parent = 0);
|
||||
PushButton (bool push = false, const std::string& tooltip = "",
|
||||
QWidget *parent = 0);
|
||||
|
||||
bool hasKeepOpen() const;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#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));
|
||||
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)
|
||||
{
|
||||
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->setIconSize (QSize (mIconSize, mIconSize));
|
||||
button->setFixedSize (mButtonSize, mButtonSize);
|
||||
|
|
Loading…
Reference in a new issue