diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2007-10-31 18:04:24 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2007-10-31 18:04:24 +0000 |
| commit | 86aac72c6547ae976059c1aee91059687ea65b8b (patch) | |
| tree | e9cacce658ec4dad6c235ee6f354232280fa4dd7 /src | |
| parent | 342ada45af81cba245abd9a2fb4a19b4974e93e4 (diff) | |
| download | qmmp-86aac72c6547ae976059c1aee91059687ea65b8b.tar.gz qmmp-86aac72c6547ae976059c1aee91059687ea65b8b.tar.bz2 qmmp-86aac72c6547ae976059c1aee91059687ea65b8b.zip | |
added visual plugin support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@171 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/configdialog.cpp | 52 | ||||
| -rw-r--r-- | src/configdialog.h | 4 | ||||
| -rw-r--r-- | src/configdialog.ui | 21 | ||||
| -rw-r--r-- | src/mainvisual.cpp | 4 | ||||
| -rw-r--r-- | src/mainvisual.h | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 13 | ||||
| -rw-r--r-- | src/mainwindow.h | 2 | ||||
| -rw-r--r-- | src/pluginitem.cpp | 34 | ||||
| -rw-r--r-- | src/pluginitem.h | 22 | ||||
| -rw-r--r-- | src/src.pro | 6 | ||||
| -rw-r--r-- | src/visualmenu.cpp | 53 | ||||
| -rw-r--r-- | src/visualmenu.h | 40 |
12 files changed, 239 insertions, 14 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp index f4833cc87..0005b1847 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -30,6 +30,7 @@ #include <output.h> #include <decoderfactory.h> #include <outputfactory.h> +#include <visualfactory.h> #include "skin.h" #include "filedialog.h" @@ -42,6 +43,7 @@ ConfigDialog::ConfigDialog ( QWidget *parent ) { ui.setupUi ( this ); setAttribute(Qt::WA_QuitOnClose, FALSE); + setAttribute(Qt::WA_DeleteOnClose, FALSE); connect ( ui. contentsWidget, SIGNAL ( currentItemChanged ( QListWidgetItem *, QListWidgetItem * ) ), this, SLOT ( changePage ( QListWidgetItem *, QListWidgetItem* ) ) ); @@ -68,6 +70,8 @@ ConfigDialog::~ConfigDialog() delete m_outputPluginItems.takeFirst(); while (!m_inputPluginItems.isEmpty()) delete m_outputPluginItems.takeFirst(); + while (!m_visualPluginItems.isEmpty()) + delete m_visualPluginItems.takeFirst(); } void ConfigDialog::readSettings() @@ -226,8 +230,38 @@ void ConfigDialog::loadPluginsInfo() ui.outputPluginTable->resizeColumnToContents ( 0 ); ui.outputPluginTable->resizeColumnToContents ( 1 ); ui.outputPluginTable->resizeRowsToContents (); + /* + load visual plugin information + */ + QList <VisualFactory *> *visuals = 0; + visuals = Visual::visualFactories(); + files = Visual::visualFiles(); + ui.visualPluginTable->setColumnCount ( 3 ); + ui.visualPluginTable->verticalHeader()->hide(); + ui.visualPluginTable->setHorizontalHeaderLabels ( QStringList() + << tr ( "Enabled" ) << tr ( "Description" ) << tr ( "Filename" ) ); + ui.visualPluginTable->setRowCount ( visuals->count () ); + + for ( int i = 0; i < visuals->count (); ++i ) + { + VisualPluginItem *item = new VisualPluginItem(this,visuals->at(i),files.at(i)); + m_visualPluginItems.append(item); + QCheckBox* button = new QCheckBox (ui.visualPluginTable); + connect(button, SIGNAL(clicked (bool)), item, SLOT(select(bool))); + button->setChecked (item->isSelected()); + ui.visualPluginTable->setCellWidget ( i, 0, button ); + ui.visualPluginTable->setItem (i,1, + new QTableWidgetItem (item->factory()->properties().name)); + ui.visualPluginTable->setItem (i,2, new QTableWidgetItem (files.at(i))); + } + + ui.visualPluginTable->resizeColumnToContents ( 0 ); + ui.visualPluginTable->resizeColumnToContents ( 1 ); + ui.visualPluginTable->resizeRowsToContents (); + } + void ConfigDialog::loadFonts() { QSettings settings ( QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat ); @@ -293,6 +327,14 @@ void ConfigDialog::showPluginSettings() m_outputPluginItems.at(row)->factory()->showSettings ( this ); break; } + case 2: + { + int row = ui.visualPluginTable->currentRow (); + if ( m_visualPluginItems.isEmpty() || row < 0 ) + return; + m_visualPluginItems.at(row)->factory()->showSettings ( this ); + break; + } } } @@ -319,6 +361,14 @@ void ConfigDialog::showPluginInfo() m_outputPluginItems.at(row)->factory()->showAbout ( this ); break; } + case 2: + { + int row = ui.visualPluginTable->currentRow (); + if ( m_visualPluginItems.isEmpty() || row < 0 ) + return; + m_visualPluginItems.at(row)->factory()->showAbout ( this ); + break; + } } } diff --git a/src/configdialog.h b/src/configdialog.h index 879034d26..e694f6a8d 100644 --- a/src/configdialog.h +++ b/src/configdialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -34,6 +34,7 @@ class QFileInfo; class Skin; class InputPluginItem; class OutputPluginItem; +class VisualPluginItem; class ConfigDialog : public QDialog { @@ -69,6 +70,7 @@ private: QList <InputPluginItem*> m_inputPluginItems; QList <OutputPluginItem*> m_outputPluginItems; + QList <VisualPluginItem*> m_visualPluginItems; }; #endif diff --git a/src/configdialog.ui b/src/configdialog.ui index 3d1c462ea..4b68c84c6 100644 --- a/src/configdialog.ui +++ b/src/configdialog.ui @@ -238,7 +238,7 @@ <string>Player:</string> </property> <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> @@ -254,7 +254,7 @@ <string>Playlist:</string> </property> <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> @@ -544,6 +544,23 @@ </item> </layout> </widget> + <widget class="QWidget" name="tab" > + <attribute name="title" > + <string>Visualization</string> + </attribute> + <layout class="QHBoxLayout" > + <item> + <widget class="QTableWidget" name="visualPluginTable" > + <property name="selectionMode" > + <enum>QAbstractItemView::SingleSelection</enum> + </property> + <property name="selectionBehavior" > + <enum>QAbstractItemView::SelectRows</enum> + </property> + </widget> + </item> + </layout> + </widget> <widget class="QWidget" name="fileDialogTab" > <attribute name="title" > <string>File Dialog</string> diff --git a/src/mainvisual.cpp b/src/mainvisual.cpp index 65bd287a1..cbd30a6dc 100644 --- a/src/mainvisual.cpp +++ b/src/mainvisual.cpp @@ -45,7 +45,7 @@ MainVisual *MainVisual::getPointer() } MainVisual::MainVisual (QWidget *parent) - : QWidget (parent), m_vis (0), m_playing (FALSE) + : Visual (parent), m_vis (0), m_playing (FALSE) { m_draw = TRUE; m_skin = Skin::getPointer(); @@ -72,6 +72,8 @@ MainVisual::~MainVisual() else settings.setValue("Visualization/type", "None"); settings.setValue("Visualization/rate", 1000/m_timer->interval()); + while (!m_nodes.isEmpty()) + delete m_nodes.takeFirst(); } void MainVisual::setVisual (VisualBase *newvis) diff --git a/src/mainvisual.h b/src/mainvisual.h index d31b1c73a..6f4b1907a 100644 --- a/src/mainvisual.h +++ b/src/mainvisual.h @@ -68,7 +68,7 @@ public: class Skin; -class MainVisual : public QWidget, public Visual +class MainVisual : public Visual { Q_OBJECT diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2a6902e2c..324c8521b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -44,6 +44,7 @@ #include <addurldialog.h> #include "filedialog.h" #include "listwidget.h" +#include "visualmenu.h" #define KEY_OFFSET 10 @@ -124,7 +125,8 @@ MainWindow::MainWindow(const QStringList& args, QWidget *parent) m_vis = MainVisual::getPointer(); m_core = new SoundCore(this); - m_core -> addVisualization(m_vis); + m_core->addVisualization(m_vis); + m_core->showVisualization(this); connect(m_core, SIGNAL(outputStateChanged(const OutputState&)), SLOT(showOutputState(const OutputState&))); @@ -459,7 +461,7 @@ void MainWindow::endSeek() seeking = FALSE; } -void MainWindow::changeEvent ( QEvent * event ) +void MainWindow::changeEvent (QEvent * event) { if (event->type() == QEvent::ActivationChange) { @@ -538,6 +540,7 @@ void MainWindow::showSettings() m_playlist->readSettings(); TextScroller::getPointer()->readSettings(); m_core->updateConfig(); + m_visMenu->updateActions(); } delete m_confDialog; } @@ -587,6 +590,10 @@ void MainWindow::createActions() m_mainMenu->addSeparator(); m_mainMenu->addAction(tr("&Jump To File"),this, SLOT(jumpToFile()), tr("J")); m_mainMenu->addSeparator(); + m_visMenu = new VisualMenu(this); + m_mainMenu->addMenu(m_visMenu); + + m_mainMenu->addSeparator(); m_mainMenu->addAction(tr("&Settings"),this, SLOT(showSettings()), tr("Ctrl+P")); m_mainMenu->addSeparator(); m_mainMenu->addAction(tr("&About"),this, SLOT(about())); @@ -808,5 +815,3 @@ void MainWindow::addUrl( ) { AddUrlDialog::popup(this,m_playListModel); } - - diff --git a/src/mainwindow.h b/src/mainwindow.h index 7faf06ef3..97caed52a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -41,6 +41,7 @@ class MainVisual; class Skin; class SoundCore; class JumpToTrackDialog; +class VisualMenu; class QMenu; class QKeyEvent; @@ -133,6 +134,7 @@ private: JumpToTrackDialog* m_jumpDialog; bool m_hide_on_titlebar_close; int m_elapsed; + VisualMenu *m_visMenu; }; #endif diff --git a/src/pluginitem.cpp b/src/pluginitem.cpp index a0498df34..391f75148 100644 --- a/src/pluginitem.cpp +++ b/src/pluginitem.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -23,6 +23,8 @@ #include <decoderfactory.h> #include <outputfactory.h> +#include <visualfactory.h> +#include <soundcore.h> #include "pluginitem.h" @@ -89,3 +91,33 @@ OutputFactory *OutputPluginItem::factory() { return m_factory; } + +/*Visual*/ +VisualPluginItem::VisualPluginItem(QObject *parent, VisualFactory *fact, + const QString &filePath): QObject(parent) +{ + m_fileName = filePath.section('/',-1); + m_factory = fact; +} + + +VisualPluginItem::~VisualPluginItem() +{} + +void VisualPluginItem::select(bool on) +{ + if(on) + SoundCore::instance()->addVisual(m_factory, 0); + else + SoundCore::instance()->removeVisual(m_factory); +} + +bool VisualPluginItem::isSelected() +{ + return Visual::isEnabled(m_factory); +} + +VisualFactory *VisualPluginItem::factory() +{ + return m_factory; +} diff --git a/src/pluginitem.h b/src/pluginitem.h index a8877e61c..4a54f0e9d 100644 --- a/src/pluginitem.h +++ b/src/pluginitem.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -28,6 +28,7 @@ class DecoderFactory; class OutputFactory; +class VisualFactory; class InputPluginItem : public QObject { @@ -69,4 +70,23 @@ private: }; +class VisualPluginItem : public QObject +{ + Q_OBJECT +public: + VisualPluginItem(QObject *parent, VisualFactory *fact, const QString &filePath); + + ~VisualPluginItem(); + + bool isSelected(); + VisualFactory * factory(); + +public slots: + void select(bool); + +private: + QString m_fileName; + VisualFactory *m_factory; +}; + #endif diff --git a/src/src.pro b/src/src.pro index 9355db692..26e584144 100644 --- a/src/src.pro +++ b/src/src.pro @@ -138,7 +138,9 @@ target.path = /bin INSTALLS += target HEADERS += addurldialog.h \ - skinreader.h + skinreader.h \ + visualmenu.h SOURCES += addurldialog.cpp \ - skinreader.cpp + skinreader.cpp \ + visualmenu.cpp FORMS += addurldialog.ui diff --git a/src/visualmenu.cpp b/src/visualmenu.cpp new file mode 100644 index 000000000..2b0ad6797 --- /dev/null +++ b/src/visualmenu.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2007 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU 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 General Public License for more details. * + * * + * You should have received a copy of the GNU 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 <QAction> + +#include <visual.h> +#include <visualfactory.h> + +#include "pluginitem.h" +#include "visualmenu.h" + +VisualMenu::VisualMenu(QWidget *parent) + : QMenu(tr("Visualization"), parent) +{ + VisualFactory *factory = 0; + foreach(factory, *Visual::visualFactories()) + { + QAction *act = this->addAction(factory->properties().name); + act->setCheckable (TRUE); + act->setChecked (Visual::isEnabled(factory)); + VisualPluginItem *vi = new VisualPluginItem(this,factory, ""); + connect(act, SIGNAL(toggled(bool)), vi, SLOT(select(bool))); + } +} + +VisualMenu::~VisualMenu() +{ +} + +void VisualMenu::updateActions() +{ + for(int i = 0; i < Visual::visualFactories()->size(); ++i) + { + actions()[i]->setChecked(Visual::isEnabled(Visual::visualFactories()->at(i))); + } +} diff --git a/src/visualmenu.h b/src/visualmenu.h new file mode 100644 index 000000000..9202a8a7d --- /dev/null +++ b/src/visualmenu.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2007 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU 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 General Public License for more details. * + * * + * You should have received a copy of the GNU 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. * + ***************************************************************************/ +#ifndef VISUALMENU_H +#define VISUALMENU_H + +#include <QMenu> + +/** + @author Ilya Kotov <forkotov02@hotmail.ru> +*/ +class VisualMenu : public QMenu +{ +Q_OBJECT +public: + VisualMenu(QWidget *parent = 0); + + ~VisualMenu(); + +void updateActions(); + +}; + +#endif |
