mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
4736191fa5
Before this commit, the Alt+- shortcut reduced the heights of group comboboxes in the main window and scan popup, but not their widths. These comboboxes did not become narrower than at the time of their construction. Fixing the height of a group combobox to that of a line edit in MainWindow's and ScanPopup's eventFilter() is still useful after this commit - to avoid the ugliness of a few pixels-higher combobox.
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
#ifndef __GROUPCOMBOBOX_HH_INCLUDED__
|
|
#define __GROUPCOMBOBOX_HH_INCLUDED__
|
|
|
|
#include <QComboBox>
|
|
#include <QAction>
|
|
#include <QSize>
|
|
#include "instances.hh"
|
|
|
|
/// This is a combo box which is for choosing the dictionary group
|
|
class GroupComboBox: public QComboBox
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
GroupComboBox( QWidget * parent );
|
|
|
|
/// Fills combo-box with the given groups
|
|
void fill( Instances::Groups const & );
|
|
|
|
/// Chooses the given group in the combobox. If there's no such group,
|
|
/// does nothing.
|
|
void setCurrentGroup( unsigned id );
|
|
|
|
|
|
/// Returns current group.
|
|
unsigned getCurrentGroup() const;
|
|
|
|
protected:
|
|
|
|
/// We handle shortcut events here.
|
|
virtual bool event( QEvent * event );
|
|
|
|
/// Work around the never-changing QComboBox::minimumSizeHint(), which prevents
|
|
/// reducing the width of a group combobox beyond the value at application start.
|
|
virtual QSize minimumSizeHint() const { return sizeHint(); }
|
|
|
|
private slots:
|
|
|
|
void popupGroups();
|
|
void selectNextGroup();
|
|
void selectPreviousGroup();
|
|
|
|
private:
|
|
|
|
QAction popupAction;
|
|
QAction selectNextAction, selectPreviousAction;
|
|
QMap< int, int > shortcuts;
|
|
};
|
|
|
|
#endif
|
|
|