2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file IconPalette.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.
|
|
|
|
*
|
2007-04-19 22:01:28 +00:00
|
|
|
* \author Edwin Leuven
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ICONPALETTE_H
|
|
|
|
#define ICONPALETTE_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2007-04-19 20:29:27 +00:00
|
|
|
#include <QMenu>
|
2007-04-20 07:29:02 +00:00
|
|
|
#include <QLayout>
|
2007-04-19 20:29:27 +00:00
|
|
|
#include "Action.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-06-17 17:55:36 +00:00
|
|
|
// FIXME: this can go when we move to Qt 4.3
|
|
|
|
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)
|
|
|
|
#include <QWidgetAction>
|
|
|
|
#endif
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2006-11-19 17:12:33 +00:00
|
|
|
namespace frontend {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* For holding an arbitrary set of icons.
|
|
|
|
*/
|
2007-06-17 17:55:36 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)
|
|
|
|
|
|
|
|
class IconPalette : public QWidgetAction {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
IconPalette(QWidget * parent);
|
|
|
|
void addButton(QAction *);
|
|
|
|
QWidget * createWidget(QWidget * parent);
|
|
|
|
public Q_SLOTS:
|
|
|
|
void updateParent();
|
|
|
|
void setIconSize(const QSize &);
|
|
|
|
Q_SIGNALS:
|
|
|
|
void enabled(bool);
|
|
|
|
void iconSizeChanged(const QSize &);
|
|
|
|
private:
|
|
|
|
QList<QAction *> actions_;
|
|
|
|
QSize size_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
class IconPalette : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2007-04-19 22:01:28 +00:00
|
|
|
IconPalette(QWidget * parent);
|
2007-04-19 20:29:27 +00:00
|
|
|
void addButton(QAction *);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void updateParent();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void triggered(QAction *);
|
|
|
|
void visible(bool);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent * event);
|
|
|
|
void hideEvent(QHideEvent * event);
|
|
|
|
void paintEvent(QPaintEvent * event);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
virtual void clicked(QAction *);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QGridLayout * layout_;
|
|
|
|
QList<QAction *> actions_;
|
|
|
|
};
|
|
|
|
|
2007-06-17 17:55:36 +00:00
|
|
|
#endif // QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
/**
|
|
|
|
* Popup menu for a toolbutton.
|
|
|
|
* We need this to keep track whether
|
|
|
|
* it is necessary to enable/disable
|
|
|
|
* the toolbutton
|
|
|
|
*/
|
|
|
|
class ButtonMenu : public QMenu {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ButtonMenu(const QString & title, QWidget * parent = 0 );
|
|
|
|
void add(QAction *);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void updateParent();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<QAction *> actions_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-19 17:12:33 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#endif // ICONPALETTE_H
|