Commit 8436d783 authored by Scott Wheeler's avatar Scott Wheeler

Remove CustomAction since it was pretty small and there wasn't any logical

reason for it to be separate from SliderAction.

svn path=/trunk/kdemultimedia/juk/; revision=302605
parent 4c921c19
......@@ -7,7 +7,6 @@ juk_SOURCES = \
artsplayer.cpp \
cache.cpp \
collectionlist.cpp \
customaction.cpp \
directorylist.cpp \
directorylistbase.ui \
dynamicplaylist.cpp \
......
/***************************************************************************
customaction.cpp - description
-------------------
begin : Wed Feb 6 2002
copyright : (C) 2002 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <ktoolbar.h>
#include "customaction.h"
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
CustomAction::CustomAction(const QString &text, QObject *parent, const char *name)
: KAction(text, 0, parent, name),
m_toolBar(0)
{
}
CustomAction::~CustomAction()
{
}
int CustomAction::plug(QWidget *parent, int index)
{
QWidget *w = createWidget(parent);
if(!w)
return -1;
// the check for null makes sure that there is only one toolbar that this is
// "plugged" in to
if(parent->inherits("KToolBar") && !m_toolBar) {
m_toolBar = static_cast<KToolBar *>(parent);
int id = KAction::getToolButtonID();
m_toolBar->insertWidget(id, w->width(), w, index);
addContainer(m_toolBar, id);
connect(m_toolBar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
return (containerCount() - 1);
}
return -1;
}
void CustomAction::unplug(QWidget *parent)
{
if (parent->inherits("KToolBar")) {
m_toolBar = static_cast<KToolBar *>(parent);
int index = findContainer(m_toolBar);
if (index != -1) {
m_toolBar->removeItem(itemId(index));
removeContainer(index);
m_toolBar = 0;
}
}
}
#include "customaction.moc"
/***************************************************************************
customaction.h - description
-------------------
begin : Wed Feb 6 2002
copyright : (C) 2002 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef CUSTOMACTION_H
#define CUSTOMACTION_H
#include <kaction.h>
// Many months after writing this, despite having felt rather clever at the time
// I am now rather convinced that this is The Wrong Way (tm) to have handled
// things and will hopefully un-hack this later.
class CustomAction : public KAction
{
Q_OBJECT
public:
CustomAction(const QString &text, QObject *parent, const char *name);
virtual ~CustomAction();
virtual int plug(QWidget *parent, int index = -1);
virtual void unplug(QWidget *widget);
protected:
KToolBar *toolBar() const { return m_toolBar; }
KToolBar *m_toolBar;
signals:
void pluggedIn(QWidget *parent);
private:
virtual QWidget *createWidget(QWidget *parent) = 0;
};
#endif
......@@ -124,8 +124,8 @@ void VolumeSlider::slotValueChanged(int value)
////////////////////////////////////////////////////////////////////////////////
SliderAction::SliderAction(const QString &text, QObject *parent, const char *name)
: CustomAction(text, parent, name),
m_dragging(false)
: KAction(text, 0, parent, name),
m_toolBar(0), m_dragging(false)
{
}
......@@ -135,6 +135,48 @@ SliderAction::~SliderAction()
}
int SliderAction::plug(QWidget *parent, int index)
{
QWidget *w = createWidget(parent);
if(!w)
return -1;
// the check for null makes sure that there is only one toolbar that this is
// "plugged" in to
if(parent->inherits("KToolBar") && !m_toolBar) {
m_toolBar = static_cast<KToolBar *>(parent);
int id = KAction::getToolButtonID();
m_toolBar->insertWidget(id, w->width(), w, index);
addContainer(m_toolBar, id);
connect(m_toolBar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
return (containerCount() - 1);
}
return -1;
}
void SliderAction::unplug(QWidget *parent)
{
if (parent->inherits("KToolBar")) {
m_toolBar = static_cast<KToolBar *>(parent);
int index = findContainer(m_toolBar);
if (index != -1) {
m_toolBar->removeItem(itemId(index));
removeContainer(index);
m_toolBar = 0;
}
}
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......@@ -142,8 +184,8 @@ SliderAction::~SliderAction()
void SliderAction::slotUpdateOrientation(QDockWindow *dockWindow)
{
// if the toolbar is not null and either the dockWindow not defined or is the toolbar
if((!dockWindow || dockWindow == dynamic_cast<QDockWindow *>(toolBar()))) {
if(toolBar()->barPos() == KToolBar::Right || toolBar()->barPos() == KToolBar::Left) {
if((!dockWindow || dockWindow == dynamic_cast<QDockWindow *>(m_toolBar))) {
if(m_toolBar->barPos() == KToolBar::Right || m_toolBar->barPos() == KToolBar::Left) {
m_trackPositionSlider->setOrientation(Vertical);
m_volumeSlider->setOrientation(Vertical);
m_layout->setDirection(QBoxLayout::TopToBottom);
......@@ -233,18 +275,18 @@ void SliderAction::slotUpdateSize()
static const int offset = 3;
static const int absoluteMax = 10000;
if(toolBar()->barPos() == KToolBar::Right || toolBar()->barPos() == KToolBar::Left) {
m_volumeSlider->setMaximumWidth(toolBar()->iconSize() - offset);
if(m_toolBar->barPos() == KToolBar::Right || m_toolBar->barPos() == KToolBar::Left) {
m_volumeSlider->setMaximumWidth(m_toolBar->iconSize() - offset);
m_volumeSlider->setMaximumHeight(volumeMax);
m_trackPositionSlider->setMaximumWidth(toolBar()->iconSize() - offset);
m_trackPositionSlider->setMaximumWidth(m_toolBar->iconSize() - offset);
m_trackPositionSlider->setMaximumHeight(absoluteMax);
}
else {
m_volumeSlider->setMaximumHeight(toolBar()->iconSize() - offset);
m_volumeSlider->setMaximumHeight(m_toolBar->iconSize() - offset);
m_volumeSlider->setMaximumWidth(volumeMax);
m_trackPositionSlider->setMaximumHeight(toolBar()->iconSize() - offset);
m_trackPositionSlider->setMaximumHeight(m_toolBar->iconSize() - offset);
m_trackPositionSlider->setMaximumWidth(absoluteMax);
}
}
......
......@@ -18,11 +18,9 @@
#ifndef SLIDERACTION_H
#define SLIDERACTION_H
#include <kaction.h>
#include <qslider.h>
#include "customaction.h"
class QBoxLayout;
class QDockWindow;
......@@ -49,7 +47,7 @@ private slots:
void slotValueChanged(int value);
};
class SliderAction : public CustomAction
class SliderAction : public KAction
{
Q_OBJECT
......@@ -62,6 +60,9 @@ public:
bool dragging() const { return m_dragging; }
virtual int plug(QWidget *parent, int index = -1);
virtual void unplug(QWidget *widget);
public slots:
void slotUpdateOrientation(QDockWindow *dockWindow = 0);
......@@ -77,6 +78,7 @@ private slots:
void slotSliderReleased();
private:
KToolBar *m_toolBar;
QBoxLayout *m_layout;
QSlider *m_trackPositionSlider;
VolumeSlider *m_volumeSlider;
......
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