Commit c4aa5cd1 authored by Scott Wheeler's avatar Scott Wheeler

I don't have home internet access at the moment, so this is a whole weeks

worth of major cleanups and redesign things.

svn path=/trunk/kdemultimedia/juk/; revision=177610
parent 6df2292a
......@@ -3,12 +3,12 @@ bin_PROGRAMS = juk
## INCLUDES were found outside kdevelop specific part
juk_SOURCES = cache.cpp audiodata.cpp cacheitem.cpp genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_SOURCES = collectionlist.cpp playlistitem.cpp playlist.cpp playlistsplitter.cpp listboxpixmap.cpp playlistbox.cpp tageditor.cpp cache.cpp audiodata.cpp genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_LDADD = -lid3 -lsoundserver_idl $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
SUBDIRS = pics data
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp filelist.cpp filelist.h tag.cpp tag.h filelistitem.cpp filelistitem.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h cacheitem.cpp cacheitem.h audiodata.cpp audiodata.h cache.cpp cache.h
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp tag.cpp tag.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h audiodata.cpp audiodata.h cache.cpp cache.h tageditor.cpp tageditor.h playlistbox.cpp playlistbox.h listboxpixmap.cpp listboxpixmap.h playlistsplitter.cpp playlistsplitter.h playlist.cpp playlist.h playlistitem.cpp playlistitem.h collectionlist.cpp collectionlist.h
install-data-local:
$(mkinstalldirs) $(kde_appsdir)/Multimedia/
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ Cache *Cache::instance()
return(cache);
}
Cache::Item *Cache::item(const QString &fileName) const
CacheItem *Cache::item(const QString &file) const
{
return(0);
}
......@@ -41,7 +41,7 @@ Cache::Item *Cache::item(const QString &fileName) const
Cache::Cache()
{
setAutoDelete(true);
}
Cache::~Cache()
......@@ -50,15 +50,20 @@ Cache::~Cache()
}
////////////////////////////////////////////////////////////////////////////////
// Cache::Item public methods
// CacheItem public methods
////////////////////////////////////////////////////////////////////////////////
Cache::Item::Item()
CacheItem::CacheItem()
{
}
Cache::Item::~Item()
CacheItem::CacheItem(const Tag &tag)
{
}
CacheItem::~CacheItem()
{
}
......@@ -19,18 +19,23 @@
#define CACHE_H
#include <qstring.h>
#include <qdict.h>
#include "tag.h"
// Eventually this should implement the same interface as the Tag class; in fact
// there should be an abstract API for both of them to use. But, for the
// moment this is just a place holder to fill in the design.
class Cache
class CacheItem;
class Cache : public QDict<CacheItem>
{
public:
class Item;
static Cache *instance();
Item *item(const QString &fileName) const;
CacheItem *item(const QString &fileName) const;
protected:
Cache();
......@@ -41,11 +46,18 @@ private:
};
class Cache::Item
class CacheItem
{
public:
Item();
virtual ~Item();
CacheItem();
CacheItem(const Tag &tag);
virtual ~CacheItem();
QString track() const { return QString::null; }
QString artist() const { return QString::null; }
QString album() const { return QString::null; }
QString trackNumber() const { return QString::null; }
QString length() const { return QString::null; }
};
#endif
......@@ -82,3 +82,4 @@ KToolBar *CustomAction::getToolBar()
{
return(toolbar);
}
#include "customaction.moc"
......@@ -22,6 +22,8 @@
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <qsplitter.h>
#include "juk.h"
////////////////////////////////////////////////////////////////////////////////
......@@ -53,7 +55,7 @@ void JuK::setupActions()
KStdAction::open(this, SLOT(openFile()), actionCollection());
(void) new KAction(i18n("Open &Directory..."), "fileopen", 0, this, SLOT(openDirectory()), actionCollection(), "openDirectory");
KStdAction::save(this, SLOT(saveFile()), actionCollection());
(void) new KAction(i18n("Delete"), "edittrash", 0, this, SLOT(deleteFile()), actionCollection(), "deleteFile");
(void) new KAction(i18n("Delete"), "edittrash", 0, this, SLOT(remove()), actionCollection(), "remove");
KStdAction::quit(this, SLOT(quit()), actionCollection());
// edit menu
......@@ -63,20 +65,10 @@ void JuK::setupActions()
KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
// play menu
addToPlaylistAction = new KAction(i18n("&Add to Playlist"), "enqueue", 0, this,
SLOT(addToPlaylist()), actionCollection(), "addToPlaylist");
removeFromPlaylistAction = new KAction(i18n("&Remove from Playlist"), "dequeue", 0, this,
SLOT(removeFromPlaylist()), actionCollection(), "removeFromPlaylist");
playAction = new KAction(i18n("&Play"), "1rightarrow", 0, this, SLOT(playFile()), actionCollection(), "playFile");
pauseAction = new KAction(i18n("P&ause"), "player_pause", 0, this, SLOT(pauseFile()), actionCollection(), "pauseFile");
stopAction = new KAction(i18n("&Stop"), "player_stop", 0, this, SLOT(stopFile()), actionCollection(), "stopFile");
// function menu
showTaggerAction = new KAction(i18n("Tagger"), "tag", 0, this, SLOT(showTagger()), actionCollection(), "showTagger");
showPlaylistAction = new KAction(i18n("Playlist Editor"), "edit", 0, this, SLOT(showPlaylist()), actionCollection(), "showPlaylist");
// just in the toolbar
sliderAction = new SliderAction(i18n("Track Position"), actionCollection(), "trackPositionAction");
......@@ -86,29 +78,23 @@ void JuK::setupActions()
void JuK::setupLayout()
{
// automagically save and restore settings
this->setAutoSaveSettings();
// create the main widgets
tagger = new TaggerWidget(this);
playlist = new PlaylistWidget(this);
setAutoSaveSettings();
showTagger();
splitter = new PlaylistSplitter(this, "playlistSplitter");
setCentralWidget(splitter);
// set the slider to the proper orientation and make it stay that way
sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *)));
// playlist item activation connection
connect(playlist->getPlaylistList(), SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(playItem(QListViewItem *)));
connect(tagger->getTaggerList(), SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(playItem(QListViewItem *)));
tagger->getTaggerList()->setFocus();
connect(splitter, SIGNAL(playlistDoubleClicked(QListViewItem *)), this, SLOT(playItem(QListViewItem *)));
}
void JuK::setupPlayer()
{
trackPositionDragging=false;
noSeek=false;
trackPositionDragging = false;
noSeek = false;
pauseAction->setEnabled(false);
stopAction->setEnabled(false);
......@@ -133,8 +119,7 @@ void JuK::processArgs()
for(int i = 0; i < args->count(); i++)
files.append(args->arg(i));
if(tagger)
tagger->add(files);
splitter->open(files);
}
void JuK::readConfig()
......@@ -172,32 +157,30 @@ void JuK::saveConfig()
void JuK::openFile()
{
QStringList files = KFileDialog::getOpenFileNames(QString::null, "*.mp3|MPEG Audio (*.mp3)");
tagger->add(files);
splitter->open(files);
}
void JuK::openDirectory()
{
tagger->add(KFileDialog::getExistingDirectory());
splitter->open(KFileDialog::getExistingDirectory());
}
void JuK::saveFile()
{
if(tagger && tagger->isVisible())
tagger->save();
splitter->save();
}
void JuK::deleteFile()
void JuK::remove()
{
QPtrList<FileListItem> items(tagger->getSelectedItems());
FileListItem *item = items.first();
QPtrList<PlaylistItem> items(splitter->playlistSelection());
PlaylistItem *item = items.first();
while(item) {
if(item == playingItem)
playingItem = 0;
item = items.next();
if(item == playingItem)
playingItem = 0;
item = items.next();
}
if(tagger && tagger->isVisible())
tagger->deleteFile();
splitter->remove();
}
void JuK::quit()
......@@ -211,78 +194,27 @@ void JuK::quit()
void JuK::cut()
{
if(tagger && tagger->isVisible()) {
QPtrList<FileListItem> items(tagger->getTaggerList()->selectedItems());
FileListItem *item = items.first();
while(item) {
if(item == playingItem)
playingItem = 0;
item = items.next();
}
QPtrList<PlaylistItem> items = splitter->playlistSelection();
tagger->getTaggerList()->remove(items);
PlaylistItem *item = items.first();
while(item) {
if(item == playingItem)
playingItem = 0;
item = items.next();
}
else if(playlist && playlist->isVisible())
removeFromPlaylist();
}
void JuK::selectAll()
{
if(tagger && tagger->isVisible()) {
tagger->getTaggerList()->selectAll(true);
}
else if(playlist && playlist->isVisible()) {
playlist->getPlaylistList()->selectAll(true);
}
splitter->clearSelectedItems();
}
////////////////////////////////////////////////////////////////////////////////
// function menu
////////////////////////////////////////////////////////////////////////////////
void JuK::showTagger()
{
playlist->hide();
tagger->show();
setCentralWidget(tagger);
addToPlaylistAction->setEnabled(true);
removeFromPlaylistAction->setEnabled(false);
showTaggerAction->setEnabled(false);
showPlaylistAction->setEnabled(true);
}
void JuK::showPlaylist()
void JuK::selectAll(bool select)
{
tagger->hide();
playlist->show();
setCentralWidget(playlist);
addToPlaylistAction->setEnabled(false);
removeFromPlaylistAction->setEnabled(true);
showTaggerAction->setEnabled(true);
showPlaylistAction->setEnabled(false);
splitter->selectAll(select);
}
////////////////////////////////////////////////////////////////////////////////
// player menu
////////////////////////////////////////////////////////////////////////////////
void JuK::addToPlaylist()
{
QPtrList<FileListItem> items(tagger->getSelectedItems());
playlist->add(items);
}
void JuK::removeFromPlaylist()
{
QPtrList<FileListItem> items(playlist->getSelectedItems());
playlist->remove(items);
}
void JuK::playFile()
{
if(player.paused()) {
......@@ -294,12 +226,12 @@ void JuK::playFile()
playTimer->start(pollInterval);
}
}
else if(playlist) {
QPtrList<FileListItem> items(playlist->getSelectedItems());
else if(splitter) {
QPtrList<PlaylistItem> items = splitter->playlistSelection();
if(items.count() > 0)
playItem(dynamic_cast<FileListItem *>(items.at(0)));
playItem(items.at(0));
else
playItem(playlist->firstItem());
playItem(splitter->playlistFirstItem());
}
}
......@@ -349,9 +281,9 @@ void JuK::pollPlay()
if(player.paused())
pauseFile();
else {
if(playingItem && dynamic_cast<FileListItem*>(playingItem->itemBelow())) {
if(playingItem && dynamic_cast<PlaylistItem *>(playingItem->itemBelow())) {
playingItem->setPixmap(0, 0);
playingItem = dynamic_cast<FileListItem *>(playingItem->itemBelow());
playingItem = dynamic_cast<PlaylistItem *>(playingItem->itemBelow());
sliderAction->getTrackPositionSlider()->setValue(0);
player.play(playingItem->absFilePath(), player.getVolume());
if(player.playing()) {
......@@ -384,12 +316,12 @@ void JuK::setVolume(int volume)
void JuK::playItem(QListViewItem *item)
{
FileListItem *fileListItem = dynamic_cast<FileListItem *>(item);
PlaylistItem *fileListItem = dynamic_cast<PlaylistItem *>(item);
if(fileListItem)
playItem(fileListItem);
}
void JuK::playItem(FileListItem *item)
void JuK::playItem(PlaylistItem *item)
{
if(player.playing() || player.paused())
stopFile();
......@@ -414,7 +346,9 @@ void JuK::playTaggerItem(QListViewItem *item)
}
void JuK::playTaggerItem(FileListItem *item)
void JuK::playTaggerItem(PlaylistItem *item)
{
}
#include "juk.moc"
......@@ -28,11 +28,14 @@
#include <kmainwindow.h>
#include <qtimer.h>
#include <qwidgetstack.h>
#include "taggerwidget.h"
#include "playlistwidget.h"
#include "slideraction.h"
#include "player.h"
#include "playlistbox.h"
#include "playlistsplitter.h"
class JuK : public KMainWindow
{
......@@ -51,8 +54,7 @@ private:
void saveConfig();
// layout objects
TaggerWidget *tagger;
PlaylistWidget *playlist;
PlaylistSplitter *splitter;
// actions
SliderAction *sliderAction;
......@@ -60,15 +62,9 @@ private:
KAction *pauseAction;
KAction *stopAction;
KAction *showTaggerAction;
KAction *showPlaylistAction;
KAction *addToPlaylistAction;
KAction *removeFromPlaylistAction;
QTimer *playTimer;
Player player;
FileListItem *playingItem;
PlaylistItem *playingItem;
bool trackPositionDragging;
bool noSeek;
......@@ -79,22 +75,14 @@ private slots:
void openFile();
void openDirectory();
void saveFile();
void deleteFile();
void remove();
void quit();
// edit menu
void cut();
void copy() {};
void paste() {};
void selectAll();
// function menu
void showTagger();
void showPlaylist();
// player menu
void addToPlaylist();
void removeFromPlaylist();
void selectAll(bool select = true);
void playFile();
void pauseFile();
......@@ -107,9 +95,9 @@ private slots:
void pollPlay();
void setVolume(int volume);
void playItem(QListViewItem *item);
void playItem(FileListItem *item);
void playItem(PlaylistItem *item);
void playTaggerItem(QListViewItem *item);
void playTaggerItem(FileListItem *item);
void playTaggerItem(PlaylistItem *item);
};
#endif
......@@ -7,18 +7,11 @@
<Separator/>
<Action name="file_save"/>
<Separator/>
<Action name="deleteFile"/>
<Action name="remove"/>
<Separator/>
<Action name="file_quit"/>
</Menu>
<Menu name="Function"><text>F&amp;unction</text>
<Action name="showTagger"/>
<Action name="showPlaylist"/>
</Menu>
<Menu name="player"><text>&amp;Player</text>
<Action name="addToPlaylist"/>
<Action name="removeFromPlaylist"/>
<Separator/>
<Menu name="player"><text>&amp;Player</text>
<Action name="playFile"/>
<Action name="pauseFile"/>
<Action name="stopFile"/>
......@@ -29,16 +22,12 @@
<Action name="file_open"/>
<Action name="openDirectory"/>
<Action name="file_save"/>
<Action name="deleteFile"/>
<Action name="addToPlaylist"/>
<Action name="removeFromPlaylist"/>
<Action name="remove"/>
<Separator lineSeparator="true"/>
<Action name="edit_cut"/>
<Action name="edit_copy"/>
<Action name="edit_paste"/>
<Separator lineSeparator="true"/>
<Action name="showTagger"/>
<Action name="showPlaylist"/>
</ToolBar>
<ToolBar name="playToolBar" noMerge="1"><text>Play Toolbar</text>
......
......@@ -48,34 +48,34 @@ void PlaylistWidget::add(QStringList &items)
playlistList->append(items);
}
void PlaylistWidget::add(FileListItem *item)
void PlaylistWidget::add(PlaylistItem *item)
{
playlistList->append(item);
}
void PlaylistWidget::add(QPtrList<FileListItem> &items)
void PlaylistWidget::add(QPtrList<PlaylistItem> &items)
{
playlistList->append(items);
}
void PlaylistWidget::remove(QPtrList<FileListItem> &items)
void PlaylistWidget::remove(QPtrList<PlaylistItem> &items)
{
playlistList->remove(items);
}
FileList *PlaylistWidget::getPlaylistList()
Playlist *PlaylistWidget::getPlaylistList()
{
return(playlistList);
}
QPtrList<FileListItem> PlaylistWidget::getSelectedItems()
QPtrList<PlaylistItem> PlaylistWidget::getSelectedItems()
{
return(playlistList->selectedItems());
}
FileListItem *PlaylistWidget::firstItem()
PlaylistItem *PlaylistWidget::firstItem()
{
return(dynamic_cast<FileListItem *>(playlistList->firstChild()));
return(dynamic_cast<PlaylistItem *>(playlistList->firstChild()));
}
////////////////////////////////////////////////////////////////////////////////
......@@ -89,6 +89,6 @@ void PlaylistWidget::setupLayout()
/////////////////////////////////////////////////////////////////////////
QVBoxLayout *playlistMainLayout = new QVBoxLayout(this);
playlistList = new FileList(this, "playlistList");
playlistList = new Playlist(this, "playlistList");
playlistMainLayout->addWidget(playlistList);
}
......@@ -22,8 +22,8 @@
#include <qptrlist.h>
#include "filelist.h"
#include "filelistitem.h"
#include "playlist.h"
#include "playlistitem.h"
class PlaylistWidget : public QWidget
{
......@@ -33,20 +33,20 @@ public:
void add(const QString &item);
void add(QStringList &items);
void add(FileListItem *item);
void add(QPtrList<FileListItem> &items);
void add(PlaylistItem *item);
void add(QPtrList<PlaylistItem> &items);
void remove(QPtrList<FileListItem> &items);
void remove(QPtrList<PlaylistItem> &items);
FileList *getPlaylistList();
QPtrList<FileListItem> getSelectedItems();
FileListItem *firstItem();
Playlist *getPlaylistList();
QPtrList<PlaylistItem> getSelectedItems();
PlaylistItem *firstItem();
private:
void setupLayout();
// main visual objects
FileList *playlistList;
Playlist *playlistList;
};
#endif
......@@ -85,32 +85,35 @@ QWidget *SliderAction::createWidget(QWidget *parent) // virtual -- used by base
{
if(parent) {
QWidget *base = new QWidget(parent);
// base->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
base->setName("kde toolbar widget");
// base->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
layout = new QBoxLayout(base, QBoxLayout::TopToBottom, 5, 5);
layout = new QBoxLayout(base, QBoxLayout::TopToBottom, 5, 5);
trackPositionSlider = new QSlider(base, "trackPositionSlider" );
trackPositionSlider = new QSlider(base, "trackPositionSlider");
trackPositionSlider->setMaxValue(1000);
QToolTip::add(trackPositionSlider, i18n("Track Position"));
layout->addWidget(trackPositionSlider);
volumeSlider = new QSlider(base, "volumeSlider" );
volumeSlider = new QSlider(base, "volumeSlider" );
volumeSlider->setMaxValue(100);
QToolTip::add(volumeSlider, i18n("Volume"));
layout->addWidget(volumeSlider);
volumeSlider->setName("kde toolbar widget");
trackPositionSlider->setName("kde toolbar widget");
layout->setStretchFactor(trackPositionSlider, 4);
layout->setStretchFactor(volumeSlider, 1);
// this->setWidget(base);
// setWidget(base);
connect(parent, SIGNAL(modechange()), this, SLOT(updateLabels()));
connect(parent, SIGNAL(modechange()), this, SLOT(updateSize()));
return(base);
}
else {
else
return(0);
}
}
////////////////////////////////////////////////////////////////////////////////
......@@ -147,3 +150,4 @@ void SliderAction::updateSize()
}
}
#include "slideraction.moc"
This diff is collapsed.
......@@ -18,17 +18,12 @@
#ifndef TAGGERWIDGET_H
#define TAGGERWIDGET_H
#include <klistview.h>
#include <kcombobox.h>
#include <klineedit.h>
#include <knuminput.h>
#include <keditcl.h>
#include <qptrlist.h>
#include "filelist.h"
#include "filelistitem.h"
#include "playlist.h"
#include "playlistitem.h"
#include "genrelist.h"
#include "tageditor.h"
class TaggerWidget : public QWidget
{
......@@ -41,44 +36,21 @@ public:
void add(const QString &item);
void add(const QStringList &items);
FileList *getTaggerList();
Playlist *getTaggerList();
QPtrList<FileListItem> getSelectedItems();
QPtrList<PlaylistItem> getSelectedItems();
public slots:
void save();
void save(const QPtrList<FileListItem> &items);
void deleteFile();
void deleteFile(const QPtrList<FileListItem> &items);
void setChanged();
void remove();
void remove(const QPtrList<PlaylistItem> &items);
private:
void setupLayout();
void readConfig();
// main visual objects
FileList *taggerList;
KComboBox *artistNameBox;
KLineEdit *trackNameBox;
KComboBox *albumNameBox;
KComboBox *genreBox;
KLineEdit *fileNameBox;
KIntSpinBox *trackSpin;
KIntSpinBox *yearSpin;
KLineEdit *lengthBox;
KLineEdit *bitrateBox;
KEdit *commentBox;
// internally useful things
QPtrList<FileListItem> previousSelection;
GenreList *genreList;
bool changed;
private slots:
void saveChangesPrompt();
void updateBoxes();
void updateCombos();
Playlist *taggerList;
TagEditor *editor;
};
#endif