Sayonara Player
MiniSearcher.h
1 /* MiniSearcher.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef MINISEARCHER_H
22 #define MINISEARCHER_H
23 
24 #include "Utils/Pimpl.h"
25 #include "GUI/Utils/Widgets/WidgetTemplate.h"
26 
27 #include <QObject>
28 #include <QFrame>
29 #include <QMap>
30 
32 class QEvent;
33 class QKeyEvent;
34 class QFocusEvent;
35 class QHideEvent;
36 
38  public QObject
39 {
40  Q_OBJECT
41 
42 signals:
43  void sig_tab_pressed();
44  void sig_focus_lost();
45 
46 public:
47  using QObject::QObject;
48 
49 protected:
50  bool eventFilter(QObject* o, QEvent* e) override;
51 };
52 
53 
54 class MiniSearcher :
55  public Gui::WidgetTemplate<QFrame>
56 {
57  Q_OBJECT
58  PIMPL(MiniSearcher)
59 
60 signals:
61  void sig_reset();
62  void sig_text_changed(const QString&);
63  void sig_find_next_row();
64  void sig_find_prev_row();
65 
66 private slots:
67  void prev_result();
68  void next_result();
69 
70 private:
71  bool is_initiator(QKeyEvent* event) const;
72  void init(const QString& text);
73  bool check_and_init(QKeyEvent* event);
74  QRect calc_geo() const;
75 
76 protected:
77  void language_changed() override;
78 
79  void keyPressEvent(QKeyEvent* e) override;
80  void showEvent(QShowEvent* e) override;
81  void hideEvent(QHideEvent* e) override;
82  void focusOutEvent(QFocusEvent* e) override;
83 
84 public:
86  virtual ~MiniSearcher();
87 
88  void handle_key_press(QKeyEvent* e);
89  void set_extra_triggers(const QMap<QChar, QString>& triggers);
90  QString current_text();
91  void set_number_results(int results);
92 
93 public slots:
94  void reset();
95 };
96 
97 #endif // MINISEARCHER_H
Definition: MiniSearcher.h:54
Definition: MiniSearcher.h:37
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:78
The SearchViewInterface class.
Definition: SearchableView.h:64
Definition: org_mpris_media_player2_adaptor.h:21