2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2006-06-17 09:14:58 +00:00
|
|
|
* \file Action.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#ifndef ACTION_H
|
|
|
|
#define ACTION_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include <QAction>
|
2016-08-03 21:06:20 +00:00
|
|
|
#include <memory>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-15 22:43:55 +00:00
|
|
|
class QIcon;
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
2007-09-28 23:14:33 +00:00
|
|
|
|
|
|
|
class FuncRequest;
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/**
|
2006-06-17 09:14:58 +00:00
|
|
|
* Action - Qt interface with LyX' FuncRequest.
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
2006-06-17 09:14:58 +00:00
|
|
|
* Action can be used in LyX menubar and/or toolbars.
|
2006-03-05 17:24:44 +00:00
|
|
|
*/
|
2007-09-28 23:14:33 +00:00
|
|
|
class Action : public QAction
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2007-09-28 23:14:33 +00:00
|
|
|
public:
|
2016-08-03 21:06:20 +00:00
|
|
|
// Makes a copy of func
|
|
|
|
Action(FuncRequest func, QIcon const & icon, QString const & text,
|
|
|
|
QString const & tooltip, QObject * parent);
|
|
|
|
|
|
|
|
// Takes shared ownership of func.
|
|
|
|
// Use for perf-sensitive code such as populating menus.
|
|
|
|
Action(std::shared_ptr<FuncRequest const> func,
|
|
|
|
QIcon const & icon, QString const & text,
|
|
|
|
QString const & tooltip, QObject * parent);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
void update();
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/// the current action is triggered
|
|
|
|
void triggered(QAction *);
|
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
private Q_SLOTS:
|
2006-03-05 17:24:44 +00:00
|
|
|
void action();
|
|
|
|
|
|
|
|
private:
|
2016-08-03 21:06:20 +00:00
|
|
|
void init(QIcon const & icon, QString const & text, QString const & tooltip);
|
|
|
|
std::shared_ptr<FuncRequest const> func_;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#endif // ACTION_H
|