[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdemultimedia/noatun/library
From: Stefan Gehn <mETz81 () web ! de>
Date: 2007-01-30 21:54:09
Message-ID: 1170194049.716959.22049.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 628682 by metz:
- port ScrollingLabel (untested)
- use namespace Noatun {...} instead of "using namespace" in sources
- do not use Global::self() in PluginHandler
M +3 -2 downloader.cpp
M +8 -6 frontend.cpp
M +7 -4 hardwarevc.cpp
M +7 -7 hardwarevc.h
M +15 -16 nmainwindow.cpp
M +3 -4 noatun/downloader.h
M +2 -1 noatun/pluginloader.h
M +9 -7 noatun/scrollinglabel.h
M +19 -19 pluginloader.cpp
M +60 -42 scrollinglabel.cpp
--- trunk/KDE/kdemultimedia/noatun/library/downloader.cpp #628681:628682
@@ -10,7 +10,8 @@
#include <klocale.h>
#include <kdebug.h>
-using namespace Noatun;
+namespace Noatun
+{
DownloadItem::DownloadItem(Global *g)
{
@@ -251,5 +252,5 @@
current->notifier->downloaded((int)percent);
}
+} // namespace Noatun
#include "downloader.moc"
-
--- trunk/KDE/kdemultimedia/noatun/library/frontend.cpp #628681:628682
@@ -1,18 +1,20 @@
-/*
- */
-
+/**
+ *
+ **/
#include <noatun/frontend.h>
#include <noatun/global.h>
#include <noatun/plugin.h>
#include <noatun/pluginloader.h>
#include <noatun/plugininterfaces.h>
+
#include <qevent.h>
#include <qtimer.h>
+
#include <kdebug.h>
-using namespace Noatun;
+namespace Noatun
+{
-
Frontend::Frontend(Global *parent)
: QObject(parent), mPlugin(0), mIface(0)
{
@@ -68,7 +70,6 @@
KMainWindow *Frontend::mainWindow()
{
- //Q_ASSERT(mIface->mainWindow());
if (mIface)
return mIface->mainWindow();
return 0;
@@ -92,4 +93,5 @@
return false;
}
+} // namespace Noatun
#include "frontend.moc"
--- trunk/KDE/kdemultimedia/noatun/library/hardwarevc.cpp #628681:628682
@@ -1,6 +1,6 @@
-/*
- */
-
+/**
+ *
+ **/
#include "hardwarevc.h"
#ifdef HARDWARE_VOLUME
@@ -13,7 +13,8 @@
#include <qfile.h>
-using namespace Noatun;
+namespace Noatun
+{
HardwareVC::HardwareVC(const QString &mixerDevice)
{
@@ -66,4 +67,6 @@
return left;
}
+} // namespace Noatun
+
#endif // HARDWARE_VOLUME
--- trunk/KDE/kdemultimedia/noatun/library/hardwarevc.h #628681:628682
@@ -6,19 +6,19 @@
#define HARDWARE_VOLUME
#if defined(__osf__)
-#undef HARDWARE_VOLUME
+ #undef HARDWARE_VOLUME
#elif defined(__linux__)
-#include <sys/soundcard.h>
+ #include <sys/soundcard.h>
#elif defined(__FreeBSD__)
-#include <sys/soundcard.h>
+ #include <sys/soundcard.h>
#elif defined(__NetBSD__)
-#include <soundcard.h>
+ #include <soundcard.h>
#elif defined(___SOMETHING_UNKNOWN__)
-#include <sys/soundcard.h>
+ #include <sys/soundcard.h>
#elif defined(_UNIXWARE)
-#include <sys/soundcard.h>
+ #include <sys/soundcard.h>
#else
-#undef HARDWARE_VOLUME
+ #undef HARDWARE_VOLUME
#endif
#ifdef HARDWARE_VOLUME
--- trunk/KDE/kdemultimedia/noatun/library/nmainwindow.cpp #628681:628682
@@ -15,13 +15,14 @@
#include <kdebug.h>
#include <kstandarddirs.h>
-using namespace Noatun;
+namespace Noatun
+{
-struct Noatun::NMainWindow::Private
+struct NMainWindow::Private
{
- bool bMergedNoatunXML;
- bool bIsSkinned;
- bool bWantMerge;
+ bool bMergedNoatunXML;
+ bool bIsSkinned;
+ bool bWantMerge;
Plugin *plugin;
};
@@ -30,23 +31,21 @@
{
//TODO: Should this decision be up to the plugins using NMainWindow?
setAttribute(Qt::WA_DeleteOnClose, false);
+ setComponentData(plug->componentData());
- kDebug(66666) << k_funcinfo << "plugin instancename = " << \
plug->componentData().componentName() << endl;
- d = new Private;
-// kapp->ref();
+ kDebug(66666) << k_funcinfo << "for plugin '"
+ << plug->componentData().componentName() << "'" << endl;
+
+ d = new NMainWindow::Private();
d->bMergedNoatunXML = false;
- d->bWantMerge = wantNoatunXML;
- d->bIsSkinned = isSkinned;
- d->plugin = plug;
- setComponentData(plug->componentData());
+ d->bWantMerge = wantNoatunXML;
+ d->bIsSkinned = isSkinned;
+ d->plugin = plug;
updateSkin();
-
- StdAction::playpause(plug->global(), actionCollection());
}
NMainWindow::~NMainWindow()
{
-// kapp->deref();
delete d;
}
@@ -132,5 +131,5 @@
KMainWindow::closeEvent(e);
}
-
+} // namespace Noatun
#include "nmainwindow.moc"
--- trunk/KDE/kdemultimedia/noatun/library/noatun/downloader.h #628681:628682
@@ -18,7 +18,6 @@
namespace Noatun
{
-
class Downloader;
class Global;
@@ -69,7 +68,8 @@
/**
- * Download playlistitems, in a queue based fasion
+ * @brief Download playlistitems in a queue based fashion
+ * @todo Check if this is still needed/wanted for KDE4
**/
class NOATUN_EXPORT Downloader : public QObject
{
@@ -124,6 +124,5 @@
bool mStarted;
};
-}
-
+} // namespace Noatun
#endif
--- trunk/KDE/kdemultimedia/noatun/library/noatun/pluginloader.h #628681:628682
@@ -11,6 +11,7 @@
{
class Plugin;
+class Global;
typedef QList<Plugin*> PluginList;
typedef QList<KPluginInfo*> PluginInfoList;
@@ -23,7 +24,7 @@
Q_OBJECT
public:
- PluginHandler(QObject *parent);
+ PluginHandler(Global *parent);
~PluginHandler();
PluginInfoList availablePlugins(const QString &category = QString::null) const;
--- trunk/KDE/kdemultimedia/noatun/library/noatun/scrollinglabel.h #628681:628682
@@ -26,17 +26,20 @@
#include <qwidget.h>
#include <noatun_export.h>
+namespace Noatun
+{
+
/**
- * A clever label that scrolls its contents as soon as there is not enough
- * space to show everything at once.
+ * @brief A label that scrolls its contents as soon as there is not enough
+ * space to show everything at once.
+ * @todo test in a toolbar, kde4 port is untested so far
**/
class NOATUN_EXPORT ScrollingLabel : public QWidget
{
Q_OBJECT
public:
- ScrollingLabel(const QString &initialText,QWidget *parent,
- const char * name = 0);
+ ScrollingLabel(const QString &text, QWidget *parent);
virtual ~ScrollingLabel();
/**
@@ -59,22 +62,21 @@
virtual void setScroll(bool on);
protected:
-
virtual void paintEvent(QPaintEvent *);
virtual void resizeEvent(QResizeEvent *);
protected slots:
-
virtual void scroll();
virtual void restoreText();
private:
-
void _update();
class Private;
Private * d;
};
+} // namespace Noatun
#endif
+
// vim:ts=2:sw=2:tw=78:noet
--- trunk/KDE/kdemultimedia/noatun/library/pluginloader.cpp #628681:628682
@@ -14,12 +14,16 @@
#include <kparts/componentfactory.h>
#include <kconfiggroup.h>
-using namespace Noatun;
+namespace Noatun
+{
-class Noatun::PluginHandler::Private
+class PluginHandler::Private
{
public:
- Private() { unloadingAll = false; }
+ Private(Global *noatunInstance) : nInstance(noatunInstance), unloadingAll(false)
+ { }
+
+ Global *nInstance;
// All available plugins, regardless of category, and loaded or not
QList<KPluginInfo*> availablePlugins;
/**
@@ -39,15 +43,15 @@
// ---------------------------------------------------------------------------
-PluginHandler::PluginHandler(QObject *parent)
- : QObject(parent)
+PluginHandler::PluginHandler(Global *parent)
+ : QObject(parent), d(new Private(parent))
{
kDebug(66666) << k_funcinfo << endl;
- d = new Private();
- //TODO: this stops us from installing new plugins at runtime
- d->availablePlugins =
- KPluginInfo::fromServices(KServiceTypeTrader::self()->query("Noatun/Plugin"));
+ //TODO: querying ktrader only once stops us from installing new plugins
+ // at runtime
+ d->availablePlugins = KPluginInfo::fromServices(
+ KServiceTypeTrader::self()->query("Noatun/Plugin"));
}
@@ -303,7 +307,6 @@
{
kDebug(66666) << k_funcinfo << pluginName << endl;
-
KPluginInfo *info = pluginInfoFromName(pluginName);
if (!info)
{
@@ -325,24 +328,20 @@
QString("[X-KDE-PluginInfo-Name]=='%1'").arg(pluginName)
);
- Plugin *plugin=0;
+ Plugin *plugin = 0;
+ QStringList slll("Noatun/Plugin");
for (QList<KSharedPtr<KService> >::Iterator i(offers.begin()); i != offers.end(); \
++i) {
KService::Ptr ptr = *i;
- KLibFactory *factory =
- KLibLoader::self()->factory(ptr->library().toLocal8Bit());
+ KLibFactory *factory = KLibLoader::self()->factory(ptr->library().toLocal8Bit());
if (!factory)
continue;
PluginFactoryBase *pfb = static_cast<PluginFactoryBase*>(factory);
if (!pfb)
continue;
- pfb->setGlobal(Global::self());
+ pfb->setNoatunInstance(d->nInstance);
- QStringList slll;
- slll << "Noatun/Plugin";
- plugin = static_cast<Plugin*>(
- pfb->create(this, ptr->name().toLatin1(), slll)
- );
+ plugin = static_cast<Plugin*>(pfb->create(this, ptr->name().toLatin1(), slll));
if (plugin)
break;
}
@@ -548,4 +547,5 @@
return 0;
}
+} // namespace Noatun
#include "pluginloader.moc"
--- trunk/KDE/kdemultimedia/noatun/library/scrollinglabel.cpp #628681:628682
@@ -20,13 +20,16 @@
*
*/
-#include <noatun/scrollinglabel.h>
+#include "noatun/scrollinglabel.h"
#include <qpainter.h>
#include <qpixmap.h>
#include <qtimer.h>
#include <qtooltip.h>
+namespace Noatun
+{
+
class ScrollingLabel::Private
{
public:
@@ -52,29 +55,26 @@
// End order dependency.
};
-ScrollingLabel::ScrollingLabel
-(
- const QString & initialText,
- QWidget * parent,
- const char * name
-)
- : QWidget(parent, name)
+
+ScrollingLabel::ScrollingLabel(const QString &text, QWidget *parent)
+ : QWidget(parent)
{
d = new Private;
- connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(scroll()));
- connect(&d->resetTimer, SIGNAL(timeout()), this, SLOT(restoreText()));
+ connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(scroll()));
+ connect(&d->resetTimer, SIGNAL(timeout()), this, SLOT(restoreText()));
- setText(initialText);
+ setText(text);
}
+
ScrollingLabel::~ScrollingLabel()
{
delete d;
}
- void
-ScrollingLabel::setText(const QString & t, int time)
+
+void ScrollingLabel::setText(const QString & t, int time)
{
d->resetTimer.stop();
@@ -83,7 +83,8 @@
restoreText();
d->originalText = d->text;
d->text = t;
- d->resetTimer.start(time, true);
+ d->resetTimer.setSingleShot(true);
+ d->resetTimer.start(time);
_update();
}
else
@@ -92,19 +93,18 @@
_update();
}
- QToolTip::remove(this);
- QToolTip::add(this, d->text);
+ setToolTip(d->text);
}
- void
-ScrollingLabel::restoreText()
+
+void ScrollingLabel::restoreText()
{
d->text = d->originalText;
_update();
}
- void
-ScrollingLabel::_update()
+
+void ScrollingLabel::_update()
{
d->scrollTimer.stop();
@@ -118,38 +118,53 @@
d->scrollSize = QMAX(0, w - width());
- d->buf.resize(w, h);
- d->buf.fill(colorGroup().background());
+ // resize if needed
+ if (w != d->buf.width() || h != d->buf.height())
+ d->buf = QPixmap(w, h);
+ //d->buf.fill(colorGroup().background());
+
QPainter p(&d->buf);
p.setFont(font());
p.drawText(0, fontMetrics().ascent(), d->text);
if (d->scroll && (d->scrollSize > 0))
- d->scrollTimer.start(100, true);
+ {
+ d->scrollTimer.setSingleShot(true);
+ d->scrollTimer.start(100);
+ }
- repaint(false);
+ repaint();
}
- void
-ScrollingLabel::paintEvent(QPaintEvent *)
-{ // TODO KDE4
+
+void ScrollingLabel::paintEvent(QPaintEvent * /*event*/)
+{
// bitBlt
// (this, 0, 0, &d->buf, d->pos, 0, d->pos + width(), height(), Qt::CopyROP);
+ QPainter p(this);
+ p.drawPixmap(
+ 0,
+ 0,
+ d->buf,
+ d->pos,
+ 0,
+ d->pos + width(),
+ height());
}
- void
-ScrollingLabel::resizeEvent(QResizeEvent *)
+
+void ScrollingLabel::resizeEvent(QResizeEvent *)
{
_update();
}
- void
-ScrollingLabel::scroll()
+
+void ScrollingLabel::scroll()
{
d->scrollTimer.stop();
- repaint(false);
+ repaint();
int scrollTime = 100;
@@ -162,35 +177,38 @@
d->pos += (d->add ? 1 : -1);
if (d->scroll)
- d->scrollTimer.start(scrollTime, true);
+ {
+ d->scrollTimer.setSingleShot(true);
+ d->scrollTimer.start(scrollTime);
+ }
}
- QSize
-ScrollingLabel::sizeHint() const
+
+QSize ScrollingLabel::sizeHint() const
{
return fontMetrics().boundingRect(d->text).size();
}
- QSize
-ScrollingLabel::minimumSizeHint() const
+
+QSize ScrollingLabel::minimumSizeHint() const
{
return QSize(0, fontMetrics().height());
}
- QString
-ScrollingLabel::text() const
+
+QString ScrollingLabel::text() const
{
return d->text;
}
- void
-ScrollingLabel::setScroll(bool b)
+
+void ScrollingLabel::setScroll(bool b)
{
d->scroll = b;
_update();
}
+} // namespace Noatun
#include "scrollinglabel.moc"
// vim:ts=2:sw=2:tw=78:noet
-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic