diff --git a/gui/kmixtoolbox.cpp b/gui/kmixtoolbox.cpp index 4acefaea..539c8085 100644 --- a/gui/kmixtoolbox.cpp +++ b/gui/kmixtoolbox.cpp @@ -1,79 +1,98 @@ /* * KMix -- KDE's full featured mini mixer * * * Copyright (C) 2004 Christian Esken * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "gui/kmixtoolbox.h" #include #include +#include +#include #include "gui/mixdevicewidget.h" /*********************************************************************************** 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 that shared GUI stuff goes into KMixToolBox here, non-GUI stuff goes into the MixerToolBox class. ***********************************************************************************/ void KMixToolBox::setIcons(QList &mdws, bool on) { for (QWidget *w : mdws) { MixDeviceWidget *mdw = qobject_cast(w); if (mdw!=nullptr) mdw->setIcons(on); } } void KMixToolBox::setLabels(QList &mdws, bool on) { for (QWidget *w : mdws) { MixDeviceWidget *mdw = qobject_cast(w); if (mdw!=nullptr) mdw->setLabeled(on); } } void KMixToolBox::setTicks(QList &mdws, bool on) { for (QWidget *w : mdws) { MixDeviceWidget *mdw = qobject_cast(w); if (mdw!=nullptr) mdw->setTicks(on); } } void KMixToolBox::notification(const char *notificationName, const QString &text) { KNotification *notification = new KNotification(notificationName); notification->setText(text); notification->setIconName(QLatin1String("kmix")); notification->addContext(QLatin1String("Application"), QCoreApplication::applicationName()); 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. + // Otherwise there will be a memory leak (although the notification is + // rarely shown). Assuming that it is safe to delete here. notification->deleteLater(); } + + +QWidget *KMixToolBox::noDevicesWarningWidget(QWidget *parent) +{ + KMessageWidget *mw = new KMessageWidget(noDevicesWarningString(), parent); + mw->setIcon(QIcon::fromTheme("dialog-warning")); + mw->setMessageType(KMessageWidget::Warning); + mw->setCloseButtonVisible(false); + mw->setWordWrap(true); + return (mw); +} + + +QString KMixToolBox::noDevicesWarningString() +{ + return (i18n("No sound devices are installed or are currently available.")); +} diff --git a/gui/kmixtoolbox.h b/gui/kmixtoolbox.h index 5ce4b5b6..30e4816c 100644 --- a/gui/kmixtoolbox.h +++ b/gui/kmixtoolbox.h @@ -1,43 +1,46 @@ //-*-C++-*- /* * KMix -- KDE's full featured mini mixer * * Copyright Christian Esken * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KMIXTOOLBOX_H #define KMIXTOOLBOX_H #include "qlist.h" #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. */ namespace KMixToolBox { void setIcons(QList &mdws, bool on); void setLabels(QList &mdws, bool on); void setTicks(QList &mdws, bool on); void notification(const char *notificationName, const QString &text); + + QWidget *noDevicesWarningWidget(QWidget *parent = nullptr); + QString noDevicesWarningString(); } // namespace KMixToolBox #endif