LMMS
Loading...
Searching...
No Matches
ComboBox.h
Go to the documentation of this file.
1/*
2 * ComboBox.h - class ComboBox, a combo box view for models
3 *
4 * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_GUI_COMBOBOX_H
26#define LMMS_GUI_COMBOBOX_H
27
28#include <QMenu>
29#include <QWidget>
30
31#include "ComboBoxModel.h"
33
34namespace lmms::gui
35{
36
37class LMMS_EXPORT ComboBox : public QWidget, public IntModelView
38{
39 Q_OBJECT
40public:
41 ComboBox( QWidget* parent = nullptr, const QString& name = QString() );
42 ~ComboBox() override = default;
43
45 {
47 }
48
49 const ComboBoxModel* model() const
50 {
52 }
53
54 static constexpr int DEFAULT_HEIGHT = 22;
55
56public slots:
57 void selectNext();
58 void selectPrevious();
59
60
61protected:
62 void contextMenuEvent( QContextMenuEvent* event ) override;
63 void mousePressEvent( QMouseEvent* event ) override;
64 void paintEvent( QPaintEvent* event ) override;
65 void wheelEvent( QWheelEvent* event ) override;
66
67
68private:
69 QPixmap m_background = embed::getIconPixmap("combobox_bg");
70 QPixmap m_arrow = embed::getIconPixmap("combobox_arrow");
71 QPixmap m_arrowSelected = embed::getIconPixmap("combobox_arrow_selected");
72
73 QMenu m_menu;
74
76
77
78private slots:
79 void setItem( QAction* item );
80
81} ;
82
83} // namespace lmms::gui
84
85#endif // LMMS_GUI_COMBOBOX_H
Definition ComboBoxModel.h:39
void mousePressEvent(QMouseEvent *event) override
Definition ComboBox.cpp:96
~ComboBox() override=default
void selectPrevious()
Definition ComboBox.cpp:73
QMenu m_menu
Definition ComboBox.h:73
ComboBoxModel * model()
Definition ComboBox.h:44
void contextMenuEvent(QContextMenuEvent *event) override
Definition ComboBox.cpp:80
QPixmap m_background
Definition ComboBox.h:69
static constexpr int DEFAULT_HEIGHT
Definition ComboBox.h:54
void wheelEvent(QWheelEvent *event) override
Definition ComboBox.cpp:211
QPixmap m_arrowSelected
Definition ComboBox.h:71
ComboBox(QWidget *parent=nullptr, const QString &name=QString())
Definition ComboBox.cpp:43
QPixmap m_arrow
Definition ComboBox.h:70
const ComboBoxModel * model() const
Definition ComboBox.h:49
bool m_pressed
Definition ComboBox.h:75
void setItem(QAction *item)
Definition ComboBox.cpp:225
void selectNext()
Definition ComboBox.cpp:65
void paintEvent(QPaintEvent *event) override
Definition ComboBox.cpp:155
T * castModel()
Definition ModelView.h:54
static const char * name
Definition pugl.h:1582
static uintptr_t parent
Definition pugl.h:1644
auto getIconPixmap(std::string_view name, int width, int height, const char *const *xpm) -> QPixmap
Definition embed.cpp:107
Definition AudioPortAudio.cpp:223
TypedModelView< IntModel > IntModelView
Definition AutomatableModelView.h:132