2024-11-07 03:53:04 +00:00
|
|
|
#pragma once
|
2009-09-21 17:50:03 +00:00
|
|
|
|
|
|
|
#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>
|
2023-04-17 20:55:34 +00:00
|
|
|
#include "dict/dictionary.hh"
|
2009-09-21 17:50:03 +00:00
|
|
|
#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
|
2024-10-01 00:02:20 +00:00
|
|
|
DictionaryBar( QWidget * parent, Config::Events &, 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;
|
|
|
|
}
|
2024-09-09 18:48:33 +00:00
|
|
|
|
|
|
|
enum class IconSize {
|
|
|
|
Small,
|
|
|
|
Normal,
|
2024-09-30 04:36:27 +00:00
|
|
|
Large,
|
2024-09-09 18:48:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void setDictionaryIconSize( IconSize size );
|
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;
|
2023-08-21 13:04:04 +00:00
|
|
|
|
|
|
|
bool enterSoloMode = false;
|
2024-10-01 00:02:20 +00:00
|
|
|
|
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
|
|
|
|
2024-09-09 18:48:33 +00:00
|
|
|
QSize normalIconSize; // cache icon size set by stylesheet provided by user
|
|
|
|
|
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
|
|
|
|
2013-06-11 18:31:01 +00:00
|
|
|
void showContextMenu( QContextMenuEvent * event, bool extended = false );
|
2023-04-29 10:04:57 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void dictsPaneClicked( QString const & );
|
2009-09-21 17:50:03 +00:00
|
|
|
};
|