2009-09-21 17:50:03 +00:00
|
|
|
#ifndef __DICTIONARYBAR_HH_INCLUDED__
|
|
|
|
#define __DICTIONARYBAR_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QSize>
|
2009-09-23 18:44:38 +00:00
|
|
|
#include <QList>
|
2012-11-28 19:32:37 +00:00
|
|
|
#include <QString>
|
2012-12-30 14:08:54 +00:00
|
|
|
#include <QTimer>
|
2009-09-21 17:50:03 +00:00
|
|
|
#include "dictionary.hh"
|
|
|
|
#include "config.hh"
|
|
|
|
|
|
|
|
/// A bar containing dictionary icons of the currently chosen group.
|
|
|
|
/// Individual dictionaries can be toggled on and off.
|
|
|
|
class DictionaryBar: public QToolBar
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Constructs an empty dictionary bar
|
|
|
|
DictionaryBar( QWidget * parent,
|
2013-06-11 18:31:01 +00:00
|
|
|
Config::Events &, QString const & _editDictionaryCommand, unsigned short const & maxDictionaryRefsInContextMenu_ );
|
2009-09-21 17:50:03 +00:00
|
|
|
|
|
|
|
/// Sets dictionaries to be displayed in the bar. Their statuses (enabled/
|
|
|
|
/// disabled) are taken from the configuration data.
|
|
|
|
void setDictionaries( std::vector< sptr< Dictionary::Class > > const & );
|
2012-09-26 13:13:47 +00:00
|
|
|
void setMutedDictionaries( Config::MutedDictionaries * mutedDictionaries_ )
|
|
|
|
{ mutedDictionaries = mutedDictionaries_; }
|
|
|
|
Config::MutedDictionaries const * getMutedDictionaries() const
|
|
|
|
{ return mutedDictionaries; }
|
2012-11-07 15:18:56 +00:00
|
|
|
void setDictionaryIconSize( int extent );
|
2009-09-21 17:50:03 +00:00
|
|
|
|
2010-05-08 14:01:59 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
/// Signalled when the user decided to edit group the bar currently
|
|
|
|
/// shows.
|
|
|
|
void editGroupRequested();
|
2009-10-12 13:58:32 +00:00
|
|
|
|
2012-09-25 13:13:35 +00:00
|
|
|
/// Signal for show dictionary info command from context menu
|
|
|
|
void showDictionaryInfo( QString const & id );
|
2014-03-01 13:11:14 +00:00
|
|
|
|
|
|
|
/// Signal for show dictionary headwords command from context menu
|
2023-04-12 19:52:35 +00:00
|
|
|
void showDictionaryHeadwords( Dictionary::Class * dict );
|
2012-09-25 13:13:35 +00:00
|
|
|
|
2013-06-09 13:31:57 +00:00
|
|
|
/// Signal for open dictionary folder from context menu
|
|
|
|
void openDictionaryFolder( QString const & id );
|
|
|
|
|
2012-09-25 13:13:35 +00:00
|
|
|
/// Signal to close context menu
|
|
|
|
void closePopupMenu();
|
|
|
|
|
2009-09-21 17:50:03 +00:00
|
|
|
private:
|
|
|
|
|
2012-09-26 13:13:47 +00:00
|
|
|
Config::MutedDictionaries * mutedDictionaries;
|
2009-09-21 17:50:03 +00:00
|
|
|
Config::Events & configEvents;
|
2012-09-27 14:28:05 +00:00
|
|
|
Config::MutedDictionaries storedMutedSet;
|
2012-11-28 19:32:37 +00:00
|
|
|
QString editDictionaryCommand;
|
2013-06-11 18:31:01 +00:00
|
|
|
// how many dictionaries should be shown in the context menu:
|
|
|
|
unsigned short const & maxDictionaryRefsInContextMenu;
|
2012-11-28 19:32:37 +00:00
|
|
|
std::vector< sptr< Dictionary::Class > > allDictionaries;
|
2009-09-23 18:44:38 +00:00
|
|
|
/// All the actions we have added to the toolbar
|
|
|
|
QList< QAction * > dictActions;
|
2013-06-11 18:31:01 +00:00
|
|
|
QAction * maxDictionaryRefsAction;
|
2009-09-23 18:44:38 +00:00
|
|
|
|
2009-10-12 13:58:32 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void contextMenuEvent( QContextMenuEvent * event );
|
|
|
|
|
2009-09-21 17:50:03 +00:00
|
|
|
private slots:
|
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
void mutedDictionariesChanged();
|
2009-09-21 17:50:03 +00:00
|
|
|
|
|
|
|
void actionWasTriggered( QAction * );
|
2012-09-19 12:44:36 +00:00
|
|
|
|
|
|
|
void dictsPaneClicked( QString const & );
|
2013-06-11 18:31:01 +00:00
|
|
|
|
|
|
|
void showContextMenu( QContextMenuEvent * event, bool extended = false );
|
2009-09-21 17:50:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|