forked from mirror/openmw-tes3mp
replaced custom toolbutton push flag with type enum
This commit is contained in:
parent
32e48edb83
commit
61a02d8a40
4 changed files with 40 additions and 14 deletions
|
@ -11,9 +11,23 @@ void CSVWidget::PushButton::setExtendedToolTip (const std::string& 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)";
|
||||
switch (mType)
|
||||
{
|
||||
case Type_TopMode:
|
||||
|
||||
tooltip +=
|
||||
"<p>(left click to change mode)";
|
||||
|
||||
break;
|
||||
|
||||
case Type_Mode:
|
||||
|
||||
tooltip +=
|
||||
"<p>(left click to activate,"
|
||||
"<br>shift-left click to activate and keep panel open)";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
setToolTip (QString::fromUtf8 (tooltip.c_str()));
|
||||
}
|
||||
|
@ -43,18 +57,18 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
|
|||
QPushButton::mouseReleaseEvent (event);
|
||||
}
|
||||
|
||||
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, const std::string& tooltip,
|
||||
CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const std::string& tooltip,
|
||||
QWidget *parent)
|
||||
: QPushButton (icon, "", parent), mKeepOpen (false), mPush (push)
|
||||
: QPushButton (icon, "", parent), mKeepOpen (false), mType (type)
|
||||
{
|
||||
setCheckable (!push);
|
||||
setCheckable (type==Type_Mode);
|
||||
setExtendedToolTip (tooltip);
|
||||
}
|
||||
|
||||
CSVWidget::PushButton::PushButton (bool push, const std::string& tooltip, QWidget *parent)
|
||||
: QPushButton (parent), mKeepOpen (false), mPush (push)
|
||||
CSVWidget::PushButton::PushButton (Type type, const std::string& tooltip, QWidget *parent)
|
||||
: QPushButton (parent), mKeepOpen (false), mType (type)
|
||||
{
|
||||
setCheckable (!push);
|
||||
setCheckable (type==Type_Mode);
|
||||
setExtendedToolTip (tooltip);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,18 @@ namespace CSVWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum Type
|
||||
{
|
||||
Type_TopMode, // top level button for mode selector panel
|
||||
Type_Mode // mode button
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
bool mKeepOpen;
|
||||
bool mPush;
|
||||
Type mType;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -27,11 +37,11 @@ namespace CSVWidget
|
|||
public:
|
||||
|
||||
/// \param push Do not maintain a toggle state
|
||||
PushButton (const QIcon& icon, bool push = false, const std::string& tooltip = "",
|
||||
PushButton (const QIcon& icon, Type type, const std::string& tooltip = "",
|
||||
QWidget *parent = 0);
|
||||
|
||||
/// \param push Do not maintain a toggle state
|
||||
PushButton (bool push = false, const std::string& tooltip = "",
|
||||
PushButton (Type type, const std::string& tooltip = "",
|
||||
QWidget *parent = 0);
|
||||
|
||||
bool hasKeepOpen() const;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, "", parent)
|
||||
CSVWidget::SceneTool::SceneTool (SceneToolbar *parent)
|
||||
: PushButton (PushButton::Type_TopMode, "", parent)
|
||||
{
|
||||
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
setIconSize (QSize (parent->getIconSize(), parent->getIconSize()));
|
||||
|
|
|
@ -31,7 +31,8 @@ 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())), PushButton::Type_Mode,
|
||||
"", mPanel);
|
||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
button->setIconSize (QSize (mIconSize, mIconSize));
|
||||
button->setFixedSize (mButtonSize, mButtonSize);
|
||||
|
|
Loading…
Reference in a new issue