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 
31 class QAbstractItemView;
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 line_edit_focus_lost();
68  void left_clicked();
69  void right_clicked();
70 
71 private:
72  bool is_initiator(QKeyEvent* event) const;
73  void init(const QString& text);
74  bool check_and_init(QKeyEvent* event);
75  QRect calc_geo() const;
76 
77 protected:
78  void language_changed() override;
79 
80  void keyPressEvent(QKeyEvent* e) override;
81 
82  void showEvent(QShowEvent* e) override;
83  void focusOutEvent(QFocusEvent* e) override;
84 
85 public:
86  MiniSearcher(QAbstractItemView* parent);
87  virtual ~MiniSearcher();
88 
89  void handle_key_press(QKeyEvent* e);
90  void set_extra_triggers(const QMap<QChar, QString>& triggers);
91  QString get_current_text();
92  void set_number_results(int results);
93  void add_tooltip_text(const QString& str);
94  void reset_tooltip();
95  void set_padding(int padding);
96 
97 public slots:
98  void reset();
99 };
100 
101 #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:47
Definition: org_mpris_media_player2_adaptor.h:21