2014-07-08 12:39:12 +02:00
|
|
|
#ifndef CSV_WIDGET_SCENETOOL_MODE_H
|
|
|
|
#define CSV_WIDGET_SCENETOOL_MODE_H
|
2013-09-28 11:27:24 +02:00
|
|
|
|
|
|
|
#include "scenetool.hpp"
|
|
|
|
|
2013-09-28 13:10:42 +02:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class QHBoxLayout;
|
2016-01-19 12:47:11 +01:00
|
|
|
class QMenu;
|
2013-09-28 13:10:42 +02:00
|
|
|
|
2014-07-08 12:39:12 +02:00
|
|
|
namespace CSVWidget
|
2013-09-28 11:27:24 +02:00
|
|
|
{
|
2013-10-07 11:14:11 +02:00
|
|
|
class SceneToolbar;
|
2014-11-06 13:26:19 +01:00
|
|
|
class ModeButton;
|
2013-10-07 11:14:11 +02:00
|
|
|
|
2013-09-28 11:27:24 +02:00
|
|
|
///< \brief Mode selector tool
|
|
|
|
class SceneToolMode : public SceneTool
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2013-09-28 13:10:42 +02:00
|
|
|
QWidget *mPanel;
|
|
|
|
QHBoxLayout *mLayout;
|
2014-11-06 13:26:19 +01:00
|
|
|
std::map<ModeButton *, std::string> mButtons; // widget, id
|
2013-10-07 11:14:11 +02:00
|
|
|
int mButtonSize;
|
2014-04-03 13:00:19 +02:00
|
|
|
int mIconSize;
|
2014-07-13 14:21:50 +02:00
|
|
|
QString mToolTip;
|
2014-07-14 14:17:27 +02:00
|
|
|
PushButton *mFirst;
|
2014-11-06 13:26:19 +01:00
|
|
|
ModeButton *mCurrent;
|
|
|
|
SceneToolbar *mToolbar;
|
2014-07-13 14:21:50 +02:00
|
|
|
|
2014-11-06 13:26:19 +01:00
|
|
|
void adjustToolTip (const ModeButton *activeMode);
|
2013-09-28 13:10:42 +02:00
|
|
|
|
2016-01-19 12:47:11 +01:00
|
|
|
virtual void contextMenuEvent (QContextMenuEvent *event);
|
|
|
|
|
2016-01-19 12:52:30 +01:00
|
|
|
/// Add context menu items to \a menu. Default-implementation: Pass on request to
|
|
|
|
/// current mode button or return false, if there is no current mode button.
|
2016-01-19 12:47:11 +01:00
|
|
|
///
|
|
|
|
/// \attention menu can be a 0-pointer
|
|
|
|
///
|
|
|
|
/// \return Have there been any menu items to be added (if menu is 0 and there
|
|
|
|
/// items to be added, the function must return true anyway.
|
|
|
|
virtual bool createContextMenu (QMenu *menu);
|
|
|
|
|
2016-03-05 11:41:42 +01:00
|
|
|
void setButton (std::map<ModeButton *, std::string>::iterator iter);
|
|
|
|
|
2013-09-28 11:27:24 +02:00
|
|
|
public:
|
|
|
|
|
2014-07-13 14:21:50 +02:00
|
|
|
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
|
2013-09-28 13:10:42 +02:00
|
|
|
|
|
|
|
virtual void showPanel (const QPoint& position);
|
|
|
|
|
2014-07-10 13:18:24 +02:00
|
|
|
void addButton (const std::string& icon, const std::string& id,
|
2014-07-13 14:21:50 +02:00
|
|
|
const QString& tooltip = "");
|
2013-09-28 13:10:42 +02:00
|
|
|
|
2014-11-07 11:11:43 +01:00
|
|
|
/// The ownership of \a button is transferred to *this.
|
|
|
|
void addButton (ModeButton *button, const std::string& id);
|
|
|
|
|
2015-09-24 15:51:16 +02:00
|
|
|
/// Will return a 0-pointer only if the mode does not have any buttons yet.
|
|
|
|
ModeButton *getCurrent();
|
|
|
|
|
2016-03-01 15:48:34 +01:00
|
|
|
/// Must not be called if there aren't any buttons yet.
|
|
|
|
std::string getCurrentId() const;
|
|
|
|
|
2016-03-05 11:41:42 +01:00
|
|
|
/// Manually change the current mode
|
|
|
|
void setButton (const std::string& id);
|
|
|
|
|
2013-09-28 13:10:42 +02:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void modeChanged (const std::string& id);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void selected();
|
2013-09-28 11:27:24 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|