toolbarcontextmenu.h 1.54 KB
Newer Older
1 2 3
#ifndef COREGUI_TOOLBARCONTEXTMENU_H
#define COREGUI_TOOLBARCONTEXTMENU_H

4 5
#include <kumir2-libs/widgets/actionproxy.h>
#include <kumir2-libs/extensionsystem/settings.h>
6 7 8

#include <QWidget>
#include <QSet>
9 10
class QGridLayout;
class QPushButton;
11

12 13
namespace CoreGUI
{
14 15 16

class ToolbarContextMenu : public QWidget
{
17
	Q_OBJECT
18
public:
19 20 21 22
	explicit ToolbarContextMenu(QWidget *parent = 0);
	void addProxy(QAction *proxyItem);
	void addSeparator();
	void finalize();
23

24 25 26 27 28 29
	void setSettingsObject(ExtensionSystem::SettingsPtr settings, const QString &settingsPrefix);
	void setExplicitImportNames(const QSet<QString> explicitItemNames);
	QAction *showAction() const
	{
		return showAction_;
	}
30

31 32
	void saveSettings() const;
	void loadSettings();
33

34 35 36
	static Qt::CheckState defaultVisible(const QString &objectName);
	static Qt::CheckState f2cs(float value);
	static float cs2f(Qt::CheckState state);
37

38
	bool isItemVisible(Qt::CheckState state, const QString &objectName) const;
39 40 41


protected Q_SLOTS:
42 43 44 45
	void toggleProxyButtonVisible(int iState);
	void reset();
	void showAll();
	void showMe();
46 47

protected:
48 49 50 51
	void showEvent(QShowEvent *event);
	void paintEvent(QPaintEvent *event);
	QList<QAction *> items_;
	QSet<QString> forcedItemNames_;
52

53 54 55 56 57 58 59 60 61 62 63
	QGridLayout *grid_;
	int currentRow_;
	int currentColumn_;
	QPushButton *btnClose_;
	QPushButton *btnReset_;
	QPushButton *btnShowAll_;
	ExtensionSystem::SettingsPtr settings_;
	QString settingsPrefix_;
	QSet<QString> explicitImportNames_;
	bool ignoreStateChange_;
	QAction *showAction_;
64 65 66 67 68 69

};

} // namespace CoreGUI

#endif // COREGUI_TOOLBARCONTEXTMENU_H