File indexing completed on 2024-05-05 04:49:25

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Seb Ruiz <ruiz@kde.org>                                           *
0003  * Copyright (c) 2010 Rick W. Chen <stuffcorpse@archlinux.us>                           *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef AMAROK_COMBO_BOX_H
0019 #define AMAROK_COMBO_BOX_H
0020 
0021 #include <KComboBox> //baseclass
0022 
0023 class QKeyEvent;
0024 
0025 namespace Amarok
0026 {
0027 
0028 /**
0029  * The Amarok::ComboBox class implements a few enhancements to an editable QComboBox.
0030  * Namely:
0031  *   1. Pressing the escape key clears the edit text
0032  *   2. Pressing down emits the downPressed signal
0033  *   3. Pressing enter adds the current text to the completion popup
0034  */
0035 class ComboBox : public KComboBox
0036 {
0037     Q_OBJECT
0038 
0039     public:
0040         explicit ComboBox( QWidget *parent = nullptr );
0041         ~ComboBox() override {}
0042 
0043     protected:
0044         void keyPressEvent( QKeyEvent *event ) override;
0045 
0046     Q_SIGNALS:
0047         void downPressed();
0048 };
0049 
0050 } // namespace AMAROK
0051 
0052 #endif // AMAROK_COMBO_BOX_H