Commit be4fbb0e authored by Michael Pyne's avatar Michael Pyne

Fix track position/volume slider appearance in toolbars.

The actions themselves need to be QWidgetActions now, not just be able
to generate them.
parent 24246f52
......@@ -205,7 +205,6 @@ void JuK::setupActions()
KStandardAction::selectAll(collection);
KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
// Setup the menu which handles the random play options.
KActionMenu *actionMenu = collection->add<KActionMenu>("actionMenu");
actionMenu->setText(i18n("&Random Play"));
......@@ -425,8 +424,6 @@ void JuK::readConfig()
const int maxVolume = 100;
const int volume = playerConfig.readEntry("Volume", maxVolume);
m_player->setVolume(volume * 0.01);
if(ActionCollection::action<VolumeAction>("volumeAction")->button())
ActionCollection::action<VolumeAction>("volumeAction")->button()->refresh();
bool enableCrossfade = playerConfig.readEntry("CrossfadeTracks", true);
m_player->setCrossfadeEnabled(enableCrossfade);
......
......@@ -33,14 +33,9 @@
#include "juk_debug.h"
TrackPositionAction::TrackPositionAction(const QString &text, QObject *parent) :
QAction(text, parent)
QWidgetAction(parent)
{
}
Slider *TrackPositionAction::slider() const
{
return parent()->findChild<Slider *>("timeSlider");
this->setText(text);
}
QWidget *TrackPositionAction::createWidget(QWidget *parent)
......@@ -50,38 +45,29 @@ QWidget *TrackPositionAction::createWidget(QWidget *parent)
PlayerManager *player = JuK::JuKInstance()->playerManager();
connect(player, SIGNAL(tick(int)), slider, SLOT(setValue(int)));
connect(player, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
connect(player, SIGNAL(totalTimeChanged(int)), this, SLOT(totalTimeChanged(int)));
connect(slider, SIGNAL(sliderMoved(int)), player, SLOT(seek(int)));
// TODO only connect the tick signal when actually visible
connect(player, &PlayerManager::tick, slider, &Slider::setValue);
connect(player, &PlayerManager::seekableChanged, slider, &Slider::setEnabled);
connect(player, &PlayerManager::seekableChanged, slider, [slider](bool seekable) {
static const QString noSeekMsg =
i18n("Seeking is not supported in this file with your audio settings.");
slider->setToolTip(seekable ? QString() : noSeekMsg);
});
connect(player, &PlayerManager::totalTimeChanged, slider, &Slider::setMaximum);
connect(slider, &Slider::valueChanged, player, &PlayerManager::seek);
return slider;
}
void TrackPositionAction::seekableChanged(bool seekable)
VolumeAction::VolumeAction(const QString &text, QObject *parent)
: QWidgetAction(parent)
{
slider()->setEnabled(seekable);
slider()->setToolTip(seekable ?
QString() :
i18n("Seeking is not supported in this file with your audio settings."));
}
void TrackPositionAction::totalTimeChanged(int ms)
{
slider()->setRange(0, ms);
}
VolumeAction::VolumeAction(const QString &text, QObject *parent) :
QAction(text, parent),
m_button(0)
{
this->setText(text);
}
QWidget *VolumeAction::createWidget(QWidget *parent)
{
m_button = new VolumePopupButton(parent);
return m_button;
return new VolumePopupButton(parent);
}
// vim: set et sw=4 tw=0 sta:
......@@ -14,39 +14,38 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SLIDERACTION_H
#define SLIDERACTION_H
#ifndef JUK_SLIDERACTION_H
#define JUK_SLIDERACTION_H
#include <QAction>
#include <QWidgetAction>
#include <QBoxLayout>
#include "volumepopupbutton.h"
class Slider;
class TrackPositionAction : public QAction
class TrackPositionAction : public QWidgetAction
{
Q_OBJECT
public:
TrackPositionAction(const QString &text, QObject *parent);
Slider *slider() const;
protected:
virtual QWidget *createWidget(QWidget *parent);
private slots:
void seekableChanged(bool seekable);
void totalTimeChanged(int ms);
QWidget *createWidget(QWidget *parent) override;
};
class VolumeAction : public QAction
class VolumeAction : public QWidgetAction
{
Q_OBJECT
public:
VolumeAction(const QString &text, QObject *parent);
VolumePopupButton *button() const { return m_button; }
protected:
virtual QWidget *createWidget(QWidget *parent);
private:
VolumePopupButton *m_button;
QWidget *createWidget(QWidget *parent) override;
signals:
void volumeChanged(float newVolume);
void muteStateChanged(bool muted);
};
#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