[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdemultimedia/noatun/modules/noatunui
From:       Stefan Gehn <mETz81 () web ! de>
Date:       2007-01-25 20:23:45
Message-ID: 1169756625.487542.13701.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 627145 by metz:

- Fix layout for now
- tried fixing the empty menubar, something is wrong with xmlgui and our actionlists
- fix drag and drop of urls

 M  +67 -84    userinterface.cpp  
 M  +6 -9      userinterface.h  


--- trunk/KDE/kdemultimedia/noatun/modules/noatunui/userinterface.cpp #627144:627145
@@ -14,21 +14,16 @@
 
 #include <qgridlayout.h>
 #include <qpushbutton.h>
-//#include <qdragobject.h>
 #include <qlayout.h>
 #include <qtooltip.h>
 #include <qevent.h>
-//#include <qobjectlist.h>
-//#include <qobjectdict.h>
 
 #include <kmenu.h>
 #include <kstatusbar.h>
 #include <kglobal.h>
 #include <klocale.h>
-#include <kiconloader.h>
-//#include <kurldrag.h>
-#include <kfiledialog.h>
-#include <kconfig.h>
+#include <kurl.h>
+#include <kxmlguifactory.h>
 
 K_EXPORT_COMPONENT_FACTORY(noatun_ui, PluginFactory<MCPlugin>("noatun_ui"))
 
@@ -42,54 +37,66 @@
 	: NMainWindow(pl), napp(gl)
 {
 	setAcceptDrops(true);
-	static const int buttonSize=32;
-	setCentralWidget(new QWidget(this));
-	QWidget *wi = centralWidget();
-	
-	QGridLayout *l=new QGridLayout(wi);
 
+	static const int buttonSize=32; // until we have a proper gui
+
+	QWidget *wi = new QWidget(this);
+	setCentralWidget(wi);
+
+
+	//FIXME: Most of these actions don't show up in the default menubar
+	//       and I have no idea why :(             (mETz, 2007-01-25)
+	StdAction::back(napp, actionCollection());
+	StdAction::stop(napp, actionCollection());
+	StdAction::playpause(napp, actionCollection());
+	StdAction::forward(napp, actionCollection());
+	StdAction::playlist(napp, actionCollection());
+	StdAction::quit(napp, actionCollection());
+
+
+	QGridLayout *l = new QGridLayout(wi);
 	{ // The buttons
 		mBack=new QPushButton(wi);
 		mBack->setFixedSize(buttonSize,buttonSize);
-		mBack->setIcon(BarIcon("noatunback"));
+		mBack->setIcon(KIcon("noatunback"));
 		connect(mBack, SIGNAL(clicked()), napp->player(), SLOT(previous()));
-		mBack->setToolTip(i18n("Back"));
+		mBack->setToolTip(i18n("Go backward in playlist"));
 
 		mStop=new QPushButton(wi);
 		mStop->setFixedSize(buttonSize,buttonSize);
-		mStop->setIcon(BarIcon("noatunstop"));
+		mStop->setIcon(KIcon("noatunstop"));
 		connect(mStop, SIGNAL(clicked()), napp->player(), SLOT(stop()));
 		mStop->setToolTip( i18n("Stop"));
 
 		mPlay=new QPushButton(wi);
-//		mPlay->setToggleButton(true);
+		mPlay->setCheckable(true);
 		mPlay->setFixedSize(buttonSize,buttonSize);
-		mPlay->setIcon(BarIcon("noatunplay"));
+		mPlay->setIcon(KIcon("noatunplay"));
 		connect(mPlay, SIGNAL(clicked()), napp->player(), SLOT(playpause()));
 		mPlay->setToolTip( i18n("Play"));
 
 		mForward=new QPushButton(wi);
 		mForward->setFixedSize(buttonSize,buttonSize);
-		mForward->setIcon(BarIcon("noatunforward"));
+		mForward->setIcon(KIcon("noatunforward"));
 		connect(mForward, SIGNAL(clicked()), napp->player(), SLOT(next()));
-		mForward->setToolTip( i18n("Forward"));
+		mForward->setToolTip(i18n("Go forward in playlist"));
 
 		mPlaylist=new QPushButton(wi);
-//		mPlaylist->setToggleButton(true);
+		mPlaylist->setCheckable(true);
 		mPlaylist->setFixedSize(buttonSize,buttonSize);
-		mPlaylist->setIcon(BarIcon("noatunplaylist"));
-		connect(mPlaylist, SIGNAL(clicked()), napp->playlist(), SLOT(showList()));
-		mPlaylist->setToolTip( i18n("Playlist"));
+		mPlaylist->setIcon(KIcon("noatunplaylist"));
+		connect(mPlaylist, SIGNAL(clicked()), napp->playlist(), SLOT(toggleList()));
+		mPlaylist->setToolTip(i18n("Playlist"));
 
 		mLoop=new QPushButton(wi);
 		mLoop->setFixedSize(buttonSize,buttonSize);
-		mLoop->setIcon(BarIcon("noatunloopnone"));
+		mLoop->setIcon(KIcon("noatunloopnone"));
 		connect(mLoop, SIGNAL(clicked()), napp->player(), SLOT(loop()));
 		mLoop->setToolTip( i18n("Change loop style"));
 
 		mPopup=new QPushButton(wi);
 		mPopup->setFixedSize(buttonSize,buttonSize);
-		mPopup->setIcon(BarIcon("noatun"));
+		mPopup->setIcon(KIcon("noatun"));
 		connect(mPopup, SIGNAL(clicked()), SLOT(popup()));
 //		mRemoveCurrent->setToolTip( i18n("Remove current file from playlist"));
 
@@ -99,9 +106,6 @@
 	mVolume->setValue(napp->player()->volume());
 	mSeeker=new L33tSlider(0,1000,10,0, Qt::Horizontal, wi);
 
-	mStatusBar=new KStatusBar(wi);
-
-
 	l->addWidget(mBack,0,0);
 	l->addWidget(mStop,0,1);
 	l->addWidget(mPlay,0,2);
@@ -111,15 +115,14 @@
 	l->addWidget(mPopup,0,6);
 //	l->addColSpacing(4, buttonSize+8);
 
-	l->addWidget(mVolume,1,1,1,6);
-	l->addWidget(mSeeker,2,2,2,6);
-	l->addWidget(mStatusBar,3,3,3,6);
+	l->addWidget(mVolume,1,0,1,6);
+	l->addWidget(mSeeker,2,0,2,6);
 
 	statusBar()->showMessage(i18n("No File Loaded"));
 	statusBar()->insertItem("--:--/--:--", 1, 0);
 
-	connect(napp, SIGNAL(hideYourself()), this, SLOT(hide()) );
-	connect(napp, SIGNAL(showYourself()), this, SLOT(show()) );
+	//connect(napp, SIGNAL(hideYourself()), this, SLOT(hide()) );
+	//connect(napp, SIGNAL(showYourself()), this, SLOT(show()) );
 
 	connect(napp->player(), SIGNAL(playing()), this, SLOT(slotPlaying()));
 	connect(napp->player(), SIGNAL(stopped()), this, SLOT(slotStopped()));
@@ -142,20 +145,21 @@
 	connect(mVolume, SIGNAL(userChanged(int)), napp->player(), SLOT(setVolume(int)));
 
 
-	connect(napp->player(), SIGNAL(playlistShown()), SLOT(playlistShown()));
-	connect(napp->player(), SIGNAL(playlistHidden()), SLOT(playlistHidden()));
+	connect(napp->playlist(), SIGNAL(listShown()), SLOT(playlistShown()));
+	connect(napp->playlist(), SIGNAL(listHidden()), SLOT(playlistHidden()));
 
 	// Event Filter for the RMB
 //	for (QPtrListIterator<QObject> i(*children()); i.current(); ++i)
 //		(*i)->installEventFilter(this);
 
 	setCaption("Noatun");
-//	setIcon(BarIcon("noatun"));
-	show();
+	setWindowIcon(KIcon("noatun"));
 
 	// What it is now, stay, stay.. roll over, good boy!
 //	setFixedSize(minimumSize());
-	setupGUI(Create | Keys, "noatun/noatun.rc");
+	setupGUI(); //(Create | Keys, "noatun/noatun.rc");
+
+	show();
 }
 
 MilkChocolate::~MilkChocolate()
@@ -165,31 +169,17 @@
 //		delete prefDlg;
 }
 
-void MilkChocolate::closeEvent(QCloseEvent*)
-{
-//	unload();
-}
-
-void MilkChocolate::showEvent(QShowEvent*e)
-{
-	QWidget::showEvent(e);
-}
-
 void MilkChocolate::dragEnterEvent(QDragEnterEvent *event)
 {
-    // accept uri drops only
-//    event->accept(KURLDrag::canDecode(event));
+	// accept uri drops only
+	event->setAccepted(KUrl::List::canDecode(event->mimeData()));
 }
 
 void MilkChocolate::dropEvent(QDropEvent *event)
 {
-	KUrl::List uri;
-/*	if (KURLDrag::decode(event, uri))
-	{
-		for (KUrl::List::Iterator i = uri.begin(); i != uri.end(); ++i)
-			napp->player()->openFile(*i, false);
-	}
-*/
+	KUrl::List uriList = KUrl::List::fromMimeData(event->mimeData());
+	if (!uriList.isEmpty())
+		napp->playlist()->addFile(uriList);
 }
 
 void MilkChocolate::mouseReleaseEvent(QMouseEvent *e)
@@ -207,20 +197,14 @@
 	statusBar()->showMessage(!text.isNull() ? text : napp->player()->currentTitle());
 }
 
