Commit 7b43ca0c authored by Jonathan Marten's avatar Jonathan Marten
Browse files

KMixToolBox: Convert to a namespace, simplify 3 "set*" functions

parent d0fecb9e
......@@ -238,10 +238,10 @@ void KMixPrefDlg::createGeneralTab()
grp->setLayout(visualLayout);
// [CONFIG]
m_showTicks = new QCheckBox(i18n("Show &tickmarks"), grp);
m_showTicks = new QCheckBox(i18n("Show slider &tickmarks"), grp);
addWidgetToLayout(m_showTicks, visualLayout, 10, i18n("Enable/disable tickmark scales on the sliders"), "Tickmarks");
m_showLabels = new QCheckBox(i18n("Show &labels"), grp);
m_showLabels = new QCheckBox(i18n("Show control &labels"), grp);
addWidgetToLayout(m_showLabels, visualLayout, 10, i18n("Enables/disables description labels above the sliders"),
"Labels");
......
......@@ -22,69 +22,58 @@
#include "gui/kmixtoolbox.h"
#include <QCoreApplication>
#include <QWidget>
#include <QString>
#include <kglobalaccel.h>
#include <knotification.h>
#include "gui/guiprofile.h"
#include "mdwslider.h"
#include "gui/mixdevicewidget.h"
#include "core/mixdevice.h"
#include "core/mixer.h"
#include "viewbase.h"
// TODO KMixToolbox is rather superfluous today, as there is no "KMix Applet" any more, and it was probably always bad style.
// I only have to think what to do with KMixToolBox::notification()
/***********************************************************************************
KMixToolbox contains several GUI relevant methods that are shared between the
KMix Main Program, and the KMix Applet.
kmixctrl - as not non-GUI application - does NOT link to KMixToolBox.
KMixToolbox contains several GUI utility functions that are only used by the
KMix main program. kded_kmix and kmixctrl - as non-GUI applications - do not
use or link to KMixToolBox.
This means: Shared GUI stuff goes into the KMixToolBox class , non-GUI stuff goes
This means that shared GUI stuff goes into KMixToolBox here, non-GUI stuff goes
into the MixerToolBox class.
***********************************************************************************/
void KMixToolBox::setIcons(QList<QWidget *> &mdws, bool on ) {
for (int i=0; i < mdws.count(); ++i ){
QWidget *mdw = mdws[i];
if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
static_cast<MixDeviceWidget*>(mdw)->setIcons( on );
}
}
void KMixToolBox::setIcons(QList<QWidget *> &mdws, bool on)
{
for (QWidget *w : mdws)
{
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(w);
if (mdw!=nullptr) mdw->setIcons(on);
}
}
void KMixToolBox::setLabels(QList<QWidget *> &mdws, bool on ) {
for (int i=0; i < mdws.count(); ++i ){
QWidget *mdw = mdws[i];
if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
static_cast<MixDeviceWidget*>(mdw)->setLabeled( on );
}
}
void KMixToolBox::setLabels(QList<QWidget *> &mdws, bool on)
{
for (QWidget *w : mdws)
{
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(w);
if (mdw!=nullptr) mdw->setLabeled(on);
}
}
void KMixToolBox::setTicks(QList<QWidget *> &mdws, bool on ) {
for (int i=0; i < mdws.count(); ++i ){
QWidget *mdw = mdws[i];
if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
static_cast<MixDeviceWidget*>(mdw)->setTicks( on );
}
}
void KMixToolBox::setTicks(QList<QWidget *> &mdws, bool on)
{
for (QWidget *w : mdws)
{
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(w);
if (mdw!=nullptr) mdw->setTicks(on);
}
}
void KMixToolBox::notification(const char *notificationName, const QString &text,
const QStringList &actions, QObject *receiver,
const char *actionSlot)
void KMixToolBox::notification(const char *notificationName, const QString &text)
{
KNotification *notification = new KNotification(notificationName);
//notification->setComponentData(componentData());
notification->setText(text);
//notification->setPixmap(...);
notification->setIconName(QLatin1String("kmix"));
notification->addContext(QLatin1String("Application"), QCoreApplication::applicationName());
if (!actions.isEmpty() && receiver && actionSlot) {
notification->setActions(actions);
QObject::connect(notification, SIGNAL(activated(uint)), receiver, actionSlot);
}
notification->sendEvent();
// Otherwise there will be a memory leak (although the notification is not
// shown very often). Assuming that it is safe to delete here.
notification->deleteLater();
}
......@@ -25,20 +25,19 @@
#include "qwidget.h"
/**
* This toolbox contains various static methods that are shared throughout KMix.
* The reason, why it is not put in a common base class is, that the classes are
* very different and cannot be changed (e.g. KPanelApplet) without major headache.
*/
class KMixToolBox {
public:
static void setIcons (QList<QWidget *> &mdws, bool on );
static void setLabels (QList<QWidget *> &mdws, bool on );
static void setTicks (QList<QWidget *> &mdws, bool on );
namespace KMixToolBox
{
void setIcons(QList<QWidget *> &mdws, bool on);
void setLabels(QList<QWidget *> &mdws, bool on);
void setTicks(QList<QWidget *> &mdws, bool on);
static void notification(const char *notificationName, const QString &text, const QStringList &actions = QStringList(), QObject *receiver = nullptr, const char *actionSlot = nullptr);
};
void notification(const char *notificationName, const QString &text);
} // namespace KMixToolBox
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment