diff options
Diffstat (limited to 'noatun/modules/noatunui')
-rw-r--r-- | noatun/modules/noatunui/Makefile.am | 16 | ||||
-rw-r--r-- | noatun/modules/noatunui/noatunui.cpp | 9 | ||||
-rw-r--r-- | noatun/modules/noatunui/noatunui.plugin | 120 | ||||
-rw-r--r-- | noatun/modules/noatunui/userinterface.cpp | 315 | ||||
-rw-r--r-- | noatun/modules/noatunui/userinterface.h | 72 |
5 files changed, 532 insertions, 0 deletions
diff --git a/noatun/modules/noatunui/Makefile.am b/noatun/modules/noatunui/Makefile.am new file mode 100644 index 00000000..443afd6c --- /dev/null +++ b/noatun/modules/noatunui/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES= -I$(top_srcdir)/noatun/library $(all_includes) +kde_module_LTLIBRARIES = noatun_ui.la + +noatun_ui_la_SOURCES = noatunui.cpp userinterface.cpp + +noatun_ui_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatun_ui_la_LIBADD = $(LIB_KFILE) $(top_builddir)/noatun/library/libnoatun.la \ + $(top_builddir)/noatun/library/libnoatuncontrols.la \ + -lqtmcop -lkmedia2_idl -lsoundserver_idl + +noatun_ui_la_METASOURCES = AUTO + +noinst_HEADERS = userinterface.h + +noatun_modules_ui_DATA = noatunui.plugin +noatun_modules_uidir = $(kde_datadir)/noatun diff --git a/noatun/modules/noatunui/noatunui.cpp b/noatun/modules/noatunui/noatunui.cpp new file mode 100644 index 00000000..adb9534b --- /dev/null +++ b/noatun/modules/noatunui/noatunui.cpp @@ -0,0 +1,9 @@ +#include "userinterface.h" + +extern "C" +{ + KDE_EXPORT Plugin *create_plugin() + { + return new MilkChocolate; + } +} diff --git a/noatun/modules/noatunui/noatunui.plugin b/noatun/modules/noatunui/noatunui.plugin new file mode 100644 index 00000000..e8413cd8 --- /dev/null +++ b/noatun/modules/noatunui/noatunui.plugin @@ -0,0 +1,120 @@ +Filename=noatun_ui.la +Author=Charles Samuels +Site=http://noatun.kde.org/plugins/milkchocolate/ +Email=charles@kde.org +Type=userinterface +License=Artistic +Name=Milk-Chocolate +Name[ar]=حليب-شوكولا +Name[az]=Şokaladlı Süd +Name[br]=Chokolad leizh +Name[bs]=Mlijeko-čokolada +Name[ca]=Xocolata amb llet +Name[cs]=Noatun mléčná čokoláda +Name[cy]=Sioclat Llefrith +Name[da]=Mælkechokolade +Name[de]=Milchschokolade +Name[eo]=Laktoĉokolado +Name[es]=Chocolate con leche +Name[fi]=Maitosuklaa +Name[fr]=Chocolat au lait +Name[gl]=Leite-Chocolate +Name[hi]=मिल्क-चॉकलेट +Name[hr]=Mliječna čokolada +Name[hu]=Tejcsoki +Name[is]=Mjólkursúkkulaði +Name[it]=Caffellatte +Name[km]=ទឹកដោះគោ-សូកូឡា +Name[ko]=밀크 초콜릿 +Name[lt]=Pieniškas šokoladas +Name[lv]=Piena-Šokolāde +Name[mk]=Млечна чоколада +Name[mt]=Ċikkulata +Name[nb]=Melkesjokolade +Name[nds]=Melkschokolaad +Name[ne]=दुध-मिठाइ +Name[nl]=Melkchocolade +Name[nn]=Mjølkesjokolade +Name[pl]=Czekolada mleczna +Name[pt]=Leite com Chocolate +Name[pt_BR]=Noatun Leite-Chocolate +Name[ro]=Ciocolată cu lapte +Name[ru]=Молочный шоколад +Name[se]=Mielkešokolada +Name[sk]=Mliečna čokoláda +Name[sl]=Mlečna čokolada +Name[sv]=Mjölkchoklad +Name[ta]=மில்க்-சாக்லேட் +Name[tg]=Шоколади Ширӣ +Name[tr]=Çikolatalı Süt +Name[uk]=Молочний шоколад +Name[ven]=Tshokholeiti ya mafhi +Name[xh]=Ubisi-ichocolate +Name[zh_CN]=牛奶巧克力 +Name[zh_HK]=牛奶巧克力 +Name[zh_TW]=牛奶巧克力 +Name[zu]=Ushokolade Wobisi +Comment=Noatun's simple GUI +Comment[ar]=واجهة بسيطة جدا لNoatun +Comment[az]=Noatun bəsit axtar üzü +Comment[bg]=Семпъл графичен интерфейс за Noatun +Comment[bs]=Jednostavan Noatunov GUI +Comment[ca]=IGU senzill pel Noatun +Comment[cs]=Jednoduché rozhraní pro Noatun +Comment[cy]=GUI syml Noatun +Comment[da]=Noatuns enkle GUI +Comment[de]=Noatuns einfache Oberfläche +Comment[el]=Το απλό περιβάλλον χρήσης του Noatun +Comment[eo]=La simpla grafika etoso de Noatun +Comment[es]=Interfaz simple de Noatun +Comment[et]=Lihtne Noatuni kasutajaliides +Comment[eu]=Noatun-en GUI simplea +Comment[fa]=ونک ساده Noatun +Comment[fi]=Noatunin yksinkertainen käyttöliittymä +Comment[fr]=Interface graphique simple de Noatun +Comment[ga]=Comhéadan simplí grafach ar Noatun +Comment[gl]=GUI sinxela de Noatun +Comment[he]=ממשק המשתמש הגרפי הפשוט של Noatun +Comment[hi]=नोआट्यून का साधारण जीयूआई +Comment[hr]=Noatunovo jednostavno sučelje +Comment[hu]=A Noatun egyszerű grafikus kezelői felülete +Comment[id]=Contoh Noatun'GUI +Comment[is]=Hið einfalda viðmót Nóatúns forritsins +Comment[it]=Interfaccia grafica semplice di Noatun +Comment[ja]=Noatun のシンプルな GUI +Comment[kk]=Noatun-ның қарапайым графикалық интерфейсі +Comment[km]=ចំណុចប្រទាក់ក្រាហ្វិកសាមញ្ញរបស់ Noatun +Comment[ko]=Noatun의 간단한 GUI +Comment[lt]=Noatun paprastas GUI +Comment[lv]=Vienkāršs Noatuna GUI +Comment[mk]=Едноставен графички интерфејс за Noatun +Comment[ms]=GUI Noatun yang ringkas +Comment[mt]=GUI sempliċi għal Noatun +Comment[nb]=Noatuns enkle GUI +Comment[nds]=Eenfach Böversiet vun Noatun +Comment[ne]=नोवटुनको साधारण GUI +Comment[nl]=Noatun's eenvoudige GUI +Comment[nn]=Det enkle Noatun-GUI-et +Comment[pa]=ਨੋਟੌਮ ਦਾ ਸਧਾਰਨ GUI +Comment[pl]=Prosty motyw Noatun +Comment[pt]=Uma interface simples do Noatun +Comment[pt_BR]=Interface simplificada do Noatun +Comment[ro]=Interfaţă grafică Noatun simplă +Comment[ru]=Простой графический интерфейс Noatun +Comment[se]=Noatuna oktageardanis grafihkkalaš lakta +Comment[sk]=Jednoduché rozhranie pre Noatun +Comment[sl]=Noatunov preprost uporabniški vmesnik +Comment[sr]=Noatun-ов једноставан GUI +Comment[sr@Latn]=Noatun-ov jednostavan GUI +Comment[sv]=Noatuns enkla gränssnitt +Comment[ta]=Noatun'இன் எளிய முகப்பொன்று +Comment[tg]=Интерфейси Графикии соддаи Noatun +Comment[th]=ส่วนติดต่อผู้ใช้แบบกราฟิกแบบเรียบง่ายของ Noatun +Comment[tr]=Noatun basit arayüzü +Comment[uk]=Простий графічний інтерфейс Noatun +Comment[ven]=Noatun yo leluwaho ya GUI +Comment[xh]=iGUI elula ye Noatun +Comment[zh_CN]=Noatun 的简单界面 +Comment[zh_HK]=Noatun 的簡單圖形界面 +Comment[zh_TW]=Noatun 簡單圖形界面 +Comment[zu]=I GUI elula ye Noatun diff --git a/noatun/modules/noatunui/userinterface.cpp b/noatun/modules/noatunui/userinterface.cpp new file mode 100644 index 00000000..c13d4d6d --- /dev/null +++ b/noatun/modules/noatunui/userinterface.cpp @@ -0,0 +1,315 @@ +/* + * noatun.cpp + * + * Copyright (C) 1999 Charles Samuels <charles@kde.org> + */ + +#include "userinterface.h" +#include <noatun/playlist.h> +#include <noatun/stdaction.h> +#include <noatun/app.h> +#include <noatun/player.h> +#include <noatun/controls.h> +#include <noatun/effects.h> + +#include <qpushbutton.h> +#include <qdragobject.h> +#include <qlayout.h> +#include <qtooltip.h> +#include <qobjectlist.h> +#include <qobjectdict.h> + +#include <kpopupmenu.h> +#include <kstatusbar.h> +#include <kglobal.h> +#include <klocale.h> +#include <kiconloader.h> +#include <kurldrag.h> +#include <kfiledialog.h> +#include <kconfig.h> + +MilkChocolate::MilkChocolate() : QWidget(0,"NoatunUI"), UserInterface() +{ + setAcceptDrops(true); + static const int buttonSize=32; + + { // The buttons + mBack=new QPushButton(this); + mBack->setFixedSize(buttonSize,buttonSize); + mBack->setPixmap(BarIcon("noatunback")); + connect(mBack, SIGNAL(clicked()), napp->player(), SLOT(back())); + QToolTip::add(mBack,i18n("Back")); + + mStop=new QPushButton(this); + mStop->setFixedSize(buttonSize,buttonSize); + mStop->setPixmap(BarIcon("noatunstop")); + connect(mStop, SIGNAL(clicked()), napp->player(), SLOT(stop())); + QToolTip::add(mStop, i18n("Stop")); + + mPlay=new QPushButton(this); + mPlay->setToggleButton(true); + mPlay->setFixedSize(buttonSize,buttonSize); + mPlay->setPixmap(BarIcon("noatunplay")); + connect(mPlay, SIGNAL(clicked()), napp->player(), SLOT(playpause())); + QToolTip::add(mPlay, i18n("Play")); + + mForward=new QPushButton(this); + mForward->setFixedSize(buttonSize,buttonSize); + mForward->setPixmap(BarIcon("noatunforward")); + connect(mForward, SIGNAL(clicked()), napp->player(), SLOT(forward())); + QToolTip::add(mForward, i18n("Forward")); + + mPlaylist=new QPushButton(this); + mPlaylist->setToggleButton(true); + mPlaylist->setFixedSize(buttonSize,buttonSize); + mPlaylist->setPixmap(BarIcon("noatunplaylist")); + connect(mPlaylist, SIGNAL(clicked()), napp->player(), SLOT(toggleListView())); + QToolTip::add(mPlaylist, i18n("Playlist")); + + mLoop=new QPushButton(this); + mLoop->setFixedSize(buttonSize,buttonSize); + mLoop->setPixmap(BarIcon("noatunloopnone")); + connect(mLoop, SIGNAL(clicked()), napp->player(), SLOT(loop())); + QToolTip::add(mLoop, i18n("Change loop style")); + + mPopup=new QPushButton(this); + mPopup->setFixedSize(buttonSize,buttonSize); + mPopup->setPixmap(BarIcon("noatun")); + connect(mPopup, SIGNAL(clicked()), SLOT(popup())); +// QToolTip::add(mRemoveCurrent, i18n("Remove current file from playlist")); + + } + + mVolume=new L33tSlider(0,100,10,0, Horizontal, this); + mVolume->setValue(napp->player()->volume()); + mSeeker=new L33tSlider(0,1000,10,0, Horizontal, this); + + mStatusBar=new KStatusBar(this); + + + QGridLayout *l=new QGridLayout(this); + l->addWidget(mBack,0,0); + l->addWidget(mStop,0,1); + l->addWidget(mPlay,0,2); + l->addWidget(mForward,0,3); + l->addWidget(mPlaylist,0,4, Qt::AlignLeft); + l->addWidget(mLoop,0,5); + l->addWidget(mPopup,0,6); + l->addColSpacing(4, buttonSize+8); + + l->addMultiCellWidget(mVolume,1,1,0,6); + l->addMultiCellWidget(mSeeker,2,2,0,6); + l->addMultiCellWidget(mStatusBar,3,3,0,6); + + statusBar()->message(i18n("No File Loaded")); + statusBar()->insertItem("--:--/--:--", 1, 0, true); + + 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())); + connect(napp->player(), SIGNAL(paused()), this, SLOT(slotPaused())); + napp->player()->handleButtons(); + + connect(napp->player(), SIGNAL(timeout()), this, SLOT(slotTimeout())); + connect(napp->player(), SIGNAL(loopTypeChange(int)), this, SLOT(changeLoopType(int))); + +// if(seeker()) + { + /* This skipToWrapper is needed to pass milliseconds to Player() as everybody + * below the GUI is based on milliseconds instead of some unprecise thingy + * like seconds or mille */ + connect(seeker(), SIGNAL(userChanged(int)), this, SLOT(skipToWrapper(int))); + connect(this, SIGNAL(skipTo(int)), napp->player(), SLOT(skipTo(int))); + connect(seeker(), SIGNAL(sliderMoved(int)), SLOT(sliderMoved(int))); + } + connect(mVolume, SIGNAL(sliderMoved(int)), napp->player(), SLOT(setVolume(int))); + connect(mVolume, SIGNAL(userChanged(int)), napp->player(), SLOT(setVolume(int))); + + + connect(napp->player(), SIGNAL(playlistShown()), SLOT(playlistShown())); + connect(napp->player(), SIGNAL(playlistHidden()), SLOT(playlistHidden())); + + // Event Filter for the RMB + for (QPtrListIterator<QObject> i(*children()); i.current(); ++i) + (*i)->installEventFilter(this); + + setCaption("Noatun"); + setIcon(BarIcon("noatun")); + show(); + + // What it is now, stay, stay.. roll over, good boy! + setFixedSize(minimumSize()); +} + +MilkChocolate::~MilkChocolate() +{ + // If cfg dialog is still open, delete it so it saves it's position +// if(prefDlgExist) +// 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)); +} + +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); + } +} + +void MilkChocolate::mouseReleaseEvent(QMouseEvent *e) +{ + QWidget::mouseReleaseEvent(e); + if (e->button()!=RightButton) return; + NoatunStdAction::ContextMenu::showContextMenu(); +} + +void MilkChocolate::changeStatusbar(const QString& text, const QString &text2) +{ + if (!text2.isNull()) + statusBar()->changeItem(text2, 1); + + statusBar()->message(!text.isNull() ? text : napp->player()->current().title()); +} + +void MilkChocolate::changeCaption(const QString& text) +{ + setCaption(text); +} + +void MilkChocolate::popup() +{ + NoatunStdAction::ContextMenu::showContextMenu( + mapToGlobal(mPopup->geometry().bottomLeft()) + ); +} + +void MilkChocolate::slotPlaying() +{ +// connect(kwinmodule, SIGNAL(windowAdded(WId)), view, SLOT(attemptReparent(WId))); + changeStatusbar(napp->player()->current().title(), napp->player()->lengthString()); + mPlay->setOn(true); + mStop->setEnabled(true); + mPlay->setPixmap(BarIcon("noatunpause")); +} + +void MilkChocolate::slotStopped() +{ + if (!napp->player()->current()) return; + changeStatusbar(i18n("No File Loaded"), napp->player()->lengthString()); + mStop->setEnabled(false); + mPlay->setOn(false); + seeker()->setValue(0); + mPlay->setPixmap(BarIcon("noatunplay")); +} + +void MilkChocolate::slotPaused() +{ + mStop->setEnabled(true); + mPlay->setOn(false); + mPlay->setPixmap(BarIcon("noatunplay")); +} + +void MilkChocolate::slotTimeout() +{ + mVolume->setValue(napp->player()->volume()); + + if (!napp->player()->current()) return; + if (static_cast<L33tSlider*>(seeker())->currentlyPressed()) return; + if (seeker()) + { + seeker()->setRange ( 0, (int)napp->player()->getLength()/1000 ); + seeker()->setValue ( (int)napp->player()->getTime()/1000 ); + } + changeStatusbar(0, napp->player()->lengthString()); +} + +void MilkChocolate::sliderMoved(int seconds) +{ + if (napp->player()->current()) + changeStatusbar(0, napp->player()->lengthString(seconds*1000)); +} + +void MilkChocolate::skipToWrapper(int second) +{ + emit skipTo((long)(second*1000)); +} + +void MilkChocolate::changeLoopType(int t) +{ + static const int time=2000; + switch (t) + { + case(Player::None): + statusBar()->message(i18n("No looping"), time); + mLoop->setPixmap(BarIcon("noatunloopnone")); + break; + case(Player::Song): + statusBar()->message(i18n("Song looping"), time); + mLoop->setPixmap(BarIcon("noatunloopsong")); + break; + case(Player::Playlist): + statusBar()->message(i18n("Playlist looping"), time); + mLoop->setPixmap(BarIcon("noatunloopplaylist")); + break; + case(Player::Random): + statusBar()->message(i18n("Random play"), time); + mLoop->setPixmap(BarIcon("noatunlooprandom")); + } + +} + +bool MilkChocolate::eventFilter(QObject *o, QEvent *e) +{ + if ((e->type() == QEvent::MouseButtonRelease) + && ((static_cast<QMouseEvent*>(e))->button()==RightButton)) + { + mouseReleaseEvent(static_cast<QMouseEvent*>(e)); + return true; + } + + if (e->type() == QEvent::Wheel) + { + wheelEvent(static_cast<QWheelEvent*>(e)); + return true; + } + return QWidget::eventFilter(o, e); +} + +void MilkChocolate::playlistShown() +{ + mPlaylist->setOn(true); +} + +void MilkChocolate::playlistHidden() +{ + mPlaylist->setOn(false); +} + +void MilkChocolate::wheelEvent(QWheelEvent *e) +{ + int delta=e->delta(); + mVolume->setValue(mVolume->value()+(delta/120)); + napp->player()->setVolume(mVolume->value()+(delta/120)); +} + +#include "userinterface.moc" diff --git a/noatun/modules/noatunui/userinterface.h b/noatun/modules/noatunui/userinterface.h new file mode 100644 index 00000000..94dc9c44 --- /dev/null +++ b/noatun/modules/noatunui/userinterface.h @@ -0,0 +1,72 @@ +#ifndef USERINTERFACE_H +#define USERINTERFACE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <noatun/plugin.h> +#include <noatun/app.h> + +// Pref dialog pointer global now for position saving +#include <noatun/pref.h> + +class Player; +class QSlider; +class QPushButton; +class KStatusBar; + +/** + * @short Main window class + * @author Charles Samuels <charles@kde.org> + * @version 0.1 + */ +class MilkChocolate : public QWidget, public UserInterface +{ +Q_OBJECT +public: + MilkChocolate(); + 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; } + +public slots: + void slotPlaying(); + void slotStopped(); + void slotPaused(); + + void playlistShown(); + void playlistHidden(); + + void slotTimeout(); + void sliderMoved(int seconds); + void changeLoopType(int t); + void skipToWrapper(int second); + +signals: + void skipTo( int ); // emitted by skipToWrapper() + +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; +}; + +#endif |