-void MilkChocolate::changeCaption(const QString& text)
-{
-	setCaption(text);
-}
 
-#include <kxmlguifactory.h>
-
 void MilkChocolate::popup()
 {
 	kDebug(66666) << "Hello" <<endl;
-	
+
 	if (!factory())
 		kDebug(66666) << "No factory" <<endl;
-	
+
 	QMenu *popup = static_cast<QMenu*>(factory()->container("NoatunContextMenu",this));
 	if (!popup)
 		kDebug(66666) << "No popup menu" <<endl;
@@ -233,9 +217,9 @@
 {
 //	connect(kwinmodule, SIGNAL(windowAdded(WId)), view, SLOT(attemptReparent(WId)));
 	changeStatusbar(napp->player()->currentTitle(), napp->player()->lengthString());
-//	mPlay->setOn(true);
+	mPlay->setChecked(true);
 	mStop->setEnabled(true);
-	mPlay->setIcon(BarIcon("noatunpause"));
+	mPlay->setIcon(KIcon("noatunpause"));
 }
 
 void MilkChocolate::slotStopped()
@@ -243,16 +227,16 @@
 	if (!napp->player()->current()) return;
 	changeStatusbar(i18n("No File Loaded"), napp->player()->lengthString());
 	mStop->setEnabled(false);
-//	mPlay->setOn(false);
+	mPlay->setChecked(false);
 	seeker()->setValue(0);
-	mPlay->setIcon(BarIcon("noatunplay"));
+	mPlay->setIcon(KIcon("noatunplay"));
 }
 
 void MilkChocolate::slotPaused()
 {
 	mStop->setEnabled(true);
-//	mPlay->setOn(false);
-	mPlay->setIcon(BarIcon("noatunplay"));
+	mPlay->setChecked(false);
+	mPlay->setIcon(KIcon("noatunplay"));
 }
 
 void MilkChocolate::slotTimeout()
