1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 00:45:36 +00:00
openmw/apps/opencs/view/widget/scenetoolmode.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.2 KiB
C++
Raw Normal View History

#ifndef CSV_WIDGET_SCENETOOL_MODE_H
#define CSV_WIDGET_SCENETOOL_MODE_H
2013-09-28 09:27:24 +00:00
#include "scenetool.hpp"
#include <map>
2022-10-19 17:02:00 +00:00
#include <string>
class QHBoxLayout;
class QMenu;
class QEvent;
2022-10-19 17:02:00 +00:00
class QContextMenuEvent;
class QObject;
class QPoint;
class QWidget;
namespace CSVWidget
2013-09-28 09:27:24 +00:00
{
class SceneToolbar;
class ModeButton;
2022-10-19 17:02:00 +00:00
class PushButton;
2013-09-28 09:27:24 +00:00
///< \brief Mode selector tool
class SceneToolMode : public SceneTool
{
Q_OBJECT
QWidget* mPanel;
QHBoxLayout* mLayout;
std::map<ModeButton*, std::string> mButtons; // widget, id
int mButtonSize;
2014-04-03 11:00:19 +00:00
int mIconSize;
QString mToolTip;
PushButton* mFirst;
ModeButton* mCurrent;
SceneToolbar* mToolbar;
void adjustToolTip(const ModeButton* activeMode);
void contextMenuEvent(QContextMenuEvent* event) override;
/// 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.
///
/// \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 10:41:42 +00:00
void setButton(std::map<ModeButton*, std::string>::iterator iter);
protected:
bool event(QEvent* event) override;
2022-09-22 18:26:05 +00:00
public:
SceneToolMode(SceneToolbar* parent, const QString& toolTip);
2013-09-28 09:27:24 +00:00
void showPanel(const QPoint& position) override;
void addButton(const std::string& icon, const std::string& id, const QString& tooltip = "");
/// The ownership of \a button is transferred to *this.
void addButton(ModeButton* button, const std::string& id);
2014-07-10 11:18:24 +00:00
/// Will return a 0-pointer only if the mode does not have any buttons yet.
ModeButton* getCurrent();
/// Must not be called if there aren't any buttons yet.
std::string getCurrentId() const;
/// Manually change the current mode
void setButton(const std::string& id);
2016-03-01 14:48:34 +00:00
signals:
2016-03-05 10:41:42 +00:00
void modeChanged(const std::string& id);
private slots:
void selected();
2013-09-28 09:27:24 +00:00
};
}
#endif