Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 38742696 authored by Jonathan Marten's avatar Jonathan Marten

Eliminate "use of old-style cast" warnings

parent 1e22a1e3
......@@ -115,7 +115,7 @@ KMixWindow::KMixWindow(bool invisible, bool reset) :
ControlManager::instance().addListener(
QString(), // All mixers (as the Global master Mixer might change)
(ControlChangeType::Type) (ControlChangeType::ControlList | ControlChangeType::MasterChanged), this,
static_cast<ControlChangeType::Type>(ControlChangeType::ControlList|ControlChangeType::MasterChanged), this,
"KMixWindow");
// Send an initial volume refresh (otherwise all volumes are 0 until the next change)
......@@ -413,9 +413,9 @@ void KMixWindow::saveViewConfig()
for (int i = 0; i < m_wsMixers->count(); ++i)
{
QWidget *w = m_wsMixers->widget(i);
if (w->inherits("KMixerWidget"))
KMixerWidget *mw = qobject_cast<KMixerWidget *>(w);
if (mw!=nullptr)
{
KMixerWidget* mw = (KMixerWidget*) w;
// Here also Views are saved. even for Mixers that are closed. This is necessary when unplugging cards.
// Otherwise the user will be confused afer re-plugging the card (as the config was not saved).
mw->saveConfig(KSharedConfig::openConfig().data());
......@@ -777,7 +777,7 @@ KMixWindow::findKMWforTab(const QString& kmwId)
{
for (int i = 0; i < m_wsMixers->count(); ++i)
{
KMixerWidget* kmw = (KMixerWidget*) m_wsMixers->widget(i);
KMixerWidget *kmw = qobject_cast<KMixerWidget *>(m_wsMixers->widget(i));
if (kmw->getGuiprof()->getId() == kmwId)
{
return kmw;
......@@ -1256,7 +1256,7 @@ void KMixWindow::forkExec(const QStringList& args)
void KMixWindow::slotConfigureCurrentView()
{
KMixerWidget* mw = (KMixerWidget*) m_wsMixers->currentWidget();
KMixerWidget *mw = qobject_cast<KMixerWidget *>(m_wsMixers->currentWidget());
ViewBase* view = 0;
if (mw)
view = mw->currentView();
......@@ -1292,8 +1292,8 @@ void KMixWindow::slotSelectMaster()
void KMixWindow::newMixerShown(int /*tabIndex*/)
{
KMixerWidget* kmw = (KMixerWidget*) m_wsMixers->currentWidget();
if (kmw)
KMixerWidget *kmw = qobject_cast<KMixerWidget *>(m_wsMixers->currentWidget());
if (kmw!=nullptr)
{
// I am using the app name as a PREFIX, as KMix is a single window app, and it is
// more helpful to the user to see "KDE Mixer" in a window list than a possibly cryptic
......
......@@ -163,7 +163,7 @@ int Mixer_ALSA::open()
.arg(snd_mixer_selem_id_get_index( sid ) );
mdID.replace(' ','_'); // Any key/ID we use, must not uses spaces (rule)
MixDevice::ChannelType ct = (MixDevice::ChannelType)identify( sid );
const MixDevice::ChannelType ct = static_cast<MixDevice::ChannelType>(identify(sid));
/* ------------------------------------------------------------------------------- */
......@@ -407,7 +407,7 @@ int Mixer_ALSA::setupAlsaPolling()
free(m_fds);
m_fds = (struct pollfd*)calloc(countNew, sizeof(struct pollfd));
m_fds = static_cast<struct pollfd *>(calloc(countNew, sizeof(struct pollfd)));
if (m_fds == NULL) {
qCDebug(KMIX_LOG) << "Mixer_ALSA::poll() , calloc() = null" << "\n";
return Mixer::ERR_OPEN;
......@@ -726,7 +726,7 @@ void Mixer_ALSA::setEnumIdHW(const QString& id, unsigned int idx) {
for (int i = 0; i <= SND_MIXER_SCHN_LAST; ++i)
{
int ret = snd_mixer_selem_set_enum_item(elem, (snd_mixer_selem_channel_id_t)i,idx);
int ret = snd_mixer_selem_set_enum_item(elem, static_cast<snd_mixer_selem_channel_id_t>(i), idx);
if (ret < 0 && i == 0)
{
// Log errors only for one channel. This should be enough, and another reason is that I also do not check which channels are supported at all.
......@@ -903,7 +903,7 @@ Mixer_ALSA::writeVolumeToHW( const QString& id, shared_ptr<MixDevice> md )
{
// Special code path for controls w/o physical mute switch. Doing it in all backends is not perfect,
// but it saves a lot of code and removes a lot of complexity in the Volume and MixDevice classes.
int ret = snd_mixer_selem_set_playback_volume_all( elem, (long)0);
int ret = snd_mixer_selem_set_playback_volume_all(elem, 0L);
if ( ret != 0 )
qCDebug(KMIX_LOG) << "writeVolumeToHW(" << devnum << ") [set_playback_volume] failed, errno=" << ret;
}
......
......@@ -125,7 +125,8 @@ void ControlManager::addListener(QString mixerId, ControlChangeType::Type change
<< target;
}
for ( ControlChangeType::Type ct = ControlChangeType::TypeFirst; ct != ControlChangeType::TypeLast; ct = (ControlChangeType::Type)(ct << 1))
for ( ControlChangeType::Type ct = ControlChangeType::TypeFirst; ct != ControlChangeType::TypeLast;
ct = static_cast<ControlChangeType::Type>(ct << 1))
{
if ( changeType & ct )
{
......
......@@ -54,7 +54,7 @@ public:
QString ret;
bool needsSeparator = false;
for (ControlChangeType::Type ct = ControlChangeType::TypeFirst; ct != ControlChangeType::TypeLast; ct =
(ControlChangeType::Type) (ct << 1))
static_cast<ControlChangeType::Type>(ct << 1))
{
if (changeType & ct)
{
......
......@@ -111,7 +111,7 @@ static const QString channelTypeToIconName( MixDevice::ChannelType type )
MixDevice::MixDevice( Mixer* mixer, const QString& id, const QString& name, ChannelType type )
: _profControl(0)
{
init(mixer, id, name, channelTypeToIconName(type), (MixSet*)0);
init(mixer, id, name, channelTypeToIconName(type), nullptr);
}
MixDevice::MixDevice( Mixer* mixer, const QString& id, const QString& name, const QString& iconName, MixSet* moveDestinationMixSet )
......@@ -412,7 +412,8 @@ void MixDevice::readPlaybackOrCapture(const KConfigGroup& config, bool capture)
if ( config.hasKey(volstr) ) {
volume.setVolume(chid, config.readEntry(volstr, 0));
} // if saved channel exists
chid = (Volume::ChannelID)( 1 + (int)chid); // ugly
// TODO: ugly, so find a better way (implement Volume::ChannelID::operator++)
chid = static_cast<Volume::ChannelID>(1+static_cast<int>(chid));
} // for all channels
}
......@@ -447,7 +448,7 @@ void MixDevice::writePlaybackOrCapture(KConfigGroup& config, bool capture)
Volume& volume = capture ? captureVolume() : playbackVolume();
foreach (VolumeChannel vc, volume.getVolumes() )
{
config.writeEntry(getVolString(vc.chid,capture) , (int)vc.volume);
config.writeEntry(getVolString(vc.chid,capture), static_cast<int>(vc.volume));
} // for all channels
}
......
......@@ -110,7 +110,7 @@ VolumeChannel::VolumeChannel(Volume::ChannelID c)
Volume::Volume(long maxVolume, long minVolume, bool hasSwitch, bool isCapture )
{
init((ChannelMask)0, maxVolume, minVolume, hasSwitch, isCapture );
init(static_cast<ChannelMask>(0), maxVolume, minVolume, hasSwitch, isCapture );
}
/**
......@@ -124,7 +124,7 @@ void Volume::addVolumeChannels(ChannelMask chmask)
{
addVolumeChannel(VolumeChannel(chid));
}
chid = (Volume::ChannelID)( 1 + (int)chid); // ugly
chid = static_cast<Volume::ChannelID>(1+static_cast<int>(chid));
} // for all channels
}
......
......@@ -41,7 +41,8 @@ DBusMixerWrapper::DBusMixerWrapper(Mixer* parent, const QString& path)
ControlManager::instance().addListener(
m_mixer->id(),
(ControlChangeType::Type)(ControlChangeType::ControlList | ControlChangeType::Volume),
// TODO: convert ControlChangeType to a QFlags
static_cast<ControlChangeType::Type>(ControlChangeType::ControlList|ControlChangeType::Volume),
this,
QString("DBusMixerWrapper.%1").arg(m_mixer->id())
);
......
......@@ -78,7 +78,7 @@ KMixDockWidget::KMixDockWidget(KMixWindow* parent)
ControlManager::instance().addListener(
QString(), // All mixers (as the Global master Mixer might change)
(ControlChangeType::Type) (ControlChangeType::Volume | ControlChangeType::MasterChanged), this,
static_cast<ControlChangeType::Type>(ControlChangeType::Volume|ControlChangeType::MasterChanged), this,
QString("KMixDockWidget"));
// Refresh in all cases. When there is no Global Master we still need
......
......@@ -97,7 +97,7 @@ int KSmallSlider::positionFromValue( int logical_val, int span ) const
return ( (p/scale) * span ) / (range/scale);
// ### the above line is probably not 100% correct
// ### but fixing it isn't worth the extreme pain...
} else if ( range > (uint)span ) {
} else if ( range > static_cast<uint>(span)) {
return (2*p*span + range) / (2*range);
} else {
uint div = span / range;
......@@ -119,7 +119,7 @@ int KSmallSlider::valueFromPosition( int pos, int span ) const
uint range = maximum() - minimum();
if ( (uint)span > range )
if (static_cast<uint>(span) > range )
return minimum() + (2*pos*range + span) / (2*span);
else {
uint div = range / span;
......
......@@ -339,9 +339,9 @@ void ViewBase::load(KConfig *config)
bool atLeastOneControlIsShown = false;
foreach(QWidget *qmdw, view->_mdws)
{
if (qmdw->inherits("MixDeviceWidget"))
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(qmdw);
if (mdw!=nullptr)
{
MixDeviceWidget* mdw = (MixDeviceWidget*) qmdw;
shared_ptr<MixDevice> md = mdw->mixDevice();
QString devgrp = md->configGroupName(grp);
KConfigGroup devcg = config->group(devgrp);
......@@ -454,9 +454,9 @@ void ViewBase::save(KConfig *config)
for (int i = 0; i < view->_mdws.count(); ++i)
{
QWidget *qmdw = view->_mdws[i];
if (qmdw->inherits("MixDeviceWidget"))
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(qmdw);
if (mdw!=nullptr)
{
MixDeviceWidget* mdw = (MixDeviceWidget*) qmdw;
shared_ptr<MixDevice> md = mdw->mixDevice();
//qCDebug(KMIX_LOG) << " grp=" << grp.toLatin1();
......
......@@ -91,8 +91,9 @@ ViewDockAreaPopup::ViewDockAreaPopup(QWidget* parent, QString id, ViewBase::View
// Register listeners for all mixers
ControlManager::instance().addListener(
QString(), // all mixers
(ControlChangeType::Type) (ControlChangeType::GUI | ControlChangeType::ControlList | ControlChangeType::Volume
| ControlChangeType::MasterChanged), this, QString("ViewDockAreaPopup"));
static_cast<ControlChangeType::Type>(ControlChangeType::GUI|ControlChangeType::ControlList|
ControlChangeType::Volume|ControlChangeType::MasterChanged),
this, QString("ViewDockAreaPopup"));
}
......
......@@ -76,9 +76,8 @@ ViewSliders::ViewSliders(QWidget* parent, QString id, Mixer* mixer, ViewBase::Vi
createDeviceWidgets();
ControlManager::instance().addListener(mixer->id(),
(ControlChangeType::Type) (ControlChangeType::GUI | ControlChangeType::ControlList | ControlChangeType::Volume),
this, QString("ViewSliders.%1").arg(mixer->id()));
static_cast<ControlChangeType::Type>(ControlChangeType::GUI|ControlChangeType::ControlList|ControlChangeType::Volume),
this, QString("ViewSliders.%1").arg(mixer->id()));
}
ViewSliders::~ViewSliders()
......
......@@ -68,7 +68,7 @@ void VolumeSlider::mousePressEvent(QMouseEvent* event)
* VolumeSlider class currently holds no pointer/reference to the "underlying" Volume object, a bit code
* "duplication" is acceptable here.
*/
qreal percentReal = ((qreal)100 * value() ) / ( maximum() - minimum());
qreal percentReal = (100.0*value())/(maximum()-minimum());
int percent = qRound(percentReal);
m_tooltip->setText(QString::number(percent));
m_tooltip->show();
......@@ -89,7 +89,7 @@ void VolumeSlider::mouseMoveEvent(QMouseEvent* event)
initStyleOption(&opt);
QRect sliderHandle = style()->subControlRect(QStyle::CC_Slider,&opt,QStyle::SC_SliderHandle,this);
qreal percentReal = ((qreal)100 * value() ) / ( maximum() - minimum() );
qreal percentReal = (100.0*value())/(maximum()-minimum());
int percent = qRound(percentReal);
//Change width of label if percent becomes 100
......
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