3 * KMix -- KDE's full featured mini mixer
5 * Copyright Christian Esken <esken@kde.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
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 GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this program; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <QPushButton>
30 #include <KActionCollection>
38 #include "core/mixdevice.h"
39 #include "core/mixset.h"
40 #include "gui/guiprofile.h"
41 #include "gui/mixdevicewidget.h"
44 * The ViewBase is a virtual base class, to be used for subclassing the real Mixer Views.
46 class ViewBase : public QWidget
50 friend class KMixToolBox; // the toolbox is everybodys friend :-)
54 typedef uint ViewFlags;
58 MenuBarVisible = 0x0002,
63 typedef uint GUIComplexity;
71 ViewBase(QWidget* parent, QString id, Qt::WFlags, ViewFlags vflags, QString guiProfileId, KActionCollection* actionCollection = 0);
74 void addMixer(Mixer *mixer);
78 // This method is called by ViewBase at the end of createDeviceWidgets(). The default
79 // implementation does nothing. Subclasses can override this method for doing final
80 // touches. This is very much like polish(), but called at an exactly well-known time.
81 // Also I do not want Views to interfere with polish()
82 virtual void constructionFinished() = 0;
85 * Creates a suitable representation for the given MixDevice.
87 virtual QWidget* add(std::shared_ptr<MixDevice>) = 0;
89 // This method is called after a configuration update (show/hide controls, split/unsplit).
90 virtual void configurationUpdate() = 0;
92 void load(KConfig *config);
93 void save(KConfig *config);
96 * Creates the widgets for all supported devices. The default implementation loops
97 * over the supported MixDevice's and calls add() for each of it.
99 virtual void createDeviceWidgets();
101 int visibleControls();
103 bool isDynamic() const;
108 virtual KMenu* getPopup();
109 virtual void popupReset();
110 virtual void showContextMenu();
112 virtual bool isValid() const;
114 void setIcons(bool on);
115 void setLabels(bool on);
116 void setTicks(bool on);
118 GUIProfile* guiProfile() { return GUIProfile::find(_guiProfileId); };
119 GUIComplexity getGuiComplexity() { return guiComplexity; };
120 ProfControl* findMdw(const QString& id);
121 ProfControl* findMdw(const QString& mdwId, QString requestedGuiComplexityName);
124 KActionCollection* actionCollection() { return _actions; };
126 QList<Mixer*>& getMixers() { return _mixers; };
129 * Contains the widgets for the _mixSet. There is a 1:1 relationship, which means:
130 * _mdws[i] is the Widget for the MixDevice _mixSet[i] - please see ViewBase::createDeviceWidgets().
131 * Hint: !! The new ViewSurround class shows that a 1:1 relationship does not work in a general scenario.
132 * I actually DID expect this. The solution is unclear yet, probably there will be a virtual mapper method.
134 QList<QWidget *> _mdws;
138 QList<Mixer*> _mixers;
140 KActionCollection* _actions; // -<- application wide action collection
143 const QString _guiProfileId;
144 KActionCollection *_localActionColletion;
146 KIcon* configureIcon;
148 virtual void _setMixSet() = 0;
150 void updateGuiOptions();
151 QPushButton* createConfigureViewButton();
153 GUIComplexity guiComplexity;
156 virtual void refreshVolumeLevels(); // TODO remove
157 virtual void configureView();
158 void toggleMenuBarSlot();
161 void mousePressEvent( QMouseEvent *e );
164 void toggleMenuBar();
168 void updateMediaPlaybackIcons();
171 void guiVisibilitySlot(MixDeviceWidget* source, bool enable);