Sayonara Player
MiniSearcher.h
1 /* MiniSearcher.h */
2 
3 /* Copyright (C) 2011-2019 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 
37 namespace Gui
38 {
44  public QObject
45  {
46  Q_OBJECT
47 
48  signals:
49  void sig_tab_pressed();
50  void sig_focus_lost();
51 
52  public:
53  using QObject::QObject;
54 
55  protected:
56  bool eventFilter(QObject* o, QEvent* e) override;
57  };
58 
59 
60  class MiniSearcher :
61  public Gui::WidgetTemplate<QFrame>
62  {
63  Q_OBJECT
64  PIMPL(MiniSearcher)
65 
66  signals:
67  void sig_reset();
68  void sig_text_changed(const QString&);
69  void sig_find_next_row();
70  void sig_find_prev_row();
71 
72  private slots:
73  void prev_result();
74  void next_result();
75 
76  private:
77  bool is_initiator(QKeyEvent* event) const;
78  void init(const QString& text);
79  bool check_and_init(QKeyEvent* event);
80  QRect calc_geo() const;
81 
82  protected:
83  void language_changed() override;
84 
85  void keyPressEvent(QKeyEvent* e) override;
86  void showEvent(QShowEvent* e) override;
87  void hideEvent(QHideEvent* e) override;
88  void focusOutEvent(QFocusEvent* e) override;
89 
90  public:
92  virtual ~MiniSearcher();
93 
94  void handle_key_press(QKeyEvent* e);
95  void set_extra_triggers(const QMap<QChar, QString>& triggers);
96  QString current_text();
97  void set_number_results(int results);
98 
99  public slots:
100  void reset();
101  };
102 }
103 
104 #endif // MINISEARCHER_H
Definition: AbstractLibrary.h:36
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:84
The SearchViewInterface class.
Definition: SearchableView.h:68
Definition: MiniSearcher.h:60
Emits signals if tab was pressed or focus was lost.
Definition: MiniSearcher.h:43
Definition: org_mpris_media_player2_adaptor.h:21