Sayonara Player
Searchbar.h
1 /* SearchBar.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 LIBRARYSEARCHBAR_H
22 #define LIBRARYSEARCHBAR_H
23 
24 #include <QLineEdit>
25 #include "Utils/Pimpl.h"
26 #include "Utils/Library/Filter.h"
27 #include "Gui/Utils/Widgets/WidgetTemplate.h"
28 
29 class QMenu;
30 
31 namespace Gui
32 {
33  class ContextMenuFilter;
34 }
35 
36 namespace Library
37 {
38  class SearchBar : public Gui::WidgetTemplate<QLineEdit>
39  {
40  Q_OBJECT
41  PIMPL(SearchBar)
42 
44 
45  signals:
46  void sigCurrentModeChanged();
47 
48  public:
49  SearchBar(QWidget* parent=nullptr);
50  ~SearchBar() override;
51 
52  void setModes(const QList<Filter::Mode>& modes);
53  void setCurrentMode(Filter::Mode mode);
54 
55  void setGenre(const QString& text, bool invalidGenreMode=false);
56  Filter updateFilter(const Filter& oldFilter) const;
57 
58  private slots:
59  void currentTextChanged(const QString& text);
60  void livesearchChanged();
61  void livesearchTriggered(bool b);
62 
63  protected:
64  bool event(QEvent* event) override;
65  void keyPressEvent(QKeyEvent* keyEvent) override;
66  void languageChanged() override;
67  void skinChanged() override;
68 
69  private:
70  QList<QAction*> initModeActions(const QList<Library::Filter::Mode>& modes);
71  void initContextMenu();
72  };
73 }
74 
75 #endif // LIBRARYSEARCHBAR_H
QList
Definition: EngineUtils.h:33
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:87
Library::Filter
Definition: Filter.h:34
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31
Library::SearchBar
Definition: Searchbar.h:39