|
|
|
@ -6,9 +6,9 @@
|
|
|
|
|
#include <QSignalMapper>
|
|
|
|
|
|
|
|
|
|
#include "scenetoolbar.hpp"
|
|
|
|
|
#include "pushbutton.hpp"
|
|
|
|
|
#include "modebutton.hpp"
|
|
|
|
|
|
|
|
|
|
void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode)
|
|
|
|
|
void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
|
|
|
|
|
{
|
|
|
|
|
QString toolTip = mToolTip;
|
|
|
|
|
|
|
|
|
@ -21,7 +21,7 @@ void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode)
|
|
|
|
|
|
|
|
|
|
CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip)
|
|
|
|
|
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()),
|
|
|
|
|
mToolTip (toolTip), mFirst (0)
|
|
|
|
|
mToolTip (toolTip), mFirst (0), mCurrent (0), mToolbar (parent)
|
|
|
|
|
{
|
|
|
|
|
mPanel = new QFrame (this, Qt::Popup);
|
|
|
|
|
|
|
|
|
@ -44,8 +44,14 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position)
|
|
|
|
|
void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id,
|
|
|
|
|
const QString& tooltip)
|
|
|
|
|
{
|
|
|
|
|
PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), PushButton::Type_Mode,
|
|
|
|
|
tooltip, mPanel);
|
|
|
|
|
ModeButton *button = new ModeButton (QIcon (QPixmap (icon.c_str())), tooltip, mPanel);
|
|
|
|
|
addButton (button, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWidget::SceneToolMode::addButton (ModeButton *button, const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
button->setParent (mPanel);
|
|
|
|
|
|
|
|
|
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
button->setIconSize (QSize (mIconSize, mIconSize));
|
|
|
|
|
button->setFixedSize (mButtonSize, mButtonSize);
|
|
|
|
@ -58,29 +64,40 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st
|
|
|
|
|
|
|
|
|
|
if (mButtons.size()==1)
|
|
|
|
|
{
|
|
|
|
|
mFirst = button;
|
|
|
|
|
mFirst = mCurrent = button;
|
|
|
|
|
setIcon (button->icon());
|
|
|
|
|
button->setChecked (true);
|
|
|
|
|
adjustToolTip (button);
|
|
|
|
|
mCurrent->activate (mToolbar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWidget::SceneToolMode::selected()
|
|
|
|
|
{
|
|
|
|
|
std::map<PushButton *, std::string>::const_iterator iter =
|
|
|
|
|
mButtons.find (dynamic_cast<PushButton *> (sender()));
|
|
|
|
|
std::map<ModeButton *, std::string>::const_iterator iter =
|
|
|
|
|
mButtons.find (dynamic_cast<ModeButton *> (sender()));
|
|
|
|
|
|
|
|
|
|
if (iter!=mButtons.end())
|
|
|
|
|
{
|
|
|
|
|
if (!iter->first->hasKeepOpen())
|
|
|
|
|
mPanel->hide();
|
|
|
|
|
|
|
|
|
|
for (std::map<PushButton *, std::string>::const_iterator iter2 = mButtons.begin();
|
|
|
|
|
for (std::map<ModeButton *, std::string>::const_iterator iter2 = mButtons.begin();
|
|
|
|
|
iter2!=mButtons.end(); ++iter2)
|
|
|
|
|
iter2->first->setChecked (iter2==iter);
|
|
|
|
|
|
|
|
|
|
setIcon (iter->first->icon());
|
|
|
|
|
adjustToolTip (iter->first);
|
|
|
|
|
|
|
|
|
|
if (mCurrent!=iter->first)
|
|
|
|
|
{
|
|
|
|
|
if (mCurrent)
|
|
|
|
|
mCurrent->deactivate (mToolbar);
|
|
|
|
|
|
|
|
|
|
mCurrent = iter->first;
|
|
|
|
|
mCurrent->activate (mToolbar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit modeChanged (iter->second);
|
|
|
|
|
}
|
|
|
|
|
}
|