summaryrefslogtreecommitdiffstats
path: root/kscd/docking.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /kscd/docking.cpp
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kscd/docking.cpp')
-rw-r--r--kscd/docking.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/kscd/docking.cpp b/kscd/docking.cpp
new file mode 100644
index 00000000..9792ba73
--- /dev/null
+++ b/kscd/docking.cpp
@@ -0,0 +1,158 @@
+/*
+ * KSCD -- a simpole cd player for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "docking.h"
+#include "kscd.h"
+
+#include <qhbox.h>
+#include <qtooltip.h>
+
+#include <kaboutdata.h>
+#include <kactioncollection.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kpopupmenu.h>
+#include <kpassivepopup.h>
+
+#include <kdebug.h>
+
+DockWidget::DockWidget( KSCD* parent, const char *name)
+ : KSystemTray( parent, name )
+{
+ m_popup = 0;
+ setPixmap( loadIcon("cdsmall") );
+
+ KActionCollection* actionCollection = parent->actionCollection();
+ m_backAction = actionCollection->action("Previous");
+ m_forwardAction = actionCollection->action("Next");
+ m_backPix = loadIcon("player_start");
+ m_forwardPix = loadIcon("player_end");
+
+ // popup menu for right mouse button
+ QPopupMenu* popup = contextMenu();
+
+ popup->insertItem(KGlobal::iconLoader()->loadIconSet("player_play", KIcon::Small), i18n("Play/Pause"), parent, SLOT(playClicked()));
+ popup->insertItem(KGlobal::iconLoader()->loadIconSet("player_stop", KIcon::Small), i18n("Stop"), parent, SLOT(stopClicked()));
+ popup->insertItem(KGlobal::iconLoader()->loadIconSet("player_end", KIcon::Small), i18n("Next"), parent, SLOT(nextClicked()));
+ popup->insertItem(KGlobal::iconLoader()->loadIconSet("player_start", KIcon::Small), i18n("Previous"), parent, SLOT(prevClicked()));
+ popup->insertItem(KGlobal::iconLoader()->loadIconSet("player_eject", KIcon::Small), i18n("Eject"), parent, SLOT(ejectClicked()));
+
+ QToolTip::add(this, kapp->aboutData()->programName());
+}
+
+DockWidget::~DockWidget()
+{
+}
+
+void DockWidget::createPopup(const QString &songName, bool addButtons)
+{
+ if (!Prefs::trackAnnouncement())
+ return;
+
+ delete m_popup;
+ m_popup = new KPassivePopup(this);
+
+ QHBox* box = new QHBox(m_popup);
+
+ if (addButtons)
+ {
+ QPushButton* backButton = new QPushButton(m_backPix, 0, box, "popup_back");
+ backButton->setFlat(true);
+ connect(backButton, SIGNAL(clicked()), m_backAction, SLOT(activate()));
+ }
+
+ QLabel* l = new QLabel(songName, box);
+ l->setMargin(3);
+
+ if (addButtons)
+ {
+ QPushButton* forwardButton = new QPushButton(m_forwardPix, 0, box, "popup_forward");
+ forwardButton->setFlat(true);
+ connect(forwardButton, SIGNAL(clicked()), m_forwardAction, SLOT(activate()));
+ }
+
+ m_popup->setView(box);
+ m_popup->setAutoDelete(false);
+ m_popup->show();
+}
+
+void DockWidget::setToolTip(const QString& text)
+{
+ if (tip == text)
+ {
+ return;
+ }
+
+ tip = text;
+ QToolTip::remove(this);
+
+ if (text.isEmpty())
+ {
+ QToolTip::add(this, kapp->aboutData()->programName());
+ }
+ else
+ {
+ QToolTip::add(this, text);
+ }
+}
+
+void DockWidget::wheelEvent(QWheelEvent *e)
+{
+ if (e->orientation() == Horizontal)
+ return;
+
+ KSCD* kscd = dynamic_cast<KSCD*>(parent());
+ if (kscd == 0)
+ return;
+
+ switch (e->state())
+ {
+ case ShiftButton:
+ {
+ if (e->delta() > 0)
+ {
+ kscd->incVolume();
+ }
+ else
+ {
+ kscd->decVolume();
+ }
+ break;
+ }
+ default:
+ {
+ if (e->delta() > 0)
+ {
+ kscd->nextClicked();
+ }
+ else
+ {
+ kscd->prevClicked();
+ }
+ }
+ }
+}
+
+#include "docking.moc"