@@ -263,8 +247,8 @@
 	if (static_cast<L33tSlider*>(seeker())->currentlyPressed()) return;
 	if (seeker())
 	{
-		seeker()->setRange ( 0, (int)napp->player()->length()/1000 );
-		seeker()->setValue ( (int)napp->player()->position()/1000 );
+		seeker()->setRange ( 0, (int)napp->player()->length() / 1000 );
+		seeker()->setValue ( (int)napp->player()->position() / 1000 );
 	}
 	changeStatusbar(0, napp->player()->lengthString());
 }
@@ -272,18 +256,18 @@
 void MilkChocolate::sliderMoved(int seconds)
 {
 	if (napp->player()->current())
-		changeStatusbar(0, napp->player()->positionString(seconds*1000));
+		changeStatusbar(0, napp->player()->positionString(seconds * 1000L));
 }
 
 void MilkChocolate::skipToWrapper(int second)
 {
-	emit skipTo((long)(second*1000));
+	emit skipTo(second * 1000L);
 }
 
-void MilkChocolate::changeLoopType(int t)
+/*void MilkChocolate::changeLoopType(int t)
 {
 	static const int time=2000;
-/*	switch (t)
+	switch (t)
 	{
 	case(Noatun::Player::None):
 		statusBar()->message(i18n("No looping"), time);
@@ -301,8 +285,7 @@
 		statusBar()->message(i18n("Random play"), time);
 		mLoop->setIcon(BarIcon("noatunlooprandom"));
 	}
-*/
-}
+}*/
 
 bool MilkChocolate::eventFilter(QObject *o, QEvent *e)
 {
@@ -323,19 +306,19 @@
 
 void MilkChocolate::playlistShown()
 {
-//	mPlaylist->setOn(true);
+	mPlaylist->setChecked(true);
 }
 
 void MilkChocolate::playlistHidden()
 {
-//	mPlaylist->setOn(false);
+	mPlaylist->setChecked(false);
 }
 
 void MilkChocolate::wheelEvent(QWheelEvent *e)
 {
-	int delta=e->delta();
-	mVolume->setValue(mVolume->value()+(delta/120));
-	napp->player()->setVolume(mVolume->value()+(delta/120));
+	int newValue = mVolume->value() + (e->delta() / 120);
+	mVolume->setValue(newValue);
+	napp->player()->setVolume(newValue);
 }
 
 #include "userinterface.moc"
--- trunk/KDE/kdemultimedia/noatun/modules/noatunui/userinterface.h #627144:627145
@@ -30,24 +30,22 @@
 {
 	Q_OBJECT
 	Global *napp;
-	
+
 public:
 	MilkChocolate(Plugin *pl, Global *gl);
 	virtual ~MilkChocolate();
 	void load(const QString& url);
-	
+
 protected:
 	virtual void dragEnterEvent(QDragEnterEvent *event);
 	virtual void dropEvent(QDropEvent *event);
-	virtual void closeEvent(QCloseEvent*);
-	virtual void showEvent(QShowEvent*e);
 	virtual void mouseReleaseEvent(QMouseEvent *);
 	virtual bool eventFilter(QObject*, QEvent*);
 	virtual void wheelEvent(QWheelEvent *e);
 
 protected:
 	QSlider *seeker() const { return mSeeker; }
-	KStatusBar *statusBar() const { return mStatusBar; }
+	//KStatusBar *statusBar() const { return mStatusBar; }
 
 public slots:
 	void slotPlaying();
@@ -59,7 +57,7 @@
 
 	void slotTimeout();
 	void sliderMoved(int seconds);
-	void changeLoopType(int t);
+	//void changeLoopType(int t);
 	void skipToWrapper(int second);
 
 signals:
@@ -67,13 +65,12 @@
 
 private slots:
 	void changeStatusbar(const QString& text, const QString &text2=0);
-	void changeCaption(const QString& text);
 	void popup();
 
 private:
 	QPushButton *mBack, *mStop, *mPlay, *mForward, *mPlaylist, *mPopup, *mLoop;
 	QSlider *mSeeker, *mVolume;
-	KStatusBar *mStatusBar;
+	//KStatusBar *mStatusBar;
 };
 
 
@@ -82,7 +79,7 @@
 	MilkChocolate *ui;
 public:
 	MCPlugin(KInstance *inst, Global *glob, const char* name);
-	
+
 	Interface *getInterface(const QString &n)
 	{
 		if (n == "FrontendInterface")
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic