diff options
Diffstat (limited to 'src/ui')
133 files changed, 72 insertions, 17472 deletions
diff --git a/src/ui/aboutdialog.cpp b/src/ui/aboutdialog.cpp deleted file mode 100644 index 5728697b9..000000000 --- a/src/ui/aboutdialog.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006 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 <QFile> -#include <QTextStream> - -#include <qmmp/decoder.h> -#include <qmmp/decoderfactory.h> -#include <qmmp/output.h> -#include <qmmp/outputfactory.h> -#include <qmmp/visual.h> -#include <qmmp/visualfactory.h> -#include <qmmp/effect.h> -#include <qmmp/effectfactory.h> -#include <qmmp/qmmp.h> -#include <qmmpui/general.h> -#include <qmmpui/generalfactory.h> - - -#include "aboutdialog.h" - -static QString getstringFromResource(const QString& res_file) -{ - QString ret_string; - QFile file(res_file); - if (file.open(QIODevice::ReadOnly)) - { - QTextStream ts(&file); - ts.setCodec("UTF-8"); - ret_string = ts.readAll(); - file.close(); - } - return ret_string; -} - -AboutDialog::AboutDialog(QWidget* parent, Qt::WFlags fl) - : QDialog( parent, fl ) -{ - setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - licenseTextEdit->setPlainText(getstringFromResource(":COPYING")); - aboutTextEdit->setHtml(loadAbout()); - authorsTextEdit->setPlainText(getstringFromResource(tr(":/txt/authors_en.txt"))); - thanksToTextEdit->setPlainText(getstringFromResource(tr(":/txt/thanks_en.txt"))); - translatorsTextEdit->setPlainText(getstringFromResource(tr(":/txt/translators_en.txt"))); -} - -AboutDialog::~AboutDialog() -{} - -/*$SPECIALIZATION$*/ -void AboutDialog::accept() -{ - QDialog::accept(); -} - -QString AboutDialog::loadAbout() -{ - QString text; - text.append("<head>"); - text.append("<META content=\"text/html; charset=UTF-8\">"); - text.append("</head>"); - text.append("<h3>"+tr("Qt-based Multimedia Player (Qmmp)")+"</h3>"); - text.append("<h4>"+tr("Version:")+" "+ Qmmp::strVersion() + "</h4>"); - text.append("<p>"+getstringFromResource(tr(":txt/description_en.txt"))+"</p>"); - text.append("<h5>"+tr("Input plugins:")+"</h5>"); - text.append("<ul type=\"square\">"); - foreach(DecoderFactory *fact, *Decoder::factories()) - { - text.append("<li>"); - text.append(fact->properties().name); - text.append("</li>"); - } - text.append("</ul>"); - text.append("<h5>"+tr("Output plugins:")+"</h5>"); - text.append("<ul type=\"square\">"); - foreach(OutputFactory *fact, *Output::factories()) - { - text.append("<li>"); - text.append(fact->properties().name); - text.append("</li>"); - } - text.append("</ul>"); - text.append("<h5>"+tr("Visual plugins:")+"</h5>"); - text.append("<ul type=\"square\">"); - foreach(VisualFactory *fact, *Visual::factories()) - { - text.append("<li>"); - text.append(fact->properties().name); - text.append("</li>"); - } - text.append("</ul>"); - text.append("<h5>"+tr("Effect plugins:")+"</h5>"); - text.append("<ul type=\"square\">"); - foreach(EffectFactory *fact, *Effect::factories()) - { - text.append("<li>"); - text.append(fact->properties().name); - text.append("</li>"); - } - text.append("</ul>"); - text.append("<h5>"+tr("General plugins:")+"</h5>"); - text.append("<ul type=\"square\">"); - foreach(GeneralFactory *fact, *General::factories()) - { - text.append("<li>"); - text.append(fact->properties().name); - text.append("</li>"); - } - text.append("</ul>"); - - return text; -} diff --git a/src/ui/aboutdialog.h b/src/ui/aboutdialog.h deleted file mode 100644 index 2d8384ea4..000000000 --- a/src/ui/aboutdialog.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006 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 ABOUTDIALOG_H -#define ABOUTDIALOG_H - -#include <QDialog> -#include "ui_aboutdialog.h" - -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> - */ - -class AboutDialog : public QDialog, private Ui::AboutDialog -{ - Q_OBJECT -public: - AboutDialog(QWidget* parent = 0, Qt::WFlags fl = 0 ); - ~AboutDialog(); - -protected slots: - virtual void accept(); - -private: - QString loadAbout(); - -}; - -#endif - diff --git a/src/ui/actionmanager.cpp b/src/ui/actionmanager.cpp deleted file mode 100644 index f4689ecd0..000000000 --- a/src/ui/actionmanager.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 <QSettings> -#include <QAction> -#include <QIcon> -#include <QFile> -#include <qmmp/qmmp.h> -#include "actionmanager.h" - -ActionManager *ActionManager::m_instance = 0; - -ActionManager::ActionManager(QObject *parent) : - QObject(parent) -{ - m_instance = this; - m_settings = new QSettings(Qmmp::configFile(), QSettings::IniFormat); - m_settings->beginGroup("Shortcuts"); - //playback - m_actions[PLAY] = createAction(tr("&Play"), "play", tr("X"), "media-playback-start"); - m_actions[PAUSE] = createAction(tr("&Pause"), "pause", tr("C"), "media-playback-pause"); - m_actions[STOP] = createAction(tr("&Stop"), "stop", tr("V"), "media-playback-stop"); - m_actions[PREVIOUS] = createAction(tr("&Previous"), "previous", tr("Z"), "media-skip-backward"); - m_actions[NEXT] = createAction(tr("&Next"), "next", tr("B"), "media-skip-forward"); - m_actions[PLAY_PAUSE] = createAction(tr("&Play/Pause"), "play_pause", tr("Space")); - m_actions[JUMP] = createAction(tr("&Jump to File"), "jump", tr("J"), "go-up"); - m_actions[REPEAT_ALL] = createAction2(tr("&Repeat Playlist"), "repeate_playlist", tr("R")); - m_actions[REPEAT_TRACK] = createAction2(tr("&Repeat Track"), "repeate_track", tr("Ctrl+R")); - m_actions[SHUFFLE] = createAction2(tr("&Shuffle"), "shuffle", tr("S")); - m_actions[NO_PL_ADVANCE] = createAction2(tr("&No Playlist Advance"), "no_playlist_advance", - tr("Ctrl+N")); - m_actions[STOP_AFTER_SELECTED] = createAction(tr("&Stop After Selected"), "stop_after_selected", - tr("Ctrl+S")); - m_actions[CLEAR_QUEUE] = createAction(tr("&Clear Queue"), "clear_queue", tr("Alt+Q")); - //view - m_actions[SHOW_PLAYLIST] = createAction2(tr("Show Playlist"), "show_playlist", tr("Alt+E")); - m_actions[SHOW_EQUALIZER] = createAction2(tr("Show Equalizer"), "show_equalizer", tr("Alt+G")); - m_actions[WM_ALLWAYS_ON_TOP] = createAction2(tr("Always on Top"), "always_on_top", ""); - m_actions[WM_STICKY] = createAction2(tr("Put on All Workspaces"), "General/always_on_top", ""); - m_actions[WM_DOUBLE_SIZE] = createAction2(tr("Double Size"), "double_size", tr("Meta+D")); - //playlist - m_actions[PL_ADD_FILE] = createAction(tr("&Add File"), "add_file", tr("F"), "audio-x-generic"); - m_actions[PL_ADD_DIRECTORY] = createAction(tr("&Add Directory"), "add_dir", tr("D"), "folder"); - m_actions[PL_ADD_URL] = createAction(tr("&Add Url"), "add_url", tr("U"), "network-server"); - m_actions[PL_REMOVE_SELECTED] = createAction(tr("&Remove Selected"), "remove_selected", - tr("Del"), "edit-delete"); - m_actions[PL_REMOVE_ALL] = createAction(tr("&Remove All"), "remove_all", "", "edit-clear"); - m_actions[PL_REMOVE_UNSELECTED] = createAction(tr("&Remove Unselected"), "remove_unselected", - "", "edit-delete"); - m_actions[PL_REMOVE_INVALID] = createAction(tr("Remove unavailable files"), "remove_invalid", - "", "dialog-error"); - m_actions[PL_REMOVE_DUPLICATES] = createAction(tr("Remove duplicates"), "remove_duplicates", ""); - m_actions[PL_ENQUEUE] = createAction(tr("&Queue Toggle"), "enqueue", tr("Q")); - m_actions[PL_INVERT_SELECTION] = createAction(tr("Invert Selection"), "invert_selection", ""); - m_actions[PL_CLEAR_SELECTION] = createAction(tr("&Select None"), "clear_selection", ""); - m_actions[PL_SELECT_ALL] = createAction(tr("&Select All"), "select_all", - tr("Ctrl+A"), "edit-select-all"); - m_actions[PL_SHOW_INFO] = createAction(tr("&View Track Details"), "show_info", tr("Alt+I"), - "dialog-information"); - m_actions[PL_NEW] = createAction(tr("&New List"), "new_pl", tr("Ctrl+T"), "document-new"); - m_actions[PL_CLOSE] = createAction(tr("&Delete List"), "close_pl", tr("Ctrl+W"), "window-close"); - m_actions[PL_LOAD] = createAction(tr("&Load List"), "load_pl", tr("O"), "document-open"); - m_actions[PL_SAVE] = createAction(tr("&Save List"), "save_pl", tr("Shift+S"), "document-save-as"); - m_actions[PL_SELECT_NEXT] = createAction(tr("&Select Next Playlist"), "next_pl", - tr("Ctrl+PgDown"), "go-next"); - m_actions[PL_SELECT_PREVIOUS] = createAction(tr("&Select Previous Playlist"), "prev_pl", - tr("Ctrl+PgUp"), "go-previous"); - m_actions[PL_SHOW_MANAGER] = createAction(tr("&Show Playlists"), "show_playlists", - tr("P"), "view-list-details"); - //other - m_actions[SETTINGS] = createAction(tr("&Settings"), "show_settings", tr("Ctrl+P"), "configure"); - m_actions[ABOUT] = createAction(tr("&About"), "about", "", ":/32x32/qmmp.png"); - m_actions[ABOUT_QT] = createAction(tr("&About Qt"), "about_qt", ""); - m_actions[QUIT] = createAction(tr("&Exit"), "exit", tr("Ctrl+Q"), "application-exit"); - m_settings->endGroup(); - delete m_settings; - m_settings = 0; -} - -ActionManager::~ActionManager() -{ - m_instance = 0; -} - -QAction *ActionManager::action(int type) -{ - return m_actions[type]; -} - -QAction *ActionManager::use(int type, const QObject *receiver, const char *member) -{ - QAction *act = m_actions[type]; - connect(act,SIGNAL(triggered(bool)), receiver, member); - return act; -} - -ActionManager* ActionManager::instance() -{ - return m_instance; -} - -QAction *ActionManager::createAction(QString name, QString confKey, QString key, QString iconName) -{ - QAction *action = new QAction(name, this); - action->setShortcut(m_settings->value(confKey, key).toString()); - action->setObjectName(confKey); - if(iconName.isEmpty()) - return action; - if(QFile::exists(iconName)) - action->setIcon(QIcon(iconName)); - else - action->setIcon(QIcon::fromTheme(iconName)); - return action; -} - -QAction *ActionManager::createAction2(QString name, QString confKey, QString key) -{ - QAction *action = createAction(name, confKey, key); - action->setCheckable(true); - return action; -} - -void ActionManager::saveActions() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - foreach(QAction *action, m_actions.values()) - { - settings.setValue(QString("Shortcuts/")+action->objectName(), action->shortcut()); - } -} diff --git a/src/ui/actionmanager.h b/src/ui/actionmanager.h deleted file mode 100644 index 33e6302fb..000000000 --- a/src/ui/actionmanager.h +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 ACTIONMANAGER_H -#define ACTIONMANAGER_H - -#include <QObject> -#include <QString> -#include <QHash> - -class QAction; -class QSettings; - -#define SET_ACTION(type, receiver, member) ActionManager::instance()->use(type, receiver, member) -#define ACTION(type) ActionManager::instance()->action(type) - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class ActionManager : public QObject -{ - Q_OBJECT -public: - explicit ActionManager(QObject *parent = 0); - ~ActionManager(); - - enum Type - { - PLAY = 0, - PAUSE, - STOP, - PREVIOUS, - NEXT, - PLAY_PAUSE, - JUMP, - - REPEAT_ALL, - REPEAT_TRACK, - SHUFFLE, - NO_PL_ADVANCE, - STOP_AFTER_SELECTED, - CLEAR_QUEUE, - - SHOW_PLAYLIST, - SHOW_EQUALIZER, - - WM_ALLWAYS_ON_TOP, - WM_STICKY, - WM_DOUBLE_SIZE, - - PL_ADD_FILE, - PL_ADD_DIRECTORY, - PL_ADD_URL, - PL_REMOVE_SELECTED, - PL_REMOVE_ALL, - PL_REMOVE_UNSELECTED, - PL_REMOVE_INVALID, - PL_REMOVE_DUPLICATES, - PL_ENQUEUE, - PL_INVERT_SELECTION, - PL_CLEAR_SELECTION, - PL_SELECT_ALL, - PL_SHOW_INFO, - PL_NEW, - PL_CLOSE, - PL_LOAD, - PL_SAVE, - PL_SELECT_NEXT, - PL_SELECT_PREVIOUS, - PL_SHOW_MANAGER, - - SETTINGS, - ABOUT, - ABOUT_QT, - QUIT, - }; - - QAction *action(int type); - QAction *use(int type, const QObject *receiver, const char *member); - QList<int> actions(); - void saveActions(); - static ActionManager* instance(); - -private: - QAction *createAction(QString name, QString confKey, QString key, QString iconName = QString()); - QAction *createAction2(QString name, QString confKey, QString key); - - QSettings *m_settings; - QHash <int, QAction *> m_actions; - static ActionManager *m_instance; - -}; - -#endif // ACTIONMANAGER_H diff --git a/src/ui/addurldialog.cpp b/src/ui/addurldialog.cpp deleted file mode 100644 index 5b65337db..000000000 --- a/src/ui/addurldialog.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 <QSettings> -#include <QDir> -#include <QNetworkAccessManager> -#include <QNetworkRequest> -#include <QNetworkReply> -#include <QNetworkProxy> -#include <QUrl> -#include <QMessageBox> -#include <qmmpui/playlistparser.h> -#include <qmmpui/playlistformat.h> -#include <qmmpui/playlistmodel.h> -#include <qmmp/qmmpsettings.h> -#include <qmmp/qmmp.h> -#include "addurldialog.h" - -#define HISTORY_SIZE 10 - -AddUrlDialog::AddUrlDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent,f) -{ - setupUi(this); - setAttribute(Qt::WA_DeleteOnClose); - setAttribute(Qt::WA_QuitOnClose, false); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_history = settings.value("URLDialog/history").toStringList(); - urlComboBox->addItems(m_history); - m_http = new QNetworkAccessManager(this); - //load global proxy settings - QmmpSettings *gs = QmmpSettings::instance(); - if (gs->isProxyEnabled()) - { - QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); - if(gs->useProxyAuth()) - { - proxy.setUser(gs->proxy().userName()); - proxy.setPassword(gs->proxy().password()); - } - m_http->setProxy(proxy); - } -} - -AddUrlDialog::~AddUrlDialog() -{ - if ( m_history.size() > HISTORY_SIZE) - m_history.removeLast(); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.setValue("URLDialog/history", m_history); -} - -QPointer<AddUrlDialog> AddUrlDialog::instance = 0; - -void AddUrlDialog::popup(QWidget* parent,PlayListModel* model ) -{ - if (!instance) - { - instance = new AddUrlDialog(parent); - instance->setModel(model); - } - instance->show(); - instance->raise(); -} - -void AddUrlDialog::accept( ) -{ - if (!urlComboBox->currentText().isEmpty()) - { - QString s = urlComboBox->currentText(); - if (!s.startsWith("http://") && !s.contains("://")) - s.prepend("http://"); - m_history.removeAll(s); - m_history.prepend(s); - - if (s.startsWith("http://")) - { - //try to download playlist - PlaylistFormat* prs = PlaylistParser::instance()->findByPath(s); - if (prs) - { - connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(readResponse(QNetworkReply *))); - QNetworkRequest request; - request.setUrl(QUrl(s)); - request.setRawHeader("User-Agent", QString("qmmp/%1").arg(Qmmp::strVersion()).toAscii()); - addButton->setEnabled(false); - m_http->get(request); - return; - } - } - m_model->add(s); - } - QDialog::accept(); -} - -void AddUrlDialog::readResponse(QNetworkReply *reply) -{ - addButton->setEnabled(true); - disconnect(m_http, SIGNAL(finished (QNetworkReply *)), 0, 0); - if (reply->error() != QNetworkReply::NoError) - QMessageBox::critical (this, tr("Error"), reply->errorString ()); - else if (!urlComboBox->currentText().isEmpty()) - { - QString s = urlComboBox->currentText(); - PlaylistFormat* prs = PlaylistParser::instance()->findByPath(s); - if (prs) - { - m_model->add(prs->decode(reply->readAll())); - QDialog::accept(); - } - } - reply->deleteLater(); -} - -void AddUrlDialog::setModel( PlayListModel *m ) -{ - m_model = m; -} diff --git a/src/ui/addurldialog.h b/src/ui/addurldialog.h deleted file mode 100644 index 49858ce11..000000000 --- a/src/ui/addurldialog.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 ADDURLDIALOG_H -#define ADDURLDIALOG_H - -#include "ui_addurldialog.h" -#include <QDialog> -#include <QPointer> - -class QNetworkAccessManager; -class QNetworkReply; -class PlayListModel; - -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> - */ - -class AddUrlDialog : public QDialog , private Ui::AddUrlDialog -{ - Q_OBJECT -public: - static void popup(QWidget* parent ,PlayListModel*); - -protected: - AddUrlDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ); - ~AddUrlDialog(); - -protected slots: - virtual void accept(); - -private slots: - void readResponse(QNetworkReply *reply); - -private: - void setModel(PlayListModel*); - static QPointer<AddUrlDialog> instance; - PlayListModel* m_model; - QStringList m_history; - QNetworkAccessManager *m_http; - -}; -#endif //ADDURLDIALOG_H diff --git a/src/ui/balancebar.cpp b/src/ui/balancebar.cpp deleted file mode 100644 index 07a56ce7a..000000000 --- a/src/ui/balancebar.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QMouseEvent> -#include <QPainter> -#include <math.h> -#include "skin.h" -#include "button.h" -#include "mainwindow.h" -#include "balancebar.h" - -BalanceBar::BalanceBar(QWidget *parent) - : PixmapWidget(parent) -{ - m_skin = Skin::instance(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setPixmap(m_skin->getBalanceBar(0)); - m_moving = false; - m_min = -100; - m_max = 100; - m_old = m_value = 0; - draw(false); -} - - -BalanceBar::~BalanceBar() -{} - -void BalanceBar::mousePressEvent(QMouseEvent *e) -{ - m_moving = true; - press_pos = e->x(); - if(e->button() == Qt::MidButton) - { - m_value = 0; - emit sliderPressed(); - emit sliderMoved(m_value); - } - else if(m_pos<e->x() && e->x()<m_pos+11*m_skin->ratio()) - { - press_pos = e->x()-m_pos; - emit sliderPressed(); - } - else - { - m_value = convert(qMax(qMin(width()-18*m_skin->ratio(),e->x()-6*m_skin->ratio()),0)); - press_pos = 6*m_skin->ratio(); - emit sliderPressed(); - if (m_value != m_old) - { - emit sliderMoved(m_value); - } - } - draw(); -} - -void BalanceBar::mouseMoveEvent (QMouseEvent *e) -{ - if(m_moving) - { - int po = e->x(); - po = po - press_pos; - - if(0 <= po && po <= width()-13*m_skin->ratio()) - { - m_value = convert(po); - draw(); - emit sliderMoved(m_value); - } - } -} - -void BalanceBar::mouseReleaseEvent(QMouseEvent*) -{ - m_moving = false; - draw(false); - m_old = m_value; - emit sliderReleased(); -} - -void BalanceBar::setValue(int v) -{ - if (m_moving || m_max == 0) - return; - m_value = v; - draw(false); -} - -void BalanceBar::setMax(int max) -{ - m_max = max; - draw(false); -} - -void BalanceBar::updateSkin() -{ - resize(m_skin->getBalanceBar(0).size()); - draw(false); -} - -void BalanceBar::draw(bool pressed) -{ - if(abs(m_value)<6) - m_value = 0; - int p=int(ceil(double(m_value-m_min)*(width()-13*m_skin->ratio())/(m_max-m_min))); - m_pixmap = m_skin->getBalanceBar(abs(27*m_value/m_max)); - QPainter paint(&m_pixmap); - if(pressed) - paint.drawPixmap(p,m_skin->ratio(),m_skin->getButton(Skin::BT_BAL_P)); - else - paint.drawPixmap(p,m_skin->ratio(),m_skin->getButton(Skin::BT_BAL_N)); - setPixmap(m_pixmap); - m_pos = p; -} - -int BalanceBar::convert(int p) -{ - return int(ceil(double(m_max-m_min)*(p)/(width()-13*m_skin->ratio())+m_min)); -} - diff --git a/src/ui/balancebar.h b/src/ui/balancebar.h deleted file mode 100644 index 68e967568..000000000 --- a/src/ui/balancebar.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 BALANCEBAR_H -#define BALANCEBAR_H - -#include "pixmapwidget.h" - -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class BalanceBar : public PixmapWidget -{ -Q_OBJECT -public: - BalanceBar(QWidget *parent = 0); - - ~BalanceBar(); - - int value() {return m_value; } - -public slots: - void setValue(int); - void setMax(int); - -signals: - void sliderMoved (int); - void sliderPressed(); - void sliderReleased(); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - bool m_moving; - int press_pos; - int m_max, m_min, m_pos, m_value, m_old; - QPixmap m_pixmap; - int convert(int); // value = convert(position); - void draw(bool pressed = true); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); -}; - -#endif diff --git a/src/ui/builtincommandlineoption.cpp b/src/ui/builtincommandlineoption.cpp index 5f71beeaa..29c2a50f5 100644 --- a/src/ui/builtincommandlineoption.cpp +++ b/src/ui/builtincommandlineoption.cpp @@ -20,7 +20,7 @@ #include <QApplication> #include <qmmp/soundcore.h> -#include "mainwindow.h" +#include <qmmpui/mediaplayer.h> #include "builtincommandlineoption.h" BuiltinCommandLineOption::BuiltinCommandLineOption(QObject *parent) : QObject(parent) @@ -69,10 +69,14 @@ const QString BuiltinCommandLineOption::helpString() const void BuiltinCommandLineOption::executeCommand(const QString &option_string, const QStringList &args, - const QString &cwd, - MainWindow *mw) + const QString &cwd/*, + MainWindow *mw*/) { - if(option_string == "--enqueue" || option_string == "-e" || option_string.isEmpty()) + SoundCore *core = SoundCore::instance(); + MediaPlayer *player = MediaPlayer::instance(); + if(!core || !player) + return; + /*if(option_string == "--enqueue" || option_string == "-e" || option_string.isEmpty()) { //QStringList args = commands.value(key); if(args.isEmpty()) @@ -86,62 +90,63 @@ void BuiltinCommandLineOption::executeCommand(const QString &option_string, full_path_list << cwd + "/" + s; } //clear playlist if option is empty - mw->setFileList(full_path_list, option_string.isEmpty()); + //mw->setFileList(full_path_list, option_string.isEmpty()); } - else if (option_string == "--play" || option_string == "-p") + else*/ if (option_string == "--play" || option_string == "-p") { - mw->play(); + player->play(); } else if (option_string == "--stop" || option_string == "-s") { - mw->stop(); + core->stop(); } else if (option_string == "--pause" || option_string == "-u") { - mw->pause(); + core->pause(); } else if (option_string == "--next") { - mw->next(); - if (mw->soundCore()->state() == Qmmp::Stopped) - mw->play(); + player->next(); + if (core->state() == Qmmp::Stopped) + player->play(); } else if (option_string == "--previous") { - mw->previous(); - if (mw->soundCore()->state() == Qmmp::Stopped) - mw->play(); + player->previous(); + if (core->state() == Qmmp::Stopped) + player->play(); } else if (option_string == "--play-pause" || option_string == "-t") { - mw->playPause(); + //mw->playPause(); } else if (option_string == "--jump-to-file" || option_string == "-j") { - mw->jumpToFile(); + //mw->jumpToFile(); } else if (option_string == "--quit" || option_string == "-q") { - mw->close(); + //mw->close(); + qApp->closeAllWindows(); } else if (option_string == "--toggle-visibility") { - mw->toggleVisibility(); + //mw->toggleVisibility(); } else if (option_string == "--add-file") { - mw->addFile(); + //mw->addFile(); } else if (option_string == "--add-dir") { - mw->addDir(); + //mw->addDir(); } else if (option_string == "--volume" && !args.isEmpty()) { bool ok = false; int volume = args.at(0).toInt(&ok); if (ok) - mw->soundCore()->setVolume(volume,volume); + core->setVolume(volume,volume); } } diff --git a/src/ui/builtincommandlineoption.h b/src/ui/builtincommandlineoption.h index fe9ca31bf..08d8e2df3 100644 --- a/src/ui/builtincommandlineoption.h +++ b/src/ui/builtincommandlineoption.h @@ -24,8 +24,6 @@ #include <QHash> #include <QStringList> -class MainWindow; - /** @author Vladimir Kuznetsov <vovanec@gmail.ru> */ @@ -44,7 +42,7 @@ public: bool identify(const QString& str)const; const QString helpString()const; void executeCommand(const QString& option, const QStringList &args, - const QString &cwd, MainWindow *mw); + const QString &cwd/*, MainWindow *mw*/); QHash <QString, QStringList> splitArgs(const QStringList &args) const; private: diff --git a/src/ui/button.cpp b/src/ui/button.cpp deleted file mode 100644 index f07088b0b..000000000 --- a/src/ui/button.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2011 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * Based on Promoe, an XMMS2 Client * - * Copyright (C) 2005-2006 by XMMS2 Team * - * * - * 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 "button.h" -#include "skin.h" -#include <QMouseEvent> - -Button::Button (QWidget *parent, uint normal, uint pressed, uint cursor) - : PixmapWidget (parent) -{ - name_normal = normal; - name_pressed = pressed; - name_cursor = cursor; - m_pressed = false; - skin = Skin::instance(); - setON (false); - setCursor (skin->getCursor (name_cursor)); - connect (skin, SIGNAL (skinChanged()), this, SLOT (updateSkin())); -} - - -Button::~Button() -{} - -void Button::updateSkin() -{ - setPixmap (skin->getButton (name_normal)); - setCursor (skin->getCursor (name_cursor)); -} - -void Button::setON (bool on) -{ - if (on) - setPixmap (skin->getButton (name_pressed)); - else - setPixmap (skin->getButton (name_normal)); -} -void Button::mousePressEvent (QMouseEvent *e) -{ - if(e->button() != Qt::LeftButton) - return; - setON (true); - m_pressed = true; - QWidget::mousePressEvent(e); -} - -void Button::mouseReleaseEvent (QMouseEvent *e) -{ - if (!m_pressed) - return; - m_pressed = false; - if(rect().contains(e->pos())) - { - setON (false); - emit clicked(); - } -} - -void Button::mouseMoveEvent (QMouseEvent *e) -{ - setON (m_pressed && rect().contains(e->pos())); -} diff --git a/src/ui/button.h b/src/ui/button.h deleted file mode 100644 index e00bd7dc7..000000000 --- a/src/ui/button.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 BUTTON_H -#define BUTTON_H - -#include "pixmapwidget.h" - -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Button : public PixmapWidget -{ -Q_OBJECT -public: - Button(QWidget *parent, uint normal, uint pressed, uint cursor); - - ~Button(); - -signals: - void clicked(); - -private slots: - void updateSkin(); - -private: - Skin *skin; - //bool m_cursorin; - bool m_pressed; - void setON(bool); - uint name_normal, name_pressed; - uint name_cursor; - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); -}; - -#endif diff --git a/src/ui/configdialog.cpp b/src/ui/configdialog.cpp deleted file mode 100644 index 26a71e38d..000000000 --- a/src/ui/configdialog.cpp +++ /dev/null @@ -1,591 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2011 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 <QDir> -#include <QSettings> -#include <QFontDialog> -#include <QTreeWidgetItem> -#include <QHeaderView> -#include <QCheckBox> -#include <QRadioButton> -#include <QMenu> -#include <QMessageBox> -#include <qmmp/decoder.h> -#include <qmmp/output.h> -#include <qmmp/decoderfactory.h> -#include <qmmp/outputfactory.h> -#include <qmmp/visualfactory.h> -#include <qmmp/effectfactory.h> -#include <qmmp/effect.h> -#include <qmmp/soundcore.h> -#include <qmmp/enginefactory.h> -#include <qmmp/abstractengine.h> -#include <qmmp/qmmpsettings.h> -#include <qmmp/inputsource.h> -#include <qmmp/inputsourcefactory.h> -#include <qmmpui/generalfactory.h> -#include <qmmpui/general.h> -#include <qmmpui/generalhandler.h> -#include <qmmpui/filedialog.h> -#include <qmmpui/mediaplayer.h> -#include <qmmpui/playlistmodel.h> -#include "shortcutdialog.h" -#include "actionmanager.h" -#include "shortcutitem.h" -#include "popupsettings.h" -#include "skin.h" -#include "pluginitem.h" -#include "configdialog.h" -#include "skinreader.h" - -ConfigDialog::ConfigDialog (QWidget *parent) - : QDialog (parent) -{ - ui.setupUi (this); - setAttribute(Qt::WA_QuitOnClose, false); - setAttribute(Qt::WA_DeleteOnClose, false); - ui.preferencesButton->setEnabled(false); - ui.informationButton->setEnabled(false); - connect (ui.mainFontButton, SIGNAL (clicked()), SLOT (setMainFont())); - connect (ui.plFontButton, SIGNAL (clicked()), SLOT (setPlFont())); - connect (this, SIGNAL(rejected()),SLOT(saveSettings())); - connect (ui.fileDialogComboBox, SIGNAL (currentIndexChanged (int)), SLOT(updateDialogButton(int))); - connect (ui.skinInstallButton, SIGNAL (clicked()), SLOT(installSkin())); - connect (ui.skinReloadButton, SIGNAL (clicked()), SLOT(loadSkins())); - connect (ui.listWidget, SIGNAL (itemClicked (QListWidgetItem *)), this, SLOT (changeSkin())); - ui.listWidget->setIconSize (QSize (105,34)); - m_skin = Skin::instance(); - ui.replayGainModeComboBox->addItem (tr("Track"), QmmpSettings::REPLAYGAIN_TRACK); - ui.replayGainModeComboBox->addItem (tr("Album"), QmmpSettings::REPLAYGAIN_ALBUM); - ui.replayGainModeComboBox->addItem (tr("Disabled"), QmmpSettings::REPLAYGAIN_DISABLED); - readSettings(); - m_reader = new SkinReader(this); - loadSkins(); - loadPluginsInfo(); - loadShortcuts(); - loadFonts(); - createMenus(); - //setup icons - ui.skinInstallButton->setIcon(QIcon::fromTheme("list-add")); - ui.skinReloadButton->setIcon(QIcon::fromTheme("view-refresh")); - ui.popupTemplateButton->setIcon(QIcon::fromTheme("configure")); - ui.preferencesButton->setIcon(QIcon::fromTheme("configure")); - ui.informationButton->setIcon(QIcon::fromTheme("dialog-information")); - ui.fdInformationButton->setIcon(QIcon::fromTheme("dialog-information")); - ui.outputInformationButton->setIcon(QIcon::fromTheme("dialog-information")); - ui.outputPreferencesButton->setIcon(QIcon::fromTheme("configure")); -} - -ConfigDialog::~ConfigDialog() -{} - -void ConfigDialog::readSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - if (MediaPlayer *player = MediaPlayer::instance()) - { - ui.formatLineEdit->setText(player->playListManager()->format()); - ui.metadataCheckBox->setChecked(player->playListManager()->useMetadata()); - ui.underscoresCheckBox->setChecked(player->playListManager()->convertUnderscore()); - ui.per20CheckBox->setChecked(player->playListManager()->convertTwenty()); - } - ui.protocolCheckBox->setChecked(settings.value ("PlayList/show_protocol", false).toBool()); - ui.numbersCheckBox->setChecked(settings.value ("PlayList/show_numbers", true).toBool()); - ui.alignCheckBox->setChecked(settings.value ("PlayList/align_numbers", false).toBool()); - ui.anchorCheckBox->setChecked(settings.value("PlayList/show_anchor", false).toBool()); - ui.playlistsCheckBox->setChecked(settings.value("PlayList/show_plalists", false).toBool()); - ui.popupCheckBox->setChecked(settings.value("PlayList/show_popup", false).toBool()); - QmmpSettings *gs = QmmpSettings::instance(); - //proxy settings - ui.enableProxyCheckBox->setChecked(gs->isProxyEnabled()); - ui.authProxyCheckBox->setChecked(gs->useProxyAuth()); - ui.hostLineEdit->setText(gs->proxy().host()); - if (gs->proxy().port(0)) - ui.portLineEdit->setText(QString::number(gs->proxy().port(0))); - ui.proxyUserLineEdit->setText(gs->proxy().userName()); - ui.proxyPasswLineEdit->setText(gs->proxy().password()); - - ui.hostLineEdit->setEnabled(ui.enableProxyCheckBox->isChecked()); - ui.portLineEdit->setEnabled(ui.enableProxyCheckBox->isChecked()); - ui.proxyUserLineEdit->setEnabled(ui.authProxyCheckBox->isChecked()); - ui.proxyPasswLineEdit->setEnabled(ui.authProxyCheckBox->isChecked()); - //transparency - ui.mwTransparencySlider->setValue(100 - settings.value("MainWindow/opacity", 1.0).toDouble()*100); - ui.eqTransparencySlider->setValue(100 - settings.value("Equalizer/opacity", 1.0).toDouble()*100); - ui.plTransparencySlider->setValue(100 - settings.value("PlayList/opacity", 1.0).toDouble()*100); - //view - ui.skinCursorsCheckBox->setChecked(settings.value("General/skin_cursors", false).toBool()); - m_currentSkinName = settings.value("General/skin_name", "default").toString(); - ui.hiddenCheckBox->setChecked(settings.value("MainWindow/start_hidden", false).toBool()); - ui.hideOnCloseCheckBox->setChecked(settings.value("MainWindow/hide_on_close", false).toBool()); - //resume playback - ui.continuePlaybackCheckBox->setChecked(settings.value("General/resume_on_startup", false).toBool()); - //cover options - ui.coverIncludeLineEdit->setText(gs->coverNameFilters(true).join(",")); - ui.coverExcludeLineEdit->setText(gs->coverNameFilters(false).join(",")); - ui.coverDepthSpinBox->setValue(gs->coverSearchDepth()); - ui.useCoverFilesCheckBox->setChecked(gs->useCoverFiles()); - //replay gain - ui.clippingCheckBox->setChecked(gs->replayGainPreventClipping()); - ui.replayGainModeComboBox->setCurrentIndex(ui.replayGainModeComboBox->findData(gs->replayGainMode())); - ui.preampDoubleSpinBox->setValue(gs->replayGainPreamp()); - ui.defaultGainDoubleSpinBox->setValue(gs->replayGainDefaultGain()); - //audio - ui.softVolumeCheckBox->setChecked(gs->useSoftVolume()); - ui.use16BitCheckBox->setChecked(gs->use16BitOutput()); - ui.bufferSizeSpinBox->setValue(gs->bufferSize()); -} - -void ConfigDialog::on_contentsWidget_currentItemChanged (QListWidgetItem *current, - QListWidgetItem *previous) -{ - if (!current) - current = previous; - ui.stackedWidget->setCurrentIndex (ui.contentsWidget->row (current)); - ui.hiddenCheckBox->setEnabled(GeneralHandler::instance()->visibilityControl()); - ui.hideOnCloseCheckBox->setEnabled(GeneralHandler::instance()->visibilityControl()); -} - -void ConfigDialog::changeSkin() -{ - int row = ui.listWidget->currentRow(); - QString path; - if (m_skinList.at (row).isDir()) - { - path = m_skinList.at (row).canonicalFilePath(); - m_skin->setSkin (path); - } - else if (m_skinList.at (row).isFile()) - { - m_reader->unpackSkin(m_skinList.at (row).canonicalFilePath()); - m_skin->setSkin(QDir::homePath() +"/.qmmp/cache/skin"); - } - if(ui.listWidget->currentItem()) - m_currentSkinName = ui.listWidget->currentItem()->text(); - else - m_currentSkinName.clear(); -} - -void ConfigDialog::loadSkins() -{ - m_reader->generateThumbs(); - m_skinList.clear(); - ui.listWidget->clear(); - QFileInfo fileInfo (":/default"); - QPixmap preview = Skin::getPixmap ("main", QDir (fileInfo.filePath())); - QListWidgetItem *item = new QListWidgetItem (fileInfo.fileName ()); - item->setIcon (preview); - ui.listWidget->addItem (item); - m_skinList << fileInfo; - if(item->text() == m_currentSkinName) - ui.listWidget->setCurrentItem(item); - - findSkins(QDir::homePath() +"/.qmmp/skins"); -#ifdef Q_OS_WIN32 - findSkins(qApp->applicationDirPath()+"/skins"); -#else - findSkins(qApp->applicationDirPath()+"/../share/qmmp/skins"); -#endif - foreach(QString path, m_reader->skins()) - { - QListWidgetItem *item = new QListWidgetItem (path.section('/', -1)); - item->setIcon (m_reader->getPreview(path)); - item->setToolTip(tr("Archived skin") + " " + path); - ui.listWidget->addItem (item); - m_skinList << QFileInfo(path); - if(item->text() == m_currentSkinName) - ui.listWidget->setCurrentItem(item); - } -} - -void ConfigDialog::findSkins(const QString &path) -{ - QDir dir(path); - dir.setFilter (QDir::Dirs | QDir::NoDotAndDotDot); - QList <QFileInfo> fileList = dir.entryInfoList(); - if (fileList.count() == 0) - return; - foreach (QFileInfo fileInfo, fileList) - { - QPixmap preview = Skin::getPixmap ("main", QDir(fileInfo.filePath ())); - if (!preview.isNull()) - { - QListWidgetItem *item = new QListWidgetItem (fileInfo.fileName ()); - item->setIcon (preview); - item->setToolTip(tr("Unarchived skin") + " " + fileInfo.filePath ()); - ui.listWidget->addItem (item); - m_skinList << fileInfo; - } - } -} - -void ConfigDialog::loadPluginsInfo() -{ - ui.treeWidget->blockSignals(true); - /* - load transport plugin information - */ - QTreeWidgetItem *item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("Transports")); - QList <InputSourceFactory *> *transports = InputSource::factories(); - QStringList files = InputSource::files(); - for (int i = 0; i < transports->count (); ++i) - new PluginItem (item, transports->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - - /* - load input plugins information - */ - item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("Decoders")); - QList <DecoderFactory *> *decoders = Decoder::factories(); - files = Decoder::files(); - for (int i = 0; i < decoders->count (); ++i) - new PluginItem (item, decoders->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - /* - load audio engines information - */ - item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("Engines")); - QList <EngineFactory *> *engines = AbstractEngine::factories(); - files = AbstractEngine::files(); - for (int i = 0; i < engines->count (); ++i) - new PluginItem (item, engines->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - /* - load effect plugin information - */ - item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("Effects")); - QList <EffectFactory *> *effects = Effect::factories(); - files = Effect::files(); - for (int i = 0; i < effects->count (); ++i) - new PluginItem (item, effects->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - /* - load visual plugin information - */ - item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("Visualization")); - QList <VisualFactory *> *visuals = Visual::factories(); - files = Visual::files(); - for (int i = 0; i < visuals->count (); ++i) - new PluginItem (item, visuals->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - /* - load general plugin information - */ - item = new QTreeWidgetItem (ui.treeWidget, QStringList() << tr("General")); - QList <GeneralFactory *> *generals = General::factories(); - files = General::files(); - for (int i = 0; i < generals->count (); ++i) - new PluginItem (item, generals->at(i), files.at (i)); - ui.treeWidget->addTopLevelItem(item); - item->setExpanded(true); - - ui.treeWidget->blockSignals(false); - ui.treeWidget->resizeColumnToContents(0); - ui.treeWidget->resizeColumnToContents(1); - /* - load output plugins information - */ - ui.outputInformationButton->setEnabled(false); - ui.outputPreferencesButton->setEnabled(false); - QList <OutputFactory *> *outputs = Output::factories(); - for (int i = 0; i < outputs->count (); ++i) - { - ui.outputComboBox->addItem(outputs->at(i)->properties().name); - if(Output::currentFactory() == outputs->at(i)) - { - ui.outputComboBox->setCurrentIndex(i); - on_outputComboBox_activated (i); - } - } - /* - load file dialog information - */ - foreach(FileDialogFactory *factory, FileDialog::registeredFactories()) - { - ui.fileDialogComboBox->addItem(factory->properties().name); - if (FileDialog::isEnabled(factory)) - ui.fileDialogComboBox->setCurrentIndex(ui.fileDialogComboBox->count()-1); - } -} - -void ConfigDialog::loadFonts() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - QString fontname = settings.value ("PlayList/Font").toString(); - QFont font = QApplication::font(); - if(!fontname.isEmpty()) - font.fromString(fontname); - ui.plFontLabel->setText (font.family () + " " + QString::number(font.pointSize ())); - ui.plFontLabel->setFont(font); - - font = QApplication::font (); - fontname = settings.value ("MainWindow/Font").toString(); - if(!fontname.isEmpty()) - font.fromString(fontname); - ui.mainFontLabel->setText (font.family () + " " + QString::number(font.pointSize ())); - ui.mainFontLabel->setFont(font); - ui.useBitmapCheckBox->setChecked(settings.value("MainWindow/bitmap_font", false).toBool()); -} - -void ConfigDialog::loadShortcuts() -{ - //playback - QTreeWidgetItem *item = new QTreeWidgetItem (ui.shortcutTreeWidget, QStringList() << tr("Playback")); - for(int i = ActionManager::PLAY; i <= ActionManager::CLEAR_QUEUE; ++i) - new ShortcutItem(item, i); - item->setExpanded(true); - ui.shortcutTreeWidget->addTopLevelItem(item); - //view - item = new QTreeWidgetItem (ui.shortcutTreeWidget, QStringList() << tr("View")); - for(int i = ActionManager::SHOW_PLAYLIST; i <= ActionManager::WM_DOUBLE_SIZE; ++i) - new ShortcutItem(item, i); - item->setExpanded(true); - ui.shortcutTreeWidget->addTopLevelItem(item); - //playlist - item = new QTreeWidgetItem (ui.shortcutTreeWidget, QStringList() << tr("Playlist")); - for(int i = ActionManager::PL_ADD_FILE; i <= ActionManager::PL_SHOW_MANAGER; ++i) - new ShortcutItem(item, i); - item->setExpanded(true); - ui.shortcutTreeWidget->addTopLevelItem(item); - //misc - item = new QTreeWidgetItem (ui.shortcutTreeWidget, QStringList() << tr("Misc")); - for(int i = ActionManager::SETTINGS; i <= ActionManager::QUIT; ++i) - new ShortcutItem(item, i); - item->setExpanded(true); - ui.shortcutTreeWidget->addTopLevelItem(item); - - ui.shortcutTreeWidget->resizeColumnToContents(0); - ui.shortcutTreeWidget->resizeColumnToContents(1); -} - -void ConfigDialog::setPlFont() -{ - bool ok; - QFont font = ui.plFontLabel->font(); - font = QFontDialog::getFont (&ok, font, this); - if (ok) - { - ui.plFontLabel->setText (font.family () + " " + QString::number(font.pointSize ())); - ui.plFontLabel->setFont(font); - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("PlayList/Font", font.toString()); - } -} - -void ConfigDialog::setMainFont() -{ - bool ok; - QFont font = ui.mainFontLabel->font(); - font = QFontDialog::getFont (&ok, font, this); - if (ok) - { - ui.mainFontLabel->setText (font.family () + " " + QString::number(font.pointSize ())); - ui.mainFontLabel->setFont(font); - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("MainWindow/Font", font.toString()); - } -} - -void ConfigDialog::on_preferencesButton_clicked() -{ - QTreeWidgetItem *item = ui.treeWidget->currentItem(); - if(item && item->type() >= PluginItem::TRANSPORT) - dynamic_cast<PluginItem *>(item)->showSettings(this); - -} - -void ConfigDialog::on_informationButton_clicked() -{ - QTreeWidgetItem *item = ui.treeWidget->currentItem(); - if(item && item->type() >= PluginItem::TRANSPORT) - dynamic_cast<PluginItem *>(item)->showAbout(this); -} - -void ConfigDialog::createMenus() -{ - QMenu *menu = new QMenu(this); - - menu->addAction(tr("Artist"))->setData("%p"); - menu->addAction(tr("Album"))->setData("%a"); - menu->addAction(tr("Title"))->setData("%t"); - menu->addAction(tr("Track number"))->setData("%n"); - menu->addAction(tr("Two-digit track number"))->setData("%NN"); - menu->addAction(tr("Genre"))->setData("%g"); - menu->addAction(tr("Comment"))->setData("%c"); - menu->addAction(tr("Composer"))->setData("%C"); - menu->addAction(tr("Disc number"))->setData("%D"); - menu->addAction(tr("File name"))->setData("%f"); - menu->addAction(tr("File path"))->setData("%F"); - menu->addAction(tr("Year"))->setData("%y"); - menu->addAction(tr("Condition"))->setData("%if(%p&%t,%p - %t,%f)"); - - ui.titleButton->setMenu(menu); - ui.titleButton->setPopupMode(QToolButton::InstantPopup); - connect(menu, SIGNAL(triggered (QAction *)), SLOT(addTitleString(QAction *))); -} - -void ConfigDialog::addTitleString(QAction * a) -{ - if (ui.formatLineEdit->cursorPosition () < 1) - ui.formatLineEdit->insert(a->data().toString()); - else - ui.formatLineEdit->insert(" - "+a->data().toString()); -} - -void ConfigDialog::saveSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - if (MediaPlayer *player = MediaPlayer::instance()) - { - player->playListManager()->setFormat(ui.formatLineEdit->text().trimmed()); - player->playListManager()->setUseMetadata(ui.metadataCheckBox->isChecked()); - player->playListManager()->setConvertUnderscore(ui.underscoresCheckBox->isChecked()); - player->playListManager()->setConvertTwenty(ui.per20CheckBox->isChecked()); - } - settings.setValue ("PlayList/show_protocol", ui.protocolCheckBox->isChecked()); - settings.setValue ("PlayList/show_numbers", ui.numbersCheckBox->isChecked()); - settings.setValue ("PlayList/align_numbers", ui.alignCheckBox->isChecked()); - settings.setValue ("PlayList/show_anchor", ui.anchorCheckBox->isChecked()); - settings.setValue ("PlayList/show_plalists", ui.playlistsCheckBox->isChecked()); - settings.setValue ("PlayList/show_popup", ui.popupCheckBox->isChecked()); - FileDialog::setEnabled(FileDialog::registeredFactories().at(ui.fileDialogComboBox->currentIndex())); - QmmpSettings *gs = QmmpSettings::instance(); - //proxy - QUrl proxyUrl; - proxyUrl.setHost(ui.hostLineEdit->text()); - proxyUrl.setPort(ui.portLineEdit->text().toUInt()); - proxyUrl.setUserName(ui.proxyUserLineEdit->text()); - proxyUrl.setPassword(ui.proxyPasswLineEdit->text()); - gs->setNetworkSettings(ui.enableProxyCheckBox->isChecked(), - ui.authProxyCheckBox->isChecked(), - proxyUrl); - - - settings.setValue ("MainWindow/opacity", 1.0 - (double)ui.mwTransparencySlider->value()/100); - settings.setValue ("Equalizer/opacity", 1.0 - (double)ui.eqTransparencySlider->value()/100); - settings.setValue ("PlayList/opacity", 1.0 - (double)ui.plTransparencySlider->value()/100); - settings.setValue ("General/resume_on_startup", ui.continuePlaybackCheckBox->isChecked()); - settings.setValue ("MainWindow/bitmap_font", ui.useBitmapCheckBox->isChecked()); - settings.setValue ("General/skin_cursors", ui.skinCursorsCheckBox->isChecked()); - settings.setValue ("General/skin_name", m_currentSkinName); - settings.setValue ("MainWindow/start_hidden", ui.hiddenCheckBox->isChecked()); - settings.setValue ("MainWindow/hide_on_close", ui.hideOnCloseCheckBox->isChecked()); - gs->setCoverSettings(ui.coverIncludeLineEdit->text().split(","), - ui.coverExcludeLineEdit->text().split(","), - ui.coverDepthSpinBox->value(), - ui.useCoverFilesCheckBox->isChecked()); - int i = ui.replayGainModeComboBox->currentIndex(); - gs->setReplayGainSettings((QmmpSettings::ReplayGainMode) - ui.replayGainModeComboBox->itemData(i).toInt(), - ui.preampDoubleSpinBox->value(), - ui.defaultGainDoubleSpinBox->value(), - ui.clippingCheckBox->isChecked()); - gs->setAudioSettings(ui.softVolumeCheckBox->isChecked(), ui.use16BitCheckBox->isChecked()); - gs->setBufferSize(ui.bufferSizeSpinBox->value()); - QList <OutputFactory *> *outputs = Output::factories(); - if(ui.outputComboBox->currentIndex() >= 0 && outputs->count()) - Output::setCurrentFactory(outputs->at(ui.outputComboBox->currentIndex())); -} - -void ConfigDialog::updateDialogButton(int index) -{ - ui.fdInformationButton->setEnabled(FileDialog::registeredFactories()[index]->properties().hasAbout); -} - -void ConfigDialog::on_fdInformationButton_clicked() -{ - int index = ui.fileDialogComboBox->currentIndex (); - FileDialog::registeredFactories()[index]->showAbout(this); -} - -void ConfigDialog::installSkin() -{ - QStringList files = FileDialog::getOpenFileNames(this,tr("Select Skin Files"), QDir::homePath(), - tr("Skin files") + " (*.tar.gz *.tgz *.tar.bz2 *.zip *.wsz)"); - foreach(QString path, files) - { - QFile file(path); - file.copy(QDir::homePath() +"/.qmmp/skins/" + QFileInfo(path).fileName()); - } - loadSkins(); -} - -void ConfigDialog::on_popupTemplateButton_clicked() -{ - PopupSettings *p = new PopupSettings(this); - p->exec(); - p->deleteLater(); -} - -void ConfigDialog::on_treeWidget_itemChanged (QTreeWidgetItem *item, int column) -{ - if(column == 0 && item->type() >= PluginItem::TRANSPORT) - dynamic_cast<PluginItem *>(item)->setEnabled(item->checkState(0) == Qt::Checked); -} - -void ConfigDialog::on_treeWidget_currentItemChanged (QTreeWidgetItem *current, QTreeWidgetItem *) -{ - if(current->type() >= PluginItem::TRANSPORT) - { - ui.preferencesButton->setEnabled(dynamic_cast<PluginItem *>(current)->hasSettings()); - ui.informationButton->setEnabled(dynamic_cast<PluginItem *>(current)->hasAbout()); - } - else - { - ui.preferencesButton->setEnabled(false); - ui.informationButton->setEnabled(false); - } -} - -void ConfigDialog::on_outputComboBox_activated (int index) -{ - OutputFactory *factory = Output::factories()->at(index); - ui.outputInformationButton->setEnabled(factory->properties().hasAbout); - ui.outputPreferencesButton->setEnabled(factory->properties().hasSettings); -} - -void ConfigDialog::on_outputPreferencesButton_clicked() -{ - int index = ui.outputComboBox->currentIndex(); - Output::factories()->at(index)->showSettings(this); -} - -void ConfigDialog::on_outputInformationButton_clicked() -{ - int index = ui.outputComboBox->currentIndex(); - Output::factories()->at(index)->showAbout(this); -} - -void ConfigDialog::on_changeShortcutButton_clicked() -{ - ShortcutItem *item = dynamic_cast<ShortcutItem *> (ui.shortcutTreeWidget->currentItem()); - if(!item) - return; - ShortcutDialog editor(item->action()->shortcut().toString(), this); - if(editor.exec() == QDialog::Accepted) - { - item->action()->setShortcut(editor.key()); - item->setText(1, item->action()->shortcut().toString()); - } -} diff --git a/src/ui/configdialog.h b/src/ui/configdialog.h deleted file mode 100644 index ad8d62ae5..000000000 --- a/src/ui/configdialog.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2011 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 CONFIGDIALOG_H -#define CONFIGDIALOG_H - -#include <QDialog> -#include <QTreeWidgetItem> - -#include "ui_configdialog.h" - - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class QFileInfo; - -class Skin; -class SkinReader; - -class ConfigDialog : public QDialog -{ - Q_OBJECT -public: - ConfigDialog(QWidget *parent = 0); - - ~ConfigDialog(); - -private slots: - void on_contentsWidget_currentItemChanged (QListWidgetItem *current, QListWidgetItem *previous); - void changeSkin(); - void setPlFont(); - void setMainFont(); - void on_preferencesButton_clicked(); - void on_informationButton_clicked(); - void addTitleString(QAction *); - void saveSettings(); - void updateDialogButton(int); - void on_fdInformationButton_clicked(); - void installSkin(); - void loadSkins(); - void on_popupTemplateButton_clicked(); - void on_treeWidget_itemChanged (QTreeWidgetItem *item, int column); - void on_treeWidget_currentItemChanged (QTreeWidgetItem *current, QTreeWidgetItem *); - void on_outputComboBox_activated (int index); - void on_outputPreferencesButton_clicked(); - void on_outputInformationButton_clicked(); - void on_changeShortcutButton_clicked(); - -private: - void readSettings(); - void findSkins(const QString &path); - void loadPluginsInfo(); - void loadFonts(); - void loadShortcuts(); - void createMenus(); - - - QList <QFileInfo> m_skinList; - Ui::ConfigDialog ui; - QString m_currentSkinName; - Skin *m_skin; - QPixmap pixmap; - SkinReader *m_reader; -}; - -#endif diff --git a/src/ui/cursorimage.cpp b/src/ui/cursorimage.cpp deleted file mode 100644 index 30fcf0173..000000000 --- a/src/ui/cursorimage.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Erik Ölsar * - * erlk.ozlr@gmail.com * - * * - * 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 <QCursor> -#include <QString> -#include <QPixmap> -#include <QImage> -#include <QByteArray> -#include <QFile> -#include <QBitmap> -#include <QtDebug> -#include "cursorimage.h" - -QCursor createCursor(QString path) -{ - if (path.isEmpty()) - return QCursor(); - - // read file headers - QFile curFile(path); - curFile.open(QIODevice::ReadOnly); - QDataStream curStream(&curFile); - curStream.setByteOrder(QDataStream::LittleEndian); - - struct { - quint16 zero; - quint16 type; - quint16 icons; - } header2; - curStream >> header2.zero >> header2.type >> header2.icons; - - struct { - quint8 width; - quint8 height; - quint8 ncolours; - quint8 zero; - quint16 xhot; - quint16 yhot; - quint32 bytes; - quint32 dibOffset; - } directory2; - curStream >> directory2.width >> directory2.height >> directory2.ncolours >> directory2.zero >> directory2.xhot >> directory2.yhot >> directory2.bytes >> directory2.dibOffset; - - curFile.seek(directory2.dibOffset); - - // prepare a .bmp for delegating decoding to qt - struct { - unsigned char magic[2]; - quint32 size; - quint32 zero; - quint32 rdataOffset; - } bmpHeader; - int bmpHeaderSize = (2+4+4+4); - struct { - quint32 hdrSize; - quint32 width; - quint32 height; - quint16 planes; - quint16 bpp; - quint32 compression; - quint32 dataSize; - quint32 unused1; - quint32 unused2; - quint32 unused3; - quint32 unused4; - } dibHeader; - int dibHeaderSize = (4+4+4+2+2+4+4+4+4+4+4); - - bmpHeader.magic[0] = 'B'; bmpHeader.magic[1] = 'M'; - bmpHeader.zero = 0; - bmpHeader.size = bmpHeaderSize + directory2.bytes; - bmpHeader.rdataOffset = bmpHeaderSize + dibHeaderSize + directory2.ncolours * 4; - - curStream >> dibHeader.hdrSize >> dibHeader.width >> dibHeader.height >> dibHeader.planes >> dibHeader.bpp >> dibHeader.compression >> dibHeader.dataSize >> dibHeader.unused1 >> dibHeader.unused2 >> dibHeader.unused3 >> dibHeader.unused4; - dibHeader.height >>= 1; - - // the bmp bytes are in 'bmpData' - QByteArray bmpData; - QDataStream bmpStream(&bmpData, QIODevice::WriteOnly); - bmpStream.setByteOrder(QDataStream::LittleEndian); - bmpStream.writeRawData((char*) bmpHeader.magic, 2); - bmpStream << bmpHeader.size << bmpHeader.zero << bmpHeader.rdataOffset; - bmpStream << dibHeader.hdrSize << dibHeader.width << dibHeader.height << dibHeader.planes << dibHeader.bpp << dibHeader.compression << dibHeader.dataSize << dibHeader.unused1 << dibHeader.unused2 << dibHeader.unused3 << dibHeader.unused4; - bmpData.append(curFile.read(directory2.bytes - dibHeaderSize)); - - // decode the image into 'pix' - int width = directory2.width; - int height = directory2.height; - QImage image; - image.loadFromData(bmpData); - //qDebug() << image.rect() << path; - QPixmap pix = QPixmap::fromImage(image); - - // now we need the mask (transparency) - QByteArray maskData = bmpData.right((width * height) / 8); - QImage maskImage = QBitmap::fromData(QSize(width, height), (const uchar*) maskData.constData(), QImage::Format_Mono).toImage().mirrored(false, true); - maskImage.invertPixels(); - pix.setMask(QBitmap::fromImage(maskImage)); - - return QCursor(pix, directory2.xhot, directory2.yhot); -} diff --git a/src/ui/cursorimage.h b/src/ui/cursorimage.h deleted file mode 100644 index cde27d62d..000000000 --- a/src/ui/cursorimage.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Erik Ölsar * - * erlk.ozlr@gmail.com * - * * - * 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 CURSORIMAGE_H -#define CURSORIMAGE_H - -QCursor createCursor(QString path); - -#endif diff --git a/src/ui/default/balance.png b/src/ui/default/balance.png Binary files differdeleted file mode 100644 index 1c2467f49..000000000 --- a/src/ui/default/balance.png +++ /dev/null diff --git a/src/ui/default/cbuttons.png b/src/ui/default/cbuttons.png Binary files differdeleted file mode 100644 index 15666b838..000000000 --- a/src/ui/default/cbuttons.png +++ /dev/null diff --git a/src/ui/default/eq_ex.png b/src/ui/default/eq_ex.png Binary files differdeleted file mode 100644 index 172a57c83..000000000 --- a/src/ui/default/eq_ex.png +++ /dev/null diff --git a/src/ui/default/eqmain.png b/src/ui/default/eqmain.png Binary files differdeleted file mode 100644 index 8e332d178..000000000 --- a/src/ui/default/eqmain.png +++ /dev/null diff --git a/src/ui/default/main.png b/src/ui/default/main.png Binary files differdeleted file mode 100644 index 3980c579d..000000000 --- a/src/ui/default/main.png +++ /dev/null diff --git a/src/ui/default/monoster.png b/src/ui/default/monoster.png Binary files differdeleted file mode 100644 index fe941fc44..000000000 --- a/src/ui/default/monoster.png +++ /dev/null diff --git a/src/ui/default/numbers.png b/src/ui/default/numbers.png Binary files differdeleted file mode 100644 index 009d0228c..000000000 --- a/src/ui/default/numbers.png +++ /dev/null diff --git a/src/ui/default/playpaus.png b/src/ui/default/playpaus.png Binary files differdeleted file mode 100644 index 268e2a43a..000000000 --- a/src/ui/default/playpaus.png +++ /dev/null diff --git a/src/ui/default/pledit.png b/src/ui/default/pledit.png Binary files differdeleted file mode 100644 index 7e8c7bc1a..000000000 --- a/src/ui/default/pledit.png +++ /dev/null diff --git a/src/ui/default/pledit.txt b/src/ui/default/pledit.txt deleted file mode 100644 index 8550b2286..000000000 --- a/src/ui/default/pledit.txt +++ /dev/null @@ -1,8 +0,0 @@ -[Text]
-Normal=#A8AEAE
-Current=#ffffff
-NormalBG=#000000
-SelectedBG=#525555
-Font=Sans
-mbBG=#000000
-mbFG=#ffffff
\ No newline at end of file diff --git a/src/ui/default/posbar.png b/src/ui/default/posbar.png Binary files differdeleted file mode 100644 index 1f1608c8b..000000000 --- a/src/ui/default/posbar.png +++ /dev/null diff --git a/src/ui/default/readme.txt b/src/ui/default/readme.txt deleted file mode 100644 index 323706573..000000000 --- a/src/ui/default/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Ergo created for QMMP project by Andrey Andreev -andreev00@gmail.com
\ No newline at end of file diff --git a/src/ui/default/shufrep.png b/src/ui/default/shufrep.png Binary files differdeleted file mode 100644 index aa063c810..000000000 --- a/src/ui/default/shufrep.png +++ /dev/null diff --git a/src/ui/default/text.png b/src/ui/default/text.png Binary files differdeleted file mode 100644 index dcf1559e5..000000000 --- a/src/ui/default/text.png +++ /dev/null diff --git a/src/ui/default/titlebar.png b/src/ui/default/titlebar.png Binary files differdeleted file mode 100644 index 9ff2e1f22..000000000 --- a/src/ui/default/titlebar.png +++ /dev/null diff --git a/src/ui/default/viscolor.txt b/src/ui/default/viscolor.txt deleted file mode 100644 index 86a1131a3..000000000 --- a/src/ui/default/viscolor.txt +++ /dev/null @@ -1,24 +0,0 @@ -152,152,152, // Bg
-152,152,152, // Dots
-255,128,0, // Analyzer
-240,128,16, // Analyzer
-225,128,32, // Analyzer
-210,128,48, // Analyzer
-195,128,64, // Analyzer
-180,128,80, // Analyzer
-165,128,96, // Analyzer
-150,128,112, // Analyzer
-128,128,128, // Analyzer
-110,110,110, // Analyzer
-92,92,92, // Analyzer
-74,74,74, // Analyzer
-56,56,56, // Analyzer
-38,38,38, // Analyzer
-20,20,20, // Analyzer
-2,2,2, // Analyzer
-2,2,2, // Osc
-20,20,20, // Osc
-20,20,20, // Osc
-38,38,38, // Osc
-38,38,38, // Osc
-255,255,255, // Peak
\ No newline at end of file diff --git a/src/ui/default/volume.png b/src/ui/default/volume.png Binary files differdeleted file mode 100644 index cd33da4cf..000000000 --- a/src/ui/default/volume.png +++ /dev/null diff --git a/src/ui/display.cpp b/src/ui/display.cpp deleted file mode 100644 index 9b54306d2..000000000 --- a/src/ui/display.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QApplication> -#include <QSettings> -#include <QMenu> -#include <qmmp/soundcore.h> -#include <qmmpui/mediaplayer.h> -#include <qmmpui/playlistmanager.h> -#include "skin.h" -#include "mainvisual.h" -#include "button.h" -#include "titlebar.h" -#include "positionbar.h" -#include "number.h" -#include "togglebutton.h" -#include "symboldisplay.h" -#include "textscroller.h" -#include "monostereo.h" -#include "playstatus.h" -#include "volumebar.h" -#include "balancebar.h" -#include "mainwindow.h" -#include "timeindicator.h" -#include "actionmanager.h" -#include "display.h" - -MainDisplay::MainDisplay (QWidget *parent) - : PixmapWidget (parent) -{ - m_shaded = false; - m_skin = Skin::instance(); - setPixmap (m_skin->getMain()); - setCursor(m_skin->getCursor(Skin::CUR_NORMAL)); - m_mw = qobject_cast<MainWindow*>(parent); - m_titlebar = new TitleBar(this); - m_titlebar->move(0,0); - m_titlebar->setActive(true); - m_previous = new Button (this, Skin::BT_PREVIOUS_N, Skin::BT_PREVIOUS_P, Skin::CUR_NORMAL); - m_previous->setToolTip(tr("Previous")); - connect (m_previous, SIGNAL (clicked()), parent, SLOT (previous())); - - m_play = new Button (this, Skin::BT_PLAY_N, Skin::BT_PLAY_P, Skin::CUR_NORMAL); - m_play->setToolTip(tr("Play")); - connect (m_play, SIGNAL (clicked()),parent,SLOT (play())); - m_pause = new Button (this, Skin::BT_PAUSE_N,Skin::BT_PAUSE_P, Skin::CUR_NORMAL); - m_pause->setToolTip(tr("Pause")); - connect (m_pause,SIGNAL (clicked()),parent,SLOT (pause())); - m_stop = new Button (this, Skin::BT_STOP_N,Skin::BT_STOP_P, Skin::CUR_NORMAL); - m_stop->setToolTip(tr("Stop")); - connect (m_stop,SIGNAL (clicked()),parent,SLOT (stop())); - m_next = new Button (this, Skin::BT_NEXT_N,Skin::BT_NEXT_P, Skin::CUR_NORMAL); - m_next->setToolTip(tr("Next")); - connect (m_next,SIGNAL (clicked()),parent,SLOT (next())); - m_eject = new Button (this, Skin::BT_EJECT_N,Skin::BT_EJECT_P, Skin::CUR_NORMAL); - m_eject->setToolTip(tr("Add file")); - connect (m_eject,SIGNAL (clicked()),parent,SLOT (addFile())); - connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin())); - m_vis = new MainVisual (this); - - m_eqButton = new ToggleButton (this,Skin::BT_EQ_ON_N,Skin::BT_EQ_ON_P, - Skin::BT_EQ_OFF_N,Skin::BT_EQ_OFF_P); - m_eqButton->setToolTip(tr("Equalizer")); - m_plButton = new ToggleButton (this,Skin::BT_PL_ON_N,Skin::BT_PL_ON_P, - Skin::BT_PL_OFF_N,Skin::BT_PL_OFF_P); - m_plButton->setToolTip(tr("Playlist")); - - m_repeatButton = new ToggleButton (this,Skin::REPEAT_ON_N,Skin::REPEAT_ON_P, - Skin::REPEAT_OFF_N,Skin::REPEAT_OFF_P); - connect(m_repeatButton,SIGNAL(clicked(bool)),this,SIGNAL(repeatableToggled(bool))); - m_repeatButton->setToolTip(tr("Repeat playlist")); - m_shuffleButton = new ToggleButton (this,Skin::SHUFFLE_ON_N,Skin::SHUFFLE_ON_P, - Skin::SHUFFLE_OFF_N,Skin::SHUFFLE_OFF_P); - m_shuffleButton->setToolTip(tr("Shuffle")); - connect(m_shuffleButton,SIGNAL(clicked(bool)),this,SIGNAL(shuffleToggled(bool))); - - m_kbps = new SymbolDisplay(this,3); - m_freq = new SymbolDisplay(this,2); - m_text = new TextScroller (this); - m_monoster = new MonoStereo (this); - m_playstatus = new PlayStatus(this); - - m_volumeBar = new VolumeBar(this); - m_volumeBar->setToolTip(tr("Volume")); - connect(m_volumeBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); - connect(m_volumeBar, SIGNAL(sliderPressed()),SLOT(updateVolume())); - connect(m_volumeBar, SIGNAL(sliderReleased()),m_text,SLOT(clear())); - - m_balanceBar = new BalanceBar(this); - m_balanceBar->setToolTip(tr("Balance")); - connect(m_balanceBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); - connect(m_balanceBar, SIGNAL(sliderPressed()),SLOT(updateVolume())); - connect(m_balanceBar, SIGNAL(sliderReleased()),m_text,SLOT(clear())); - - m_posbar = new PositionBar(this); - connect(m_posbar, SIGNAL(sliderPressed()),SLOT(showPosition())); - connect(m_posbar, SIGNAL(sliderMoved(qint64)),SLOT(showPosition())); - connect(m_posbar, SIGNAL(sliderReleased()),SLOT(updatePosition())); - - m_timeIndicator = new TimeIndicator(this); - m_aboutWidget = new QWidget(this); - m_core = SoundCore::instance(); - connect(m_core, SIGNAL(elapsedChanged(qint64)), SLOT(setTime(qint64))); - connect(m_core, SIGNAL(bitrateChanged(int)), m_kbps, SLOT(display(int))); - connect(m_core, SIGNAL(frequencyChanged(quint32)), SLOT(setSampleRate(quint32))); - connect(m_core, SIGNAL(channelsChanged(int)), m_monoster, SLOT(setChannels(int))); - connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(setState(Qmmp::State))); - connect(m_core, SIGNAL(volumeChanged(int,int)), SLOT(setVolume(int, int))); - connect(m_core, SIGNAL(elapsedChanged(qint64)),m_titlebar, SLOT(setTime(qint64))); - PlayListManager *pl_manager = MediaPlayer::instance()->playListManager(); - connect(pl_manager, SIGNAL(repeatableListChanged(bool)), m_repeatButton, SLOT(setON(bool))); - connect(pl_manager, SIGNAL(shuffleChanged(bool)), m_shuffleButton, SLOT(setON(bool))); - updatePositions(); - updateMask(); -} - -MainDisplay::~MainDisplay() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("Playlist/visible",m_plButton->isChecked()); - settings.setValue ("Equalizer/visible",m_eqButton->isChecked()); -} - -void MainDisplay::updatePositions() -{ - int r = m_skin->ratio(); - m_previous->move (r*16, r*88); - m_play->move (r*39, r*88); - m_pause->move (r*62, r*88); - m_vis->move(r*24, r*43); - m_stop->move (r*85, r*88); - m_next->move (r*108, r*88); - m_eject->move (r*136, r*89); - m_posbar->move (r*16, r*72); - m_eqButton->move (r*219, r*58); - m_plButton->move (r*241, r*58); - m_repeatButton->move (r*210, r*89); - m_shuffleButton->move (r*164, r*89); - m_kbps->move (r*111, r*43); - m_freq->move (r*156, r*43); - m_text->resize (r*154, r*15); - m_text->move (r*109, r*23); - m_monoster->move (r*212, r*41); - m_playstatus->move(r*24, r*28); - m_volumeBar->move(r*107, r*57); - m_balanceBar->move(r*177, r*57); - m_timeIndicator->move(r*34, r*26); - m_aboutWidget->setGeometry(r*247,r*83,r*20,r*25); -} - -void MainDisplay::setTime (qint64 t) -{ - m_posbar->setValue (t); - m_timeIndicator->setTime(t/1000); -} -void MainDisplay::setDuration(qint64 t) -{ - m_posbar->setMaximum (t); - m_timeIndicator->setSongDuration(t/1000); -} - -void MainDisplay::setState(Qmmp::State state) -{ - switch ((int) state) - { - case Qmmp::Playing: - m_playstatus->setStatus(PlayStatus::PLAY); - m_timeIndicator->setNeedToShowTime(true); - setDuration(m_core->totalTime()); - break; - case Qmmp::Paused: - m_playstatus->setStatus(PlayStatus::PAUSE); - break; - case Qmmp::Stopped: - m_playstatus->setStatus(PlayStatus::STOP); - m_monoster->setChannels (0); - m_timeIndicator->setNeedToShowTime(false); - m_posbar->setValue (0); - m_posbar->setMaximum (0); - m_titlebar->setTime(-1); - } -} - -void MainDisplay::setVolume(int left, int right) -{ - int maxVol = qMax(left, right); - m_volumeBar->setValue(maxVol); - if (maxVol && !m_volumeBar->isPressed()) - m_balanceBar->setValue((right - left) * 100/maxVol); -} - -void MainDisplay::updateSkin() -{ - setPixmap (m_skin->getMain()); - m_mw->resize(size()); - setCursor(m_skin->getCursor(Skin::CUR_NORMAL)); - setMinimalMode(m_shaded); - updatePositions(); -} - -void MainDisplay::updateMask() -{ - m_mw->clearMask(); - m_mw->setMask(QRegion(0,0,m_mw->width(),m_mw->height())); - QRegion region = m_skin->getRegion(m_shaded? Skin::WINDOW_SHADE : Skin::NORMAL); - if (!region.isEmpty()) - m_mw->setMask(region); -} - -void MainDisplay::setMinimalMode(bool b) -{ - m_shaded = b; - int r = m_skin->ratio(); - - if(m_shaded) - m_mw->resize(r*275,r*14); - else - m_mw->resize(r*275,r*116); - updateMask(); -} - -void MainDisplay::setActive(bool b) -{ - m_titlebar->setActive(b); -} - -void MainDisplay::setSampleRate(quint32 rate) -{ - m_freq->display((int) rate/1000); -} -//TODO optimize this connections -void MainDisplay::setEQ (QWidget* w) -{ - m_equlizer = w; - m_eqButton->setON (m_equlizer->isVisible()); - ACTION(ActionManager::SHOW_EQUALIZER)->setChecked(m_equlizer->isVisible()); - - connect (ACTION(ActionManager::SHOW_EQUALIZER), SIGNAL(triggered(bool)), - m_equlizer, SLOT (setVisible (bool))); - connect (ACTION(ActionManager::SHOW_EQUALIZER), SIGNAL(triggered(bool)), - m_eqButton, SLOT (setON (bool))); - - connect (m_eqButton, SIGNAL(clicked(bool)), - ACTION(ActionManager::SHOW_EQUALIZER), SLOT(setChecked (bool))); - connect (m_eqButton, SIGNAL(clicked(bool)), m_equlizer, SLOT (setVisible (bool))); - connect (m_equlizer, SIGNAL(closed ()), m_eqButton, SLOT (click())); -} - -void MainDisplay::setPL (QWidget* w) -{ - m_playlist = w; - m_plButton->setON (m_playlist->isVisible()); - ACTION(ActionManager::SHOW_PLAYLIST)->setChecked(m_playlist->isVisible()); - - connect (ACTION(ActionManager::SHOW_PLAYLIST), SIGNAL(triggered(bool)), - m_playlist, SLOT (setVisible (bool))); - connect (ACTION(ActionManager::SHOW_PLAYLIST), SIGNAL(triggered(bool)), - m_plButton, SLOT (setON (bool))); - - connect (m_plButton, SIGNAL(clicked(bool)), - ACTION(ActionManager::SHOW_PLAYLIST), SLOT(setChecked (bool))); - connect (m_plButton, SIGNAL (clicked (bool)), m_playlist, SLOT (setVisible (bool))); - connect (m_playlist, SIGNAL (closed ()), m_plButton, SLOT (click())); -} - -bool MainDisplay::isPlaylistVisible() const -{ - return m_plButton->isChecked(); -} - -bool MainDisplay::isEqualizerVisible() const -{ - return m_eqButton->isChecked(); -} - -void MainDisplay::updateVolume() -{ - if(sender() == m_volumeBar) - m_text->setText(tr("Volume: %1%").arg(m_volumeBar->value())); - if(sender() == m_balanceBar) - { - if(m_balanceBar->value() > 0) - m_text->setText(tr("Balance: %1% right").arg(m_balanceBar->value())); - else if(m_balanceBar->value() < 0) - m_text->setText(tr("Balance: %1% left").arg(-m_balanceBar->value())); - else - m_text->setText(tr("Balance: center")); - } - m_mw->setVolume(m_volumeBar->value(), m_balanceBar->value()); -} - -void MainDisplay::showPosition() -{ - int sec = m_posbar->value() / 1000; - if(sec > 3600) - sec /= 60; - QString time = QString("%1:%2").arg(sec/60, 2, 10, QChar('0')).arg(sec%60, 2, 10, QChar('0')); - m_text->setText(tr("Seek to: %1").arg(time)); -} - -void MainDisplay::updatePosition() -{ - m_text->clear(); - m_core->seek(m_posbar->value()); -} - -void MainDisplay::wheelEvent (QWheelEvent *e) -{ - m_mw->setVolume(m_volumeBar->value()+e->delta()/10, m_balanceBar->value()); -} - -bool MainDisplay::isRepeatable() const -{ - return m_repeatButton->isChecked(); -} - -bool MainDisplay::isShuffle() const -{ - return m_shuffleButton->isChecked(); -} - -void MainDisplay::setIsRepeatable(bool yes) -{ - m_repeatButton->setON(yes); -} - -void MainDisplay::setIsShuffle(bool yes) -{ - m_shuffleButton->setON(yes); -} - -void MainDisplay::mousePressEvent(QMouseEvent *e) -{ - if (e->button() == Qt::RightButton) - m_mw->menu()->exec(e->globalPos()); - else if(e->button() == Qt::LeftButton && m_aboutWidget->underMouse()) - m_mw->about(); - PixmapWidget::mousePressEvent(e); -} - diff --git a/src/ui/display.h b/src/ui/display.h deleted file mode 100644 index 1a7a05b82..000000000 --- a/src/ui/display.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 DISPLAY_H -#define DISPLAY_H - -#include <QPixmap> -#include <qmmp/statehandler.h> -#include "pixmapwidget.h" - -class TimeIndicator; -class PositionBar; -class Skin; -class ToggleButton; -class TitleBar; -class NumberDisplay; -class SymbolDisplay; -class MonoStereo; -class PlayStatus; -class VolumeBar; -class BalanceBar; -class MainWindow; -class SoundCore; -class Button; -class TextScroller; -class MainVisual; -class TitleBar; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class MainDisplay : public PixmapWidget -{ - Q_OBJECT -public: - MainDisplay(QWidget *parent = 0); - - ~MainDisplay(); - - void setEQ(QWidget*); - void setPL(QWidget*); - bool isEqualizerVisible()const; - bool isPlaylistVisible()const; - bool isRepeatable()const; - bool isShuffle()const; - void setIsRepeatable(bool); - void setIsShuffle(bool); - void setMinimalMode(bool b = true); - void setActive(bool b); - -public slots: - void setDuration(qint64); - -signals: - void repeatableToggled(bool); - void shuffleToggled(bool); - -protected: - void wheelEvent(QWheelEvent *); - void mousePressEvent(QMouseEvent*); - -private slots: - void updateSkin(); - void updateVolume(); - void showPosition(); - void updatePosition(); - void setSampleRate(quint32 rate); - void setTime(qint64); - void setState(Qmmp::State state); - void setVolume(int left, int right); - - -private: - void updatePositions(); - void updateMask(); - QWidget* m_equlizer; - QWidget* m_playlist; - bool m_shaded; - Skin *m_skin; - PositionBar *m_posbar; - Button *m_previous; - Button *m_play; - Button *m_pause; - Button *m_stop; - Button *m_next; - Button *m_eject; - TextScroller *m_text; - ToggleButton *m_eqButton; - ToggleButton *m_plButton; - ToggleButton *m_shuffleButton; - ToggleButton *m_repeatButton; - SymbolDisplay* m_kbps; - SymbolDisplay* m_freq; - MonoStereo* m_monoster; - PlayStatus* m_playstatus; - VolumeBar* m_volumeBar; - BalanceBar* m_balanceBar; - MainWindow* m_mw; - MainVisual* m_vis; - TimeIndicator* m_timeIndicator; - TitleBar *m_titlebar; - SoundCore *m_core; - QWidget *m_aboutWidget; -}; - -#endif diff --git a/src/ui/dock.cpp b/src/ui/dock.cpp deleted file mode 100644 index a4e5d52d2..000000000 --- a/src/ui/dock.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 <QDesktopWidget> -#include <QApplication> - -#include "dock.h" - - -Dock *Dock::m_instance = 0; - -Dock *Dock::instance() -{ - if (!m_instance) - m_instance = new Dock(); - return m_instance; -} - -Dock::Dock (QObject *parent) - : QObject (parent) -{ - m_instance = this; - m_mainWidget = 0; -} - -Dock::~Dock() -{ - m_instance = 0; -} - -void Dock::setMainWidget (QWidget *widget) -{ - m_mainWidget = widget; - m_widgetList.prepend (widget); - m_dockedList.prepend (false); -} - - -QPoint Dock::snap (QPoint npos, QWidget* mv, QWidget* st) -{ - int nx = npos.x() - st->x(); - int ny = abs (npos.y() - st->y() + mv->height()); - - if (abs (nx) < 13 && ny < 13) //above - npos.rx() = st->x(); - if (ny < 13 && nx > -mv->width() && nx < st->width()) - npos.ry() = st->y() - mv->height(); - nx = abs (npos.x() + mv->width() - st->x() - st->width()); - if (nx < 13 && ny < 13) - npos.rx() = st->x() + st->width() - mv->width(); - - /***********/ - nx = npos.x() - st->x(); - ny = abs (npos.y() - st->y() - st->height()); - - if (abs (nx) < 13 && ny < 13) //near - npos.rx() = st->x(); - if (ny < 13 && nx > -mv->width() && nx < st->width()) - npos.ry() = st->y() + st->height(); - nx = abs (npos.x() + mv->width() - st->x() - st->width()); - if (nx < 13 && ny < 13) - npos.rx() = st->x() + st->width() - mv->width(); - /**************/ - nx = abs (npos.x() - st->x() + mv->width()); - ny = npos.y() - st->y(); - - if (nx < 13 && abs (ny) < 13) //left - npos.ry() = st->y(); - if (nx < 13 && ny > -mv->height() && ny < st->height()) - npos.rx() = st->x() - mv->width(); - - ny = abs (npos.y() + mv->height() - st->y() - st->height()); - if (nx < 13 && ny < 13) - npos.ry() = st->y() + st->height() - mv->height(); - /*****************/ - nx = abs (npos.x() - st->x() - st->width()); - ny = npos.y() - st->y(); - - if (nx < 13 && abs (ny) < 13) //right - npos.ry() = st->y(); - if (nx < 13 && ny > -mv->height() && ny < st->height()) - npos.rx() = st->x() + st->width(); - - ny = abs (npos.y() + mv->height() - st->y() - st->height()); - if (nx < 13 && ny < 13) - npos.ry() = st->y() + st->height() - mv->height(); - - return (npos); -} - -void Dock::addWidget (QWidget *widget) -{ - m_widgetList.append (widget); - m_dockedList.append (false); - widget->addActions(m_actions); - -} - -void Dock::move (QWidget* mv, QPoint npos) -{ - QRect DesktopRect = QApplication::desktop()->availableGeometry(m_mainWidget); - if(npos.y() < DesktopRect.y()) - npos.setY(DesktopRect.y()); - if(npos.x() < DesktopRect.x()) - npos.setX(DesktopRect.x()); - if (mv == m_mainWidget) - { - - for (int i = 1; i<m_widgetList.size(); ++i) - { - if (!m_dockedList.at (i)) - { - if (m_widgetList.at (i)->isVisible()) - npos = snap (npos, mv, m_widgetList.at (i)); - - } - else - { - QPoint pos = QPoint (npos.x() + x_list.at (i), - npos.y() + y_list.at (i)); - for (int j = 1; j<m_widgetList.size(); ++j) - { - if (!m_dockedList.at (j) && m_widgetList.at (j)->isVisible()) - { - pos = snap (pos, m_widgetList.at (i), m_widgetList.at (j)); - npos = QPoint (pos.x() - x_list.at (i), - pos.y() - y_list.at (i)); - } - } - } - } - mv->move (npos); - for (int i = 1; i<m_widgetList.size(); ++i) - { - if (m_dockedList.at (i)) - m_widgetList.at (i)->move(npos.x() + x_list.at (i), - npos.y() + y_list.at (i)); - } - } - else - { - for (int i = 0; i<m_widgetList.size(); ++i) - { - m_dockedList[i] = false; - if (mv != m_widgetList.at (i) && !m_dockedList.at (i) && m_widgetList.at (i)->isVisible()) - { - npos = snap (npos, mv, m_widgetList.at (i)); - } - } - mv->move (npos); - } -} - -void Dock::calculateDistances() -{ - x_list.clear(); - y_list.clear(); - foreach (QWidget *w, m_widgetList) - { - if (w!=m_mainWidget) - { - x_list.append (- m_mainWidget->x() + w->x()); - y_list.append (- m_mainWidget->y() + w->y()); - } - else - { - x_list.prepend (0); - y_list.prepend (0); - } - } -} - -void Dock::updateDock() -{ - QWidget *mv = m_widgetList.at (0); - for (int j = 1; j<m_widgetList.size(); ++j) - { - QWidget *st = m_widgetList.at (j); - m_dockedList[j] = isDocked (mv, st); - } - for (int j = 1; j<m_widgetList.size(); ++j) - { - if (m_dockedList[j]) - for (int i = 1; i<m_widgetList.size(); ++i) - { - if (!m_dockedList[i]) - { - mv = m_widgetList.at (j); - QWidget *st = m_widgetList.at (i); - m_dockedList[i] = isDocked (mv, st); - } - } - } - -} - -bool Dock::isDocked (QWidget* mv, QWidget* st) -{ - int nx = mv->x() - st->x(); - int ny = abs (mv->y() - st->y() + mv->height()); - if (ny < 2 && nx > -mv->width() && nx < st->width()) //above - return true; - - /***********/ - nx = mv->x() - st->x(); - ny = abs (mv->y() - st->y() - st->height()); - if (ny < 2 && nx > -mv->width() && nx < st->width()) //near - return true; - - /**************/ - nx = abs (mv->x() - st->x() + mv->width()); - ny = mv->y() - st->y(); - if (nx < 2 && ny > -mv->height() && ny < st->height()) //left - return true; - - /*****************/ - nx = abs (mv->x() - st->x() - st->width()); - ny = mv->y() - st->y(); - if (nx < 2 && ny > -mv->height() && ny < st->height()) //right - return true; - return false; -} - -void Dock::addActions (QList<QAction *> actions) -{ - m_actions << actions; - for (int i = 0; i<m_widgetList.size(); ++i) - m_widgetList.at (i)->addActions (actions); -} - -bool Dock::isUnder(QWidget* upper, QWidget* nether, int dy) -{ - int nx = upper->x() - nether->x(); - return abs (upper->y() + upper->height() -dy - nether->y()) < 2 && - nx > -upper->width() && nx < nether->width(); -} - -void Dock::align(QWidget* w, int dy) -{ - for (int i = 0; i<m_dockedList.size(); ++i) - { - if (m_widgetList.at(i) != w && isUnder(w, m_widgetList.at(i), dy)) - { - m_widgetList.at(i)->move(m_widgetList.at(i)->x(), m_widgetList.at(i)->y()+dy); - align(m_widgetList.at(i), dy); - } - } -} diff --git a/src/ui/dock.h b/src/ui/dock.h deleted file mode 100644 index e843ed142..000000000 --- a/src/ui/dock.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 DOCK_H -#define DOCK_H - -#include <QObject> -#include <QPoint> -#include <QWidget> - -class QAction; -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Dock : public QObject -{ - Q_OBJECT -public: - Dock(QObject *parent = 0); - - ~Dock(); - - static Dock *instance(); - void setMainWidget(QWidget*); - void addWidget(QWidget *); - void move(QWidget*, QPoint); - void calculateDistances(); - void updateDock(); - QPoint snap(QPoint, QWidget*, QWidget*); - void addActions(QList<QAction *> actions); - void align(QWidget*, int dy); - -private: - bool isDocked(QWidget*, QWidget*); - bool isUnder(QWidget*, QWidget*, int); - static Dock *m_instance; - QWidget *m_mainWidget; - QList <QWidget *> m_widgetList; - QList <bool> m_dockedList; - QList <int> x_list; - QList <int> y_list; - QList <QAction *> m_actions; -}; - -#endif diff --git a/src/ui/eqgraph.cpp b/src/ui/eqgraph.cpp deleted file mode 100644 index 1d7d070f7..000000000 --- a/src/ui/eqgraph.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QPainter> - -#include "skin.h" -#include "eqgraph.h" - -EQGraph::EQGraph (QWidget *parent) - : PixmapWidget (parent) -{ - m_skin = Skin::instance(); - setPixmap (m_skin->getEqPart (Skin::EQ_GRAPH)); - clear(); - m_ratio = m_skin->ratio(); - draw(); - connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin())); - setVisible(!m_skin->getEqPart (Skin::EQ_GRAPH).isNull()); -} - -EQGraph::~EQGraph() -{} - -void EQGraph::addValue (int value) -{ - if (m_values.size() >= 10) - return; - m_values.append (value); - if (m_values.size() == 10) - { - draw(); - } -} - -void EQGraph::clear () -{ - m_values.clear(); - update(); -} - -void EQGraph::init_spline (double * x, double * y, int n, double * y2) -{ - int i, k; - double p, qn, sig, un, *u; - - u = new double[n]; - - y2[0] = u[0] = 0.0; - - for (i = 1; i < n - 1; i++) - { - sig = ((double) x[i] - x[i - 1]) / ((double) x[i + 1] - x[i - 1]); - p = sig * y2[i - 1] + 2.0; - y2[i] = (sig - 1.0) / p; - u[i] = - (((double) y[i + 1] - y[i]) / (x[i + 1] - x[i])) - - (((double) y[i] - y[i - 1]) / (x[i] - x[i - 1])); - u[i] = (6.0 * u[i] / (x[i + 1] - x[i - 1]) - sig * u[i - 1]) / p; - } - qn = un = 0.0; - - y2[n - 1] = (un - qn * u[n - 2]) / (qn * y2[n - 2] + 1.0); - for (k = n - 2; k >= 0; k--) - y2[k] = y2[k] * y2[k + 1] + u[k]; - delete[] u; -} - -double EQGraph::eval_spline (double xa[], double ya[], double y2a[], int n, double x) -{ - int klo, khi, k; - double h, b, a; - - klo = 0; - khi = n - 1; - while (khi - klo > 1) - { - k = (khi + klo) >> 1; - if (xa[k] > x) - khi = k; - else - klo = k; - } - h = xa[khi] - xa[klo]; - a = (xa[khi] - x) / h; - b = (x - xa[klo]) / h; - return (a * ya[klo] + b * ya[khi] + - ((a * a * a - a) * y2a[klo] + - (b * b * b - b) * y2a[khi]) * (h * h) / 6.0); -} - -void EQGraph::draw() -{ - QPixmap pixmap = m_skin->getEqPart (Skin::EQ_GRAPH); - if (pixmap.isNull()) - pixmap = QPixmap(113*m_ratio,19*m_ratio); - - if (m_values.size()!=10) - { - setPixmap (pixmap); - return; - } - - int i, y, ymin, ymax, py = 0; - double x[] = { 0, 11, 23, 35, 47, 59, 71, 83, 97, 109 }, yf[10]; - double *bands = new double[10]; - - for (int i = 0; i < 10; ++i) - { - bands[i] = m_values.at (i); - } - - init_spline (x, bands, 10, yf); - for (i = 0; i < 113; i++) - { - y = 9 - (int) ((eval_spline (x, bands, yf, 10, i) * 9.0) / 20.0); - if (y < 0) - y = 0; - if (y > 18) - y = 18; - if (!i) - py = y; - if (y < py) - { - ymin = y; - ymax = py; - } - else - { - ymin = py; - ymax = y; - } - py = y; - - QPainter paint (&pixmap); - paint.drawPixmap (i*m_ratio, y*m_ratio, m_skin->getEqSpline (y)); - } - setPixmap (pixmap); - delete [] bands; -} - -void EQGraph::updateSkin() -{ - m_ratio = m_skin->ratio(); - draw(); - setVisible(!m_skin->getEqPart (Skin::EQ_GRAPH).isNull()); -} - diff --git a/src/ui/eqgraph.h b/src/ui/eqgraph.h deleted file mode 100644 index 96e5db521..000000000 --- a/src/ui/eqgraph.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 EQGRAPH_H -#define EQGRAPH_H - -#include "pixmapwidget.h" - -class Skin; -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class EQGraph : public PixmapWidget -{ - Q_OBJECT -public: - EQGraph (QWidget *parent = 0); - - ~EQGraph(); - - void addValue (int); - void clear(); - -private slots: - void updateSkin(); - -private: - QList <int> m_values; - Skin *m_skin; - void init_spline (double * x, double * y, int n, double * y2); - double eval_spline (double xa[], double ya[], double y2a[], int n, double x); - void draw(); - int m_ratio; - -}; - -#endif diff --git a/src/ui/eqpreset.cpp b/src/ui/eqpreset.cpp deleted file mode 100644 index 533dd4f67..000000000 --- a/src/ui/eqpreset.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 "eqpreset.h" - -EQPreset::EQPreset() - : QListWidgetItem() -{ - m_preamp = 0; - for(int i = 0; i < 10; ++i) - m_bands[i] = 0; -} - - -EQPreset::~EQPreset() -{} - -void EQPreset::setGain(int n, double value) -{ - if(n > 9 || n < 0) - return; - m_bands[n] = value; -} - -void EQPreset::setPreamp(double preamp) -{ - m_preamp = preamp; -} - -double EQPreset::gain(int n) -{ - if(n > 9 || n < 0) - return 0; - return m_bands[n]; -} - -double EQPreset::preamp() -{ - return m_preamp; -} diff --git a/src/ui/eqpreset.h b/src/ui/eqpreset.h deleted file mode 100644 index fd99e6826..000000000 --- a/src/ui/eqpreset.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 EQPRESET_H -#define EQPRESET_H - -#include <QListWidgetItem> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class EQPreset : public QListWidgetItem -{ -public: - EQPreset(); - - ~EQPreset(); - - void setGain(int n, double value); - void setPreamp(double); - - double gain(int n); - double preamp(); - -private: - double m_bands[10]; - double m_preamp; - -}; - -#endif diff --git a/src/ui/eqslider.cpp b/src/ui/eqslider.cpp deleted file mode 100644 index 5c1925a4f..000000000 --- a/src/ui/eqslider.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QMouseEvent> -#include <QPainter> -#include <QWheelEvent> -#include <math.h> - -#include "skin.h" - -#include "eqslider.h" - - -EqSlider::EqSlider(QWidget *parent): PixmapWidget(parent) -{ - m_skin = Skin::instance(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setPixmap(m_skin->getEqSlider(0)); - m_moving = false; - m_min = -20; - m_max = 20; - m_old = m_value = 0; - draw(false); - setCursor(m_skin->getCursor(Skin::CUR_EQSLID)); -} - -EqSlider::~EqSlider() -{} - -void EqSlider::mousePressEvent(QMouseEvent *e) -{ - m_moving = true; - press_pos = e->y(); - if (e->button() == Qt::MidButton) - { - m_value = 0; - emit sliderMoved(m_value); - m_old = m_value; - } - else if (m_pos<e->y() && e->y()<m_pos+11*m_skin->ratio()) - { - press_pos = e->y()-m_pos; - } - else - { - m_value = convert(qMax(qMin(height()-12*m_skin->ratio(),e->y()-6*m_skin->ratio()),0)); - press_pos = 6*m_skin->ratio(); - if (m_value!=m_old) - { - emit sliderMoved(m_value); - m_old = m_value; - } - } - draw(); -} - -void EqSlider::mouseReleaseEvent(QMouseEvent*) -{ - m_moving = false; - draw(false); -} - -void EqSlider::mouseMoveEvent(QMouseEvent* e) -{ - if (m_moving) - { - int po = e->y(); - po = po - press_pos; - - if (0<=po && po<=height()-12*m_skin->ratio()) - { - m_value = convert(po); - draw(); - if (m_value!=m_old) - { - - m_old = m_value; - //qDebug ("%d",-m_value); - emit sliderMoved(-m_value); - } - } - } -} - -double EqSlider::value() -{ - return - m_value; -} - -void EqSlider::setValue(double p) -{ - if (m_moving) - return; - m_value = -p; - draw(false); -} - -void EqSlider::setMax(double m) -{ - m_max = m; - draw(false); -} - -void EqSlider::updateSkin() -{ - resize(m_skin->getEqSlider(0).size()); - draw(false); - setCursor(m_skin->getCursor(Skin::CUR_EQSLID)); -} - -void EqSlider::draw(bool pressed) -{ - int p=int(ceil(double(m_value-m_min)*(height()-12*m_skin->ratio())/(m_max-m_min))); - m_pixmap = m_skin->getEqSlider(27-27*(m_value-m_min)/(m_max-m_min)); - QPainter paint(&m_pixmap); - if (pressed) - paint.drawPixmap(1,p,m_skin->getButton(Skin::EQ_BT_BAR_P)); - else - paint.drawPixmap(1,p,m_skin->getButton(Skin::EQ_BT_BAR_N)); - setPixmap(m_pixmap); - m_pos = p; -} - -double EqSlider::convert(int p) -{ - return (m_max - m_min)*(p)/(height() - 12*m_skin->ratio()) + m_min; -} - -void EqSlider::wheelEvent(QWheelEvent *e) -{ - m_value -= e->delta()/60; - m_value = m_value > m_max ? m_max : m_value; - m_value = m_value < m_min ? m_min : m_value; - draw(false); - emit sliderMoved(m_value); -} - diff --git a/src/ui/eqslider.h b/src/ui/eqslider.h deleted file mode 100644 index 0a36a16ee..000000000 --- a/src/ui/eqslider.h +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 EQSLIDER_H -#define EQSLIDER_H - -#include "pixmapwidget.h" - -class QMouseEvent; -class QWheelEvent; -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class EqSlider : public PixmapWidget -{ -Q_OBJECT -public: - EqSlider(QWidget *parent = 0); - - ~EqSlider(); - - double value(); - -public slots: - void setValue(double); - void setMax(double); - -signals: - void sliderMoved (double); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - bool m_moving; - int press_pos; - double m_max, m_min, m_pos, m_value, m_old; - QPixmap m_pixmap; - double convert(int); // value = convert(position); - void draw(bool pressed = true); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void wheelEvent(QWheelEvent *); - - -}; - -#endif diff --git a/src/ui/eqtitlebar.cpp b/src/ui/eqtitlebar.cpp deleted file mode 100644 index e26a35e89..000000000 --- a/src/ui/eqtitlebar.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 <QMouseEvent> -#include <QMenu> -#include <QSettings> -#include "eqwidget.h" -#include "skin.h" -#include "shadedbar.h" -#include "dock.h" -#include "mainwindow.h" -#include "button.h" -#include "eqtitlebar.h" - -EqTitleBar::EqTitleBar(QWidget *parent) - : PixmapWidget(parent) -{ - m_volumeBar = 0; - m_balanceBar = 0; - m_shade2 = 0; - m_left = 0; - m_right = 0; - m_shaded = false; - m_align = false; - m_skin = Skin::instance(); - m_eq = parentWidget(); - m_mw = qobject_cast<MainWindow*>(m_eq->parent()); - m_close = new Button(this, Skin::EQ_BT_CLOSE_N, Skin::EQ_BT_CLOSE_P, Skin::CUR_EQCLOSE); - connect(m_close, SIGNAL(clicked()),m_eq, SIGNAL(closed())); - m_shade = new Button(this, Skin::EQ_BT_SHADE1_N, Skin::EQ_BT_SHADE1_P, Skin::CUR_EQNORMAL); - connect(m_shade, SIGNAL(clicked()), SLOT(shade())); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - if (settings.value("Equalizer/shaded", false).toBool()) - shade(); - m_align = true; - setActive(false); - setCursor(m_skin->getCursor(Skin::CUR_EQTITLE)); - connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin())); - updatePositions(); -} - - -EqTitleBar::~EqTitleBar() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.setValue("Equalizer/shaded", m_shaded); -} - -void EqTitleBar::updatePositions() -{ - int r = m_skin->ratio(); - m_close->move(r*264,r*3); - m_shade->move(r*254,r*3); - if(m_volumeBar) - m_volumeBar->move(r*61,r*4); - if(m_balanceBar) - m_balanceBar->move(r*164,r*4); - if(m_shade2) - m_shade2->move(r*254,r*3); -} - -void EqTitleBar::setActive(bool active) -{ - if (active) - { - if (m_shaded) - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_SHADED_A)); - else - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_A)); - } - else - { - if (m_shaded) - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_SHADED_I)); - else - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_I)); - } -} - -void EqTitleBar::setVolume(int left, int right) -{ - m_left = left; - m_right = right; - if (m_volumeBar && m_balanceBar) - { - int maxVol = qMax(left, right); - m_volumeBar->setValue(maxVol); - if (maxVol && !m_volumeBar->isPressed()) - m_balanceBar->setValue((right - left)*100/maxVol); - } -} - -void EqTitleBar::mousePressEvent(QMouseEvent* event) -{ - switch ((int) event->button ()) - { - case Qt::LeftButton: - m_pos = event->pos(); - break; - case Qt::RightButton: - m_mw->menu()->exec(event->globalPos()); - } -} - -void EqTitleBar::mouseMoveEvent(QMouseEvent* event) -{ - if (m_pos.x() < width() - 30 * m_skin->ratio()) - { - QPoint npos = (event->globalPos()-m_pos); - Dock::instance()->move(m_eq, npos); - } -} - -void EqTitleBar::mouseReleaseEvent(QMouseEvent*) -{ - Dock::instance()->updateDock(); -} - -void EqTitleBar::mouseDoubleClickEvent (QMouseEvent *) -{ - EqTitleBar::shade(); -} - -void EqTitleBar::shade() -{ - m_shaded = !m_shaded; - int r = m_skin->ratio(); - - if (m_shaded) - { - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_SHADED_A)); - m_shade->hide(); - m_shade2 = new Button(this, Skin::EQ_BT_SHADE2_N, Skin::EQ_BT_SHADE2_P, Skin::CUR_EQNORMAL); - m_shade2->move(r*254,r*3); - connect(m_shade2, SIGNAL(clicked()), SLOT(shade())); - m_shade2->show(); - m_volumeBar = new ShadedBar(this, Skin::EQ_VOLUME1, Skin::EQ_VOLUME2, Skin::EQ_VOLUME3); - m_volumeBar->move(r*61,r*4); - m_volumeBar->show(); - connect(m_volumeBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); - m_balanceBar = new ShadedBar(this, Skin::EQ_BALANCE1, Skin::EQ_BALANCE2, Skin::EQ_BALANCE3); - m_balanceBar->move(r*164,r*4); - m_balanceBar->setRange(-100, 100); - m_balanceBar->show(); - connect(m_balanceBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); - setVolume(m_left, m_right); //show current volume and balance - } - else - { - setPixmap(m_skin->getEqPart(Skin::EQ_TITLEBAR_A)); - m_shade2->deleteLater(); - m_volumeBar->deleteLater(); - m_balanceBar->deleteLater(); - m_volumeBar = 0; - m_balanceBar = 0; - m_shade2 = 0; - m_shade->show(); - } - qobject_cast<EqWidget *>(m_eq)->setMimimalMode(m_shaded); - if (m_align) - Dock::instance()->align(m_eq, m_shaded? -102*r: 102*r); -} - -void EqTitleBar::updateVolume() -{ - m_mw->setVolume(m_volumeBar->value(), m_balanceBar->value()); -} - -void EqTitleBar::updateSkin() -{ - setCursor(m_skin->getCursor(Skin::CUR_EQTITLE)); - updatePositions(); -} diff --git a/src/ui/eqtitlebar.h b/src/ui/eqtitlebar.h deleted file mode 100644 index d2ea09c6a..000000000 --- a/src/ui/eqtitlebar.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 EQTITLEBAR_H -#define EQTITLEBAR_H - -#include "pixmapwidget.h" - -class QMouseEvent; -class Skin; -class MainWindow; -class Button; -class ShadedBar; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class EqTitleBar : public PixmapWidget -{ -Q_OBJECT -public: - EqTitleBar(QWidget *parent = 0); - - ~EqTitleBar(); - - void setActive(bool); - -public slots: - void setVolume(int left, int right); - -private slots: - void shade(); - void updateVolume(); - void updateSkin(); - -private: - void updatePositions(); - Skin* m_skin; - bool m_active; - int m_left; - int m_right; - QPoint m_pos; - QWidget* m_eq; - MainWindow* m_mw; - Button* m_close; - Button* m_shade; - Button* m_shade2; - bool m_shaded, m_align; - ShadedBar* m_volumeBar; - ShadedBar* m_balanceBar; - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void mouseDoubleClickEvent (QMouseEvent *); -}; - -#endif diff --git a/src/ui/eqwidget.cpp b/src/ui/eqwidget.cpp deleted file mode 100644 index 1327b1bd9..000000000 --- a/src/ui/eqwidget.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 <QSettings> -#include <QEvent> -#include <QMenu> -#include <QInputDialog> -#include <QCloseEvent> -#include <qmmpui/filedialog.h> -#include <qmmp/soundcore.h> -#include "skin.h" -#include "eqslider.h" -#include "eqtitlebar.h" -#include "togglebutton.h" -#include "eqgraph.h" -#include "button.h" -#include "eqpreset.h" -#include "preseteditor.h" -#include "mainwindow.h" -#include "playlist.h" -#include "windowsystem.h" -#include "eqwidget.h" - -EqWidget::EqWidget (QWidget *parent) - : PixmapWidget (parent) -{ - setWindowTitle(tr("Equalizer")); - m_shaded = false; - m_skin = Skin::instance(); - setPixmap (m_skin->getEqPart (Skin::EQ_MAIN)); - setCursor (m_skin->getCursor (Skin::CUR_EQNORMAL)); - m_titleBar = new EqTitleBar (this); - m_titleBar->move (0,0); - connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin())); - - m_preamp = new EqSlider (this); - connect (m_preamp,SIGNAL (sliderMoved (double)),SLOT (writeEq())); - - m_on = new ToggleButton (this,Skin::EQ_BT_ON_N,Skin::EQ_BT_ON_P, Skin::EQ_BT_OFF_N,Skin::EQ_BT_OFF_P); - connect (m_on, SIGNAL (clicked(bool)), SLOT(writeEq())); - - m_autoButton = new ToggleButton(this, Skin::EQ_BT_AUTO_1_N, Skin::EQ_BT_AUTO_1_P, - Skin::EQ_BT_AUTO_0_N, Skin::EQ_BT_AUTO_0_P); - m_eqg = new EQGraph(this); - m_presetsMenu = new QMenu(this); - m_presetButton = new Button (this, Skin::EQ_BT_PRESETS_N, Skin::EQ_BT_PRESETS_P, Skin::CUR_EQNORMAL); - connect(m_presetButton, SIGNAL(clicked()), SLOT(showPresetsMenu())); - connect(SoundCore::instance(), SIGNAL(eqSettingsChanged()), SLOT(readEq())); - - for (int i = 0; i<10; ++i) - { - m_sliders << new EqSlider (this); - connect (m_sliders.at (i), SIGNAL (sliderMoved (double)),SLOT (writeEq())); - } - readSettings(); - createActions(); - updatePositions(); - updateMask(); - connect(SoundCore::instance(), SIGNAL(volumeChanged(int, int)), m_titleBar, SLOT(setVolume(int, int))); -#ifdef Q_WS_X11 - QString wm_name = WindowSystem::netWindowManagerName(); - if(wm_name.contains("metacity", Qt::CaseInsensitive) || - wm_name.contains("openbox", Qt::CaseInsensitive)) - setWindowFlags (Qt::Tool | Qt::FramelessWindowHint); - else -#endif - setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); -} - -EqWidget::~EqWidget() -{ - while (!m_presets.isEmpty()) - delete m_presets.takeFirst(); - while (!m_autoPresets.isEmpty()) - delete m_autoPresets.takeFirst(); -} - -void EqWidget::updatePositions() -{ - int r = m_skin->ratio(); - m_preamp->move (21*r,38*r); - m_on->move (14*r,18*r); - m_autoButton->move(39*r,18*r); - m_eqg->move(87*r,17*r); - m_presetButton->move(217*r,18*r); - for (int i = 0; i < 10; ++i) - m_sliders.at (i)->move ((78+i*18)*r,38*r); -} - -void EqWidget::changeEvent (QEvent * event) -{ - if (event->type() == QEvent::ActivationChange) - { - m_titleBar->setActive(isActiveWindow()); - } -} - -void EqWidget::closeEvent (QCloseEvent* e) -{ - if (e->spontaneous ()) - emit closed(); - writeSettings(); -} - -void EqWidget::updateSkin() -{ - m_titleBar->setActive (false); - setPixmap (m_skin->getEqPart (Skin::EQ_MAIN)); - setCursor (m_skin->getCursor (Skin::CUR_EQNORMAL)); - setMimimalMode(m_shaded); - updatePositions(); -} - -void EqWidget::setMimimalMode(bool b) -{ - m_shaded = b; - int r = m_skin->ratio(); - - if(m_shaded) - resize(r*275,r*14); - else - resize(r*275,r*116); - updateMask(); -} - -void EqWidget::readSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - move (settings.value ("Equalizer/pos", QPoint (100, 216)).toPoint()); //geometry - readEq(); - //equalizer presets - QSettings eq_preset (QDir::homePath() +"/.qmmp/eq.preset", QSettings::IniFormat); - for (int i = 1; true; ++i) - { - if (eq_preset.contains("Presets/Preset"+QString("%1").arg(i))) - { - QString name = eq_preset.value("Presets/Preset"+QString("%1").arg(i), - tr("preset")).toString(); - EQPreset *preset = new EQPreset(); - preset->setText(name); - eq_preset.beginGroup(name); - for (int j = 0; j < 10; ++j) - { - preset->setGain(j,eq_preset.value("Band"+QString("%1").arg(j), - 0).toDouble()); - } - preset->setPreamp(eq_preset.value("Preamp",0).toDouble()); - m_presets.append(preset); - eq_preset.endGroup(); - } - else - break; - } - //equalizer auto-load presets - QSettings eq_auto (QDir::homePath() +"/.qmmp/eq.auto_preset", QSettings::IniFormat); - for (int i = 1; true; ++i) - { - if (eq_auto.contains("Presets/Preset"+QString("%1").arg(i))) - { - QString name = eq_auto.value("Presets/Preset"+QString("%1").arg(i), - tr("preset")).toString(); - EQPreset *preset = new EQPreset(); - preset->setText(name); - eq_auto.beginGroup(name); - for (int j = 0; j < 10; ++j) - { - preset->setGain(j,eq_auto.value("Band"+QString("%1").arg(j), - 0).toDouble()); - } - preset->setPreamp(eq_auto.value("Preamp",0).toDouble()); - m_autoPresets.append(preset); - eq_auto.endGroup(); - } - else - break; - } -} - -void EqWidget::writeSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("Equalizer/pos", this->pos()); //geometry - //equalizer presets - QSettings eq_preset (QDir::homePath() +"/.qmmp/eq.preset", QSettings::IniFormat); - eq_preset.clear (); - for (int i = 0; i < m_presets.size(); ++i) - { - eq_preset.setValue("Presets/Preset"+QString("%1").arg(i+1), - m_presets.at(i)->text()); - eq_preset.beginGroup(m_presets.at(i)->text()); - for (int j = 0; j < 10; ++j) - { - eq_preset.setValue("Band"+QString("%1").arg(j),m_presets.at(i)->gain(j)); - } - eq_preset.setValue("Preamp",m_presets.at(i)->preamp()); - eq_preset.endGroup(); - } - //equalizer auto-load presets - QSettings eq_auto (QDir::homePath() +"/.qmmp/eq.auto_preset", - QSettings::IniFormat); - eq_auto.clear(); - for (int i = 0; i < m_autoPresets.size(); ++i) - { - eq_auto.setValue("Presets/Preset"+QString("%1").arg(i+1), - m_autoPresets.at(i)->text()); - eq_auto.beginGroup(m_autoPresets.at(i)->text()); - for (int j = 0; j < 10; ++j) - { - eq_auto.setValue("Band"+QString("%1").arg(j),m_autoPresets.at(i)->gain(j)); - } - eq_auto.setValue("Preamp",m_autoPresets.at(i)->preamp()); - eq_auto.endGroup(); - } -} - -void EqWidget::readEq() -{ - m_eqg->clear(); - EqSettings eqSettings = SoundCore::instance()->eqSettings(); - m_preamp->setValue(eqSettings.preamp()); - for (int i=0; i<10; ++i) - { - m_sliders.at(i)->setValue(eqSettings.gain(i)); - m_eqg->addValue(m_sliders.at(i)->value()); - } - m_on->setON(eqSettings.isEnabled()); -} - -void EqWidget::writeEq() -{ - m_eqg->clear(); - EqSettings eqSettings; - eqSettings.setPreamp(m_preamp->value()); - for (int i=0; i<10; ++i) - { - eqSettings.setGain(i,m_sliders.at(i)->value()); - m_eqg->addValue(m_sliders.at(i)->value()); - } - eqSettings.setEnabled(m_on->isChecked()); - SoundCore::instance()->setEqSettings(eqSettings); -} - -void EqWidget::createActions() -{ - m_presetsMenu->addAction(tr("&Load/Delete"),this, SLOT(showEditor())); - m_presetsMenu->addSeparator(); - m_presetsMenu->addAction(QIcon::fromTheme("document-save"), tr("&Save Preset"), - this, SLOT(savePreset())); - m_presetsMenu->addAction(QIcon::fromTheme("document-save"), tr("&Save Auto-load Preset"), - this, SLOT(saveAutoPreset())); - m_presetsMenu->addAction(QIcon::fromTheme("document-open"), tr("&Import"), - this, SLOT(importWinampEQF())); - m_presetsMenu->addSeparator(); - m_presetsMenu->addAction(QIcon::fromTheme("edit-clear"), tr("&Clear"), this, SLOT(reset())); -} - -void EqWidget::showPresetsMenu() -{ - m_presetsMenu->exec(m_presetButton->mapToGlobal(QPoint(0, 0))); -} - -void EqWidget::reset() -{ - for (int i = 0; i < m_sliders.size(); ++i) - m_sliders.at(i)->setValue(0); - m_preamp->setValue(0); - writeEq(); -} - -void EqWidget::showEditor() -{ - PresetEditor *editor = new PresetEditor(this); - editor->addPresets(m_presets); - editor->addAutoPresets(m_autoPresets); - connect (editor, SIGNAL(presetLoaded(EQPreset*)), SLOT(setPreset(EQPreset*))); - connect (editor, SIGNAL(presetDeleted(EQPreset*)), SLOT(deletePreset(EQPreset*))); - editor->show(); -} - -void EqWidget::savePreset() -{ - bool ok; - QString text = QInputDialog::getText(this, tr("Saving Preset"), - tr("Preset name:"), QLineEdit::Normal, - tr("preset #")+QString("%1").arg(m_presets.size()+1), &ok); - if (ok) - { - EQPreset* preset = new EQPreset; - preset->setText(text); - preset->setPreamp(m_preamp->value()); - for (int i = 0; i<10; ++i) - preset->setGain(i, m_sliders.at (i)->value()); - foreach(EQPreset *p, m_presets) //remove preset with same name - { - if (p->text() == text) - { - m_presets.removeAll(p); - delete p; - } - } - m_presets.append(preset); - } -} - -void EqWidget::saveAutoPreset() -{ - PlayList* playlist = qobject_cast<MainWindow*>(parent())->playlist(); - if (!playlist->currentItem()) - return; - //delete preset if it already exists - EQPreset* preset = findPreset(playlist->currentItem()->url().section("/",-1)); - if (preset) - deletePreset(preset); - //create new preset - preset = new EQPreset(); - preset->setText(playlist->currentItem()->url().section("/",-1)); - preset->setPreamp(m_preamp->value()); - for (int i = 0; i<10; ++i) - { - preset->setGain(i, m_sliders.at (i)->value()); - } - m_autoPresets.append(preset); -} - -void EqWidget::setPreset(EQPreset* preset) -{ - for (int i = 0; i<10; ++i) - m_sliders.at(i)->setValue(preset->gain(i)); - m_preamp->setValue(preset->preamp()); - writeEq(); -} - -void EqWidget::deletePreset(EQPreset* preset) -{ - int p = m_presets.indexOf(preset); - if (p != -1) - { - delete m_presets.takeAt(p); - return; - } - p = m_autoPresets.indexOf(preset); - if (p != -1) - { - delete m_autoPresets.takeAt(p); - return; - } -} - -void EqWidget::loadPreset(const QString &name) -{ - if (m_autoButton->isChecked()) - { - EQPreset *preset = findPreset(name); - if (preset) - setPreset(preset); - else - reset(); - } -} - -EQPreset *EqWidget::findPreset(const QString &name) -{ - foreach(EQPreset *preset, m_autoPresets) - { - if (preset->text() == name) - return preset; - } - return 0; -} - -void EqWidget::importWinampEQF() -{ - char header[31]; - char name[257]; - char bands[11]; - QString path = FileDialog::getOpenFileName(this, tr("Import Preset"), - "/home", - QString("Winamp EQF (*.q1)")); - - QFile file(path); - file.open(QIODevice::ReadOnly); - file.read (header, 31); - if (QString::fromAscii(header).contains("Winamp EQ library file v1.1")) - { - while (file.read (name, 257)) - { - EQPreset* preset = new EQPreset; - preset->setText(QString::fromAscii(name)); - - file.read(bands,11); - - for (int i = 0; i<10; ++i) - { - preset->setGain(i, 20 - bands[i]*40/64); - } - preset->setPreamp(20 - bands[10]*40/64); - m_presets.append(preset); - } - } - file.close(); - -} - -void EqWidget::keyPressEvent (QKeyEvent *ke) -{ - QKeyEvent event = QKeyEvent(ke->type(), ke->key(), - ke->modifiers(), ke->text(),ke->isAutoRepeat(), ke->count()); - QApplication::sendEvent(qobject_cast<MainWindow*>(parent())->playlist(), &event); -} - -#ifdef Q_WS_X11 -bool EqWidget::event (QEvent *event) -{ - if(event->type() == QEvent::WinIdChange || event->type() == QEvent::Show) - { - WindowSystem::ghostWindow(winId()); - WindowSystem::setWinHint(winId(), "equalizer", "Qmmp"); - } - return QWidget::event(event); -} -#endif - -void EqWidget::updateMask() -{ - clearMask(); - setMask(QRegion(0,0,width(),height())); - QRegion region = m_skin->getRegion(m_shaded? Skin::EQUALIZER_WS : Skin::EQUALIZER); - if (!region.isEmpty()) - setMask(region); -} diff --git a/src/ui/eqwidget.h b/src/ui/eqwidget.h deleted file mode 100644 index 7d0fb6086..000000000 --- a/src/ui/eqwidget.h +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2008 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 EQWIDGET_H -#define EQWIDGET_H - -#include "pixmapwidget.h" -#include <qmmp/output.h> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ - -class QMenu; -class Skin; -class EqTitleBar; -class EqSlider; -class ToggleButton; -class EQGraph; -class Button; -class EQPreset; -class PlayListItem; -class SoundCore; - -class EqWidget : public PixmapWidget -{ - Q_OBJECT -public: - EqWidget(QWidget *parent = 0); - - ~EqWidget(); - - /*! - * necessary for auto-load presets - */ - void loadPreset(const QString &name); - void setMimimalMode(bool b = true); - -signals: - void closed(); - -private slots: - void updateSkin(); - void readEq(); - void writeEq(); - void showPresetsMenu(); - void reset(); - void showEditor(); - void savePreset(); - void saveAutoPreset(); - void setPreset(EQPreset*); - void deletePreset(EQPreset*); - void importWinampEQF(); - -private: - void updatePositions(); - void readSettings(); - void writeSettings(); - void createActions(); - void updateMask(); - EQPreset *findPreset(const QString &name); - //events - virtual void keyPressEvent (QKeyEvent *); - virtual void changeEvent(QEvent*); - virtual void closeEvent(QCloseEvent*); -#ifdef Q_WS_X11 - virtual bool event (QEvent *event); -#endif - - Skin *m_skin; - EqTitleBar *m_titleBar; - EqSlider *m_preamp; - Button *m_presetButton; - QList<EqSlider*> m_sliders; - QPoint m_pos; - ToggleButton *m_on; - ToggleButton *m_autoButton; - EQGraph *m_eqg; - QMenu *m_presetsMenu; - QList<EQPreset*> m_presets; - QList<EQPreset*> m_autoPresets; - QString m_autoName; - bool m_shaded; -}; - -#endif diff --git a/src/ui/fft.c b/src/ui/fft.c deleted file mode 100644 index 7ca1978a5..000000000 --- a/src/ui/fft.c +++ /dev/null @@ -1,296 +0,0 @@ -/* fft.c: Iterative implementation of a FFT - * Copyright (C) 1999 Richard Boulton <richard@tartarus.org> - * Convolution stuff by Ralph Loader <suckfish@ihug.co.nz> - * - * 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. - */ - -/* - * TODO - * Remove compiling in of FFT_BUFFER_SIZE? (Might slow things down, but would - * be nice to be able to change size at runtime.) - * Finish making / checking thread-safety. - * More optimisations. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "fft.h" - -//#include <glib.h> -#include <stdlib.h> -#include <math.h> -#ifndef PI -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 /* pi */ -#endif -#endif - -/* ########### */ -/* # Structs # */ -/* ########### */ - -struct _struct_fft_state { - /* Temporary data stores to perform FFT in. */ - float real[FFT_BUFFER_SIZE]; - float imag[FFT_BUFFER_SIZE]; -}; - -/* ############################# */ -/* # Local function prototypes # */ -/* ############################# */ - -static void fft_prepare(const sound_sample * input, float *re, float *im); -static void fft_calculate(float *re, float *im); -static void fft_output(const float *re, const float *im, float *output); -static int reverseBits(unsigned int initial); - -/* #################### */ -/* # Global variables # */ -/* #################### */ - -/* Table to speed up bit reverse copy */ -static unsigned int bitReverse[FFT_BUFFER_SIZE]; - -/* The next two tables could be made to use less space in memory, since they - * overlap hugely, but hey. */ -static float sintable[FFT_BUFFER_SIZE / 2]; -static float costable[FFT_BUFFER_SIZE / 2]; - -/* ############################## */ -/* # Externally called routines # */ -/* ############################## */ - -/* --------- */ -/* FFT stuff */ -/* --------- */ - -/* - * Initialisation routine - sets up tables and space to work in. - * Returns a pointer to internal state, to be used when performing calls. - * On error, returns NULL. - * The pointer should be freed when it is finished with, by fft_close(). - */ -fft_state * -fft_init(void) -{ - fft_state *state; - unsigned int i; - - state = (fft_state *) malloc(sizeof(fft_state)); - if (!state) - return NULL; - - for (i = 0; i < FFT_BUFFER_SIZE; i++) { - bitReverse[i] = reverseBits(i); - } - for (i = 0; i < FFT_BUFFER_SIZE / 2; i++) { - float j = 2 * PI * i / FFT_BUFFER_SIZE; - costable[i] = cos(j); - sintable[i] = sin(j); - } - - return state; -} - -/* - * Do all the steps of the FFT, taking as input sound data (as described in - * sound.h) and returning the intensities of each frequency as floats in the - * range 0 to ((FFT_BUFFER_SIZE / 2) * 32768) ^ 2 - * - * FIXME - the above range assumes no frequencies present have an amplitude - * larger than that of the sample variation. But this is false: we could have - * a wave such that its maximums are always between samples, and it's just - * inside the representable range at the places samples get taken. - * Question: what _is_ the maximum value possible. Twice that value? Root - * two times that value? Hmmm. Think it depends on the frequency, too. - * - * The input array is assumed to have FFT_BUFFER_SIZE elements, - * and the output array is assumed to have (FFT_BUFFER_SIZE / 2 + 1) elements. - * state is a (non-NULL) pointer returned by fft_init. - */ -void -fft_perform(const sound_sample * input, float *output, fft_state * state) -{ - /* Convert data from sound format to be ready for FFT */ - fft_prepare(input, state->real, state->imag); - - /* Do the actual FFT */ - fft_calculate(state->real, state->imag); - - /* Convert the FFT output into intensities */ - fft_output(state->real, state->imag, output); -} - -/* - * Free the state. - */ -void -fft_close(fft_state * state) -{ - if (state) - free(state); -} - -/* ########################### */ -/* # Locally called routines # */ -/* ########################### */ - -/* - * Prepare data to perform an FFT on - */ -static void -fft_prepare(const sound_sample * input, float *re, float *im) -{ - unsigned int i; - float *realptr = re; - float *imagptr = im; - - /* Get input, in reverse bit order */ - for (i = 0; i < FFT_BUFFER_SIZE; i++) { - *realptr++ = input[bitReverse[i]]; - *imagptr++ = 0; - } -} - -/* - * Take result of an FFT and calculate the intensities of each frequency - * Note: only produces half as many data points as the input had. - * This is roughly a consequence of the Nyquist sampling theorm thingy. - * (FIXME - make this comment better, and helpful.) - * - * The two divisions by 4 are also a consequence of this: the contributions - * returned for each frequency are split into two parts, one at i in the - * table, and the other at FFT_BUFFER_SIZE - i, except for i = 0 and - * FFT_BUFFER_SIZE which would otherwise get float (and then 4* when squared) - * the contributions. - */ -static void -fft_output(const float *re, const float *im, float *output) -{ - float *outputptr = output; - const float *realptr = re; - const float *imagptr = im; - float *endptr = output + FFT_BUFFER_SIZE / 2; - -#ifdef DEBUG - unsigned int i, j; -#endif - - while (outputptr <= endptr) { - *outputptr = (*realptr * *realptr) + (*imagptr * *imagptr); - outputptr++; - realptr++; - imagptr++; - } - /* Do divisions to keep the constant and highest frequency terms in scale - * with the other terms. */ - *output /= 4; - *endptr /= 4; - -#ifdef DEBUG - printf("Recalculated input:\n"); - for (i = 0; i < FFT_BUFFER_SIZE; i++) { - float val_real = 0; - float val_imag = 0; - for (j = 0; j < FFT_BUFFER_SIZE; j++) { - float fact_real = cos(-2 * j * i * PI / FFT_BUFFER_SIZE); - float fact_imag = sin(-2 * j * i * PI / FFT_BUFFER_SIZE); - val_real += fact_real * re[j] - fact_imag * im[j]; - val_imag += fact_real * im[j] + fact_imag * re[j]; - } - printf("%5d = %8f + i * %8f\n", i, - val_real / FFT_BUFFER_SIZE, val_imag / FFT_BUFFER_SIZE); - } - printf("\n"); -#endif -} - -/* - * Actually perform the FFT - */ -static void -fft_calculate(float *re, float *im) -{ - unsigned int i, j, k; - unsigned int exchanges; - float fact_real, fact_imag; - float tmp_real, tmp_imag; - unsigned int factfact; - - /* Set up some variables to reduce calculation in the loops */ - exchanges = 1; - factfact = FFT_BUFFER_SIZE / 2; - - /* Loop through the divide and conquer steps */ - for (i = FFT_BUFFER_SIZE_LOG; i != 0; i--) { - /* In this step, we have 2 ^ (i - 1) exchange groups, each with - * 2 ^ (FFT_BUFFER_SIZE_LOG - i) exchanges - */ - /* Loop through the exchanges in a group */ - for (j = 0; j != exchanges; j++) { - /* Work out factor for this exchange - * factor ^ (exchanges) = -1 - * So, real = cos(j * PI / exchanges), - * imag = sin(j * PI / exchanges) - */ - fact_real = costable[j * factfact]; - fact_imag = sintable[j * factfact]; - - /* Loop through all the exchange groups */ - for (k = j; k < FFT_BUFFER_SIZE; k += exchanges << 1) { - int k1 = k + exchanges; - /* newval[k] := val[k] + factor * val[k1] - * newval[k1] := val[k] - factor * val[k1] - **/ -#ifdef DEBUG - printf("%d %d %d\n", i, j, k); - printf("Exchange %d with %d\n", k, k1); - printf("Factor %9f + i * %8f\n", fact_real, fact_imag); -#endif - /* FIXME - potential scope for more optimization here? */ - tmp_real = fact_real * re[k1] - fact_imag * im[k1]; - tmp_imag = fact_real * im[k1] + fact_imag * re[k1]; - re[k1] = re[k] - tmp_real; - im[k1] = im[k] - tmp_imag; - re[k] += tmp_real; - im[k] += tmp_imag; -#ifdef DEBUG - for (k1 = 0; k1 < FFT_BUFFER_SIZE; k1++) { - printf("%5d = %8f + i * %8f\n", k1, real[k1], imag[k1]); - } -#endif - } - } - exchanges <<= 1; - factfact >>= 1; - } -} - -static int -reverseBits(unsigned int initial) -{ - unsigned int reversed = 0, loop; - for (loop = 0; loop < FFT_BUFFER_SIZE_LOG; loop++) { - reversed <<= 1; - reversed += (initial & 1); - initial >>= 1; - } - return reversed; -} diff --git a/src/ui/fft.h b/src/ui/fft.h deleted file mode 100644 index 431afa365..000000000 --- a/src/ui/fft.h +++ /dev/null @@ -1,45 +0,0 @@ -/* fft.h: Header for iterative implementation of a FFT - * Copyright (C) 1999 Richard Boulton <richard@tartarus.org> - * - * 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 _FFT_H_ -#define _FFT_H_ - -#define FFT_BUFFER_SIZE_LOG 9 - -#define FFT_BUFFER_SIZE (1 << FFT_BUFFER_SIZE_LOG) - -/* sound sample - should be an signed 16 bit value */ -typedef short int sound_sample; - -#ifdef __cplusplus -extern "C" { -#endif - -/* FFT library */ - typedef struct _struct_fft_state fft_state; - fft_state *fft_init(void); - void fft_perform(const sound_sample * input, float *output, - fft_state * state); - void fft_close(fft_state * state); - - - -#ifdef __cplusplus -} -#endif -#endif /* _FFT_H_ */ diff --git a/src/ui/forms/aboutdialog.ui b/src/ui/forms/aboutdialog.ui deleted file mode 100644 index f9ea40fca..000000000 --- a/src/ui/forms/aboutdialog.ui +++ /dev/null @@ -1,162 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AboutDialog</class> - <widget class="QDialog" name="AboutDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>523</width> - <height>511</height> - </rect> - </property> - <property name="windowTitle"> - <string>About Qmmp</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="margin"> - <number>9</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="pixmapLabel"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../images/images.qrc">:/logo-qmmp.png</pixmap> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="aboutTab"> - <attribute name="title"> - <string>About</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QTextEdit" name="aboutTextEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="authorsTab"> - <attribute name="title"> - <string>Authors</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QTextEdit" name="authorsTextEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Translators</string> - </attribute> - <layout class="QVBoxLayout"> - <item> - <widget class="QTextEdit" name="translatorsTextEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="thanksToTab"> - <attribute name="title"> - <string>Thanks To</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTextEdit" name="thanksToTextEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="licenseTab"> - <attribute name="title"> - <string>License Agreement</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QTextEdit" name="licenseTextEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - <property name="overwriteMode"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="2" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../images/images.qrc"/> - </resources> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>AboutDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>AboutDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/addurldialog.ui b/src/ui/forms/addurldialog.ui deleted file mode 100644 index 64ac928fc..000000000 --- a/src/ui/forms/addurldialog.ui +++ /dev/null @@ -1,99 +0,0 @@ -<ui version="4.0" > - <class>AddUrlDialog</class> - <widget class="QDialog" name="AddUrlDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>394</width> - <height>77</height> - </rect> - </property> - <property name="windowTitle" > - <string>Enter URL to add</string> - </property> - <layout class="QGridLayout" > - <property name="leftMargin" > - <number>5</number> - </property> - <property name="topMargin" > - <number>5</number> - </property> - <property name="rightMargin" > - <number>5</number> - </property> - <property name="bottomMargin" > - <number>5</number> - </property> - <item row="0" column="0" colspan="3" > - <widget class="QComboBox" name="urlComboBox" > - <property name="editable" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>181</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1" > - <widget class="QPushButton" name="addButton" > - <property name="text" > - <string>&Add</string> - </property> - </widget> - </item> - <item row="1" column="2" > - <widget class="QPushButton" name="cancelButton" > - <property name="text" > - <string>&Cancel</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>addButton</sender> - <signal>clicked()</signal> - <receiver>AddUrlDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>248</x> - <y>51</y> - </hint> - <hint type="destinationlabel" > - <x>184</x> - <y>72</y> - </hint> - </hints> - </connection> - <connection> - <sender>cancelButton</sender> - <signal>clicked()</signal> - <receiver>AddUrlDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>343</x> - <y>62</y> - </hint> - <hint type="destinationlabel" > - <x>392</x> - <y>60</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/configdialog.ui b/src/ui/forms/configdialog.ui deleted file mode 100644 index d6a6f7a47..000000000 --- a/src/ui/forms/configdialog.ui +++ /dev/null @@ -1,1576 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigDialog</class> - <widget class="QDialog" name="ConfigDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>659</width> - <height>466</height> - </rect> - </property> - <property name="windowTitle"> - <string>Qmmp Settings</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <widget class="QListWidget" name="contentsWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>170</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>180</width> - <height>16777215</height> - </size> - </property> - <property name="iconSize"> - <size> - <width>38</width> - <height>38</height> - </size> - </property> - <property name="movement"> - <enum>QListView::Static</enum> - </property> - <property name="flow"> - <enum>QListView::TopToBottom</enum> - </property> - <property name="isWrapping" stdset="0"> - <bool>false</bool> - </property> - <property name="resizeMode"> - <enum>QListView::Adjust</enum> - </property> - <property name="spacing"> - <number>2</number> - </property> - <property name="viewMode"> - <enum>QListView::ListMode</enum> - </property> - <property name="uniformItemSizes"> - <bool>false</bool> - </property> - <property name="batchSize"> - <number>100</number> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - <property name="currentRow"> - <number>0</number> - </property> - <item> - <property name="text"> - <string>Appearance</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/interface.png</normaloff>:/interface.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Playlist</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/playlist.png</normaloff>:/playlist.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Plugins</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/plugins.png</normaloff>:/plugins.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Advanced</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/advanced.png</normaloff>:/advanced.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Connectivity</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/network.png</normaloff>:/network.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Audio</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/replaygain.png</normaloff>:/replaygain.png</iconset> - </property> - </item> - <item> - <property name="text"> - <string>Shortcuts</string> - </property> - <property name="icon"> - <iconset resource="../images/images.qrc"> - <normaloff>:/shortcuts.png</normaloff>:/shortcuts.png</iconset> - </property> - </item> - </widget> - </item> - <item> - <widget class="QStackedWidget" name="stackedWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="widget1"> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab_4"> - <attribute name="title"> - <string>Skins</string> - </attribute> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="4"> - <widget class="QListWidget" name="listWidget"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="movement"> - <enum>QListView::Static</enum> - </property> - <property name="flow"> - <enum>QListView::TopToBottom</enum> - </property> - <property name="viewMode"> - <enum>QListView::ListMode</enum> - </property> - <property name="modelColumn"> - <number>0</number> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QPushButton" name="skinInstallButton"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Add...</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="skinReloadButton"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Refresh</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab_5"> - <attribute name="title"> - <string>Miscellaneous</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>View</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QCheckBox" name="hideOnCloseCheckBox"> - <property name="text"> - <string>Hide on close</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="hiddenCheckBox"> - <property name="text"> - <string>Start hidden</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="skinCursorsCheckBox"> - <property name="text"> - <string>Use skin cursors</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="plGroupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Fonts</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Player:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="mainFontLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <property name="text"> - <string>???</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QToolButton" name="mainFontButton"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Playlist:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="plFontLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <property name="text"> - <string>???</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QToolButton" name="plFontButton"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QCheckBox" name="useBitmapCheckBox"> - <property name="text"> - <string>Use bitmap font if available</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_7"> - <property name="title"> - <string>Transparency</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Main window</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSlider" name="mwTransparencySlider"> - <property name="maximum"> - <number>90</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="mwTransparencyLabel"> - <property name="minimumSize"> - <size> - <width>25</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>0</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Equalizer</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSlider" name="eqTransparencySlider"> - <property name="maximum"> - <number>90</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="eqTransparencyLabel"> - <property name="text"> - <string>0</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Playlist</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSlider" name="plTransparencySlider"> - <property name="maximum"> - <number>90</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="plTransparencyLabel"> - <property name="text"> - <string>0</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="page"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Metadata</string> - </property> - <layout class="QGridLayout"> - <property name="margin"> - <number>9</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <item row="0" column="0"> - <widget class="QCheckBox" name="metadataCheckBox"> - <property name="text"> - <string>Load metadata from files</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Song Display</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Title format:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="formatLineEdit"/> - </item> - <item row="0" column="2"> - <widget class="QToolButton" name="titleButton"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QCheckBox" name="underscoresCheckBox"> - <property name="text"> - <string>Convert underscores to blanks</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QCheckBox" name="per20CheckBox"> - <property name="text"> - <string>Convert %20 to blanks</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="protocolCheckBox"> - <property name="text"> - <string>Show protocol</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QCheckBox" name="numbersCheckBox"> - <property name="text"> - <string>Show song numbers</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="2"> - <widget class="QCheckBox" name="playlistsCheckBox"> - <property name="text"> - <string>Show playlists</string> - </property> - </widget> - </item> - <item row="8" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QCheckBox" name="popupCheckBox"> - <property name="text"> - <string>Show popup information</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="popupTemplateButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Edit template</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="7" column="0" colspan="2"> - <widget class="QCheckBox" name="anchorCheckBox"> - <property name="text"> - <string>Show anchor</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="3"> - <widget class="QCheckBox" name="alignCheckBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Align song numbers</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>54</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="widget"> - <layout class="QGridLayout"> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <item row="1" column="0"> - <widget class="QPushButton" name="preferencesButton"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Preferences</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="informationButton"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Information</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>101</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" colspan="3"> - <widget class="QTreeWidget" name="treeWidget"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="animated"> - <bool>true</bool> - </property> - <property name="allColumnsShowFocus"> - <bool>false</bool> - </property> - <property name="columnCount"> - <number>2</number> - </property> - <column> - <property name="text"> - <string>Description</string> - </property> - </column> - <column> - <property name="text"> - <string>Filename</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_2"> - <layout class="QGridLayout" name="gridLayout_5"> - <item row="0" column="0" colspan="2"> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>File Dialog</string> - </property> - <layout class="QHBoxLayout"> - <item> - <widget class="QComboBox" name="fileDialogComboBox"/> - </item> - <item> - <widget class="QPushButton" name="fdInformationButton"> - <property name="text"> - <string>Information</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QGroupBox" name="groupBox_9"> - <property name="title"> - <string>Cover Image Retrieve</string> - </property> - <layout class="QGridLayout" name="gridLayout_6"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="useCoverFilesCheckBox"> - <property name="text"> - <string>Use separate image files</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Include files:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="coverIncludeLineEdit"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_12"> - <property name="text"> - <string>Exclude files:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="coverExcludeLineEdit"/> - </item> - <item row="3" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_13"> - <property name="text"> - <string>Recursive search depth:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="coverDepthSpinBox"> - <property name="maximum"> - <number>6</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QGroupBox" name="groupBox_6"> - <property name="title"> - <string>Playback</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_8"> - <item> - <widget class="QCheckBox" name="continuePlaybackCheckBox"> - <property name="text"> - <string>Continue playback on startup</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="network"> - <layout class="QVBoxLayout"> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_5"> - <property name="title"> - <string>Proxy</string> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QGridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="enableProxyCheckBox"> - <property name="text"> - <string>Enable proxy usage</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Proxy host name:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="hostLineEdit"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Proxy port:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="portLineEdit"/> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="authProxyCheckBox"> - <property name="text"> - <string>Use authentication with proxy</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Proxy user name:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="proxyUserLineEdit"/> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Proxy password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="proxyPasswLineEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="audio"> - <layout class="QVBoxLayout" name="verticalLayout_7"> - <item> - <widget class="QGroupBox" name="groupBox_10"> - <property name="title"> - <string>Replay Gain</string> - </property> - <layout class="QGridLayout" name="gridLayout_7"> - <item row="1" column="0"> - <widget class="QLabel" name="label_14"> - <property name="text"> - <string>Replay Gain mode:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="replayGainModeComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_15"> - <property name="text"> - <string>Preamp:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QDoubleSpinBox" name="preampDoubleSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <double>-15.000000000000000</double> - </property> - <property name="maximum"> - <double>15.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.010000000000000</double> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="label_17"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>dB</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_16"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Default gain:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QDoubleSpinBox" name="defaultGainDoubleSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <double>-15.000000000000000</double> - </property> - <property name="maximum"> - <double>15.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.010000000000000</double> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QLabel" name="label_18"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>dB</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0" colspan="3"> - <widget class="QCheckBox" name="clippingCheckBox"> - <property name="text"> - <string>Use peak info to prevent clipping</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_11"> - <property name="title"> - <string>Audio</string> - </property> - <layout class="QGridLayout" name="gridLayout_8"> - <item row="0" column="0"> - <widget class="QLabel" name="label_19"> - <property name="text"> - <string>Output:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="outputComboBox"/> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="outputPreferencesButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Preferences</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QPushButton" name="outputInformationButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Information</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_20"> - <property name="text"> - <string>Buffer size:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="bufferSizeSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="suffix"> - <string>ms</string> - </property> - <property name="minimum"> - <number>500</number> - </property> - <property name="maximum"> - <number>6000</number> - </property> - <property name="singleStep"> - <number>50</number> - </property> - </widget> - </item> - <item row="1" column="2" colspan="3"> - <spacer name="horizontalSpacer_6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>266</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QCheckBox" name="softVolumeCheckBox"> - <property name="text"> - <string>Use software volume control</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="use16BitCheckBox"> - <property name="text"> - <string>16-bit output</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>132</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="shortcuts"> - <layout class="QGridLayout" name="gridLayout_9"> - <item row="0" column="0" colspan="2"> - <widget class="QTreeWidget" name="shortcutTreeWidget"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="animated"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>Action</string> - </property> - </column> - <column> - <property name="text"> - <string>Shortcut</string> - </property> - </column> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="changeShortcutButton"> - <property name="text"> - <string>Change shortcut...</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <spacer name="horizontalSpacer_7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>341</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources> - <include location="../images/images.qrc"/> - </resources> - <connections> - <connection> - <sender>enableProxyCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>hostLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>286</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>enableProxyCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>portLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>286</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>272</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>authProxyCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>proxyUserLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>272</x> - <y>38</y> - </hint> - <hint type="destinationlabel"> - <x>272</x> - <y>38</y> - </hint> - </hints> - </connection> - <connection> - <sender>authProxyCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>proxyPasswLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>272</x> - <y>38</y> - </hint> - <hint type="destinationlabel"> - <x>272</x> - <y>37</y> - </hint> - </hints> - </connection> - <connection> - <sender>popupCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>popupTemplateButton</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>362</x> - <y>310</y> - </hint> - <hint type="destinationlabel"> - <x>455</x> - <y>315</y> - </hint> - </hints> - </connection> - <connection> - <sender>mwTransparencySlider</sender> - <signal>valueChanged(int)</signal> - <receiver>mwTransparencyLabel</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>252</x> - <y>90</y> - </hint> - <hint type="destinationlabel"> - <x>283</x> - <y>90</y> - </hint> - </hints> - </connection> - <connection> - <sender>eqTransparencySlider</sender> - <signal>valueChanged(int)</signal> - <receiver>eqTransparencyLabel</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>252</x> - <y>84</y> - </hint> - <hint type="destinationlabel"> - <x>274</x> - <y>84</y> - </hint> - </hints> - </connection> - <connection> - <sender>plTransparencySlider</sender> - <signal>valueChanged(int)</signal> - <receiver>plTransparencyLabel</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>252</x> - <y>78</y> - </hint> - <hint type="destinationlabel"> - <x>274</x> - <y>78</y> - </hint> - </hints> - </connection> - <connection> - <sender>useCoverFilesCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>coverIncludeLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>286</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>useCoverFilesCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>coverExcludeLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>286</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>useCoverFilesCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>coverDepthSpinBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>286</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>651</x> - <y>458</y> - </hint> - <hint type="destinationlabel"> - <x>225</x> - <y>421</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ConfigDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>651</x> - <y>458</y> - </hint> - <hint type="destinationlabel"> - <x>141</x> - <y>414</y> - </hint> - </hints> - </connection> - <connection> - <sender>numbersCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>alignCheckBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>278</x> - <y>208</y> - </hint> - <hint type="destinationlabel"> - <x>271</x> - <y>236</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/jumptotrackdialog.ui b/src/ui/forms/jumptotrackdialog.ui deleted file mode 100644 index 7f94a2845..000000000 --- a/src/ui/forms/jumptotrackdialog.ui +++ /dev/null @@ -1,152 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>JumpToTrackDialog</class> - <widget class="QDialog" name="JumpToTrackDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>487</width> - <height>315</height> - </rect> - </property> - <property name="windowTitle"> - <string>Jump To Track</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Filter</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="filterLineEdit"/> - </item> - </layout> - </item> - <item> - <widget class="QListView" name="songsListView"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="queuePushButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Queue</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="refreshPushButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Refresh</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="jumpToPushButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Jump To</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>JumpToTrackDialog</receiver> - <slot>hide()</slot> - <hints> - <hint type="sourcelabel"> - <x>457</x> - <y>294</y> - </hint> - <hint type="destinationlabel"> - <x>481</x> - <y>279</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/playlistbrowser.ui b/src/ui/forms/playlistbrowser.ui deleted file mode 100644 index 0f9280905..000000000 --- a/src/ui/forms/playlistbrowser.ui +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PlayListBrowser</class> - <widget class="QDialog" name="PlayListBrowser"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>402</width> - <height>298</height> - </rect> - </property> - <property name="windowTitle"> - <string>Playlist Browser</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <item row="0" column="0" colspan="5"> - <widget class="QListWidget" name="listWidget"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="newButton"> - <property name="text"> - <string>New</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="deleteButton"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item row="1" column="4"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QToolButton" name="downButton"> - <property name="text"> - <string>...</string> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QToolButton" name="upButton"> - <property name="text"> - <string>...</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>PlayListBrowser</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>PlayListBrowser</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/popupsettings.ui b/src/ui/forms/popupsettings.ui deleted file mode 100644 index c59db2b72..000000000 --- a/src/ui/forms/popupsettings.ui +++ /dev/null @@ -1,251 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PopupSettings</class> - <widget class="QDialog" name="PopupSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>277</width> - <height>335</height> - </rect> - </property> - <property name="windowTitle"> - <string>Popup Information Settings</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item row="0" column="0" colspan="5"> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Template</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0" colspan="3"> - <widget class="QPlainTextEdit" name="textEdit"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="1" column="0"> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>138</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="resetButton"> - <property name="text"> - <string>Reset</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="insertButton"> - <property name="text"> - <string>Insert</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="5"> - <widget class="QCheckBox" name="coverCheckBox"> - <property name="text"> - <string>Show cover</string> - </property> - </widget> - </item> - <item row="2" column="4"> - <widget class="QLabel" name="coverSizeLabel"> - <property name="text"> - <string notr="true">0</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Cover size:</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QSlider" name="coverSizeSlider"> - <property name="minimum"> - <number>32</number> - </property> - <property name="maximum"> - <number>128</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - <property name="pageStep"> - <number>16</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="3" column="0" colspan="3"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Transparency:</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QSlider" name="transparencySlider"> - <property name="maximum"> - <number>90</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="3" column="4"> - <widget class="QLabel" name="trasparencyLabel"> - <property name="minimumSize"> - <size> - <width>18</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string notr="true">0</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="3"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Delay:</string> - </property> - </widget> - </item> - <item row="5" column="3"> - <widget class="QSpinBox" name="delaySpinBox"> - <property name="minimum"> - <number>20</number> - </property> - <property name="maximum"> - <number>7000</number> - </property> - <property name="singleStep"> - <number>500</number> - </property> - </widget> - </item> - <item row="6" column="0" colspan="5"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="5" column="4"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>ms</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>PopupSettings</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>281</x> - <y>286</y> - </hint> - <hint type="destinationlabel"> - <x>62</x> - <y>299</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>PopupSettings</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>281</x> - <y>286</y> - </hint> - <hint type="destinationlabel"> - <x>95</x> - <y>299</y> - </hint> - </hints> - </connection> - <connection> - <sender>transparencySlider</sender> - <signal>valueChanged(int)</signal> - <receiver>trasparencyLabel</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>251</y> - </hint> - <hint type="destinationlabel"> - <x>282</x> - <y>251</y> - </hint> - </hints> - </connection> - <connection> - <sender>coverSizeSlider</sender> - <signal>valueChanged(int)</signal> - <receiver>coverSizeLabel</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>223</y> - </hint> - <hint type="destinationlabel"> - <x>282</x> - <y>223</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/preseteditor.ui b/src/ui/forms/preseteditor.ui deleted file mode 100644 index 224a41ed3..000000000 --- a/src/ui/forms/preseteditor.ui +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PresetEditor</class> - <widget class="QDialog" name="PresetEditor"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>330</width> - <height>275</height> - </rect> - </property> - <property name="windowTitle"> - <string>Preset Editor</string> - </property> - <property name="modal"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item row="0" column="0" colspan="3"> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Preset</string> - </attribute> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="QListWidget" name="presetListWidget"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab_2"> - <attribute name="title"> - <string>Auto-preset</string> - </attribute> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="QListWidget" name="autoPresetListWidget"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="1" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="loadButton"> - <property name="text"> - <string>Load</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteButton"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>clicked(QAbstractButton*)</signal> - <receiver>PresetEditor</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>269</x> - <y>235</y> - </hint> - <hint type="destinationlabel"> - <x>298</x> - <y>192</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/forms/shortcutdialog.ui b/src/ui/forms/shortcutdialog.ui deleted file mode 100644 index db1cf466e..000000000 --- a/src/ui/forms/shortcutdialog.ui +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ShortcutDialog</class> - <widget class="QDialog" name="HotkeyDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>310</width> - <height>89</height> - </rect> - </property> - <property name="windowTitle"> - <string>Change Shortcut</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item row="0" column="0" colspan="3"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Press the key combination you want to assign</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="3"> - <widget class="QLineEdit" name="keyLineEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QPushButton" name="clearButton"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>106</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>HotkeyDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>212</x> - <y>70</y> - </hint> - <hint type="destinationlabel"> - <x>192</x> - <y>269</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>HotkeyDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>212</x> - <y>70</y> - </hint> - <hint type="destinationlabel"> - <x>246</x> - <y>214</y> - </hint> - </hints> - </connection> - <connection> - <sender>clearButton</sender> - <signal>clicked()</signal> - <receiver>keyLineEdit</receiver> - <slot>clear()</slot> - <hints> - <hint type="sourcelabel"> - <x>195</x> - <y>22</y> - </hint> - <hint type="destinationlabel"> - <x>113</x> - <y>25</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/ui/inlines.h b/src/ui/inlines.h deleted file mode 100644 index 39b81bd57..000000000 --- a/src/ui/inlines.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com> -// -// Use, modification and distribution is allowed without limitation, -// warranty, or liability of any kind. -// - -#ifndef INLINES_H -#define INLINES_H - -#include "fft.h" - -// *fast* convenience functions -static inline void calc_freq(short* dest, short *src) -{ - static fft_state *state = NULL; - float tmp_out[257]; - int i; - - if (!state) - state = fft_init(); - - fft_perform(src, tmp_out, state); - - for (i = 0; i < 256; i++) - dest[i] = ((int) sqrt(tmp_out[i + 1])) >> 8; -} - -static inline void stereo16_from_multichannel(register short *l, - register short *r, - register short *s, - long cnt, int chan) -{ - while (cnt > 0) - { - l[0] = s[0]; - r[0] = s[1]; - s += chan; - l++; - r++; - cnt--; - } -} - -static inline void mono16_from_multichannel(register short *l, - register short *s, - long cnt, int chan) -{ - while (cnt > 0) - { - l[0] = s[0]; - s += chan; - l++; - cnt--; - } -} - -#endif // INLINES_H diff --git a/src/ui/jumptotrackdialog.cpp b/src/ui/jumptotrackdialog.cpp deleted file mode 100644 index d9df0bb75..000000000 --- a/src/ui/jumptotrackdialog.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 "jumptotrackdialog.h" -#include <qmmpui/playlistmanager.h> -#include <QAction> -#include <QStringListModel> -#include <QSortFilterProxyModel> -#include <QShortcut> -#include <QKeySequence> - -JumpToTrackDialog::JumpToTrackDialog(PlayListManager *manager, QWidget* parent) - : QDialog (parent) -{ - setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - m_pl_manager = manager; - m_listModel = new QStringListModel(this); - - m_proxyModel = new QSortFilterProxyModel; - m_proxyModel->setDynamicSortFilter(true); - m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - m_proxyModel->setSourceModel(m_listModel); - songsListView->setModel(m_proxyModel); - - connect(songsListView,SIGNAL(doubleClicked(const QModelIndex &)), - this,SLOT(jumpTo(const QModelIndex&))); - connect(songsListView,SIGNAL(activated(const QModelIndex &)), - this,SLOT(jumpTo(const QModelIndex&))); - connect(songsListView,SIGNAL(activated(const QModelIndex &)), - this,SLOT(accept())); - connect(songsListView->selectionModel(), - SIGNAL(currentRowChanged(const QModelIndex&,const QModelIndex&)), - this,SLOT(queueUnqueue(const QModelIndex&,const QModelIndex&))); - - new QShortcut(tr("Q"),this,SLOT(on_queuePushButton_clicked())); - new QShortcut(tr("J"),this,SLOT(on_jumpToPushButton_clicked())); - new QShortcut(tr("F5"),this,SLOT(on_refreshPushButton_clicked())); - - QAction *selectSongViewAction = new QAction(filterLineEdit); - selectSongViewAction->setShortcut(Qt::Key_Down); - selectSongViewAction->setShortcutContext(Qt::WidgetShortcut); - filterLineEdit->addAction(selectSongViewAction); - connect(selectSongViewAction, SIGNAL(triggered()),songsListView, SLOT(setFocus())); - //setup icons - refreshPushButton->setIcon(QIcon::fromTheme("view-refresh")); - jumpToPushButton->setIcon(QIcon::fromTheme("go-top")); -} - -JumpToTrackDialog::~JumpToTrackDialog() -{ -} - -void JumpToTrackDialog::on_refreshPushButton_clicked() -{ - refresh(); -} - -void JumpToTrackDialog::on_queuePushButton_clicked() -{ - QModelIndexList mi_list = songsListView->selectionModel()->selectedRows(); - if (!mi_list.isEmpty()) - { - int selected = (m_proxyModel->mapToSource(mi_list.at(0))).row(); - m_pl_manager->selectedPlayList()->setQueued(m_pl_manager->selectedPlayList()->item(selected)); - if (m_pl_manager->selectedPlayList()->isQueued(m_pl_manager->selectedPlayList()->item(selected))) - queuePushButton->setText(tr("Unqueue")); - else - queuePushButton->setText(tr("Queue")); - } -} - -void JumpToTrackDialog::on_jumpToPushButton_clicked() -{ - QModelIndexList mi_list = songsListView->selectionModel()->selectedRows(); - if (!mi_list.isEmpty()) - { - jumpTo(mi_list.at(0)); - } -} - -void JumpToTrackDialog::refresh() -{ - filterLineEdit->clear(); - QStringList titles = m_pl_manager->selectedPlayList()->getTitles(0, m_pl_manager->selectedPlayList()->count()); - m_listModel->setStringList(titles); - filterLineEdit->setFocus(); -} - -void JumpToTrackDialog::on_filterLineEdit_textChanged(const QString &str) -{ - m_proxyModel->setFilterFixedString(str); - if (m_proxyModel->hasIndex(0,0)) - songsListView->setCurrentIndex (m_proxyModel->index (0,0)); -} - -void JumpToTrackDialog::on_filterLineEdit_returnPressed () -{ - QModelIndexList mi_list = songsListView->selectionModel()->selectedRows(); - if (!mi_list.isEmpty()) - { - jumpTo(mi_list.at(0)); - accept(); - } -} - -void JumpToTrackDialog::jumpTo(const QModelIndex & index) -{ - int selected = (m_proxyModel->mapToSource(index)).row(); - m_pl_manager->selectedPlayList()->setCurrent(selected); - emit playRequest(); -} - -void JumpToTrackDialog::queueUnqueue(const QModelIndex& curr,const QModelIndex&) -{ - int row = m_proxyModel->mapToSource(curr).row(); - if (m_pl_manager->selectedPlayList()->isQueued(m_pl_manager->selectedPlayList()->item(row))) - queuePushButton->setText(tr("Unqueue")); - else - queuePushButton->setText(tr("Queue")); -} diff --git a/src/ui/jumptotrackdialog.h b/src/ui/jumptotrackdialog.h deleted file mode 100644 index 36186d72c..000000000 --- a/src/ui/jumptotrackdialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 JUMPTOTRACKDIALOG_H -#define JUMPTOTRACKDIALOG_H - -#include <QDialog> -#include "ui_jumptotrackdialog.h" - -class QStringListModel; -class QSortFilterProxyModel; -class PlayListManager; - -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> - */ -class JumpToTrackDialog : public QDialog, private Ui::JumpToTrackDialog -{ - Q_OBJECT - -public: - JumpToTrackDialog(PlayListManager *manager, QWidget* parent = 0); - ~JumpToTrackDialog(); - void refresh(); - -protected slots: - void on_refreshPushButton_clicked(); - void on_queuePushButton_clicked(); - void on_jumpToPushButton_clicked(); - void on_filterLineEdit_textChanged(const QString&); - void on_filterLineEdit_returnPressed (); - void jumpTo(const QModelIndex&); - void queueUnqueue(const QModelIndex&,const QModelIndex&); - -signals: - void playRequest(); - -private: - QStringListModel* m_listModel; - QSortFilterProxyModel* m_proxyModel; - PlayListManager *m_pl_manager; -}; - -#endif - diff --git a/src/ui/keyboardmanager.cpp b/src/ui/keyboardmanager.cpp deleted file mode 100644 index cbdc70c33..000000000 --- a/src/ui/keyboardmanager.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QKeyEvent> -#include <qmmpui/playlistmodel.h> -#include "playlist.h" -#include "listwidget.h" -#include "keyboardmanager.h" -#include "mainwindow.h" - - -KeyboardManager::KeyboardManager (PlayList* pl) -{ - m_playlist = pl; -} - -bool KeyboardManager::handleKeyPress (QKeyEvent* ke) -{ - bool handled = true; - switch (ke->key()) - { - case Qt::Key_Up: - keyUp (ke); - break; - case Qt::Key_Down: - keyDown (ke); - break; - case Qt::Key_PageUp: - keyPgUp (ke); - break; - case Qt::Key_PageDown: - keyPgDown (ke); - break; - case Qt::Key_Enter: - case Qt::Key_Return: - keyEnter (ke); - break; - case Qt::Key_Home: - keyHome(ke); - break; - case Qt::Key_End: - keyEnd(ke); - break; - default: - handled = false; - } - return handled; -} - -bool KeyboardManager::handleKeyRelease (QKeyEvent*) -{ - return false; -} - -void KeyboardManager::keyUp (QKeyEvent * ke) -{ - QList<int> rows = m_playlist->listWidget()->model()->getSelectedRows(); - ListWidget* list_widget = m_playlist->listWidget(); - - if (rows.count() > 0) - { - if(rows[0] == 0 && rows.count() == 1) - return; - - if (! (ke->modifiers() & Qt::ShiftModifier || ke->modifiers() & Qt::AltModifier)) - { - m_playlist->listWidget()->model()->clearSelection(); - list_widget->setAnchorRow(-1); - } - - bool select_top = false; - int first_visible = list_widget->firstVisibleRow(); - int last_visible = list_widget->visibleRows() + first_visible - 1; - foreach (int i, rows) - { - if (i > last_visible || i < first_visible) - { - select_top = true; - break; - } - } - - if (!select_top || ke->modifiers() & Qt::ShiftModifier || ke->modifiers() & Qt::AltModifier) - { - if (ke->modifiers() == Qt::AltModifier) - { - m_playlist->listWidget()->model()->moveItems (rows[0],rows[0] - 1); - list_widget->setAnchorRow (list_widget->getAnchorRow() - 1); - } - else - { - if (rows.last() > list_widget->getAnchorRow() && ke->modifiers() & Qt::ShiftModifier) - { - m_playlist->listWidget()->model()->setSelected (rows.last(),false); - } - else if (rows[0] > 0) - { - m_playlist->listWidget()->model()->setSelected (rows[0] - 1,true); - } - else - { - m_playlist->listWidget()->model()->setSelected (rows[0],true); - if(list_widget->getAnchorRow() == -1) - list_widget->setAnchorRow(rows[0]); - } - - if (! (ke->modifiers() & Qt::ShiftModifier) && rows[0] > 0) - list_widget->setAnchorRow (rows[0] - 1); - } - } - else - { - m_playlist->listWidget()->model()->setSelected (list_widget->firstVisibleRow(),true); - list_widget->setAnchorRow(list_widget->firstVisibleRow()); - } - - rows = m_playlist->listWidget()->model()->getSelectedRows(); - - if (rows[0] < list_widget->firstVisibleRow() && list_widget->firstVisibleRow() > 0) - { - int r = rows.last() > list_widget->getAnchorRow() ? rows.last(): rows.first(); - if(ke->modifiers() & Qt::ShiftModifier && (r >= list_widget->firstVisibleRow())) - ; - else - list_widget->scroll (list_widget->firstVisibleRow() - 1); - } - } - else - { - //if(list_widget->getAnchorRow() == -1) - list_widget->setAnchorRow(list_widget->firstVisibleRow()); - m_playlist->listWidget()->model()->setSelected (list_widget->firstVisibleRow(),true); - } -} - -void KeyboardManager::keyDown (QKeyEvent * ke) -{ - QList<int> rows = m_playlist->listWidget()->model()->getSelectedRows(); - ListWidget* list_widget = m_playlist->listWidget(); - //qWarning("count: %d",rows.count()); - if (rows.count() > 0) - { - if (! (ke->modifiers() & Qt::ShiftModifier || ke->modifiers() & Qt::AltModifier)) - { - m_playlist->listWidget()->model()->clearSelection(); - list_widget->setAnchorRow(-1); - } - - bool select_top = false; - int first_visible = list_widget->firstVisibleRow(); - int last_visible = list_widget->visibleRows() + first_visible - 1; - foreach (int i, rows) - { - if (i > last_visible || i < first_visible) - { - select_top = true; - break; - } - } - - if (!select_top || ke->modifiers() & Qt::ShiftModifier || ke->modifiers() & Qt::AltModifier) - { - if (ke->modifiers() == Qt::AltModifier) - { - m_playlist->listWidget()->model()->moveItems (rows.last(),rows.last() + 1); - list_widget->setAnchorRow (list_widget->getAnchorRow() + 1); - } - else - { - //qWarning("list_widget %d",list_widget->getAnchorRow()); - //qWarning("model count: %d rows.last(): %d",m_playlist->listWidget()->model()->count(),rows.last()); - if (rows[0] < list_widget->getAnchorRow() && ke->modifiers() & Qt::ShiftModifier) - m_playlist->listWidget()->model()->setSelected (rows[0],false); - else if (rows.last() < m_playlist->listWidget()->model()->count() - 1) - { - m_playlist->listWidget()->model()->setSelected (rows.last() + 1,true); - } - else - { - m_playlist->listWidget()->model()->setSelected (rows.last(),true); - if(list_widget->getAnchorRow() == -1) - list_widget->setAnchorRow(rows.last()); - } - - if (! (ke->modifiers() & Qt::ShiftModifier) && rows.last() < m_playlist->listWidget()->model()->count() - 1) - list_widget->setAnchorRow (rows.last() + 1); - } - } - else - { - m_playlist->listWidget()->model()->setSelected (list_widget->firstVisibleRow(),true); - list_widget->setAnchorRow(list_widget->firstVisibleRow()); - } - - rows = m_playlist->listWidget()->model()->getSelectedRows(); - - if (!rows.isEmpty() && rows.last() >= list_widget->visibleRows() + list_widget->firstVisibleRow()) - { - int r = rows.first() < list_widget->getAnchorRow() ? rows.first(): rows.last(); - if(ke->modifiers() & Qt::ShiftModifier && - (r < list_widget->firstVisibleRow() + list_widget->visibleRows())) - ; - else - list_widget->scroll (list_widget->firstVisibleRow() + 1); - } - } - else - { - m_playlist->listWidget()->model()->setSelected (list_widget->firstVisibleRow(),true); - //if(list_widget->getAnchorRow() == -1) - list_widget->setAnchorRow(list_widget->firstVisibleRow()); - } -} - -void KeyboardManager::keyPgUp (QKeyEvent *) -{ - ListWidget* list_widget = m_playlist->listWidget(); - int page_size = list_widget->visibleRows(); - int offset= (list_widget->firstVisibleRow()-page_size >= 0) ?list_widget->firstVisibleRow()-page_size:0; - list_widget->scroll (offset); -} - -void KeyboardManager::keyPgDown (QKeyEvent *) -{ - ListWidget* list_widget = m_playlist->listWidget(); - int page_size = list_widget->visibleRows(); - int offset = (list_widget->firstVisibleRow() +page_size < m_playlist->listWidget()->model()->count()) ? - list_widget->firstVisibleRow() +page_size:m_playlist->listWidget()->model()->count() - 1; - list_widget->scroll (offset); -} - -void KeyboardManager::keyEnter (QKeyEvent *) -{ - QList<int> rows = m_playlist->listWidget()->model()->getSelectedRows(); - MainWindow* mw = qobject_cast<MainWindow*> (m_playlist->parentWidget()); - if (mw && rows.count() > 0) - { - m_playlist->listWidget()->model()->setCurrent (rows[0]); - mw->replay(); - } -} - -void KeyboardManager::keyHome(QKeyEvent *ke) -{ - ListWidget* list_widget = m_playlist->listWidget(); - m_playlist->listWidget()->scroll (0); - if(ke->modifiers() & Qt::ShiftModifier) - for(int i = 0; i <= list_widget->getAnchorRow(); ++i) - m_playlist->listWidget()->model()->setSelected (i,true); -} - -void KeyboardManager::keyEnd(QKeyEvent *ke) -{ - ListWidget* list_widget = m_playlist->listWidget(); - int page_size = list_widget->visibleRows(); - int scroll_to = m_playlist->listWidget()->model()->count() - page_size; - if(scroll_to >= 0) - list_widget->scroll(scroll_to); - if(ke->modifiers() & Qt::ShiftModifier) - for(int i = list_widget->getAnchorRow(); i < m_playlist->listWidget()->model()->count(); ++i) - m_playlist->listWidget()->model()->setSelected (i,true); -} diff --git a/src/ui/keyboardmanager.h b/src/ui/keyboardmanager.h deleted file mode 100644 index 120dbe9dc..000000000 --- a/src/ui/keyboardmanager.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 _KEYBOARDMANAGER_H -#define _KEYBOARDMANAGER_H - -class PlayList; -class QKeyEvent; - - -/*! - * Class \b KeyboardManager represents key handler object that processes - * all key events passed to the \b PlayList - * @author Vladimir Kuznetsov <vovanec@gmail.com> - */ -class KeyboardManager -{ - public: - /*! - * Constructor. Takes \b PlayList object as an argument. - */ - KeyboardManager (PlayList*); - - /*! - * Handles key press events from \b PlayList object. Returns \b true - * if the key was handled, otherwise \b false. - */ - bool handleKeyPress (QKeyEvent*); - - /*! - * Handles key release events from \b PlayList object. Returns \b true - * if the key was handled, otherwise \b false. - */ - bool handleKeyRelease (QKeyEvent*); - - protected: - void keyUp (QKeyEvent* ke); - void keyDown (QKeyEvent* ke); - void keyPgUp (QKeyEvent* ke); - void keyPgDown (QKeyEvent* ke); - void keyEnter (QKeyEvent* ke); - void keyHome(QKeyEvent* ke); - void keyEnd(QKeyEvent* ke); - private: - PlayList* m_playlist; -}; - -#endif - diff --git a/src/ui/listwidget.cpp b/src/ui/listwidget.cpp deleted file mode 100644 index fe261c24a..000000000 --- a/src/ui/listwidget.cpp +++ /dev/null @@ -1,569 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QPixmap> -#include <QResizeEvent> -#include <QPainter> -#include <QFont> -#include <QFontMetrics> -#include <QSettings> -#include <QMenu> -#include <QUrl> -#include <QApplication> -#include <QHelpEvent> -#include <QTimer> -#include <qmmpui/playlistitem.h> -#include <qmmpui/playlistmodel.h> -#include <qmmpui/mediaplayer.h> -#include "listwidget.h" -#include "skin.h" -#include "popupwidget.h" -#include "playlist.h" - -#define INVALID_ROW -1 - -ListWidget::ListWidget(QWidget *parent) - : QWidget(parent) -{ - m_update = false; - m_skin = Skin::instance(); - m_popupWidget = 0; - m_metrics = 0; - m_extra_metrics = 0; - loadColors(); - m_menu = new QMenu(this); - m_scroll_direction = NONE; - m_prev_y = 0; - m_anchor_row = INVALID_ROW; - m_player = MediaPlayer::instance(); - connect (m_player, SIGNAL(repeatableChanged(bool)), SLOT(updateList())); - m_first = 0; - m_rows = 0; - m_scroll = false; - m_select_on_release = false; - readSettings(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setAcceptDrops(true); - setMouseTracking(true); - m_timer = new QTimer(this); - m_timer->setInterval(50); - connect(m_timer, SIGNAL(timeout()), SLOT(autoscroll())); -} - - -ListWidget::~ListWidget() -{ - if(m_metrics) - delete m_metrics; - if(m_extra_metrics) - delete m_extra_metrics; -} - -void ListWidget::readSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_font.fromString(settings.value("PlayList/Font", QApplication::font().toString()).toString()); - m_extra_font = m_font; - m_extra_font.setPointSize(m_font.pointSize() - 1); - m_show_protocol = settings.value ("PlayList/show_protocol", false).toBool(); - m_show_number = settings.value ("PlayList/show_numbers", true).toBool(); - m_align_numbres = settings.value ("PlayList/align_numbers", false).toBool(); - m_show_anchor = settings.value("PlayList/show_anchor", false).toBool(); - bool show_popup = settings.value("PlayList/show_popup", false).toBool(); - - if (m_update) - { - delete m_metrics; - delete m_extra_metrics; - m_metrics = new QFontMetrics(m_font); - m_extra_metrics = new QFontMetrics(m_extra_font); - m_rows = height() / (m_metrics->lineSpacing() + 2); - updateList(); - if(m_popupWidget) - { - m_popupWidget->deleteLater(); - m_popupWidget = 0; - } - } - else - { - m_update = true; - m_metrics = new QFontMetrics(m_font); - m_extra_metrics = new QFontMetrics(m_extra_font); - } - if(show_popup) - m_popupWidget = new PlayListPopup::PopupWidget(this); -} - -void ListWidget::loadColors() -{ - m_normal.setNamedColor(m_skin->getPLValue("normal")); - m_current.setNamedColor(m_skin->getPLValue("current")); - m_normal_bg.setNamedColor(m_skin->getPLValue("normalbg")); - m_selected_bg.setNamedColor(m_skin->getPLValue("selectedbg")); -} - -void ListWidget::paintEvent(QPaintEvent *) -{ - QPainter m_painter(this); - m_painter.setFont(m_font); - m_painter.setBrush(QBrush(m_normal_bg)); - m_painter.drawRect(-1,-1,width()+1,height()+1); - int font_y = 0; - - for (int i = 0; i < m_titles.size(); ++i ) - { - if (m_show_anchor && i == m_anchor_row - m_first) - { - m_painter.setBrush(m_model->isSelected(i + m_first) ? m_selected_bg : m_normal_bg); - m_painter.setPen(m_normal); - m_painter.drawRect (6, i * (m_metrics->lineSpacing() + 2), - width() - 10, m_metrics->lineSpacing() + 1); - } - else - { - if (m_model->isSelected(i + m_first)) - { - m_painter.setBrush(QBrush(m_selected_bg)); - m_painter.setPen(m_selected_bg); - m_painter.drawRect (6, i * (m_metrics->lineSpacing() + 2), - width() - 10, m_metrics->lineSpacing() + 1); - } - } - - if (m_model->currentRow() == i + m_first) - m_painter.setPen(m_current); - else - m_painter.setPen(m_normal); //243,58 - - font_y = (i + 1) * (2 + m_metrics->lineSpacing()) - 2 - m_metrics->descent(); - - - - if(m_number_width) - { - QString number = QString("%1").arg(m_first+i+1); - m_painter.drawText(10 + m_number_width - m_extra_metrics->width(number), - font_y, number); - m_painter.drawText(10 + m_number_width + m_metrics->width("9"), font_y, m_titles.at(i)); - } - else - m_painter.drawText(10, font_y, m_titles.at(i)); - - - QString extra_string = getExtraString(m_first + i); - if(!extra_string.isEmpty()) - { - m_painter.setFont(m_extra_font); - - if(m_times.at(i).isEmpty()) - m_painter.drawText(width() - 7 - m_extra_metrics->width(extra_string), - font_y, extra_string); - else - m_painter.drawText(width() - 10 - m_extra_metrics->width(extra_string) - - m_metrics->width(m_times.at(i)), font_y, extra_string); - m_painter.setFont(m_font); - } - m_painter.drawText(width() - 7 - m_metrics->width(m_times.at(i)), font_y, m_times.at(i)); - } - //draw line - if(m_number_width) - { - m_painter.setPen(m_normal); - m_painter.drawLine(10 + m_number_width + m_metrics->width("9") / 2, 2, - 10 + m_number_width + m_metrics->width("9") / 2, font_y); - } -} - -void ListWidget::mouseDoubleClickEvent (QMouseEvent *e) -{ - int y = e->y(); - int row = rowAt(y); - if (INVALID_ROW != row) - { - m_model->setCurrent(row); - emit selectionChanged(); - update(); - } -} - - -void ListWidget::mousePressEvent(QMouseEvent *e) -{ - if(m_popupWidget) - m_popupWidget->hide(); - m_scroll = true; - int y = e->y(); - int row = rowAt(y); - - if (INVALID_ROW != row && m_model->count() > row) - { - m_pressed_row = row; - if(e->button() == Qt::RightButton && !m_model->isSelected(row)) - { - m_model->clearSelection(); - m_model->setSelected(row, true); - m_anchor_row = m_pressed_row; - QWidget::mousePressEvent(e); - return; - } - - if (m_model->isSelected(row) && (e->modifiers() == Qt::NoModifier)) - { - m_select_on_release = true; - QWidget::mousePressEvent(e); - return; - } - - if ((Qt::ShiftModifier & e->modifiers())) - { - bool select = true; - if (m_pressed_row > m_anchor_row) - { - for (int j = m_anchor_row;j <= m_pressed_row;j++) - { - m_model->setSelected(j, select); - } - } - else - { - for (int j = m_anchor_row;j >= m_pressed_row;j--) - { - m_model->setSelected(j, select); - } - } - m_anchor_row = m_pressed_row; - } - else //ShiftModifier released - { - if ((Qt::ControlModifier & e->modifiers())) - { - m_model->setSelected(row, !m_model->isSelected(row)); - } - else //ControlModifier released - { - m_model->clearSelection(); - m_model->setSelected(row, true); - } - m_anchor_row = m_pressed_row; - } - update(); - } - QWidget::mousePressEvent(e); -} - -void ListWidget::resizeEvent(QResizeEvent *e) -{ - m_rows = e->size().height() / (m_metrics->lineSpacing() + 2); - m_scroll = true; - updateList(); - QWidget::resizeEvent(e); -} - -void ListWidget::wheelEvent (QWheelEvent *e) -{ - if (m_model->count() <= m_rows) - return; - if ((m_first == 0 && e->delta() > 0) || - ((m_first == m_model->count() - m_rows) && e->delta() < 0)) - return; - m_first -= e->delta()/40; //40*3 TODO: add step to config - if (m_first < 0) - m_first = 0; - - if (m_first > m_model->count() - m_rows) - m_first = m_model->count() - m_rows; - - m_scroll = false; - updateList(); -} - -bool ListWidget::event (QEvent *e) -{ - if(m_popupWidget) - { - if(e->type() == QEvent::ToolTip) - { - QHelpEvent *helpEvent = (QHelpEvent *) e; - int row = rowAt(helpEvent->y()); - if(row < 0) - { - m_popupWidget->deactivate(); - return QWidget::event(e); - } - e->accept(); - m_popupWidget->prepare(m_model->item(row), helpEvent->globalPos()); - return true; - } - else if(e->type() == QEvent::Leave) - m_popupWidget->deactivate(); - } - return QWidget::event(e); -} - -void ListWidget::updateList() -{ - if (m_model->count() < (m_rows+m_first+1) && m_rows< m_model->count()) - { - m_first = m_model->count() - m_rows; - } - if (m_model->count() < m_rows + 1) - { - m_first = 0; - emit positionChanged(0,0); - } - else - emit positionChanged(m_first, m_model->count() - m_rows); - if (m_model->count() <= m_first) - { - m_first = 0; - emit positionChanged(0, qMax(0, m_model->count() - m_rows)); - } - - m_titles = m_model->getTitles(m_first, m_rows); - m_times = m_model->getTimes(m_first, m_rows); - m_scroll = false; - //add numbers - for (int i = 0; i < m_titles.size() && m_show_number && !m_align_numbres; ++i) - { - QString title = m_titles.at(i); - m_titles.replace(i, title.prepend(QString("%1").arg(m_first+i+1)+". ")); - - } - //song numbers width - if(m_show_number && m_align_numbres && m_model->count()) - { - m_number_width = m_metrics->width("9") * QString::number(m_model->count()).size(); - } - else - m_number_width = 0; - - //elide title - QString extra_string; - for (int i=0; i<m_titles.size(); ++i) - { - extra_string = getExtraString(m_first + i); - int extra_string_space = extra_string.isEmpty() ? 0 : m_metrics->width(extra_string); - if(m_number_width) - extra_string_space += m_number_width + m_metrics->width("9"); - m_titles.replace(i, m_metrics->elidedText (m_titles.at(i), Qt::ElideRight, - width() - m_metrics->width(m_times.at(i)) - 22 - extra_string_space)); - } - - update(); -} - -void ListWidget::autoscroll() -{ - SimpleSelection sel = m_model->getSelection(m_pressed_row); - if ((sel.m_top == 0 && m_scroll_direction == TOP && sel.count() > 1) || - (sel.m_bottom == m_model->count() - 1 && m_scroll_direction == DOWN && sel.count() > 1)) - return; - - if(m_scroll_direction == DOWN) - { - int row = m_first + m_rows; - (m_first + m_rows < m_model->count()) ? m_first ++ : m_first; - m_model->moveItems(m_pressed_row,row); - m_pressed_row = row; - } - else if(m_scroll_direction == TOP && m_first > 0) - { - m_first --; - m_model->moveItems(m_pressed_row, m_first); - m_pressed_row = m_first; - } -} - -void ListWidget::setModel(PlayListModel *selected, PlayListModel *previous) -{ - if(previous) - disconnect(previous, 0, this, 0); //disconnect previous model - qApp->processEvents(); - m_model = selected; - m_first = 0; - m_scroll = false; - recenterCurrent(); - updateList(); - connect (m_model, SIGNAL(currentChanged()), SLOT(recenterCurrent())); - connect (m_model, SIGNAL(listChanged()), SLOT(updateList())); -} - -void ListWidget::scroll(int sc) -{ - if (m_model->count() <= m_rows) - return; - m_first = sc; //*(m_model->count() - m_rows)/99; - m_scroll = true; - updateList(); -} - -void ListWidget::updateSkin() -{ - loadColors(); - update(); -} - -void ListWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("text/uri-list")) - event->acceptProposedAction(); -} - - -void ListWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasUrls()) - { - QList<QUrl> list_urls = event->mimeData()->urls(); - event->acceptProposedAction(); - QApplication::restoreOverrideCursor(); - - foreach(QUrl u,list_urls) - { - QString add_string = u.toString(QUrl::RemoveScheme); - if (!add_string.isEmpty()) - processFileInfo(QFileInfo(add_string)); - } - } -} - -void ListWidget::processFileInfo(const QFileInfo& info) -{ - m_model->add(info.absoluteFilePath()); -} - -const QString ListWidget::getExtraString(int i) -{ - QString extra_string; - - if (m_show_protocol && m_model->item(i)->url().contains("://")) - extra_string = "[" + m_model->item(i)->url().split("://").at(0) + "]"; - - if (m_model->isQueued(m_model->item(i))) - { - int index = m_model->queuedIndex(m_model->item(i)); - extra_string += "|"+QString::number(index + 1)+"|"; - } - - if(m_model->currentRow() == i && m_player->isRepeatable()) - extra_string += "|R|"; - else if(m_model->isStopAfter(m_model->item(i))) - extra_string += "|S|"; - - extra_string = extra_string.trimmed(); //remove white space - if(!extra_string.isEmpty()) - extra_string.prepend(" "); - return extra_string; -} - -void ListWidget::mouseMoveEvent(QMouseEvent *e) -{ - if(e->buttons() == Qt::LeftButton) - { - m_scroll = true; - if (m_prev_y > e->y()) - m_scroll_direction = TOP; - else if (m_prev_y < e->y()) - m_scroll_direction = DOWN; - else - m_scroll_direction = NONE; - - if(e->y() < 0 || e->y() > height()) - { - if(!m_timer->isActive()) - m_timer->start(); - return; - } - m_timer->stop(); - - int row = rowAt(e->y()); - - if (INVALID_ROW != row) - { - SimpleSelection sel = m_model->getSelection(m_pressed_row); - if(sel.count() > 1 && m_scroll_direction == TOP) - { - if(sel.m_top == 0 || sel.m_top == m_first) - return; - } - else if(sel.count() > 1 && m_scroll_direction == DOWN) - { - if(sel.m_bottom == m_model->count() - 1 || sel.m_bottom == m_first + m_rows) - return; - } - m_model->moveItems(m_pressed_row,row); - - m_prev_y = e->y(); - m_scroll = false; - m_pressed_row = row; - m_anchor_row = row; - } - } - else if(m_popupWidget) - { - int row = rowAt(e->y()); - if(row < 0 || m_popupWidget->item() != m_model->item(row)) - m_popupWidget->deactivate(); - } -} - -void ListWidget::mouseReleaseEvent(QMouseEvent *e) -{ - if (m_select_on_release) - { - m_model->clearSelection(); - m_model->setSelected(m_pressed_row,true); - m_anchor_row = m_pressed_row; - m_select_on_release = false; - } - m_pressed_row = INVALID_ROW; - m_scroll_direction = NONE; - m_timer->stop(); - m_scroll = false; - QWidget::mouseReleaseEvent(e); -} - -int ListWidget::rowAt(int y) const -{ - for (int i = 0; i < qMin(m_rows, m_model->count() - m_first); ++i) - { - if ((y >= i * (m_metrics->lineSpacing() + 2)) && (y <= (i+1) * (m_metrics->lineSpacing() + 2))) - return m_first + i; - } - return INVALID_ROW; -} - -void ListWidget::contextMenuEvent(QContextMenuEvent * event) -{ - if (menu()) - menu()->exec(event->globalPos()); -} - -void ListWidget::recenterCurrent() -{ - if (!m_scroll && m_rows) - { - if (m_first + m_rows < m_model->currentRow() + 1) - m_first = qMin(m_model->count() - m_rows, - m_model->currentRow() - m_rows/2); - else if (m_first > m_model->currentRow()) - m_first = qMax (m_model->currentRow() - m_rows/2, 0); - } -} diff --git a/src/ui/listwidget.h b/src/ui/listwidget.h deleted file mode 100644 index 7e901d34f..000000000 --- a/src/ui/listwidget.h +++ /dev/null @@ -1,165 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 LISTWIDGET_H -#define LISTWIDGET_H - -#include <QWidget> -#include <QDir> -#include <QContextMenuEvent> -#include <QPen> - -class QFont; -class QFontMetrics; -class QMenu; -class QAction; -class QTimer; -class PlayList; -class PlayListModel; -class Skin; -class PlayListItem; -class MediaPlayer; -namespace PlayListPopup{ -class PopupWidget; -} - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class ListWidget : public QWidget -{ - Q_OBJECT -public: - ListWidget(QWidget *parent = 0); - - ~ListWidget(); - - void readSettings(); - /*! - * Returns count of currently visible rows. - */ - int visibleRows()const - { - return m_rows; - } - - /*! - * Returns number of first visible row. - */ - int firstVisibleRow()const - { - return m_first; - } - - int getAnchorRow()const - { - return m_anchor_row; - } - - void setAnchorRow(int r) - { - m_anchor_row = r; - } - - QMenu *menu() - { - return m_menu; - } - - PlayListModel *model() - { - Q_ASSERT(!m_model); - return m_model; - } - - -public slots: - void updateList(); - void scroll(int); //0-99 - void recenterCurrent(); - void setModel(PlayListModel *selected, PlayListModel *previous = 0); - - -signals: - void selectionChanged(); - void positionChanged(int, int); //current position, maximum value - -protected: - void paintEvent(QPaintEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void resizeEvent(QResizeEvent *); - void wheelEvent(QWheelEvent *); - int rowAt(int)const; - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - void contextMenuEvent (QContextMenuEvent * event); - bool event (QEvent *e); - -private slots: - void updateSkin(); - void autoscroll(); - -private: - void loadColors(); - void processFileInfo(const QFileInfo&); - bool m_update; - bool m_scroll; - int m_pressed_row; - QMenu *m_menu; - PlayListModel *m_model; - /*! - * Returns string with queue number or(and) repeate flag for the item number \b i. - */ - const QString getExtraString(int i); - int m_rows, m_first; - QList <QString> m_titles; - QList <QString> m_times; - PlayList *m_pl; - QFont m_font, m_extra_font; - QFontMetrics *m_metrics; - QFontMetrics *m_extra_metrics; - Skin *m_skin; - QColor m_normal, m_current, m_normal_bg, m_selected_bg; - int m_anchor_row; - - enum ScrollDirection - { - NONE = 0,TOP,DOWN - }; - - /*! - * Scroll direction that is preforming in current moment. - */ - ScrollDirection m_scroll_direction; - int m_prev_y; - bool m_select_on_release; - bool m_show_protocol; - bool m_show_number; - bool m_show_anchor; - bool m_align_numbres; - int m_number_width; - MediaPlayer *m_player; - PlayListPopup::PopupWidget *m_popupWidget; - QTimer *m_timer; -}; - -#endif diff --git a/src/ui/mp3player.cpp b/src/ui/main.cpp index b42b52632..86df24ee8 100644 --- a/src/ui/mp3player.cpp +++ b/src/ui/main.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -29,9 +29,8 @@ #include <QLibraryInfo> #include <stdio.h> #include <stdlib.h> +#include <qmmp/qmmp.h> #include "lxdesupport.h" -#include "mainwindow.h" -#include "playlist.h" #include "qmmpstarter.h" int main(int argc, char *argv[]) diff --git a/src/ui/mainvisual.cpp b/src/ui/mainvisual.cpp deleted file mode 100644 index 222878e36..000000000 --- a/src/ui/mainvisual.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 <QTimer> -#include <QSettings> -#include <QPainter> -#include <QMenu> -#include <QActionGroup> -#include <qmmp/buffer.h> -#include <qmmp/qmmp.h> -#include <math.h> -#include <stdlib.h> -#include "skin.h" -#include "fft.h" -#include "inlines.h" -#include "mainvisual.h" - -#define VISUAL_NODE_SIZE 512 //samples -#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE) - - -MainVisual *MainVisual::m_instance = 0; - -MainVisual *MainVisual::instance() -{ - if (!m_instance) - qFatal ("MainVisual: this object is not created!"); - return m_instance; -} - -MainVisual::MainVisual (QWidget *parent) - : Visual (parent), m_vis (0), m_playing (false) -{ - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSettings())); - m_timer = new QTimer (this); - connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); - createMenu(); - readSettings(); - m_left_buffer = new short[VISUAL_BUFFER_SIZE]; - m_buffer_at = 0; - m_instance = this; -} - -MainVisual::~MainVisual() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - if (m_vis) - { - settings.setValue("Visualization/type",m_vis->name()); - delete m_vis; - m_vis = 0; - } - else - settings.setValue("Visualization/type", "None"); - settings.setValue("Visualization/rate", 1000/m_timer->interval()); - delete [] m_left_buffer; - m_instance = 0; -} - -void MainVisual::setVisual (VisualBase *newvis) -{ - m_timer->stop(); - if (m_vis) - delete m_vis; - m_vis = newvis; - if (m_vis) - m_timer->start(); - else - { - m_pixmap.fill (Qt::transparent); - update(); - } -} - -void MainVisual::clear() -{ - m_buffer_at = 0; - if (m_vis) - m_vis->clear(); - m_pixmap = m_bg; - update(); -} - -void MainVisual::add (unsigned char *data, qint64 size, int chan) -{ - if (!m_timer->isActive () || !m_vis) - return; - - if(VISUAL_BUFFER_SIZE == m_buffer_at) - { - m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - return; - } - - int frames = qMin((int)size/chan >> 1, VISUAL_BUFFER_SIZE - m_buffer_at); - - if (chan >= 2) - { - mono16_from_multichannel(m_left_buffer + m_buffer_at, (short *) data, frames, chan); - } - else - { - memcpy(m_left_buffer + m_buffer_at, (short *) data, frames << 1); - } - - m_buffer_at += frames; -} - -void MainVisual::timeout() -{ - mutex()->lock (); - - if(m_buffer_at < VISUAL_NODE_SIZE) - { - mutex()->unlock (); - return; - } - - if (m_vis) - { - m_vis->process (m_left_buffer); - m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - m_pixmap = m_bg; - QPainter p(&m_pixmap); - m_vis->draw (&p); - } - mutex()->unlock (); - update(); -} - -void MainVisual::paintEvent (QPaintEvent *) -{ - QPainter painter (this); - painter.drawPixmap (0,0, m_pixmap); -} - -void MainVisual::hideEvent (QHideEvent *) -{ - m_timer->stop(); -} - -void MainVisual::showEvent (QShowEvent *) -{ - if (m_vis) - m_timer->start(); -} - -void MainVisual::mousePressEvent (QMouseEvent *e) -{ - if (e->button() == Qt::RightButton) - m_menu->exec(e->globalPos()); - else - { - m_pixmap = m_bg; - if (!m_vis) - setVisual(new mainvisual::Analyzer); - else if (m_vis->name() == "Analyzer") - setVisual(new mainvisual::Scope); - else if (m_vis->name() == "Scope") - setVisual(0); - - QString str = "Off"; - if (m_vis) - str = m_vis->name(); - foreach(QAction *act, m_visModeGroup->actions ()) - if (str == act->data().toString()) - { - act->setChecked(true); - break; - } - } -} - -void MainVisual::drawBackGround() -{ - m_bg = QPixmap (76 * m_ratio, 16 * m_ratio); - if (m_transparentAction->isChecked()) - { - m_bg.fill (Qt::transparent); - return; - } - QPainter painter(&m_bg); - for (int x = 0; x < 76 * m_ratio; x += 2) - { - painter.setPen(m_skin->getVisColor(0)); - painter.drawLine(x + 1, 0, x + 1, 16 *m_ratio); - for (int y = 0; y < 16 *m_ratio; y += 2) - { - painter.setPen(m_skin->getVisColor(0)); - painter.drawPoint(x,y); - painter.setPen(m_skin->getVisColor(1)); - painter.drawPoint(x,y + 1); - } - } -} - -void MainVisual::updateSettings() -{ - m_ratio = m_skin->ratio(); - resize(76 * m_ratio, 16 * m_ratio); - m_pixmap = QPixmap (76 * m_ratio, 16 * m_ratio); - drawBackGround(); - m_pixmap = m_bg; - update(); - QAction *act = m_fpsGroup->checkedAction (); - if (act) - m_timer->setInterval (1000/act->data().toInt()); - else - m_timer->setInterval (40); - - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - act = m_peaksFalloffGroup->checkedAction (); - if (act) - settings.setValue("Visualization/peaks_falloff", act->data().toInt()); - else - settings.setValue("Visualization/peaks_falloff", 3); - - act = m_analyzerFalloffGroup->checkedAction (); - if (act) - settings.setValue("Visualization/analyzer_falloff", act->data().toInt()); - else - settings.setValue("Visualization/analyzer_falloff", 3); - - settings.setValue("Visualization/show_peaks", m_peaksAction->isChecked()); - - act = m_analyzerModeGroup->checkedAction(); - if (act) - settings.setValue("Visualization/analyzer_mode", act->data().toInt()); - else - settings.setValue("Visualization/analyzer_mode", 0); - - act = m_analyzerTypeGroup->checkedAction(); - if (act) - settings.setValue("Visualization/analyzer_type", act->data().toInt()); - else - settings.setValue("Visualization/analyzer_type", 1); - - settings.setValue("Visualization/transparent_bg", m_transparentAction->isChecked()); - - act = m_visModeGroup->checkedAction (); - QString visName; - if (act) - visName = act->data().toString(); - else - visName == "Off"; - - if (visName == "Analyzer") - setVisual(new mainvisual::Analyzer); - else if (visName == "Scope") - setVisual(new mainvisual::Scope); - else - setVisual(0); - -} - -void MainVisual::createMenu() -{ - m_menu = new QMenu (this); - connect(m_menu, SIGNAL(triggered (QAction *)),SLOT(updateSettings())); - QMenu *visMode = m_menu->addMenu(tr("Visualization Mode")); - m_visModeGroup = new QActionGroup(this); - m_visModeGroup->setExclusive(true); - m_visModeGroup->addAction(tr("Analyzer"))->setData("Analyzer"); - m_visModeGroup->addAction(tr("Scope"))->setData("Scope"); - m_visModeGroup->addAction(tr("Off"))->setData("None"); - foreach(QAction *act, m_visModeGroup->actions ()) - { - act->setCheckable(true); - visMode->addAction(act); - } - - QMenu *analyzerMode = m_menu->addMenu(tr("Analyzer Mode")); - m_analyzerModeGroup = new QActionGroup(this); - m_analyzerTypeGroup = new QActionGroup(this); - m_analyzerModeGroup->addAction(tr("Normal"))->setData(0); - m_analyzerModeGroup->addAction(tr("Fire"))->setData(1); - m_analyzerModeGroup->addAction(tr("Vertical Lines"))->setData(2); - m_analyzerTypeGroup->addAction(tr("Lines"))->setData(0); - m_analyzerTypeGroup->addAction(tr("Bars"))->setData(1); - foreach(QAction *act, m_analyzerModeGroup->actions ()) - { - act->setCheckable(true); - analyzerMode->addAction(act); - } - analyzerMode->addSeparator (); - foreach(QAction *act, m_analyzerTypeGroup->actions ()) - { - act->setCheckable(true); - analyzerMode->addAction(act); - } - analyzerMode->addSeparator (); - m_peaksAction = analyzerMode->addAction(tr("Peaks")); - m_peaksAction->setCheckable(true); - - - QMenu *refreshRate = m_menu->addMenu(tr("Refresh Rate")); - m_fpsGroup = new QActionGroup(this); - m_fpsGroup->setExclusive(true); - m_fpsGroup->addAction(tr("50 fps"))->setData(50); - m_fpsGroup->addAction(tr("25 fps"))->setData(25); - m_fpsGroup->addAction(tr("10 fps"))->setData(10); - m_fpsGroup->addAction(tr("5 fps"))->setData(5); - foreach(QAction *act, m_fpsGroup->actions ()) - { - act->setCheckable(true); - refreshRate->addAction(act); - } - - QMenu *analyzerFalloff = m_menu->addMenu(tr("Analyzer Falloff")); - m_analyzerFalloffGroup = new QActionGroup(this); - m_analyzerFalloffGroup->setExclusive(true); - m_analyzerFalloffGroup->addAction(tr("Slowest"))->setData(1); - m_analyzerFalloffGroup->addAction(tr("Slow"))->setData(2); - m_analyzerFalloffGroup->addAction(tr("Medium"))->setData(3); - m_analyzerFalloffGroup->addAction(tr("Fast"))->setData(4); - m_analyzerFalloffGroup->addAction(tr("Fastest"))->setData(5); - foreach(QAction *act, m_analyzerFalloffGroup->actions ()) - { - act->setCheckable(true); - analyzerFalloff->addAction(act); - } - - QMenu *peaksFalloff = m_menu->addMenu(tr("Peaks Falloff")); - m_peaksFalloffGroup = new QActionGroup(this); - m_peaksFalloffGroup->setExclusive(true); - m_peaksFalloffGroup->addAction(tr("Slowest"))->setData(1); - m_peaksFalloffGroup->addAction(tr("Slow"))->setData(2); - m_peaksFalloffGroup->addAction(tr("Medium"))->setData(3); - m_peaksFalloffGroup->addAction(tr("Fast"))->setData(4); - m_peaksFalloffGroup->addAction(tr("Fastest"))->setData(5); - foreach(QAction *act, m_peaksFalloffGroup->actions ()) - { - act->setCheckable(true); - peaksFalloff->addAction(act); - } - QMenu *background = m_menu->addMenu(tr("Background")); - m_transparentAction = background->addAction(tr("Transparent")); - m_transparentAction->setCheckable(true); - update(); -} - - -void MainVisual::readSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - - QString name = settings.value("Visualization/type","Analyzer").toString(); - m_visModeGroup->actions ()[0]->setChecked(true); - foreach(QAction *act, m_visModeGroup->actions ()) - if (name == act->data().toString()) - act->setChecked(true); - - m_peaksAction->setChecked( - settings.value("Visualization/show_peaks", true).toBool()); - - int fps = settings.value("Visualization/rate", 25).toInt(); - m_fpsGroup->actions ()[1]->setChecked(true); - foreach(QAction *act, m_fpsGroup->actions ()) - if (fps == act->data().toInt()) - act->setChecked(true); - - int mode = settings.value("Visualization/analyzer_mode", 0).toInt(); - m_analyzerModeGroup->actions ()[0]->setChecked(true); - foreach(QAction *act, m_analyzerModeGroup->actions ()) - if (mode == act->data().toInt()) - act->setChecked(true); - - int type = settings.value("Visualization/analyzer_type", 1).toInt(); - m_analyzerTypeGroup->actions ()[1]->setChecked(true); - foreach(QAction *act, m_analyzerTypeGroup->actions ()) - if (type == act->data().toInt()) - act->setChecked(true); - - int speed = settings.value("Visualization/peaks_falloff", 3).toInt(); - m_peaksFalloffGroup->actions ()[2]->setChecked(true); - foreach(QAction *act, m_peaksFalloffGroup->actions ()) - if (speed == act->data().toInt()) - act->setChecked(true); - - speed = settings.value("Visualization/analyzer_falloff", 3).toInt(); - m_analyzerFalloffGroup->actions ()[2]->setChecked(true); - foreach(QAction *act, m_analyzerFalloffGroup->actions ()) - if (speed == act->data().toInt()) - act->setChecked(true); - - m_transparentAction->setChecked( - settings.value("Visualization/transparent_bg", false).toBool()); - - updateSettings(); -} - -using namespace mainvisual; - -Analyzer::Analyzer() - : m_analyzerBarWidth (4), m_fps (20) -{ - clear(); - m_skin = Skin::instance(); - m_size = QSize(76*m_skin->ratio(), 16*m_skin->ratio()); - - double peaks_speed[] = { 0.05, 0.1, 0.2, 0.4, 0.8 }; - double analyzer_speed[] = { 1.2, 1.8, 2.2, 2.8, 2.4 }; - - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_peaks_falloff = - peaks_speed[settings.value("Visualization/peaks_falloff", 3).toInt()-1]; - m_analyzer_falloff = - analyzer_speed[settings.value("Visualization/analyzer_falloff", 3).toInt()-1]; - m_show_peaks = settings.value("Visualization/show_peaks", true).toBool(); - - m_lines = settings.value("Visualization/analyzer_type", 1).toInt() == 0; - m_mode = settings.value("Visualization/analyzer_mode", 0).toInt(); -} - -Analyzer::~Analyzer() -{} - -void Analyzer::clear() -{ - for (int i = 0; i< 75; ++i) - { - m_intern_vis_data[i] = 0; - m_peaks[i] = 0; - } -} - -bool Analyzer::process (short *l) -{ - static fft_state *state = 0; - if (!state) - state = fft_init(); - short dest[256]; - - static const int xscale_long[] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 61, 66, 71, 76, 81, 87, 93, 100, 107, - 114, 122, 131, 140, 150, 161, 172, 184, 255 - }; - - static const int xscale_short[] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 15, 20, 27, - 36, 47, 62, 82, 107, 141, 184, 255 - }; - - calc_freq (dest, l); - - const double y_scale = 3.60673760222; /* 20.0 / log(256) */ - int max = m_lines ? 75 : 19, y, j; - - for (int i = 0; i < max; i++) - { - if (m_lines) - for (j = xscale_long[i], y = 0; j < xscale_long[i + 1]; j++) - { - if (dest[j] > y) - y = dest[j]; - } - else - for (j = xscale_short[i], y = 0; j < xscale_short[i + 1]; j++) - { - if (dest[j] > y) - y = dest[j]; - } - y >>= 7; - int magnitude = 0; - if (y != 0) - { - magnitude = int(log (y) * y_scale); - if (magnitude > 15) - magnitude = 15; - if (magnitude < 0) - magnitude = 0; - } - - m_intern_vis_data[i] -= m_analyzer_falloff; - m_intern_vis_data[i] = magnitude > m_intern_vis_data[i] - ? magnitude : m_intern_vis_data[i]; - if (m_show_peaks) - { - m_peaks[i] -= m_peaks_falloff; - m_peaks[i] = magnitude > m_peaks[i] - ? magnitude : m_peaks[i]; - } - } - return true; -} - -void Analyzer::draw (QPainter *p) -{ - int r = m_skin->ratio(); - if (m_lines) - for (int j = 0; j < 75; ++j) - { - for (int i = 0; i <= m_intern_vis_data[j]; ++i) - { - if (m_mode == 0) - p->setPen (m_skin->getVisColor (18-i)); - else if (m_mode == 1) - p->setPen (m_skin->getVisColor (3+(int(m_intern_vis_data[j])-i))); - else - p->setPen (m_skin->getVisColor (18-int(m_intern_vis_data[j]))); - p->drawPoint (j*r, m_size.height() - r*i); - if(r == 2) - p->drawPoint (j*r+1, m_size.height() - r*i); - } - p->setPen (m_skin->getVisColor (23)); - if (m_show_peaks) - { - p->drawPoint (j*r, m_size.height() - r*m_peaks[j]); - if(r == 2) - p->drawPoint (j*r+1, m_size.height() - r*m_peaks[j]); - } - } - else - for (int j = 0; j < 19; ++j) - { - for (int i = 0; i <= m_intern_vis_data[j]; ++i) - { - if (m_mode == 0) - p->setPen (m_skin->getVisColor (18-i)); - else if (m_mode == 1) - p->setPen (m_skin->getVisColor (3+(int(m_intern_vis_data[j])-i))); - else - p->setPen (m_skin->getVisColor (18-int(m_intern_vis_data[j]))); - - p->drawLine (j*4*r,m_size.height()-r*i, (j*4+2)*r,m_size.height()-r*i); - if(r == 2) - p->drawLine (j*4*r, m_size.height()-r*i +1, (j*4+2)*r,m_size.height()-r*i+1); - } - p->setPen (m_skin->getVisColor (23)); - if (m_show_peaks) - { - p->drawLine (j*4*r,m_size.height()-r*m_peaks[j], - (j*4+2)*r,m_size.height()-r*m_peaks[j]); - if(r == 2) - p->drawLine (j*4*r,m_size.height()-r*m_peaks[j]+1, - (j*4+2)*r,m_size.height()-r*m_peaks[j]+1); - } - } -} - -Scope::Scope() -{ - clear(); - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); -} - -void Scope::clear() -{ - for (int i = 0; i< 76; ++i) - m_intern_vis_data[i] = 5; -} - -Scope::~Scope() -{} - -bool Scope::process(short *l) -{ - int step = (VISUAL_NODE_SIZE << 8)/76; - int pos = 0; - - for (int i = 0; i < 76; ++i) - { - pos += step; - m_intern_vis_data[i] = (l[pos >> 8] >> 12); - - if (m_intern_vis_data[i] > 4) - m_intern_vis_data[i] = 4; - else if (m_intern_vis_data[i] < -4) - m_intern_vis_data[i] = -4; - } - return true; -} - -void Scope::draw(QPainter *p) -{ - for (int i = 0; i<75; ++i) - { - int h1 = 8 - m_intern_vis_data[i]; - int h2 = 8 - m_intern_vis_data[i+1]; - if (h1 > h2) - qSwap(h1, h2); - p->setPen (m_skin->getVisColor(18 + qAbs(8 - h2))); - p->drawLine(i*m_ratio, h1*m_ratio, (i+1)*m_ratio, h2*m_ratio); - } - for (int i = 0; i< 76; ++i) - m_intern_vis_data[i] = 0; -} diff --git a/src/ui/mainvisual.h b/src/ui/mainvisual.h deleted file mode 100644 index 9807483d7..000000000 --- a/src/ui/mainvisual.h +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 MAINVISUAL_H -#define MAINVISUAL_H - -#include <QWidget> -#include <QResizeEvent> -#include <qmmp/visual.h> - -class QTimer; -class QMenu; -class QActionGroup; - -class VisualBase -{ -public: - virtual ~VisualBase(){} - virtual void clear() = 0; - virtual bool process(short *l) = 0; - virtual void draw(QPainter *) = 0; - virtual const QString name() = 0; -}; - -class Skin; - -class MainVisual : public Visual -{ - Q_OBJECT - -public: - MainVisual( QWidget *parent = 0); - virtual ~MainVisual(); - - static MainVisual *instance(); - void setVisual(VisualBase *newvis); - void add(unsigned char *data, qint64 size, int chan); - void clear(); - void paintEvent(QPaintEvent *); - -protected: - virtual void hideEvent (QHideEvent *); - virtual void showEvent (QShowEvent *); - virtual void mousePressEvent (QMouseEvent *); - -public slots: - void timeout(); - -private slots: - void updateSettings(); - -private: - void drawBackGround(); - void createMenu(); - void readSettings(); - static MainVisual *m_instance; - VisualBase *m_vis; - QPixmap m_pixmap; - QPixmap m_bg; - QTimer *m_timer; - bool m_playing; - Skin *m_skin; - //menu and actions - QMenu *m_menu; - //action groups - QActionGroup *m_visModeGroup; - QActionGroup *m_fpsGroup; - QActionGroup *m_peaksFalloffGroup; - QActionGroup *m_analyzerFalloffGroup; - QActionGroup *m_analyzerModeGroup; - QActionGroup *m_analyzerTypeGroup; - QAction *m_peaksAction; - QAction *m_transparentAction; - int m_ratio; - short *m_left_buffer; - short *m_right_buffer; - int m_buffer_at; -}; - -namespace mainvisual -{ -class Analyzer : public VisualBase -{ -public: - Analyzer(); - virtual ~Analyzer(); - - void clear(); - bool process(short *l); - void draw(QPainter *p); - const QString name() - { - return "Analyzer"; - } - -private: - QSize m_size; - int m_analyzerBarWidth, m_fps; - double m_intern_vis_data[75]; - double m_peaks[75]; - double m_peaks_falloff; - double m_analyzer_falloff; - bool m_show_peaks; - bool m_lines; - int m_mode; - Skin *m_skin; -}; - -class Scope : public VisualBase -{ -public: - Scope(); - virtual ~Scope(); - void clear(); - bool process(short *l); - void draw(QPainter *p); - const QString name() - { - return "Scope"; - } - -private: - int m_intern_vis_data[76]; - Skin *m_skin; - int m_ratio; -}; -} - -#endif diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp deleted file mode 100644 index 445133216..000000000 --- a/src/ui/mainwindow.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QtGui> -#include <QFileDialog> -#include <QDir> -#include <QAction> -#include <QMenu> -#include <math.h> -#include <qmmp/soundcore.h> -#include <qmmp/visual.h> -#include <qmmp/metadatamanager.h> -#include <qmmpui/generalhandler.h> -#include <qmmpui/general.h> -#include <qmmpui/playlistparser.h> -#include <qmmpui/playlistformat.h> -#include <qmmpui/commandlinemanager.h> -#include <qmmpui/filedialog.h> -#include <qmmpui/playlistmodel.h> -#include <qmmpui/playlistmanager.h> -#include <qmmpui/mediaplayer.h> -#include "mainwindow.h" -#include "skin.h" -#include "playlist.h" -#include "configdialog.h" -#include "dock.h" -#include "eqwidget.h" -#include "mainvisual.h" -#include "jumptotrackdialog.h" -#include "aboutdialog.h" -#include "addurldialog.h" -#include "listwidget.h" -#include "visualmenu.h" -#include "windowsystem.h" -#include "actionmanager.h" -#include "builtincommandlineoption.h" - -#define KEY_OFFSET 10000 - -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) -{ -#ifdef Q_WS_X11 - qDebug("MainWindow: detected wm: %s", qPrintable(WindowSystem::netWindowManagerName())); -#endif - m_vis = 0; - m_update = false; - setWindowIcon(QIcon(":/32x32/qmmp.png")); - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | - Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint); - setWindowTitle("Qmmp"); - - new ActionManager(); - - //prepare libqmmp and libqmmpui libraries for playing - m_player = new MediaPlayer(this); - m_core = SoundCore::instance(); - m_pl_manager = PlayListManager::instance(); - //additional featuries - new PlaylistParser(this); - m_generalHandler = new GeneralHandler(this); - - //user interface - m_skin = new Skin(this); - resize(275 * m_skin->ratio(),116 * m_skin->ratio()); - Dock *dock = new Dock(this); - dock->setMainWidget(this); - m_display = new MainDisplay(this); - setCentralWidget(m_display); - m_display->setFocus (); - - m_playlist = new PlayList(m_pl_manager, this); - dock->addWidget(m_playlist); - - m_equalizer = new EqWidget(this); - dock->addWidget(m_equalizer); - - m_jumpDialog = new JumpToTrackDialog(m_pl_manager, this); - m_jumpDialog->hide(); - - createActions(); - //prepare visualization - Visual::initialize(this, m_visMenu, SLOT(updateActions())); - m_vis = MainVisual::instance(); - Visual::add(m_vis); - //connections - connect (m_playlist,SIGNAL(next()),SLOT(next())); - connect (m_playlist,SIGNAL(prev()),SLOT(previous())); - connect (m_playlist,SIGNAL(play()),SLOT(play())); - connect (m_playlist,SIGNAL(pause()), m_core ,SLOT(pause())); - connect (m_playlist,SIGNAL(stop()),SLOT(stop())); - connect (m_playlist,SIGNAL(eject()),SLOT(addFile())); - connect (m_playlist,SIGNAL(loadPlaylist()),SLOT(loadPlaylist())); - connect (m_playlist,SIGNAL(savePlaylist()),SLOT(savePlaylist())); - - connect(m_display,SIGNAL(shuffleToggled(bool)),m_pl_manager,SLOT(setShuffle(bool))); - connect(m_display,SIGNAL(repeatableToggled(bool)),m_pl_manager,SLOT(setRepeatableList(bool))); - - connect(m_jumpDialog,SIGNAL(playRequest()), SLOT(replay())); - - connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(showState(Qmmp::State))); - connect(m_core, SIGNAL(elapsedChanged(qint64)),m_playlist, SLOT(setTime(qint64))); - connect(m_core, SIGNAL(metaDataChanged()),SLOT(showMetaData())); - connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility())); - connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close())); - - readSettings(); - m_display->setEQ(m_equalizer); - m_display->setPL(m_playlist); - dock->updateDock(); - m_pl_manager->currentPlayList()->doCurrentVisibleRequest(); - if (m_startHidden && m_generalHandler->visibilityControl()) - toggleVisibility(); -} - -MainWindow::~MainWindow() -{} - -void MainWindow::play() -{ - m_player->play(); -} - -void MainWindow::replay() -{ - stop(); - m_pl_manager->activatePlayList(m_pl_manager->selectedPlayList()); - play(); -} - -void MainWindow::forward() -{ - m_core->seek(m_core->elapsed() + KEY_OFFSET); -} - -void MainWindow::backward() -{ - m_core->seek(qMax(qint64(0), m_core->elapsed() - KEY_OFFSET)); -} - -void MainWindow::setVolume(int volume, int balance) -{ - m_core->setVolume(volume-qMax(balance,0)*volume/100, - volume+qMin(balance,0)*volume/100); -} - -void MainWindow::pause(void) -{ - m_core->pause(); -} - -void MainWindow::stop() -{ - m_player->stop(); -} - -void MainWindow::next() -{ - m_player->next(); -} - -void MainWindow::previous() -{ - m_player->previous(); -} - -void MainWindow::showState(Qmmp::State state) -{ - disconnectPl(); - switch ((int) state) - { - case Qmmp::Playing: - if (m_pl_manager->currentPlayList()->currentItem()) - m_equalizer->loadPreset(m_pl_manager->currentPlayList()->currentItem()->url().section("/",-1)); - break; - case Qmmp::Paused: - break; - case Qmmp::Stopped: - m_playlist->setTime(-1); - if (m_playlist->currentItem()) - setWindowTitle(m_playlist->currentItem()->text()); - else - setWindowTitle("Qmmp"); - break; - } -} - -void MainWindow::showMetaData() -{ - if (m_playlist->currentItem() && - m_playlist->currentItem()->url() == m_core->metaData().value(Qmmp::URL)) - { - setWindowTitle(m_playlist->currentItem()->text()); - } -} - -void MainWindow::closeEvent (QCloseEvent *) -{ - writeSettings(); - m_playlist->close(); - m_equalizer->close(); - QApplication::quit (); -} - -void MainWindow::addDir() -{ - FileDialog::popup(this, FileDialog::AddDirs, &m_lastDir, - m_pl_manager->selectedPlayList(), SLOT(add(const QStringList&)), - tr("Choose a directory")); -} - -void MainWindow::addFile() -{ - QStringList filters; - filters << tr("All Supported Bitstreams")+" (" + - MetaDataManager::instance()->nameFilters().join (" ") +")"; - filters << MetaDataManager::instance()->filters(); - FileDialog::popup(this, FileDialog::AddDirsFiles, &m_lastDir, - m_pl_manager->selectedPlayList(), SLOT(add(const QStringList&)), - tr("Select one or more files to open"), filters.join(";;")); -} - -void MainWindow::changeEvent (QEvent * event) -{ - if (event->type() == QEvent::ActivationChange) - { - m_display->setActive(isActiveWindow()); - } -} - -void MainWindow::readSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - if (!m_update) - { - settings.beginGroup("MainWindow"); - - move(settings.value("pos", QPoint(100, 100)).toPoint()); //geometry - - m_lastDir = settings.value("last_dir","/").toString(); //last directory - m_startHidden = settings.value("start_hidden", false).toBool(); - settings.endGroup(); - - if(settings.value("General/always_on_top", false).toBool()) - { - ACTION(ActionManager::WM_ALLWAYS_ON_TOP)->setChecked(true); - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - } - ACTION(ActionManager::WM_STICKY)->setChecked(settings.value("General/show_on_all_desktops", - false).toBool()); - show(); - qApp->processEvents(); - //visibility - m_playlist->setVisible(settings.value("Playlist/visible",true).toBool()); - qApp->processEvents(); - m_equalizer->setVisible(settings.value("Equalizer/visible",true).toBool()); - qApp->processEvents(); - bool val = settings.value("Playlist/repeatable",false).toBool(); - - // Repeat/Shuffle - m_pl_manager->setRepeatableList(val); - m_display->setIsRepeatable(val); - val = settings.value("Playlist/shuffle",false).toBool(); - m_display->setIsShuffle(val); - m_pl_manager->setShuffle(val); - - m_update = true; - } - else - { - if(ACTION(ActionManager::WM_ALLWAYS_ON_TOP)->isChecked()) - { - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - m_playlist->setWindowFlags(m_playlist->windowFlags() | Qt::WindowStaysOnTopHint); - m_equalizer->setWindowFlags(m_equalizer->windowFlags() | Qt::WindowStaysOnTopHint); - } - else - { - setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); - m_playlist->setWindowFlags(m_playlist->windowFlags() & ~Qt::WindowStaysOnTopHint); - m_equalizer->setWindowFlags(m_equalizer->windowFlags() & ~Qt::WindowStaysOnTopHint); - } - show(); - qApp->processEvents(); - m_playlist->setVisible(m_display->isPlaylistVisible()); - m_equalizer->setVisible(m_display->isEqualizerVisible()); - } -#ifdef Q_WS_X11 - WindowSystem::changeWinSticky(winId(), ACTION(ActionManager::WM_STICKY)->isChecked()); - WindowSystem::setWinHint(winId(), "player", "Qmmp"); -#endif - //Call setWindowOpacity only if needed - double opacity = settings.value("MainWindow/opacity", 1.0).toDouble(); - if(opacity != windowOpacity ()) - setWindowOpacity(opacity); - - opacity = settings.value("Equalizer/opacity", 1.0).toDouble(); - if(opacity != m_equalizer->windowOpacity ()) - m_equalizer->setWindowOpacity(opacity); - - opacity = settings.value("PlayList/opacity", 1.0).toDouble(); - if(opacity != m_playlist->windowOpacity ()) - m_playlist->setWindowOpacity(opacity); - - m_hideOnClose = settings.value("MainWindow/hide_on_close", false).toBool(); -} - -void MainWindow::writeSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("MainWindow"); - //geometry - settings.setValue("pos", this->pos()); - //last directory - settings.setValue("last_dir",m_lastDir); - settings.endGroup(); - // Repeat/Shuffle - settings.beginGroup("Playlist"); - settings.setValue("repeatable",m_display->isRepeatable()); - settings.setValue("shuffle",m_display->isShuffle()); - settings.endGroup(); - // playback state - settings.beginGroup("General"); - settings.setValue("resume_playback", m_core->state() == Qmmp::Playing && - settings.value("resume_on_startup", false).toBool()); - settings.setValue("resume_playback_time", m_core->totalTime() > 0 ? m_core->elapsed() : 0); - settings.setValue("double_size", ACTION(ActionManager::WM_DOUBLE_SIZE)->isChecked()); - settings.setValue("always_on_top", ACTION(ActionManager::WM_ALLWAYS_ON_TOP)->isChecked()); - settings.setValue("show_on_all_desktops", ACTION(ActionManager::WM_STICKY)->isChecked()); - settings.endGroup(); -} - -void MainWindow::showSettings() -{ - ConfigDialog *confDialog = new ConfigDialog(this); - confDialog->exec(); - updateSettings(); - confDialog->deleteLater(); - ActionManager::instance()->saveActions(); -} - -void MainWindow::toggleVisibility() -{ - if (isHidden()) - { - show(); - raise(); - activateWindow(); - m_playlist->setVisible(m_display->isPlaylistVisible()); - m_equalizer->setVisible(m_display->isEqualizerVisible()); -#ifdef Q_WS_X11 - if(WindowSystem::netWindowManagerName() == "Metacity") - { - m_playlist->activateWindow(); - m_equalizer->activateWindow(); - } -#endif - qApp->processEvents(); - setFocus (); - if (isMinimized()) - { - if (isMaximized()) - showMaximized(); - else - showNormal(); - } -#ifdef Q_WS_X11 - WindowSystem::changeWinSticky(winId(), ACTION(ActionManager::WM_STICKY)->isChecked()); - WindowSystem::setWinHint(winId(), "player", "Qmmp"); - raise(); -#endif - } - else - { - if (m_playlist->isVisible()) - m_playlist->hide(); - if (m_equalizer->isVisible()) - m_equalizer->hide(); - hide(); - } - qApp->processEvents(); -} - -void MainWindow::createActions() -{ - m_mainMenu = new QMenu(this); - m_mainMenu->addAction(SET_ACTION(ActionManager::PLAY, this, SLOT(play()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::PAUSE, this, SLOT(pause()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::STOP, this, SLOT(stop()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::PREVIOUS, this, SLOT(previous()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::NEXT, this, SLOT(next()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::PLAY_PAUSE, this, SLOT(playPause()))); - m_mainMenu->addSeparator(); - m_mainMenu->addAction(QIcon::fromTheme("go-up"), tr("&Jump To File"), - this, SLOT(jumpToFile()), tr("J")); - m_mainMenu->addSeparator(); - QMenu *viewMenu = m_mainMenu->addMenu(tr("View")); - viewMenu->addAction(ACTION(ActionManager::SHOW_PLAYLIST)); - viewMenu->addAction(ACTION(ActionManager::SHOW_EQUALIZER)); - viewMenu->addSeparator(); - viewMenu->addAction(SET_ACTION(ActionManager::WM_ALLWAYS_ON_TOP, this, SLOT(updateSettings()))); - viewMenu->addAction(SET_ACTION(ActionManager::WM_STICKY, this, SLOT(updateSettings()))); - viewMenu->addAction(SET_ACTION(ActionManager::WM_DOUBLE_SIZE, this, SLOT(updateSettings()))); - - QMenu *plMenu = m_mainMenu->addMenu(tr("Playlist")); - plMenu->addAction(SET_ACTION(ActionManager::REPEAT_ALL, m_pl_manager, SLOT(setRepeatableList(bool)))); - plMenu->addAction(SET_ACTION(ActionManager::REPEAT_TRACK, m_player, SLOT(setRepeatable(bool)))); - plMenu->addAction(SET_ACTION(ActionManager::SHUFFLE, m_pl_manager, SLOT(setShuffle(bool)))); - plMenu->addAction(SET_ACTION(ActionManager::NO_PL_ADVANCE, m_player, - SLOT(setNoPlaylistAdvance(bool)))); - plMenu->addAction(SET_ACTION(ActionManager::STOP_AFTER_SELECTED, m_pl_manager, - SLOT(stopAfterSelected()))); - plMenu->addAction(SET_ACTION(ActionManager::CLEAR_QUEUE, m_pl_manager, SLOT(clearQueue()))); - connect(m_pl_manager, SIGNAL(repeatableListChanged(bool)), - ACTION(ActionManager::REPEAT_ALL), SLOT(setChecked(bool))); - connect(m_player, SIGNAL (repeatableChanged(bool)), - ACTION(ActionManager::REPEAT_TRACK), SLOT(setChecked(bool))); - connect(m_player, SIGNAL (noPlaylistAdvanceChanged(bool)), - ACTION(ActionManager::NO_PL_ADVANCE), SLOT(setChecked(bool))); - connect(m_pl_manager, SIGNAL(shuffleChanged(bool)), - ACTION(ActionManager::SHUFFLE), SLOT(setChecked(bool))); - - m_visMenu = new VisualMenu(this); - m_mainMenu->addMenu(m_visMenu); - m_mainMenu->addMenu(m_generalHandler->createMenu(GeneralHandler::TOOLS_MENU, tr("Tools"), this)); - m_mainMenu->addSeparator(); - m_mainMenu->addAction(SET_ACTION(ActionManager::SETTINGS, this, SLOT(showSettings()))); - m_mainMenu->addSeparator(); - m_mainMenu->addAction(SET_ACTION(ActionManager::ABOUT, this, SLOT(about()))); - m_mainMenu->addAction(SET_ACTION(ActionManager::ABOUT_QT, qApp, SLOT(aboutQt()))); - m_mainMenu->addSeparator(); - m_mainMenu->addAction(SET_ACTION(ActionManager::QUIT, this, SLOT(close()))); - - QAction* forward = new QAction(this); - forward->setShortcut(QKeySequence(Qt::Key_Right)); - connect(forward,SIGNAL(triggered(bool)),this,SLOT(forward())); - QAction* backward = new QAction(this); - backward->setShortcut(QKeySequence(Qt::Key_Left)); - connect(backward,SIGNAL(triggered(bool)),this,SLOT(backward())); - - Dock::instance()->addActions(QList<QAction*>() << forward << backward); - Dock::instance()->addActions(m_mainMenu->actions()); -} - - -void MainWindow::about() -{ - AboutDialog dlg(this); - dlg.exec(); -} - -void MainWindow::updateSettings() -{ - readSettings(); - m_playlist->readSettings(); - m_visMenu->updateActions(); - m_skin->reloadSkin(); - Dock::instance()->updateDock(); -} - -QMenu* MainWindow::menu() -{ - return m_mainMenu; -} - -void MainWindow::loadPlaylist() -{ - QStringList l; - QList<PlaylistFormat*> p_list = PlaylistParser::instance()->formats(); - if (!p_list.isEmpty()) - { - foreach(PlaylistFormat* fmt,p_list) - l << fmt->getExtensions(); - - QString mask = tr("Playlist Files")+" (" + l.join(" *.").prepend("*.") + ")"; - //TODO use nonmodal dialog and multiplier playlists - QString f_name = FileDialog::getOpenFileName(this,tr("Open Playlist"),m_lastDir,mask); - if (!f_name.isEmpty()) - { - m_pl_manager->selectedPlayList()->clear(); - m_pl_manager->selectedPlayList()->loadPlaylist(f_name); - m_pl_manager->selectedPlayList()->setName(QFileInfo(f_name).baseName()); - m_lastDir = QFileInfo(f_name).absoluteDir().path(); - } - } - else - { - qWarning("Error: There is no registered playlist parsers"); - } -} - -void MainWindow::savePlaylist() -{ - QStringList l; - QList<PlaylistFormat*> p_list = PlaylistParser::instance()->formats(); - if (!p_list.isEmpty()) - { - foreach(PlaylistFormat* fmt,p_list) - l << fmt->getExtensions(); - - QString mask = tr("Playlist Files")+" (" + l.join(" *.").prepend("*.") + ")"; - QString f_name = FileDialog::getSaveFileName(this, tr("Save Playlist"),m_lastDir + "/" + - m_pl_manager->selectedPlayList()->name() + "." + l[0],mask); - - if (!f_name.isEmpty()) - { - m_pl_manager->selectedPlayList()->savePlaylist(f_name); - m_lastDir = QFileInfo(f_name).absoluteDir().path(); - } - } - else - qWarning("Error: There is no registered playlist parsers"); -} - -void MainWindow::setFileList(const QStringList &l, bool clear) -{ - m_pl_manager->activatePlayList(m_pl_manager->selectedPlayList()); - if(!clear) - { - m_pl_manager->selectedPlayList()->add(l); - return; - } - if (m_core->state() != Qmmp::Stopped) - { - stop(); - qApp->processEvents(); //receive stop signal - } - m_model = m_pl_manager->selectedPlayList(); - m_model->clear(); - connect(m_model, SIGNAL(itemAdded(PlayListItem*)), SLOT(play())); - connect(m_model, SIGNAL(loaderFinished()), SLOT(disconnectPl())); - m_model->add(l); -} - -void MainWindow::playPause() -{ - if (m_core->state() == Qmmp::Playing) - m_core->pause(); - else - play(); -} - -void MainWindow::jumpToFile() -{ - if (m_jumpDialog->isHidden()) - { - m_jumpDialog->show(); - m_jumpDialog->refresh(); - } -} - -void MainWindow::handleCloseRequest() -{ - if (m_hideOnClose && m_generalHandler->visibilityControl()) - toggleVisibility(); - else - QApplication::closeAllWindows(); -} - -void MainWindow::disconnectPl() -{ - if(m_model) - { - disconnect(m_model, SIGNAL(itemAdded(PlayListItem*)), this, SLOT(play())); - disconnect(m_model, SIGNAL(loaderFinished()), this, SLOT(disconnectPl())); - m_model = 0; - } -} - -void MainWindow::addUrl() -{ - AddUrlDialog::popup(this, m_pl_manager->selectedPlayList()); -} - -SoundCore * MainWindow::soundCore() const -{ - return m_core; -} - -MainDisplay * MainWindow::mainDisplay() const -{ - return m_display; -} - -void MainWindow::keyPressEvent(QKeyEvent *ke) -{ - QKeyEvent event = QKeyEvent(ke->type(), ke->key(), - ke->modifiers(), ke->text(),ke->isAutoRepeat(), ke->count()); - QApplication::sendEvent(m_playlist,&event); -} - -void MainWindow::resume() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("General"); - if(settings.value("resume_playback", false).toBool()) - { - qint64 pos = settings.value("resume_playback_time").toLongLong(); - m_player->play(pos); - } -} diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h deleted file mode 100644 index a3cfa8b99..000000000 --- a/src/ui/mainwindow.h +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> -#include <QPointer> -#include <qmmp/output.h> -#include <qmmp/decoder.h> -#include <qmmp/decoderfactory.h> -#include <qmmpui/playlistitem.h> -#include "display.h" -#include "titlebar.h" - -class PlayList; -class PlayListManager; -class EqWidget; -class MainVisual; -class Skin; -class SoundCore; -class JumpToTrackDialog; -class VisualMenu; -class GeneralHandler; -class MediaPlayer; -class QMenu; -class QKeyEvent; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(QWidget *parent = 0); - - ~MainWindow(); - - PlayList *playlist(){return m_playlist;} - - QMenu* menu(); - void setVolume(int volume, int balance); - SoundCore* soundCore()const; - MainDisplay* mainDisplay()const; - void resume(); - -public slots: - void previous(); - void play(); - void pause(); - void playPause(); - void stop(); - void next(); - void replay(); - void jumpToFile(); - void toggleVisibility(); - - void addDir(); - void addFile(); - void addUrl(); - - void loadPlaylist(); - void savePlaylist(); - void setFileList(const QStringList&, bool clear = true); - void about(); - - void updateSettings(); - -protected: - virtual void closeEvent (QCloseEvent *); - virtual void changeEvent (QEvent *event); - virtual void keyPressEvent (QKeyEvent* ); - -private slots: - void showState(Qmmp::State state); - void showMetaData(); - void showSettings(); - void forward(); - void backward(); - void handleCloseRequest(); - void disconnectPl(); - -private: - void readSettings(); - void writeSettings(); - void createActions(); - SoundCore *m_core; - QMenu *m_mainMenu; - MainDisplay *m_display; - PlayList *m_playlist; - PlayListManager *m_pl_manager; - QPointer <PlayListModel> m_model; - int m_preamp; - EqWidget *m_equalizer; - MainVisual *m_vis; - QString m_lastDir; - bool m_update; - Skin *m_skin; - JumpToTrackDialog* m_jumpDialog; - bool m_hideOnClose, m_startHidden; - VisualMenu *m_visMenu; - GeneralHandler *m_generalHandler; - MediaPlayer *m_player; -}; - -#endif diff --git a/src/ui/monostereo.cpp b/src/ui/monostereo.cpp deleted file mode 100644 index 89f3621e5..000000000 --- a/src/ui/monostereo.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QPainter> - -#include "skin.h" -#include "monostereo.h" - -MonoStereo::MonoStereo (QWidget *parent) - : PixmapWidget (parent) -{ - m_skin = Skin::instance(); - m_pixmap = QPixmap (54*m_skin->ratio(), 12*m_skin->ratio()); - setChannels (0); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); -} - - -MonoStereo::~MonoStereo() -{} - -void MonoStereo::setChannels (int c) -{ - m_channels = c; - QPainter paint (&m_pixmap); - switch ((int) c) - { - case 0: - { - paint.drawPixmap (0,0,m_skin->getMSPart (Skin::MONO_I)); - paint.drawPixmap (27*m_skin->ratio(),0,m_skin->getMSPart (Skin::STEREO_I)); - break; - } - case 1: - { - paint.drawPixmap (0,0,m_skin->getMSPart (Skin::MONO_A)); - paint.drawPixmap (27*m_skin->ratio(),0,m_skin->getMSPart (Skin::STEREO_I)); - break; - } - } - if (c > 1) - { - paint.drawPixmap (0,0,m_skin->getMSPart (Skin::MONO_I)); - paint.drawPixmap (27*m_skin->ratio(),0,m_skin->getMSPart (Skin::STEREO_A)); - } - setPixmap (m_pixmap); -} - -void MonoStereo::updateSkin() -{ - m_pixmap = QPixmap (54*m_skin->ratio(), 12*m_skin->ratio()); - setChannels (m_channels); -} diff --git a/src/ui/monostereo.h b/src/ui/monostereo.h deleted file mode 100644 index 547a545da..000000000 --- a/src/ui/monostereo.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 MONOSTEREO_H -#define MONOSTEREO_H - -#include "pixmapwidget.h" - -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class MonoStereo : public PixmapWidget -{ -Q_OBJECT -public: - MonoStereo(QWidget *parent = 0); - - ~MonoStereo(); - -public slots: - void setChannels(int); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - QPixmap m_pixmap; - int m_channels; - -}; - -#endif diff --git a/src/ui/number.cpp b/src/ui/number.cpp deleted file mode 100644 index d818da72f..000000000 --- a/src/ui/number.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 "number.h" -#include "skin.h" - -Number::Number(QWidget *parent) - : PixmapWidget(parent) -{ - m_skin = Skin::instance(); - //TODO default value?? - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); -} - - -Number::~Number() -{ -} - -void Number::setValue(int n) -{ - setPixmap(m_skin->getNumber(n)); - m_value = n; -} - -void Number::updateSkin(void) -{ - setValue(m_value); -} diff --git a/src/ui/number.h b/src/ui/number.h deleted file mode 100644 index 1c89f71d4..000000000 --- a/src/ui/number.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 NUMBER_H -#define NUMBER_H - -#include "pixmapwidget.h" - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Skin; - -class Number : public PixmapWidget -{ -Q_OBJECT -public: - Number(QWidget *parent = 0); - - ~Number(); - - void setValue(int); - -private slots: - void updateSkin(void); - -private: - Skin *m_skin; - int m_value; - -}; - -#endif diff --git a/src/ui/pixmapwidget.cpp b/src/ui/pixmapwidget.cpp deleted file mode 100644 index 081298df5..000000000 --- a/src/ui/pixmapwidget.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 <QPixmap> -#include <QPainter> -#include <QPaintEvent> -#include <QStyle> -#include "pixmapwidget.h" - -PixmapWidget::PixmapWidget(QWidget *parent) - : QWidget(parent) -{} - - -PixmapWidget::~PixmapWidget() -{} - -void PixmapWidget::setPixmap(const QPixmap pixmap) -{ - m_pixmap = pixmap; - resize(m_pixmap.size()); - update(); -} - -void PixmapWidget::paintEvent (QPaintEvent *e) -{ - Q_UNUSED(e); - QPainter paint(this); - style()->drawItemPixmap(&paint, rect(), Qt::AlignCenter, m_pixmap); -} - diff --git a/src/ui/pixmapwidget.h b/src/ui/pixmapwidget.h deleted file mode 100644 index 24d34260e..000000000 --- a/src/ui/pixmapwidget.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 PIXMAPWIDGET_H -#define PIXMAPWIDGET_H - -#include <QWidget> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class QPixmap; - -class PixmapWidget : public QWidget -{ -Q_OBJECT -public: - PixmapWidget(QWidget *parent = 0); - - ~PixmapWidget(); - - virtual void setPixmap(const QPixmap); - -protected: - void paintEvent ( QPaintEvent * event ); - -private: - QPixmap m_pixmap; - - - -}; - -#endif diff --git a/src/ui/playlist.cpp b/src/ui/playlist.cpp deleted file mode 100644 index 75a6110ea..000000000 --- a/src/ui/playlist.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 <QPainter> -#include <QResizeEvent> -#include <QSettings> -#include <QMenu> -#include <QAction> -#include <QSignalMapper> -#include <QHBoxLayout> -#include <QCloseEvent> -#include <qmmpui/playlistitem.h> -#include <qmmpui/playlistmodel.h> -#include <qmmpui/playlistmanager.h> -#include <qmmpui/generalhandler.h> -#include <qmmp/soundcore.h> -#include "dock.h" -#include "skin.h" -#include "listwidget.h" -#include "button.h" -#include "playlisttitlebar.h" -#include "playlistslider.h" -#include "pixmapwidget.h" -#include "symboldisplay.h" -#include "playlistcontrol.h" -#include "keyboardmanager.h" -#include "playlistbrowser.h" -#include "playlistselector.h" -#include "windowsystem.h" -#include "actionmanager.h" -#include "playlist.h" - -PlayList::PlayList (PlayListManager *manager, QWidget *parent) - : QWidget (parent) -{ - setAttribute(Qt::WA_AlwaysShowToolTips,true); - setWindowTitle(tr("Playlist")); - m_pl_manager = manager; - m_update = false; - m_resize = false; - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - m_shaded = false; - m_pl_browser = 0; - m_pl_selector = 0; - - resize (275*m_ratio, 116*m_ratio); - setSizeIncrement (25*m_ratio, 29*m_ratio); - setMinimumSize(275*m_ratio, 116*m_ratio); - - m_listWidget = new ListWidget (this); - m_plslider = new PlayListSlider (this); - m_buttonAdd = new Button (this,Skin::PL_BT_ADD,Skin::PL_BT_ADD, Skin::CUR_PNORMAL); - m_buttonSub = new Button (this,Skin::PL_BT_SUB,Skin::PL_BT_SUB, Skin::CUR_PNORMAL); - m_selectButton = new Button (this,Skin::PL_BT_SEL,Skin::PL_BT_SEL, Skin::CUR_PNORMAL); - m_sortButton= new Button (this,Skin::PL_BT_SORT,Skin::PL_BT_SORT, Skin::CUR_PNORMAL); - m_playlistButton = new Button (this,Skin::PL_BT_LST,Skin::PL_BT_LST, Skin::CUR_PNORMAL); - m_resizeWidget = new QWidget(this); - m_resizeWidget->resize(25,25); - m_resizeWidget->setCursor(m_skin->getCursor (Skin::CUR_PSIZE)); - m_pl_control = new PlaylistControl (this); - - m_length_totalLength = new SymbolDisplay (this,14); - m_length_totalLength->setAlignment (Qt::AlignLeft); - - m_current_time = new SymbolDisplay (this,6); - m_keyboardManager = new KeyboardManager (this); - - connect (m_listWidget, SIGNAL (selectionChanged()), parent, SLOT (replay())); - - connect (m_plslider, SIGNAL (sliderMoved (int)), m_listWidget, SLOT (scroll (int))); - connect (m_listWidget, SIGNAL (positionChanged (int, int)), m_plslider, - SLOT (setPos (int, int))); - connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin())); - connect (m_buttonAdd, SIGNAL (clicked()), SLOT (showAddMenu())); - connect (m_buttonSub, SIGNAL (clicked()), SLOT (showSubMenu())); - connect (m_selectButton, SIGNAL (clicked()), SLOT (showSelectMenu())); - connect (m_sortButton, SIGNAL (clicked()), SLOT (showSortMenu())); - connect (m_playlistButton, SIGNAL (clicked()), SLOT (showPlaylistMenu())); - - connect (m_pl_control, SIGNAL (nextClicked()), SIGNAL (next())); - connect (m_pl_control, SIGNAL (previousClicked()), SIGNAL (prev())); - connect (m_pl_control, SIGNAL (playClicked()), SIGNAL (play())); - connect (m_pl_control, SIGNAL (pauseClicked()), SIGNAL (pause())); - connect (m_pl_control, SIGNAL (stopClicked()), SIGNAL (stop())); - connect (m_pl_control, SIGNAL (ejectClicked()), SIGNAL (eject())); - - connect (m_pl_manager, SIGNAL (selectedPlayListChanged(PlayListModel *, PlayListModel *)), - m_listWidget, SLOT(setModel(PlayListModel*))); - m_listWidget->setModel(m_pl_manager->selectedPlayList()); - - m_titleBar = new PlayListTitleBar (this); - m_titleBar->move (0,0); - connect (m_pl_manager, SIGNAL (currentPlayListChanged(PlayListModel *, PlayListModel *)), - m_titleBar, SLOT(setModel(PlayListModel*))); - m_titleBar->setModel(m_pl_manager->currentPlayList()); - - createMenus(); - createActions(); - - readSettings(); - setCursor(m_skin->getCursor(Skin::CUR_PNORMAL)); - updatePositions(); -#ifdef Q_WS_X11 - QString wm_name = WindowSystem::netWindowManagerName(); - if(wm_name.contains("metacity", Qt::CaseInsensitive) || - wm_name.contains("openbox", Qt::CaseInsensitive)) - setWindowFlags (Qt::Tool | Qt::FramelessWindowHint); - else -#endif - setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); -} - -PlayList::~PlayList() -{ - delete m_keyboardManager; -} - -void PlayList::updatePositions() -{ - int sx = (width()-275*m_ratio)/25; - int sy = (height()-116*m_ratio)/29; - if (sx < 0 || sy < 0 || m_shaded) //skip shaded mode - return; - - m_titleBar->resize (275*m_ratio+25*sx, 20*m_ratio); - m_plslider->resize (20*m_ratio, 58*m_ratio+sy*29); - - if(m_pl_selector) - { - m_listWidget->resize (243*m_ratio+25*sx, 58*m_ratio+29*sy - m_pl_selector->height()); - m_pl_selector->resize(243*m_ratio+25*sx, m_pl_selector->height()); - m_pl_selector->move(12*m_ratio, 20*m_ratio + 58*m_ratio+29*sy - m_pl_selector->height()); - } - else - m_listWidget->resize (243*m_ratio+25*sx, 58*m_ratio+29*sy); - m_listWidget->move (12*m_ratio,20*m_ratio); - - m_buttonAdd->move (11*m_ratio, 86*m_ratio+29*sy); - m_buttonSub->move (40*m_ratio, 86*m_ratio+29*sy); - m_selectButton->move (70*m_ratio, 86*m_ratio+29*sy); - m_sortButton->move (99*m_ratio, 86*m_ratio+29*sy); - - m_pl_control->move (128*m_ratio+sx*25, 100*m_ratio+29*sy); - m_playlistButton->move (228*m_ratio+sx*25,86*m_ratio+29*sy); - - m_length_totalLength -> move (131*m_ratio+sx*25,88*m_ratio+29*sy); - m_current_time->move (190*m_ratio+sx*25,101*m_ratio+29*sy); - - m_plslider->move (255*m_ratio+sx*25,20*m_ratio); - m_resizeWidget->move(width() - 25, height() - 29); -} - -void PlayList::createMenus() -{ - m_addMenu = new QMenu (this); - m_subMenu = new QMenu (this); - m_selectMenu = new QMenu (this); - m_sortMenu = new QMenu (this); - m_playlistMenu = new QMenu (this); - m_copySelectedMenu = new QMenu (tr("&Copy Selection To"), m_listWidget->menu()); - m_copySelectedMenu->setIcon(QIcon::fromTheme("edit-copy")); - connect (m_copySelectedMenu, SIGNAL (aboutToShow () ), this, SLOT (generateCopySelectedMenu ())); - connect (m_copySelectedMenu, SIGNAL (triggered ( QAction *) ), this, SLOT (copySelectedMenuActionTriggered( QAction *))); -} - -void PlayList::createActions() -{ - //add menu - m_addMenu->addAction(SET_ACTION(ActionManager::PL_ADD_FILE, parent(), SLOT(addFile()))); - m_addMenu->addAction(SET_ACTION(ActionManager::PL_ADD_DIRECTORY, parent(), SLOT(addDir()))); - m_addMenu->addAction(SET_ACTION(ActionManager::PL_ADD_URL, parent(), SLOT(addUrl()))); - //sub menu - m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_SELECTED, m_pl_manager, SLOT(removeSelected()))); - m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_ALL, m_pl_manager, SLOT(clear()))); - m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_UNSELECTED, m_pl_manager, - SLOT(removeUnselected()))); - m_subMenu->addSeparator(); - m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_INVALID, m_pl_manager, - SLOT(removeInvalidItems()))); - m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_DUPLICATES, m_pl_manager, - SLOT(removeDuplicates()))); - //sort menu - m_sortMenu->addAction(SET_ACTION(ActionManager::PL_SHOW_INFO, m_pl_manager, SLOT (showDetails ()))); - m_sortMenu->addAction (ActionManager::instance()->action(ActionManager::PL_SHOW_INFO)); - m_sortMenu->addSeparator(); - - QMenu* sort_mode_menu = new QMenu (tr("Sort List"), m_sortMenu); - sort_mode_menu->setIcon(QIcon::fromTheme("view-sort-ascending")); - QSignalMapper* signalMapper = new QSignalMapper (this); - QAction* titleAct = sort_mode_menu->addAction (tr ("By Title")); - connect (titleAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (titleAct, PlayListModel::TITLE); - - QAction* albumAct = sort_mode_menu->addAction (tr ("By Album")); - connect (albumAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (albumAct, PlayListModel::ALBUM); - - QAction* artistAct = sort_mode_menu->addAction (tr ("By Artist")); - connect (artistAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (artistAct, PlayListModel::ARTIST); - - QAction* nameAct = sort_mode_menu->addAction (tr ("By Filename")); - connect (nameAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (nameAct, PlayListModel::FILENAME); - - QAction* pathnameAct = sort_mode_menu->addAction (tr ("By Path + Filename")); - connect (pathnameAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (pathnameAct, PlayListModel::PATH_AND_FILENAME); - - QAction* dateAct = sort_mode_menu->addAction (tr ("By Date")); - connect (dateAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (dateAct, PlayListModel::DATE); - - QAction* trackAct = sort_mode_menu->addAction (tr("By Track Number")); - connect (trackAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (trackAct, PlayListModel::TRACK); - - connect (signalMapper, SIGNAL (mapped (int)), m_pl_manager, SLOT (sort (int))); - - m_sortMenu->addMenu (sort_mode_menu); - - sort_mode_menu = new QMenu (tr("Sort Selection"), m_sortMenu); - sort_mode_menu->setIcon(QIcon::fromTheme("view-sort-ascending")); - signalMapper = new QSignalMapper (this); - titleAct = sort_mode_menu->addAction (tr ("By Title")); - connect (titleAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (titleAct, PlayListModel::TITLE); - - albumAct = sort_mode_menu->addAction (tr ("By Album")); - connect (albumAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (albumAct, PlayListModel::ALBUM); - - artistAct = sort_mode_menu->addAction (tr ("By Artist")); - connect (artistAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (artistAct, PlayListModel::ARTIST); - - nameAct = sort_mode_menu->addAction (tr ("By Filename")); - connect (nameAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (nameAct, PlayListModel::FILENAME); - - pathnameAct = sort_mode_menu->addAction (tr ("By Path + Filename")); - connect (pathnameAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (pathnameAct, PlayListModel::PATH_AND_FILENAME); - - dateAct = sort_mode_menu->addAction (tr ("By Date")); - connect (dateAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (dateAct, PlayListModel::DATE); - - trackAct = sort_mode_menu->addAction (tr ("By Track Number")); - connect (trackAct, SIGNAL (triggered (bool)), signalMapper, SLOT (map())); - signalMapper->setMapping (trackAct, PlayListModel::TRACK); - - connect (signalMapper, SIGNAL (mapped (int)), m_pl_manager, SLOT (sortSelection (int))); - - m_sortMenu->addMenu (sort_mode_menu); - m_sortMenu->addSeparator(); - m_sortMenu->addAction (QIcon::fromTheme("media-playlist-shuffle"), tr("Randomize List"), - m_pl_manager, SLOT(randomizeList())); - m_sortMenu->addAction (QIcon::fromTheme("view-sort-descending"), tr("Reverse List"), - m_pl_manager, SLOT(reverseList())); - //playlist context menu - m_listWidget->menu()->addAction(ActionManager::instance()->action(ActionManager::PL_SHOW_INFO)); - m_listWidget->menu()->addSeparator(); - m_listWidget->menu()->addActions (m_subMenu->actions().mid(0,3)); //use 3 first actions - m_listWidget->menu()->addMenu(GeneralHandler::instance()->createMenu(GeneralHandler::PLAYLIST_MENU, - tr("Actions"), this)); - m_listWidget->menu()->addSeparator(); - m_listWidget->menu()->addAction(SET_ACTION(ActionManager::PL_ENQUEUE, m_pl_manager, SLOT(addToQueue()))); - //select menu - m_selectMenu->addAction(SET_ACTION(ActionManager::PL_INVERT_SELECTION, m_pl_manager, - SLOT(invertSelection ()))); - m_selectMenu->addSeparator(); - m_selectMenu->addAction(SET_ACTION(ActionManager::PL_CLEAR_SELECTION, m_pl_manager, - SLOT(clearSelection ()))); - m_selectMenu->addAction(SET_ACTION(ActionManager::PL_SELECT_ALL, m_pl_manager, SLOT(selectAll()))); - //Playlist Menu - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_NEW, m_pl_manager, SLOT(createPlayList()))); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_CLOSE, this, SLOT(deletePlaylist()))); - m_playlistMenu->addSeparator(); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_LOAD, this, SIGNAL(loadPlaylist()))); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_SAVE, this, SIGNAL(savePlaylist()))); - m_playlistMenu->addSeparator(); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_SELECT_NEXT, m_pl_manager, - SLOT(selectNextPlayList()))); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_SELECT_PREVIOUS, m_pl_manager, - SLOT(selectPreviousPlayList()))); - m_playlistMenu->addAction(SET_ACTION(ActionManager::PL_SHOW_MANAGER, this, SLOT(showPlayLists()))); - Dock::instance()->addActions (m_addMenu->actions()); - Dock::instance()->addActions (m_subMenu->actions()); - Dock::instance()->addActions (m_sortMenu->actions()); - Dock::instance()->addActions (m_listWidget->menu()->actions()); - Dock::instance()->addActions (m_selectMenu->actions()); - Dock::instance()->addActions (m_playlistMenu->actions()); -} - -void PlayList::closeEvent (QCloseEvent *e) -{ - if (e->spontaneous ()) - emit closed(); - writeSettings(); -} - -void PlayList::paintEvent (QPaintEvent *) -{ - int sx = (width()-275*m_ratio) /25; - int sy = (height()-116*m_ratio) /29; - - QPainter paint(this); - drawPixmap (&paint, 0, 20*m_ratio, m_skin->getPlPart (Skin::PL_LFILL)); - for (int i = 1; i<sy+2*m_ratio; i++) - { - drawPixmap (&paint, 0, 20*m_ratio+29*i, m_skin->getPlPart (Skin::PL_LFILL)); - } - drawPixmap (&paint, 0, 78*m_ratio+29*sy, m_skin->getPlPart (Skin::PL_LSBAR)); - - for (int i = 0; i<sx; i++) - { - drawPixmap (&paint, 125*m_ratio+i*25,78*m_ratio+sy*29,m_skin->getPlPart (Skin::PL_SFILL1)); - } - drawPixmap (&paint,125*m_ratio+sx*25,78*m_ratio+sy*29,m_skin->getPlPart (Skin::PL_RSBAR)); - -} - -void PlayList::drawPixmap (QPainter *painter, int x, int y, const QPixmap &pix) -{ - style()->drawItemPixmap(painter, QRect(x, y, pix.width(), pix.height()), Qt::AlignCenter, pix); -} - -void PlayList::resizeEvent (QResizeEvent *) -{ - updatePositions(); -} - -void PlayList::mousePressEvent (QMouseEvent *e) -{ - m_pos = e->pos (); - if (m_resizeWidget->underMouse()) - { - m_resize = true; - setCursor (m_skin->getCursor (Skin::CUR_PSIZE)); - } - else - m_resize = false; -} - -void PlayList::mouseMoveEvent (QMouseEvent *e) -{ - if (m_resize) - { -#ifdef Q_OS_WIN32 - int sx = (width()-275) /25; - int sy = (height()-116) /29; - if(width() < e->x() - 14) - sx++; - else if(width() > e->x() + 14) - sx--; - if(height() < e->y() - 14) - sy++; - else if(height() > e->y() + 14) - sy--; - resize (275+25*sx,116+29*sy); -#else - resize (e->x() +25, e->y() +25); -#endif - } -} - -void PlayList::mouseReleaseEvent (QMouseEvent *) -{ - setCursor (m_skin->getCursor (Skin::CUR_PNORMAL)); - /*if (m_resize) - m_listWidget->updateList();*/ - m_resize = false; - Dock::instance()->updateDock(); -} - -void PlayList::changeEvent (QEvent * event) -{ - if (event->type() == QEvent::ActivationChange) - { - m_titleBar->setActive (isActiveWindow()); - } -} - -void PlayList::readSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - if (settings.value("PlayList/show_plalists", false).toBool()) - { - if(!m_pl_selector) - m_pl_selector = new PlayListSelector(m_pl_manager, this); - m_pl_selector->show(); - m_listWidget->menu()->insertMenu(m_listWidget->menu()->actions().at(2),m_copySelectedMenu); - } - else - { - if(m_pl_selector) - { - m_pl_selector->deleteLater(); - m_listWidget->menu()->removeAction(m_copySelectedMenu->menuAction()); - } - m_pl_selector = 0; - } - if (m_update) - { - m_listWidget->readSettings(); - m_titleBar->readSettings(); - if(m_pl_selector) - m_pl_selector->readSettings(); - updatePositions(); - } - else - { - move (settings.value ("PlayList/pos", QPoint (100, 332)).toPoint()); //position - m_update = true; - } -} - -#ifdef Q_WS_X11 -bool PlayList::event (QEvent *event) -{ - if(event->type() == QEvent::WinIdChange || event->type() == QEvent::Show) - { - WindowSystem::ghostWindow(winId()); - WindowSystem::setWinHint(winId(), "playlist", "Qmmp"); - } - return QWidget::event(event); -} -#endif - -void PlayList::writeSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup ("PlayList"); - //position - settings.setValue ("pos", this->pos()); - settings.endGroup(); -} - -void PlayList::showAddMenu() -{ - m_addMenu->exec (m_buttonAdd->mapToGlobal (QPoint (0,0))); -} - -void PlayList::showSubMenu() -{ - m_subMenu->exec (m_buttonSub->mapToGlobal (QPoint (0,0))); -} - -void PlayList::showSelectMenu() -{ - m_selectMenu->exec (m_selectButton->mapToGlobal (QPoint (0,0))); -} - -void PlayList::showSortMenu() -{ - m_sortMenu->exec (m_sortButton->mapToGlobal (QPoint (0,0))); -} - -QString PlayList::formatTime (int sec) -{ - if(sec > 3600) - sec /= 60; - return QString("%1:%2").arg(sec/60, 2, 10, QChar('0')).arg(sec%60, 2, 10, QChar('0')); -} - -void PlayList::setTime(qint64 time) -{ - if (time < 0) - m_current_time->display ("--:--"); - else - m_current_time->display (formatTime (time/1000)); - m_current_time->update(); - - if (SoundCore::instance()) - { - QString str_length = formatTime (m_pl_manager->currentPlayList()->totalLength()) + - "/" + formatTime (SoundCore::instance()->totalTime()/1000); - m_length_totalLength->display (str_length); - m_length_totalLength->update(); - } -} - -void PlayList::updateList() -{ - m_listWidget->updateList(); - m_titleBar->showCurrent(); -} - -PlayListItem *PlayList::currentItem() -{ - return m_pl_manager->currentPlayList()->currentItem(); -} - -void PlayList::showPlaylistMenu() -{ - m_playlistMenu->exec (m_playlistButton->mapToGlobal (QPoint (0,0))); -} - -void PlayList::keyPressEvent (QKeyEvent *ke) -{ - if (m_keyboardManager->handleKeyPress (ke)) - update(); -} - -void PlayList::updateSkin() -{ - setCursor(m_skin->getCursor(Skin::CUR_PNORMAL)); // TODO shaded - m_resizeWidget->setCursor(m_skin->getCursor (Skin::CUR_PSIZE)); - m_ratio = m_skin->ratio(); - setMinimalMode(m_shaded); -} - -void PlayList::deletePlaylist() -{ - m_pl_manager->removePlayList(m_pl_manager->selectedPlayList()); -} - -void PlayList::showPlayLists() -{ - if(!m_pl_browser) - { - m_pl_browser = new PlayListBrowser(m_pl_manager, this); - m_pl_browser->show(); - } - else - m_pl_browser->show(); -} - -void PlayList::generateCopySelectedMenu() -{ - m_copySelectedMenu->clear(); - QAction* action = m_copySelectedMenu->addAction (tr ("&New PlayList")); - action->setIcon(QIcon::fromTheme("document-new")); - m_copySelectedMenu->addSeparator(); - - foreach(QString name, m_pl_manager->playListNames()) - { - action = m_copySelectedMenu->addAction("&"+name.replace("&", "&&")); - } -} - -void PlayList::copySelectedMenuActionTriggered( QAction * action) -{ - PlayListModel *targetPlayList = 0; - QString actionText=action->text(); - if(action == m_copySelectedMenu->actions().at(0))//actionText == tr ("&New PlayList")) - { - targetPlayList = m_pl_manager->createPlayList(m_pl_manager->selectedPlayList()->name()); - } - else - { - actionText.remove(0,1).replace("&&", "&"); - foreach(PlayListModel *model, m_pl_manager->playLists()) - { - //if("&" + model->name().replace("&", "&&") == actionText) - if(model->name() == actionText) - { - targetPlayList=model; - break; - } - } - } - if(!targetPlayList) - { - qWarning("Error: Cannot find target playlist '%s'",qPrintable(actionText)); - return; - } - QList <PlayListItem *> theCopy; - foreach(PlayListItem *item, m_pl_manager->selectedPlayList()->getSelectedItems()) - { - PlayListItem *newItem = new PlayListItem(*item); - theCopy << newItem; - } - targetPlayList->add(theCopy); -} - -void PlayList::setMinimalMode(bool b) -{ - if(!m_shaded) - m_height = height(); - m_shaded = b; - if(m_shaded) - { - m_height = height(); - setSizeIncrement (25*m_ratio, 1); - setMinimumSize (275*m_ratio, 14*m_ratio); - resize(width(), 14*m_ratio); - } - else - { - setMinimumSize(275*m_ratio, 116*m_ratio); - resize (width(), m_height); - setSizeIncrement (25*m_ratio, 29*m_ratio); - - } - updatePositions(); - update(); -} diff --git a/src/ui/playlist.h b/src/ui/playlist.h deleted file mode 100644 index ae4d5cda8..000000000 --- a/src/ui/playlist.h +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 PLAYLIST_H -#define PLAYLIST_H - -#include <QWidget> -#include <QPointer> - -class QMenu;; -class Skin; -class ListWidget; -class PlayListItem; -class Button; -class PlayListModel; -class PlayListTitleBar; -class PlayListSlider; -class MainWindow; -class SymbolDisplay; -class OutputState; -class PixmapWidget; -class PlaylistControl; -class KeyboardManager; -class PlayListManager; -class PlayListBrowser; -class PlayListSelector; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PlayList : public QWidget -{ - Q_OBJECT - public: - PlayList (PlayListManager *manager, QWidget *parent = 0); - - ~PlayList(); - void load (PlayListItem *); - void readSettings(); - PlayListItem *currentItem(); - ListWidget* listWidget() const - { - return m_listWidget; - } - void setMinimalMode(bool b = true); - - signals: - void play(); - void next(); - void prev(); - void pause(); - void stop(); - void eject(); - void loadPlaylist(); - void savePlaylist(); - void closed(); - - public slots: - void setTime(qint64 time); - void updateList(); - - private slots: - void showAddMenu(); - void showSubMenu(); - void showSelectMenu(); - void showSortMenu(); - void showPlaylistMenu(); - void updateSkin(); - void deletePlaylist(); - void showPlayLists(); - void generateCopySelectedMenu(); - void copySelectedMenuActionTriggered( QAction * action); - - private: - void updatePositions(); - QString formatTime (int sec); - void drawPixmap (QPainter *painter, int x, int y, const QPixmap &pix); - void writeSettings(); - void createMenus(); - void createActions(); - //events - virtual void paintEvent (QPaintEvent *); - virtual void resizeEvent (QResizeEvent *); - virtual void mouseMoveEvent (QMouseEvent *); - virtual void mousePressEvent (QMouseEvent *); - virtual void mouseReleaseEvent (QMouseEvent *); - virtual void changeEvent (QEvent*); - virtual void closeEvent (QCloseEvent*); - virtual void keyPressEvent (QKeyEvent*); -#ifdef Q_WS_X11 - virtual bool event (QEvent *event); -#endif - QMenu *m_addMenu; - QMenu *m_subMenu; - QMenu *m_selectMenu; - QMenu *m_sortMenu; - QMenu *m_playlistMenu; - QMenu *m_copySelectedMenu; - QWidget *m_resizeWidget; - Button *m_buttonAdd; - Button *m_buttonSub; - Button *m_selectButton; - Button *m_sortButton; - Button* m_playlistButton; - PlaylistControl* m_pl_control; - SymbolDisplay* m_length_totalLength; - SymbolDisplay* m_current_time; - Skin *m_skin; - ListWidget *m_listWidget; - PlayListTitleBar *m_titleBar; - PlayListSlider *m_plslider; - QPoint m_pos; - bool m_resize; - bool m_update; - int m_ratio; - int m_height; - bool m_shaded; - PlayListManager *m_pl_manager; - KeyboardManager* m_keyboardManager; - QPointer <PlayListBrowser> m_pl_browser; - PlayListSelector *m_pl_selector; -}; - -#endif diff --git a/src/ui/playlistbrowser.cpp b/src/ui/playlistbrowser.cpp deleted file mode 100644 index d7e630c43..000000000 --- a/src/ui/playlistbrowser.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2010 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 <QApplication> -#include <QStyle> -#include <qmmpui/playlistmanager.h> -#include "playlistbrowser.h" - -PlayListBrowser::PlayListBrowser(PlayListManager *manager, QWidget *parent) : QDialog(parent) -{ - setAttribute(Qt::WA_DeleteOnClose, true); - setAttribute(Qt::WA_QuitOnClose, false); - setWindowModality(Qt::NonModal); - ui.setupUi(this); - m_pl_manager = manager; - connect(m_pl_manager, SIGNAL(playListsChanged()), SLOT(updateList())); - connect(ui.newButton, SIGNAL(clicked()), m_pl_manager, SLOT(createPlayList())); - updateList(); - //actions - QAction *renameAct = new QAction(tr("Rename"), this); - QAction *removeAct = new QAction(tr("Delete"), this); - connect(renameAct,SIGNAL(triggered()), SLOT(rename())); - connect(removeAct,SIGNAL(triggered()), SLOT(on_deleteButton_clicked())); - ui.listWidget->setContextMenuPolicy(Qt::ActionsContextMenu); - ui.listWidget->addAction(renameAct); - ui.listWidget->addAction(removeAct); - ui.downButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); - ui.upButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp)); - ui.newButton->setIcon(QIcon::fromTheme("document-new")); - ui.deleteButton->setIcon(QIcon::fromTheme("edit-delete")); -} - -PlayListBrowser::~PlayListBrowser() -{} - -void PlayListBrowser::updateList() -{ - ui.listWidget->clear(); - foreach(PlayListModel *model, m_pl_manager->playLists()) - ui.listWidget->addItem(model->name()); - ui.listWidget->setCurrentRow (m_pl_manager->selectedPlayListIndex()); - //mark current playlist - int current = m_pl_manager->currentPlayListIndex(); - QListWidgetItem *item = ui.listWidget->item(current); - if(item) - { - QFont font = item->font(); - font.setBold(true); - item->setFont(font); - } -} - -void PlayListBrowser::on_listWidget_itemDoubleClicked(QListWidgetItem *item) -{ - m_pl_manager->activatePlayList(ui.listWidget->row(item)); -} - -void PlayListBrowser::on_listWidget_itemChanged(QListWidgetItem *item) -{ - m_pl_manager->playListAt(ui.listWidget->row(item))->setName(item->text()); -} - -void PlayListBrowser::on_listWidget_itemPressed (QListWidgetItem *item) -{ - m_pl_manager->selectPlayList(ui.listWidget->row(item)); -} - -void PlayListBrowser::rename() -{ - QListWidgetItem *item = ui.listWidget->currentItem(); - if(item) - { - item->setFlags(Qt::ItemIsEditable | item->flags()); - ui.listWidget->editItem(item); - } -} - -void PlayListBrowser::on_deleteButton_clicked() -{ - QList <PlayListModel *> models; - foreach(QListWidgetItem *item, ui.listWidget->selectedItems()) - models.append(m_pl_manager->playListAt(ui.listWidget->row (item))); - foreach(PlayListModel *model, models) - m_pl_manager->removePlayList(model); -} - -void PlayListBrowser::on_downButton_clicked() -{ - int pos = m_pl_manager->indexOf(m_pl_manager->selectedPlayList()); - if(pos < m_pl_manager->count() - 1) - m_pl_manager->move(pos, pos + 1); -} - -void PlayListBrowser::on_upButton_clicked() -{ - int pos = m_pl_manager->indexOf(m_pl_manager->selectedPlayList()); - if(pos > 0) - m_pl_manager->move(pos, pos - 1); -} diff --git a/src/ui/playlistbrowser.h b/src/ui/playlistbrowser.h deleted file mode 100644 index 563b527a5..000000000 --- a/src/ui/playlistbrowser.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 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 PLAYLISTBROWSER_H -#define PLAYLISTBROWSER_H - -#include <QDialog> -#include "ui_playlistbrowser.h" - -class PlayListManager; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PlayListBrowser : public QDialog -{ -Q_OBJECT -public: - PlayListBrowser(PlayListManager *manager, QWidget *parent = 0); - ~PlayListBrowser(); - -private slots: - void updateList(); - void on_listWidget_itemDoubleClicked(QListWidgetItem *item); - void on_listWidget_itemChanged(QListWidgetItem *item); - void on_listWidget_itemPressed (QListWidgetItem *item); - void rename(); - void on_deleteButton_clicked(); - void on_downButton_clicked(); - void on_upButton_clicked(); - -private: - Ui::PlayListBrowser ui; - PlayListManager *m_pl_manager; -}; - -#endif // PLAYLISTBROWSER_H diff --git a/src/ui/playlistcontrol.cpp b/src/ui/playlistcontrol.cpp deleted file mode 100644 index 9f6f1cb60..000000000 --- a/src/ui/playlistcontrol.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QPainter> -#include <QPaintEvent> -#include <QMouseEvent> - -#include "playlistcontrol.h" -#include "skin.h" - -PlaylistControl::PlaylistControl(QWidget* parent) : PixmapWidget(parent) -{ - m_skin = Skin::instance(); - setPixmap(m_skin->getPlPart(Skin::PL_CONTROL)); - m_ratio = m_skin->ratio(); - connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin())); -} - -void PlaylistControl::mouseReleaseEvent(QMouseEvent *me) -{ - QPoint pt = me->pos(); - if(QRect(4*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit previousClicked(); - else if(QRect(12*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit playClicked(); - else if(QRect(21*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit pauseClicked(); - else if(QRect(31*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit stopClicked(); - else if(QRect(40*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit nextClicked(); - else if(QRect(49*m_ratio,m_ratio,7*m_ratio,7*m_ratio).contains(pt)) - emit ejectClicked(); -} - -void PlaylistControl::updateSkin() -{ - setCursor(m_skin->getCursor(Skin::CUR_PNORMAL)); - setPixmap(m_skin->getPlPart(Skin::PL_CONTROL)); - m_ratio = m_skin->ratio(); -} diff --git a/src/ui/playlistcontrol.h b/src/ui/playlistcontrol.h deleted file mode 100644 index 6c0ed0eaf..000000000 --- a/src/ui/playlistcontrol.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 _PALYLISTCONTROL_H -#define _PALYLISTCONTROL_H - -#include "pixmapwidget.h" - -class QMouseEvent; -class PaintEvent; -class Skin; - - /** - @author Vladimir Kuznetsov <vovanec@gmail.ru> - */ -class PlaylistControl : public PixmapWidget -{ -Q_OBJECT -public: - PlaylistControl(QWidget* parent = 0); - - -signals: - void previousClicked(); - void nextClicked(); - void pauseClicked(); - void playClicked(); - void stopClicked(); - void ejectClicked(); - -private slots: - void updateSkin(); - -private: - void mouseReleaseEvent(QMouseEvent*); - int m_ratio; - Skin* m_skin; -}; - -#endif diff --git a/src/ui/playlistselector.cpp b/src/ui/playlistselector.cpp deleted file mode 100644 index 132c708ea..000000000 --- a/src/ui/playlistselector.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2011 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 <QPainter> -#include <QFont> -#include <QFontMetrics> -#include <QSettings> -#include <QApplication> -#include <QMouseEvent> -#include <QMenu> -#include <QLineEdit> -#include <QInputDialog> -#include <qmmp/qmmp.h> -#include <qmmpui/playlistmanager.h> -#include "skin.h" -#include "playlistselector.h" - -PlayListSelector::PlayListSelector(PlayListManager *manager, QWidget *parent) : QWidget(parent) -{ - m_update = false; - m_scrollable = false; - m_left_pressed = false; - m_right_pressed = false; - m_offset = 0; - m_offset_max = 0; - m_skin = Skin::instance(); - m_pl_manager = manager; - connect(m_pl_manager, SIGNAL(playListsChanged()), SLOT(updateTabs())); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - loadColors(); - readSettings(); - updateTabs(); - m_menu = new QMenu(this); - m_menu->addAction(tr("&Load"), parent, SIGNAL (loadPlaylist())); - m_menu->addAction(tr("&Save As..."), parent, SIGNAL (savePlaylist())); - m_menu->addSeparator(); - m_menu->addAction(tr("Rename"),this, SLOT (renamePlaylist())); - m_menu->addAction(tr("&Delete"),parent, SLOT (deletePlaylist())); -} - -PlayListSelector::~PlayListSelector() -{} - -void PlayListSelector::readSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_font.fromString(settings.value("PlayList/Font", QApplication::font().toString()).toString()); - if (m_update) - { - delete m_metrics; - m_metrics = new QFontMetrics(m_font); - updateTabs(); - } - else - { - m_update = true; - } - m_metrics = new QFontMetrics(m_font); - - resize(width(), m_metrics->height () +1); - drawButtons(); -} - -void PlayListSelector::updateTabs() -{ - m_rects.clear(); - QRect rect; - foreach(QString text, m_pl_manager->playListNames()) - { - if(m_rects.isEmpty()) - rect.setX(9); - else - rect.setX(m_rects.last().right() + m_metrics->width(" | ")); - rect.setY(0); - rect.setWidth(m_metrics->width(text)); - rect.setHeight(m_metrics->ascent ()); - m_rects.append(rect); - } - updateScrollers(); - update(); -} - -void PlayListSelector::updateSkin() -{ - loadColors(); - drawButtons(); - updateTabs(); -} - -void PlayListSelector::renamePlaylist() -{ - bool ok = false; - QString name = QInputDialog::getText (this, - tr("Rename Playlist"), tr("Playlist name:"), - QLineEdit::Normal, - m_pl_manager->selectedPlayList()->name(), &ok); - if(ok) - m_pl_manager->selectedPlayList()->setName(name); -} - -void PlayListSelector::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setFont(m_font); - painter.setBrush(QBrush(m_normal_bg)); - painter.drawRect(-1,-1,width()+1,height()+1); - QStringList names = m_pl_manager->playListNames(); - int current = m_pl_manager->indexOf(m_pl_manager->currentPlayList()); - int selected = m_pl_manager->indexOf(m_pl_manager->selectedPlayList()); - painter.setBrush(QBrush(m_selected_bg)); - painter.setPen(m_selected_bg); - painter.drawRect(m_rects.at(selected).x()- 3 - m_offset, 0, - m_rects.at(selected).width()+4, height()-1); - - for (int i = 0; i < m_rects.size(); ++i) - { - if(i == current) - painter.setPen(m_current); - else - painter.setPen(m_normal); - painter.drawText(m_rects[i].x() - m_offset, m_metrics->ascent(), names.at(i)); - if(i < m_rects.size() - 1) - { - painter.setPen(m_normal); - painter.drawText(m_rects[i].x() + m_rects[i].width() - m_offset, m_metrics->ascent(), " | "); - } - } - if(m_scrollable) - { - painter.drawPixmap(width()-40, 0, m_pixmap); - painter.setBrush(QBrush(m_normal_bg)); - painter.setPen(m_normal_bg); - painter.drawRect(0,0,6,height()); - } -} - -void PlayListSelector::mousePressEvent (QMouseEvent *e) -{ - if(m_scrollable && e->x() > width() - 20) - { - m_offset += m_rects.at(lastVisible()).right() - m_offset - width() + 42; - m_offset = qMin(m_offset, m_offset_max); - m_right_pressed = true; - drawButtons(); - update(); - return; - } - if(m_scrollable && (width() - 40 < e->x()) && (e->x() <= width() - 20)) - { - m_offset -= 11 - m_rects.at(firstVisible()).x() + m_offset; - m_offset = qMax(0, m_offset); - m_left_pressed = true; - drawButtons(); - update(); - return; - } - - QPoint pp = e->pos(); - pp.rx() += m_offset; - bool selected = false; - for(int i = 0; i < m_rects.count(); ++i) - { - if(m_rects.at(i).contains(pp)) - { - selected = true; - m_pl_manager->selectPlayList(i); - break; - } - } - update(); - if(e->button() == Qt::RightButton) - m_menu->exec(e->globalPos()); - else if(e->button() == Qt::MidButton && selected) - m_pl_manager->removePlayList(m_pl_manager->selectedPlayList()); - else - QWidget::mousePressEvent(e); -} - -void PlayListSelector::mouseReleaseEvent (QMouseEvent *e) -{ - m_left_pressed = false; - m_right_pressed = false; - drawButtons(); - update(); - QWidget::mouseReleaseEvent(e); -} - -void PlayListSelector::mouseDoubleClickEvent (QMouseEvent *e) -{ - if(e->button() == Qt::LeftButton && !(m_scrollable && (e->x() > width() - 40))) - renamePlaylist(); - else - QWidget::mouseDoubleClickEvent(e); -} - -void PlayListSelector::mouseMoveEvent(QMouseEvent *e) -{ - QPoint mp = e->pos(); - mp.rx() += m_offset; - int dest = -1; - for(int i = 0; i < m_rects.count(); ++i) - { - if(mp.x() >= m_rects.at(i).x() && mp.x() <= m_rects.at(i).x() + m_rects.at(i).width()) - { - dest = i; - break; - } - } - if(dest == -1 || dest == m_pl_manager->selectedPlayListIndex()) - { - QWidget::mouseMoveEvent(e); - return; - } - m_pl_manager->move(m_pl_manager->selectedPlayListIndex(), dest); -} - -void PlayListSelector::resizeEvent (QResizeEvent *) -{ - updateScrollers(); -} - -void PlayListSelector::loadColors() -{ - m_normal.setNamedColor(m_skin->getPLValue("normal")); - m_current.setNamedColor(m_skin->getPLValue("current")); - m_normal_bg.setNamedColor(m_skin->getPLValue("normalbg")); - m_selected_bg.setNamedColor(m_skin->getPLValue("selectedbg")); -} - -void PlayListSelector::drawButtons() -{ - m_pixmap = QPixmap(40, height()); - m_pixmap.fill(m_normal_bg); - QPainter painter(&m_pixmap); - painter.setPen(m_left_pressed ? m_current : m_normal); - painter.setBrush(QBrush(m_left_pressed ? m_current : m_normal)); - QPoint points[3] = { - QPoint(m_pixmap.width() - 25, height()/2 - 5), - QPoint(m_pixmap.width() - 35, height()/2-1), - QPoint(m_pixmap.width() - 25, height()/2 + 3), - }; - painter.drawPolygon(points, 3); - painter.setPen(m_right_pressed ? m_current : m_normal); - painter.setBrush(QBrush(m_right_pressed ? m_current : m_normal)); - QPoint points2[3] = { - QPoint(m_pixmap.width() - 20, height()/2 - 5), - QPoint(m_pixmap.width() - 10, height()/2-1), - QPoint(m_pixmap.width() - 20, height()/2 + 3), - }; - painter.drawPolygon(points2, 3); -} - -void PlayListSelector::updateScrollers() -{ - m_scrollable = m_rects.last().right() > width(); - if(m_scrollable) - { - m_offset_max = m_rects.last().right() - width() + 42; - m_offset = qMin(m_offset, m_offset_max); - } - else - { - m_offset = 0; - m_offset_max = 0; - } -} - -int PlayListSelector::firstVisible() -{ - for(int i = 0; i < m_rects.size(); ++i) - { - if(m_rects.at(i).right() - m_offset + m_metrics->width(" - ") + 2 >= 9) - return i; - } - return 0; -} - -int PlayListSelector::lastVisible() -{ - for(int i = m_rects.size() - 1; i >= 0; --i) - { - if(m_rects.at(i).x() - m_offset - m_metrics->width(" - ") - 2 <= width() - 40) - return i; - } - return m_rects.count() - 1; -} diff --git a/src/ui/playlistselector.h b/src/ui/playlistselector.h deleted file mode 100644 index 67e281f75..000000000 --- a/src/ui/playlistselector.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2010 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 PLAYLISTSELECTOR_H -#define PLAYLISTSELECTOR_H - -#include <QWidget> -#include <QColor> -#include <QPixmap> - -class QFontMetrics; -class QFont; -class QMouseEvent; -class QMenu; -class PlayListManager; -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PlayListSelector : public QWidget -{ -Q_OBJECT -public: - PlayListSelector(PlayListManager *manager, QWidget *parent = 0); - ~PlayListSelector(); - void readSettings(); - -private slots: - void updateTabs(); - void updateSkin(); - void renamePlaylist(); - -private: - void paintEvent(QPaintEvent *); - void mousePressEvent (QMouseEvent *e); - void mouseReleaseEvent (QMouseEvent *e); - void mouseDoubleClickEvent (QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void resizeEvent (QResizeEvent *); - void updateOffsets(); - void loadColors(); - void drawButtons(); - void updateScrollers(); - int firstVisible(); - int lastVisible(); - PlayListManager *m_pl_manager; - QFontMetrics *m_metrics; - QFont m_font; - QMenu *m_menu; - bool m_update; - bool m_scrollable; - QList <QRect> m_rects; - Skin *m_skin; - QColor m_normal, m_current, m_normal_bg, m_selected_bg; - QPixmap m_pixmap; - bool m_showButtons; - int m_offset, m_offset_max; - bool m_left_pressed, m_right_pressed; -}; - -#endif // PLAYLISTSELECTOR_H diff --git a/src/ui/playlistslider.cpp b/src/ui/playlistslider.cpp deleted file mode 100644 index df958fa6b..000000000 --- a/src/ui/playlistslider.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QPainter> -#include <QResizeEvent> -#include <math.h> - -#include "skin.h" -#include "playlistslider.h" -#include "pixmapwidget.h" - -PlayListSlider::PlayListSlider(QWidget *parent) - : QWidget(parent) -{ - m_skin = Skin::instance(); - m_moving = false; - m_pressed = false; - m_min = 0; - m_max = 0; - m_value = 0; - pos = 0; - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setCursor(m_skin->getCursor(Skin::CUR_PVSCROLL)); -} - - -PlayListSlider::~PlayListSlider() -{} - -void PlayListSlider::paintEvent(QPaintEvent *) -{ - int sy = (height()-58)/29; - int p=int(ceil(double(m_value-m_min)*(height()-18)/(m_max-m_min))); - QPainter paint(this); - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_RFILL)); - paint.drawPixmap(0,29,m_skin->getPlPart(Skin::PL_RFILL)); - - for (int i = 0; i<sy; i++) - { - paint.drawPixmap(0,58+i*29,m_skin->getPlPart(Skin::PL_RFILL)); - } - if (m_pressed) - paint.drawPixmap(5*m_skin->ratio(),p,m_skin->getButton(Skin::PL_BT_SCROLL_P)); - else - paint.drawPixmap(5*m_skin->ratio(),p,m_skin->getButton(Skin::PL_BT_SCROLL_N)); - m_pos = p; -} - -void PlayListSlider::mousePressEvent(QMouseEvent *e) -{ - m_moving = true; - m_pressed = true; - press_pos = e->y(); - if (m_pos<e->y() && e->y()<m_pos+18*m_skin->ratio()) - { - press_pos = e->y()-m_pos; - } - else - { - m_value = convert(qMax(qMin(height()-18*m_skin->ratio(),e->y()-9*m_skin->ratio()),0)); - press_pos = 9*m_skin->ratio(); - if (m_value!=m_old) - { - emit sliderMoved(m_value); - m_old = m_value; - //qDebug ("%d",m_value); - } - } - update(); -} - -void PlayListSlider::mouseReleaseEvent(QMouseEvent*) -{ - m_moving = false; - m_pressed = false; - update(); -} - -void PlayListSlider::mouseMoveEvent(QMouseEvent* e) -{ - if (m_moving) - { - int po = e->y(); - po = po - press_pos; - - if (0<=po && po<=height()-18*m_skin->ratio()) - { - m_value = convert(po); - update(); - if (m_value!=m_old) - { - - m_old = m_value; - emit sliderMoved(m_value); - } - } - } -} - -void PlayListSlider::setPos(int p, int max) -{ - m_max = max; - m_value = p; - if(m_moving) - return; - update(); -} - -void PlayListSlider::updateSkin() -{ - update(); - setCursor(m_skin->getCursor(Skin::CUR_PVSCROLL)); -} - -int PlayListSlider::convert(int p) -{ - return int(floor(double(m_max-m_min)*(p)/(height()-18*m_skin->ratio())+m_min)); -} - diff --git a/src/ui/playlistslider.h b/src/ui/playlistslider.h deleted file mode 100644 index cd42a6c3a..000000000 --- a/src/ui/playlistslider.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 PLAYLISTSLIDER_H -#define PLAYLISTSLIDER_H - -#include <QWidget> - -class Skin; -class PixmapWidget; -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PlayListSlider : public QWidget -{ -Q_OBJECT -public: - PlayListSlider(QWidget *parent = 0); - - ~PlayListSlider(); - -public slots: - void setPos(int pos, int max); - -signals: - void sliderMoved (int); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - PixmapWidget *m_scroll; - int m_old; - bool m_moving, m_pressed; - int press_pos; - int m_min, m_max, m_value, pos, m_pos; - int convert(int); // value = convert(position); - -protected: - void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); -}; - -#endif diff --git a/src/ui/playlisttitlebar.cpp b/src/ui/playlisttitlebar.cpp deleted file mode 100644 index ddcc2b244..000000000 --- a/src/ui/playlisttitlebar.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2011 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 <QPainter> -#include <QResizeEvent> -#include <QMenu> -#include <QSettings> -#include <QApplication> -#include <qmmpui/playlistmodel.h> -#include "dock.h" -#include "button.h" -#include "playlisttitlebar.h" -#include "skin.h" - -// TODO {shademode, updateskin} -> do we have the shaded cursor -PlayListTitleBar::PlayListTitleBar(QWidget *parent) - : PixmapWidget(parent) -{ - m_active = false; - m_resize = false; - m_shade2 = 0; - m_model = 0; - m_shaded = false; - m_align = false; - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - m_pl = qobject_cast<PlayList*>(parent); - m_mw = qobject_cast<MainWindow*>(m_pl->parent()); - - m_close = new Button(this,Skin::PL_BT_CLOSE_N, Skin::PL_BT_CLOSE_P, Skin::CUR_PCLOSE); - connect (m_close, SIGNAL(clicked()), m_pl, SIGNAL(closed())); - - m_shade = new Button(this, Skin::PL_BT_SHADE1_N, Skin::PL_BT_SHADE1_P, Skin::CUR_PWINBUT); - connect(m_shade, SIGNAL(clicked()), SLOT(shade())); - - resize(275*m_ratio,20*m_ratio); - setMinimumWidth(275*m_ratio); - - readSettings(); - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - m_pl->resize (settings.value ("PlayList/size", QSize (m_ratio*275, m_ratio*116)).toSize()); - if (settings.value ("PlayList/shaded", false).toBool()) - shade(); - resize(m_pl->width(),height()); - m_align = true; - setCursor(m_skin->getCursor(Skin::CUR_PTBAR)); - updatePositions(); -} - - -PlayListTitleBar::~PlayListTitleBar() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("PlayList/size", QSize (m_pl->width(), m_shaded ? m_height:m_pl->height())); - settings.setValue ("PlayList/shaded", m_shaded); -} - -void PlayListTitleBar::updatePositions() -{ - int sx = (width()-275*m_ratio)/25; - m_ratio = m_skin->ratio(); - m_close->move(m_ratio*264+sx*25,m_ratio*3); - m_shade->move(m_ratio*255+sx*25,m_ratio*3); - if (m_shade2) - m_shade2->move(m_ratio*255+sx*25,m_ratio*3); -} - -void PlayListTitleBar::updatePixmap() -{ - int sx = ((m_shaded ? m_pl->width() : width())-275*m_ratio)/25; - QPixmap pixmap(275*m_ratio+sx*25,20*m_ratio); - QPainter paint; - paint.begin(&pixmap); - if (m_shaded) - { - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_TITLEBAR_SHADED2)); - for (int i = 1; i<sx+9*m_ratio; i++) - { - paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL_SHADED)); - } - } - - if (m_active) - { - if (m_shaded) - paint.drawPixmap(225*m_ratio+sx*25,0,m_skin->getPlPart(Skin::PL_TITLEBAR_SHADED1_A)); - else - { - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_A)); - for (int i = 1; i<sx+10*m_ratio; i++) - { - paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_A)); - } - paint.drawPixmap((100-12)*m_ratio+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_A)); - paint.drawPixmap(250*m_ratio+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_A)); - } - } - else - { - if (m_shaded) - paint.drawPixmap(225*m_ratio+sx*25,0,m_skin->getPlPart(Skin::PL_TITLEBAR_SHADED1_I)); - else - { - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_I)); - for (int i = 1; i<sx+10*m_ratio; i++) - { - paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_I)); - } - paint.drawPixmap((100-12)*m_ratio+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_I)); - paint.drawPixmap(250*m_ratio+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_I)); - } - } - if (m_shaded) - { - QColor col; - col.setNamedColor(QString(m_skin->getPLValue("mbbg"))); - paint.setBrush(QBrush(col)); - paint.setPen(col); - paint.drawRect(8*m_ratio, m_ratio, 235*m_ratio + sx*25, 11*m_ratio); - //draw text - paint.setFont(m_font); - paint.setPen(QString(m_skin->getPLValue("mbfg"))); - paint.drawText(9*m_ratio, 11*m_ratio, m_truncatedText); - } - paint.end(); - setPixmap(pixmap); -} - -void PlayListTitleBar::resizeEvent(QResizeEvent *) -{ - QFontMetrics metrics(m_font); - m_truncatedText = metrics.elidedText (m_text, Qt::ElideRight, width() - 35*m_ratio); - updatePixmap(); - updatePositions(); -} - -void PlayListTitleBar::mousePressEvent(QMouseEvent* event) -{ - switch ((int) event->button ()) - { - case Qt::LeftButton: - pos = event->pos(); - if (m_shaded && (width() - 30*m_ratio) < pos.x() && pos.x() < (width() - 22*m_ratio)) - { - m_resize = true; - setCursor (Qt::SizeHorCursor); - } - break; - case Qt::RightButton: - m_mw->menu()->exec(event->globalPos()); - } -} - -void PlayListTitleBar::mouseReleaseEvent(QMouseEvent*) -{ - Dock::instance()->updateDock(); - m_resize = false; - setCursor (Qt::ArrowCursor); -} - -void PlayListTitleBar::mouseMoveEvent(QMouseEvent* event) -{ - QPoint npos = (event->globalPos()-pos); - QPoint oldpos = npos; - if (m_shaded && m_resize) - { - resize((event->x() + 25*m_ratio), height()); - m_pl->resize((event->x() + 25*m_ratio), m_pl->height()); - } - else if (pos.x() < width() - 30*m_ratio) - Dock::instance()->move(m_pl, npos); -} - -void PlayListTitleBar::setActive(bool a) -{ - m_active = a; - updatePixmap(); -} - - -void PlayListTitleBar::setModel(PlayListModel *selected, PlayListModel *previous) -{ - if(previous) - disconnect(previous, 0, this, 0); //disconnect previous model - m_model = selected; - connect (m_model, SIGNAL(listChanged()), SLOT(showCurrent())); - showCurrent(); -} - -void PlayListTitleBar::readSettings() -{ - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - m_font.fromString(settings.value("PlayList/Font", QApplication::font().toString()).toString()); - m_font.setPointSize(8); -} - -void PlayListTitleBar::updateSkin() -{ - setCursor(m_skin->getCursor(Skin::CUR_PTBAR)); - if(m_ratio != m_skin->ratio()) - { - m_ratio = m_skin->ratio(); - setMinimumWidth(275*m_ratio); - updatePositions(); - } - updatePixmap(); -} - -void PlayListTitleBar::shade() -{ - m_shaded = !m_shaded; - if (m_shaded) - { - m_height = m_pl->height(); - m_shade->hide(); - m_shade2 = new Button(this, Skin::PL_BT_SHADE2_N, Skin::PL_BT_SHADE2_P, Skin::CUR_PWSNORM); - m_shade2->move(254,3); - connect(m_shade2, SIGNAL(clicked()), SLOT(shade())); - m_shade2->show(); - } - else - { - m_shade2->deleteLater(); - m_shade2 = 0; - m_shade->show(); - } - m_pl->setMinimalMode(m_shaded); - showCurrent(); - update(); - if (m_align) - Dock::instance()->align(m_pl, m_shaded? -m_height+14*m_ratio: m_height-14*m_ratio); - updatePositions(); -} - -void PlayListTitleBar::mouseDoubleClickEvent (QMouseEvent *) -{ - PlayListTitleBar::shade(); -} - -void PlayListTitleBar::showCurrent() -{ - if (m_model) - { - PlayListItem* info = m_model->currentItem(); - if (info) - { - m_text = QString("%1. ").arg(m_model->currentRow()+1); - m_text.append(info->text()); - m_text.append(QString(" (%1:%2)").arg(info->length()/60) - .arg(info->length()%60, 2, 10, QChar('0'))); - } - else - m_text.clear(); - } - QFontMetrics metrics(m_font); - m_truncatedText = metrics.elidedText (m_text, Qt::ElideRight, width() - 35*m_ratio); - updatePixmap(); -} diff --git a/src/ui/playlisttitlebar.h b/src/ui/playlisttitlebar.h deleted file mode 100644 index 01163f987..000000000 --- a/src/ui/playlisttitlebar.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 PLAYLISTTITLEBAR_H -#define PLAYLISTTITLEBAR_H - -#include "playlist.h" -#include "pixmapwidget.h" -#include "mainwindow.h" - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Skin; -class MainWindow; -class Button; -class PlayListModel; - -class PlayListTitleBar : public PixmapWidget -{ -Q_OBJECT -public: - PlayListTitleBar(QWidget *parent = 0); - ~PlayListTitleBar(); - void setActive(bool); - void readSettings(); - -public slots: - void showCurrent(); - void setModel(PlayListModel *selected, PlayListModel *previous = 0); - -private slots: - void updateSkin(); - void shade(); - -private: - void updatePositions(); - void updatePixmap(); - Skin *m_skin; - QPoint pos; - bool m_active; - PlayList* m_pl; - MainWindow* m_mw; - Button* m_close; - Button* m_shade; - Button* m_shade2; - bool m_shaded; - bool m_align, m_resize; - int m_ratio; - int m_height; - PlayListModel* m_model; - QString m_text; - QString m_truncatedText; - QFont m_font; - -protected: - void resizeEvent(QResizeEvent*); - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void mouseDoubleClickEvent(QMouseEvent*); -}; - -#endif diff --git a/src/ui/playstatus.cpp b/src/ui/playstatus.cpp deleted file mode 100644 index f12efb258..000000000 --- a/src/ui/playstatus.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 "skin.h" -#include "playstatus.h" - -PlayStatus::PlayStatus ( QWidget *parent ) - : PixmapWidget ( parent ) -{ - m_skin = Skin::instance(); - setStatus ( STOP ); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); -} - - -PlayStatus::~PlayStatus() -{} - -void PlayStatus::setStatus ( Type st ) -{ - m_status = st; - switch ( ( uint ) st ) - { - case PLAY: - { - setPixmap ( m_skin->getItem ( Skin::PLAY )); - break; - } - case STOP: - { - setPixmap ( m_skin->getItem ( Skin::STOP )); - break; - } - case PAUSE: - { - setPixmap ( m_skin->getItem ( Skin::PAUSE )); - break; - } - } -} - -void PlayStatus::updateSkin() -{ - setStatus ( m_status ); -} - - diff --git a/src/ui/playstatus.h b/src/ui/playstatus.h deleted file mode 100644 index 1ddf9748c..000000000 --- a/src/ui/playstatus.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 PLAYSTATUS_H -#define PLAYSTATUS_H - -#include "pixmapwidget.h" - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Skin; - -class PlayStatus : public PixmapWidget -{ -Q_OBJECT -public: - PlayStatus(QWidget *parent = 0); - - ~PlayStatus(); - - enum Type - { - PLAY, - STOP, - PAUSE, - }; - -void setStatus(Type); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - Type m_status; -}; - -#endif diff --git a/src/ui/pluginitem.cpp b/src/ui/pluginitem.cpp deleted file mode 100644 index 0f0fa1f58..000000000 --- a/src/ui/pluginitem.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 <QSettings> -#include <QDir> - -#include <qmmp/inputsourcefactory.h> -#include <qmmp/decoderfactory.h> -#include <qmmp/outputfactory.h> -#include <qmmp/visualfactory.h> -#include <qmmp/effectfactory.h> -#include <qmmp/effect.h> -#include <qmmp/soundcore.h> -#include <qmmp/enginefactory.h> -#include <qmmp/abstractengine.h> -#include <qmmpui/generalfactory.h> -#include <qmmpui/general.h> -#include <qmmpui/generalhandler.h> - -#include "pluginitem.h" - - -PluginItem::PluginItem(QTreeWidgetItem *parent, InputSourceFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), TRANSPORT) -{ - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - - -PluginItem::PluginItem(QTreeWidgetItem *parent, DecoderFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), DECODER) -{ - setCheckState(0, Decoder::isEnabled(factory) ? Qt::Checked : Qt::Unchecked); - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - -PluginItem::PluginItem(QTreeWidgetItem *parent, EngineFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), ENGINE) -{ - setCheckState(0, AbstractEngine::isEnabled(factory) ? Qt::Checked : Qt::Unchecked); - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - -PluginItem::PluginItem(QTreeWidgetItem *parent, EffectFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), EFFECT) -{ - setCheckState(0, Effect::isEnabled(factory) ? Qt::Checked : Qt::Unchecked); - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - -PluginItem::PluginItem(QTreeWidgetItem *parent, VisualFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), VISUAL) -{ - setCheckState(0, Visual::isEnabled(factory) ? Qt::Checked : Qt::Unchecked); - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - -PluginItem::PluginItem(QTreeWidgetItem *parent, GeneralFactory *factory, const QString &path) - : QTreeWidgetItem(parent, QStringList() << factory->properties().name << path.section('/',-1), GENERAL) -{ - setCheckState(0, General::isEnabled(factory) ? Qt::Checked : Qt::Unchecked); - m_has_about = factory->properties().hasAbout; - m_has_config = factory->properties().hasSettings; - m_factory = factory; -} - -PluginItem::~PluginItem() -{ - -} - -bool PluginItem::hasAbout() const -{ - return m_has_about; -} -bool PluginItem::hasSettings() const -{ - return m_has_config; -} - -void PluginItem::showAbout(QWidget *parent) -{ - switch(type()) - { - case PluginItem::TRANSPORT: - static_cast<InputSourceFactory *>(m_factory)->showAbout(parent); - break; - case PluginItem::DECODER: - static_cast<DecoderFactory *>(m_factory)->showAbout(parent); - break; - case PluginItem::ENGINE: - static_cast<EngineFactory *>(m_factory)->showAbout(parent); - break; - case PluginItem::EFFECT: - static_cast<EffectFactory *>(m_factory)->showAbout(parent); - break; - case PluginItem::VISUAL: - static_cast<VisualFactory *>(m_factory)->showAbout(parent); - break; - case PluginItem::GENERAL: - static_cast<GeneralFactory *>(m_factory)->showAbout(parent); - break; - default: - ; - } - -} - -void PluginItem::showSettings(QWidget *parent) -{ - switch(type()) - { - case PluginItem::TRANSPORT: - static_cast<InputSourceFactory *>(m_factory)->showSettings(parent); - break; - case PluginItem::DECODER: - static_cast<DecoderFactory *>(m_factory)->showSettings (parent); - break; - case PluginItem::ENGINE: - static_cast<EngineFactory *>(m_factory)->showSettings (parent); - break; - case PluginItem::EFFECT: - static_cast<EffectFactory *>(m_factory)->showSettings (parent); - break; - case PluginItem::VISUAL: - Visual::showSettings(static_cast<VisualFactory *>(m_factory), parent); - break; - case PluginItem::GENERAL: - GeneralHandler::instance()->showSettings(static_cast<GeneralFactory *>(m_factory), parent); - break; - default: - ; - } -} - -void PluginItem::setEnabled(bool enabled) -{ - switch(type()) - { - case PluginItem::TRANSPORT: - //dynamic_cast<InputSourceFactory *>(m_factory) - break; - case PluginItem::DECODER: - Decoder::setEnabled(static_cast<DecoderFactory *>(m_factory), enabled); - break; - case PluginItem::ENGINE: - AbstractEngine::setEnabled(static_cast<EngineFactory *>(m_factory), enabled); - break; - case PluginItem::EFFECT: - Effect::setEnabled(static_cast<EffectFactory *>(m_factory), enabled); - break; - case PluginItem::VISUAL: - Visual::setEnabled(static_cast<VisualFactory *>(m_factory), enabled); - break; - case PluginItem::GENERAL: - GeneralHandler::instance()->setEnabled(static_cast<GeneralFactory *>(m_factory), enabled); - break; - default: - ; - } -} diff --git a/src/ui/pluginitem.h b/src/ui/pluginitem.h deleted file mode 100644 index da1ba4909..000000000 --- a/src/ui/pluginitem.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 PLUGINITEM_H -#define PLUGINITEM_H - -#include <QTreeWidgetItem> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ - -class QWidget; -class InputSourceFactory; -class DecoderFactory; -class EngineFactory; -class OutputFactory; -class VisualFactory; -class EffectFactory; -class GeneralFactory; - -class PluginItem : public QTreeWidgetItem -{ -public: - - PluginItem(QTreeWidgetItem *parent, InputSourceFactory *factory, const QString &path); - PluginItem(QTreeWidgetItem *parent, DecoderFactory *factory, const QString &path); - PluginItem(QTreeWidgetItem *parent, EngineFactory *factory, const QString &path); - PluginItem(QTreeWidgetItem *parent, EffectFactory *factory, const QString &path); - PluginItem(QTreeWidgetItem *parent, VisualFactory *factory, const QString &path); - PluginItem(QTreeWidgetItem *parent, GeneralFactory *factory, const QString &path); - ~PluginItem(); - - enum PluginType - { - TRANSPORT = QTreeWidgetItem::UserType, - DECODER, - ENGINE, - EFFECT, - VISUAL, - GENERAL - }; - - bool hasAbout() const; - bool hasSettings() const; - void showAbout(QWidget *parent); - void showSettings(QWidget *parent); - void setEnabled(bool enabled); - - -private: - bool m_has_about; - bool m_has_config; - void *m_factory; -}; - -#endif diff --git a/src/ui/popupsettings.cpp b/src/ui/popupsettings.cpp deleted file mode 100644 index 837afbf3c..000000000 --- a/src/ui/popupsettings.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2010 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 <QSettings> -#include <QMenu> -#include <qmmp/qmmp.h> -#include "popupwidget.h" -#include "popupsettings.h" - -PopupSettings::PopupSettings(QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("PlayList"); - ui.transparencySlider->setValue(100 - settings.value("popup_opacity", 1.0).toDouble()*100); - ui.coverSizeSlider->setValue(settings.value ("popup_cover_size", 48).toInt()); - ui.textEdit->setPlainText(settings.value ("popup_template", DEFAULT_TEMPLATE).toString()); - ui.delaySpinBox->setValue(settings.value("popup_delay", 2500).toInt()); - ui.coverCheckBox->setChecked(settings.value("popup_show_cover",true).toBool()); - settings.endGroup(); - createMenu(); -} - - -PopupSettings::~PopupSettings() -{} - -void PopupSettings::accept() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("PlayList"); - settings.setValue("popup_opacity", 1.0 - (double)ui.transparencySlider->value()/100); - settings.setValue("popup_cover_size", ui.coverSizeSlider->value()); - settings.setValue("popup_template", ui.textEdit->toPlainText()); - settings.setValue("popup_delay", ui.delaySpinBox->value()); - settings.setValue("popup_show_cover", ui.coverCheckBox->isChecked()); - settings.endGroup(); - QDialog::accept(); -} - -void PopupSettings::createMenu() -{ - QMenu *menu = new QMenu(this); - menu->addAction(tr("Artist"))->setData("%p"); - menu->addAction(tr("Album"))->setData("%a"); - menu->addAction(tr("Title"))->setData("%t"); - menu->addAction(tr("Track number"))->setData("%n"); - menu->addAction(tr("Two-digit track number"))->setData("%NN"); - menu->addAction(tr("Genre"))->setData("%g"); - menu->addAction(tr("Comment"))->setData("%c"); - menu->addAction(tr("Composer"))->setData("%C"); - menu->addAction(tr("Duration"))->setData("%l"); - menu->addAction(tr("Disc number"))->setData("%D"); - menu->addAction(tr("File name"))->setData("%f"); - menu->addAction(tr("File path"))->setData("%F"); - menu->addAction(tr("Year"))->setData("%y"); - menu->addAction(tr("Condition"))->setData("%if(%p&%t,%p - %t,%f)"); - ui.insertButton->setMenu(menu); - connect(menu, SIGNAL(triggered (QAction *)), SLOT(insertExpression(QAction *))); -} - -void PopupSettings::insertExpression(QAction *a) -{ - ui.textEdit->insertPlainText(a->data().toString()); -} - -void PopupSettings::on_resetButton_clicked() -{ - ui.textEdit->setPlainText(DEFAULT_TEMPLATE); -} diff --git a/src/ui/popupsettings.h b/src/ui/popupsettings.h deleted file mode 100644 index ed7dde6c4..000000000 --- a/src/ui/popupsettings.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 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 SETTINGSDIALOG_H -#define SETTINGSDIALOG_H - -#include <QDialog> -#include "ui_popupsettings.h" - -class Action; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PopupSettings : public QDialog -{ -Q_OBJECT -public: - PopupSettings(QWidget *parent = 0); - ~PopupSettings(); - - -public slots: - virtual void accept(); - -private slots: - void insertExpression(QAction *); - void on_resetButton_clicked(); - -private: - void createMenu(); - Ui::PopupSettings ui; - QMap<uint, QPushButton*> m_buttons; -}; - -#endif diff --git a/src/ui/popupwidget.cpp b/src/ui/popupwidget.cpp deleted file mode 100644 index 08768b5f9..000000000 --- a/src/ui/popupwidget.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008-2010 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 <QVBoxLayout> -#include <QLabel> -#include <QApplication> -#include <QDesktopWidget> -#include <QTimer> -#include <QSettings> -#include <QApplication> -#include <qmmp/soundcore.h> -#include <qmmp/metadatamanager.h> -#include <qmmpui/metadataformatter.h> -#include <qmmpui/playlistitem.h> - -#include "popupwidget.h" - -using namespace PlayListPopup; - -PopupWidget::PopupWidget(QWidget *parent) - : QWidget(parent) -{ - setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::Dialog | Qt::FramelessWindowHint); - //setFrameStyle(QFrame::Box | QFrame::Plain); - setAttribute(Qt::WA_QuitOnClose, false); - m_item = 0; - QHBoxLayout *hlayout = new QHBoxLayout(this); //layout - m_pixlabel = new QLabel(this); - hlayout->addWidget(m_pixlabel); - - m_label1 = new QLabel(this); - hlayout->addWidget (m_label1); - - //settings - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("PlayList"); - setWindowOpacity(settings.value("popup_opacity", 1.0).toDouble()); - m_coverSize = settings.value("popup_cover_size", 48).toInt(); - m_template = settings.value("popup_template",DEFAULT_TEMPLATE).toString(); - int delay = settings.value("popup_delay", 2500).toInt(); - bool show_cover = settings.value("popup_show_cover",true).toBool(); - settings.endGroup(); - //timer - m_timer = new QTimer(this); - m_timer->setInterval(delay); - m_timer->setSingleShot (true); - connect(m_timer, SIGNAL(timeout ()), SLOT(show())); - if(show_cover) - connect(m_timer, SIGNAL(timeout ()), SLOT(loadCover())); - else - m_pixlabel->hide(); - setMouseTracking(true); -} - -PopupWidget::~PopupWidget() -{} - -void PopupWidget::mousePressEvent (QMouseEvent *) -{ - hide(); -} - -void PopupWidget::mouseMoveEvent (QMouseEvent *) -{ - hide(); -} - -void PopupWidget::prepare(PlayListItem *item, QPoint pos) -{ - pos += QPoint(15,10); - - m_item = item; - hide(); - if(!item) - { - m_timer->stop(); - return; - } - - QString title = m_template; - MetaDataFormatter f(title); - title = f.parse(item); - m_label1->setText(title); - qApp->processEvents(); - updateGeometry (); - resize(sizeHint()); - qApp->processEvents(); - m_timer->start(); - QRect rect = QApplication::desktop()->availableGeometry(this); - if(pos.x() + width() > rect.x() + rect.width()) - pos.rx() -= width(); - move(pos); -} - -void PopupWidget::deactivate() -{ - m_timer->stop(); - hide(); -} - -PlayListItem *PopupWidget::item() -{ - return m_item; -} - -void PopupWidget::loadCover() -{ - if(!m_item) - return; - QPixmap pix = MetaDataManager::instance()->getCover(m_item->url()); - if(pix.isNull()) - pix = QPixmap(":/ui_no_cover.png"); - m_pixlabel->setFixedSize(m_coverSize,m_coverSize); - m_pixlabel->setPixmap(pix.scaled(m_coverSize,m_coverSize)); - qApp->processEvents(); - updateGeometry (); - resize(sizeHint()); - qApp->processEvents(); -} diff --git a/src/ui/popupwidget.h b/src/ui/popupwidget.h deleted file mode 100644 index 5e630313e..000000000 --- a/src/ui/popupwidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008-2010 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 POPUPWIDGET_H -#define POPUPWIDGET_H - -#include <QWidget> - -#define DEFAULT_TEMPLATE "<b>%if(%t,%t,%f)</b>\n%if(%p,<br>%p,)\n%if(%a,<br>%a,)" - -class QTimer; -class QLabel; -class PlayListItem; - -namespace PlayListPopup { -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PopupWidget : public QWidget -{ - Q_OBJECT -public: - PopupWidget(QWidget *parent = 0); - - ~PopupWidget(); - - void prepare(PlayListItem *item, QPoint pos); - void deactivate(); - PlayListItem *item(); - -protected: - virtual void mousePressEvent (QMouseEvent *); - virtual void mouseMoveEvent (QMouseEvent *); - -private slots: - void loadCover(); - -private: - QTimer *m_timer; - QLabel *m_label1; - QLabel *m_pixlabel; - QString m_template; - uint m_pos; - int m_coverSize; - PlayListItem *m_item; - -}; -} - -#endif diff --git a/src/ui/positionbar.cpp b/src/ui/positionbar.cpp deleted file mode 100644 index 7b27f68e9..000000000 --- a/src/ui/positionbar.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2011 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 <QMouseEvent> -#include <QPainter> -#include <math.h> -#include "skin.h" -#include "button.h" -#include "positionbar.h" - -PositionBar::PositionBar(QWidget *parent) : PixmapWidget(parent) -{ - m_skin = Skin::instance(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setPixmap(m_skin->getPosBar()); - m_moving = false; - m_min = 0; - m_max = 0; - m_old = m_value = 0; - draw(false); - setCursor(m_skin->getCursor(Skin::CUR_POSBAR)); -} - - -PositionBar::~PositionBar() -{} - -void PositionBar::mousePressEvent(QMouseEvent *e) -{ - if(m_max <= 0) - return; - m_moving = true; - press_pos = e->x(); - if (m_pos<e->x() && e->x()<m_pos+29*m_skin->ratio()) - { - press_pos = e->x()-m_pos; - emit sliderPressed(); - } - else - { - m_value = convert(qMax(qMin(width()-30*m_skin->ratio(),e->x()-15*m_skin->ratio()),0)); - press_pos = 15*m_skin->ratio(); - emit sliderPressed(); - if (m_value!=m_old) - { - emit sliderMoved(m_value); - - } - } - draw(); -} - -void PositionBar::mouseMoveEvent (QMouseEvent *e) -{ - if (m_moving) - { - qint64 po = e->x(); - po = po - press_pos; - - if (0<=po && po<=width()-30*m_skin->ratio()) - { - m_value = convert(po); - draw(); - emit sliderMoved(m_value); - } - } -} - -void PositionBar::mouseReleaseEvent(QMouseEvent*) -{ - draw(false); - if (m_value != m_old && m_max > 0) - m_old = m_value; - m_moving = false; - if(m_max > 0) - emit sliderReleased(); -} - -void PositionBar::setValue(qint64 v) -{ - if (m_moving || m_max == 0) - return; - m_value = v; - draw(false); -} - -void PositionBar::setMaximum(qint64 max) -{ - m_max = max; - draw(false); -} - -void PositionBar::updateSkin() -{ - resize(m_skin->getPosBar().size()); - draw(false); - setCursor(m_skin->getCursor(Skin::CUR_POSBAR)); -} - -void PositionBar::draw(bool pressed) -{ - qint64 p=qint64(ceil(double(m_value-m_min)*(width()-30*m_skin->ratio())/(m_max-m_min))); - m_pixmap = m_skin->getPosBar(); - if (m_max > 0) - { - QPainter paint(&m_pixmap); - if (pressed) - paint.drawPixmap(p,0,m_skin->getButton(Skin::BT_POSBAR_P)); - else - paint.drawPixmap(p,0,m_skin->getButton(Skin::BT_POSBAR_N)); - } - setPixmap(m_pixmap); - m_pos = p; -} - -qint64 PositionBar::convert(qint64 p) -{ - return qint64(ceil(double(m_max-m_min)*(p)/(width()-30*m_skin->ratio())+m_min)); -} diff --git a/src/ui/positionbar.h b/src/ui/positionbar.h deleted file mode 100644 index 8fb768664..000000000 --- a/src/ui/positionbar.h +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009-2011 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 POSITIONBAR_H -#define POSITIONBAR_H - -#include "pixmapwidget.h" - -class QMouseEvent; -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class PositionBar : public PixmapWidget -{ - Q_OBJECT -public: - PositionBar(QWidget *parent = 0); - virtual ~PositionBar(); - -public slots: - void setValue(qint64); - qint64 value()const{return m_value;} - void setMaximum(qint64); - qint64 maximum() const {return m_max;} - -signals: - void sliderMoved (qint64); - void sliderPressed(); - void sliderReleased(); - -private slots: - void updateSkin(); - -private: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - Skin *m_skin; - bool m_moving; - qint64 press_pos; - qint64 m_max, m_min, m_pos, m_value, m_old; - QPixmap m_pixmap; - qint64 convert(qint64); // value = convert(position); - void draw(bool pressed = true); -}; - -#endif diff --git a/src/ui/preseteditor.cpp b/src/ui/preseteditor.cpp deleted file mode 100644 index 8e5249c0c..000000000 --- a/src/ui/preseteditor.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 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 <QIcon> -#include "eqpreset.h" -#include "preseteditor.h" - -PresetEditor::PresetEditor(QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - setAttribute(Qt::WA_DeleteOnClose); - connect(ui.loadButton,SIGNAL(clicked()),SLOT(loadPreset())); - connect(ui.deleteButton,SIGNAL(clicked()),SLOT(deletePreset())); - ui.loadButton->setIcon(QIcon::fromTheme("document-open")); - ui.deleteButton->setIcon(QIcon::fromTheme("edit-delete")); -} - - -PresetEditor::~PresetEditor() -{ - while (ui.presetListWidget->count () !=0) - ui.presetListWidget->takeItem (0); - - while (ui.autoPresetListWidget->count () !=0) - ui.autoPresetListWidget->takeItem (0); -} - -void PresetEditor::addPresets(const QList<EQPreset*> &presets) -{ - foreach(QListWidgetItem *item, presets) - { - ui.presetListWidget->addItem(item); - } -} - -void PresetEditor::addAutoPresets(const QList<EQPreset*> &presets) -{ - foreach(QListWidgetItem *item, presets) - { - ui.autoPresetListWidget->addItem(item); - } -} - -void PresetEditor::loadPreset() -{ - EQPreset* preset = 0; - if (ui.tabWidget->currentIndex () == 0) - preset = (EQPreset *) ui.presetListWidget->currentItem (); - if (ui.tabWidget->currentIndex () == 1) - preset = (EQPreset *) ui.autoPresetListWidget->currentItem (); - if (preset) - emit presetLoaded(preset); -} - -void PresetEditor::deletePreset() -{ - EQPreset* preset = 0; - if (ui.tabWidget->currentIndex () == 0) - preset = (EQPreset *) ui.presetListWidget->currentItem (); - if (ui.tabWidget->currentIndex () == 1) - preset = (EQPreset *) ui.autoPresetListWidget->currentItem (); - if (preset) - emit presetDeleted(preset); -} diff --git a/src/ui/preseteditor.h b/src/ui/preseteditor.h deleted file mode 100644 index 35302b185..000000000 --- a/src/ui/preseteditor.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 PRESETEDITOR_H -#define PRESETEDITOR_H - -#include <QDialog> - -#include "ui_preseteditor.h" - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ - -class EQPreset; - -class PresetEditor : public QDialog -{ -Q_OBJECT -public: - PresetEditor(QWidget *parent = 0); - - ~PresetEditor(); - - void addPresets(const QList<EQPreset*>&); - void addAutoPresets(const QList<EQPreset*>&); - -signals: - void presetLoaded(EQPreset*); - void presetDeleted(EQPreset*); - -private slots: - void loadPreset(); - void deletePreset(); - -private: - Ui::PresetEditor ui; - -}; - -#endif diff --git a/src/ui/qmmpstarter.cpp b/src/ui/qmmpstarter.cpp index 71bef91f6..c24bd5789 100644 --- a/src/ui/qmmpstarter.cpp +++ b/src/ui/qmmpstarter.cpp @@ -27,8 +27,12 @@ #include <unistd.h> #include <sys/types.h> #include <string.h> +#include <qmmp/qmmp.h> #include <qmmpui/commandlinemanager.h> -#include "mainwindow.h" +#include <qmmpui/mediaplayer.h> +#include <qmmpui/playlistparser.h> +#include <qmmpui/generalhandler.h> +#include <qmmpui/uiloader.h> #include "qmmpstarter.h" #include "builtincommandlineoption.h" @@ -40,7 +44,7 @@ using namespace std; -QMMPStarter::QMMPStarter(int argc,char **argv, QObject* parent) : QObject(parent), mw(NULL) +QMMPStarter::QMMPStarter(int argc,char **argv, QObject* parent) : QObject(parent) { m_option_manager = new BuiltinCommandLineOption(this); QStringList tmp; @@ -114,18 +118,35 @@ QMMPStarter::QMMPStarter(int argc,char **argv, QObject* parent) : QObject(parent QMMPStarter::~QMMPStarter() { - if (mw) - delete mw; + /*if (mw) + delete mw;*/ } void QMMPStarter::startMainWindow() { connect(m_server, SIGNAL(newConnection()), SLOT(readCommand())); QStringList args = argString.split("\n", QString::SkipEmptyParts); - mw = new MainWindow(); + + //prepare libqmmp and libqmmpui libraries for playing + /*m_player = */new MediaPlayer(this); + //m_core = */SoundCore::instance(); + /*m_pl_manager = */PlayListManager::instance(); + //additional featuries + new PlaylistParser(this); + /*m_generalHandler = */new GeneralHandler(this); + + UiFactory *factory = UiLoader::currentUiFactory(); + if(factory) + { + QObject *ui = factory->create(); + //ui->setParent(this); + } + + + /*mw = new MainWindow(); processCommandArgs(args, QDir::currentPath()); if(args.isEmpty()) - mw->resume(); + mw->resume();*/ } void QMMPStarter::writeCommand() @@ -187,7 +208,7 @@ QString QMMPStarter::processCommandArgs(const QStringList &slist, const QString& } if(!paths.isEmpty()) { - m_option_manager->executeCommand(QString(), paths, cwd, mw); //add paths only + m_option_manager->executeCommand(QString(), paths, cwd/*, mw*/); //add paths only return QString(); } QHash<QString, QStringList> commands = m_option_manager->splitArgs(slist); @@ -200,7 +221,7 @@ QString QMMPStarter::processCommandArgs(const QStringList &slist, const QString& if (CommandLineManager::hasOption(key)) return CommandLineManager::executeCommand(key, commands.value(key)); else if (m_option_manager->identify(key)) - m_option_manager->executeCommand(key, commands.value(key), cwd, mw); + m_option_manager->executeCommand(key, commands.value(key), cwd); else return QString(); } diff --git a/src/ui/qmmpstarter.h b/src/ui/qmmpstarter.h index 314716084..95596ea49 100644 --- a/src/ui/qmmpstarter.h +++ b/src/ui/qmmpstarter.h @@ -66,7 +66,7 @@ private: void startMainWindow(); private: - MainWindow* mw; + //MainWindow* mw; QString argString; BuiltinCommandLineOption* m_option_manager; QLocalServer *m_server; diff --git a/src/ui/shadedbar.cpp b/src/ui/shadedbar.cpp deleted file mode 100644 index bdabbe516..000000000 --- a/src/ui/shadedbar.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 <QMouseEvent> -#include <QPainter> -#include <QPainter> -#include <math.h> -#include "skin.h" -#include "shadedbar.h" - -ShadedBar::ShadedBar(QWidget *parent, uint slider1, uint slider2, uint slider3) - : QWidget(parent) -{ - m_slider1 = slider1; - m_slider2 = slider2; - m_slider3 = slider3; - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - if(slider1 == Skin::EQ_VOLUME1) - resize(m_ratio*97,m_ratio*7); - else - resize(m_ratio*42,m_ratio*7); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - m_moving = false; - m_min = 0; - m_max = 100; - m_old = m_value = 0; - draw(); -} - - -ShadedBar::~ShadedBar() -{ -} - -void ShadedBar::mousePressEvent(QMouseEvent *e) -{ - m_moving = true; - press_pos = e->x(); - if(m_pos<e->x() && e->x()<m_pos+3) - { - press_pos = e->x()-m_pos; - } - else - { - m_value = convert(qMax(qMin(width()-3,e->x()-1),0)); - press_pos = 1; - if (m_value!=m_old) - { - emit sliderMoved(m_value); - } - } - draw(); -} - -void ShadedBar::mouseMoveEvent (QMouseEvent *e) -{ - if(m_moving) - { - int po = e->x(); - po = po - press_pos; - - if(0<=po && po<=width()-3) - { - m_value = convert(po); - draw(); - emit sliderMoved(m_value); - } - } -} - -void ShadedBar::mouseReleaseEvent(QMouseEvent*) -{ - m_moving = false; - draw(); - m_old = m_value; -} - -void ShadedBar::setValue(int v) -{ - if (m_moving || m_max == 0) - return; - m_value = v; - draw(); -} - -void ShadedBar::setRange(int min, int max) -{ - m_max = max; - m_min = min; - draw(); -} - -void ShadedBar::updateSkin() -{ - m_ratio = m_skin->ratio(); - if(m_slider1 == Skin::EQ_VOLUME1) - resize(m_ratio*97,m_ratio*7); - else - resize(m_ratio*42,m_ratio*7); - draw(); -} - -void ShadedBar::draw() -{ - if (m_value <= m_min + (m_max - m_min)/3) - m_pixmap = m_skin->getEqPart(m_slider1); - else if(m_min + (m_max - m_min)/3 < m_value && m_value <= m_min + 2*(m_max - m_min)/3) - m_pixmap = m_skin->getEqPart(m_slider2); - else - m_pixmap = m_skin->getEqPart(m_slider3); - m_pos = int(ceil(double(m_value-m_min)*(width()-3*m_ratio)/(m_max-m_min))); - update(); -} - -int ShadedBar::convert(int p) -{ - return int(ceil(double(m_max-m_min)*(p)/(width()-3)+m_min)); -} - -void ShadedBar::paintEvent(QPaintEvent*) -{ - QPainter paint(this); - paint.drawPixmap(m_pos,0,m_pixmap); -} - diff --git a/src/ui/shadedbar.h b/src/ui/shadedbar.h deleted file mode 100644 index 09272e9e1..000000000 --- a/src/ui/shadedbar.h +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 SHADEDBAR_H -#define SHADEDBAR_H - -#include <QWidget> - -class QMouseEvent; -class QPaintEvent; -class Skin; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class ShadedBar : public QWidget -{ - Q_OBJECT -public: - ShadedBar(QWidget *parent = 0, uint slider1 = 0, uint slider2 = 0, uint slider3 = 0); - - ~ShadedBar(); - int value() - { - return m_value; - } - int isPressed() - { - return m_moving; - } - void setRange(int min, int max); - -public slots: - void setValue(int); - -signals: - void sliderMoved (int); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - bool m_moving; - int press_pos; - int m_max, m_min, m_pos, m_value, m_old, m_x; - QPixmap m_pixmap; - int convert(int); // value = convert(position); - void draw(); - uint m_slider1, m_slider2, m_slider3; - int m_ratio; - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void paintEvent(QPaintEvent*); -}; - -#endif diff --git a/src/ui/shadedvisual.cpp b/src/ui/shadedvisual.cpp deleted file mode 100644 index e249752ca..000000000 --- a/src/ui/shadedvisual.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 <QTimer> -#include <math.h> -#include "skin.h" -#include "mainvisual.h" -#include "inlines.h" -#include "shadedvisual.h" - -#define VISUAL_NODE_SIZE 512 //samples -#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE) - -ShadedVisual::ShadedVisual(QWidget *parent) : Visual(parent) -{ - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - resize(m_ratio*38,m_ratio*5); - m_pixmap = QPixmap (m_ratio*38,m_ratio*5); - m_timer = new QTimer(this); - connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - m_left_buffer = new short[VISUAL_BUFFER_SIZE]; - m_right_buffer = new short[VISUAL_BUFFER_SIZE]; - m_buffer_at = 0; - m_timer->setInterval(50); - m_timer->start(); - clear(); -} - -ShadedVisual::~ShadedVisual() -{ - delete [] m_left_buffer; - delete [] m_right_buffer; -} - -void ShadedVisual::add(unsigned char *data, qint64 size, int chan) -{ - if (!m_timer->isActive ()) - return; - - if(VISUAL_BUFFER_SIZE == m_buffer_at) - { - m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - return; - } - - int frames = qMin((int)size/chan >> 1, VISUAL_BUFFER_SIZE - m_buffer_at); - - if (chan >= 2) - { - stereo16_from_multichannel(m_left_buffer + m_buffer_at, - m_right_buffer + m_buffer_at,(short *) data, frames, chan); - } - else - { - memcpy(m_left_buffer + m_buffer_at, (short *) data, frames << 1); - memcpy(m_right_buffer + m_buffer_at, (short *) data, frames << 1); - } - - m_buffer_at += frames; -} - -void ShadedVisual::clear() -{ - m_buffer_at = 0; - m_l = 0; - m_r = 0; - m_pixmap.fill(m_skin->getVisColor(0)); - update(); -} - -void ShadedVisual::timeout() -{ - m_pixmap.fill(m_skin->getVisColor(0)); - - mutex()->lock (); - if(m_buffer_at < VISUAL_NODE_SIZE) - { - mutex()->unlock (); - return; - } - - process (m_left_buffer, m_right_buffer); - m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - QPainter p(&m_pixmap); - draw (&p); - mutex()->unlock (); - update(); -} - -void ShadedVisual::process (short *left, short *right) -{ - int step = (VISUAL_NODE_SIZE << 8)/74; - int pos = 0; - int l = 0; - int r = 0; - int j_l = 0, j_r = 0; - - for (int i = 0; i < 75; ++i) - { - pos += step; - - if (left) - { - j_l = abs((left[pos >> 8] >> 12)); - - if (j_l > 15) - j_l = 15; - l = qMax(l, j_l); - } - if (right) - { - j_r = abs((right[pos >> 8] >> 12)); - if (j_r > 15) - j_r = 15; - r = qMax(r, j_r); - } - } - m_l -= 0.5; - m_l = m_l > l ? m_l : l; - m_r -= 0.5; - m_r = m_r > r ? m_r : r; -} - -void ShadedVisual::draw (QPainter *p) -{ - for (int i = 0; i < m_l; ++i) - { - p->fillRect (i*3*m_ratio, 0, 3*m_ratio, 2*m_ratio, QBrush(m_skin->getVisColor (17-i))); - } - for (int i = 0; i < m_r; ++i) - { - p->fillRect (i*3*m_ratio, 3*m_ratio, 3*m_ratio, 2*m_ratio, QBrush(m_skin->getVisColor (17-i))); - } -} - -void ShadedVisual::paintEvent (QPaintEvent *) -{ - QPainter painter (this); - painter.drawPixmap (0,0,m_pixmap); -} - -void ShadedVisual::hideEvent (QHideEvent *) -{ - m_timer->stop(); -} - -void ShadedVisual::showEvent (QShowEvent *) -{ - m_timer->start(); -} - -void ShadedVisual::updateSkin() -{ - m_ratio = m_skin->ratio(); - resize(m_ratio*38,m_ratio*5); - m_pixmap = QPixmap (m_ratio*38,m_ratio*5); - clear(); -} diff --git a/src/ui/shadedvisual.h b/src/ui/shadedvisual.h deleted file mode 100644 index 0592ec78f..000000000 --- a/src/ui/shadedvisual.h +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 SHADEDVISUAL_H -#define SHADEDVISUAL_H - -#include <QPainter> -#include <qmmp/visual.h> -#include <qmmp/buffer.h> - -class QTimer; -class QPixmap; -class Skin; -//class VisualNode; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class ShadedVisual : public Visual -{ - Q_OBJECT -public: - ShadedVisual(QWidget *parent = 0); - - ~ShadedVisual(); - - void add(unsigned char *data, qint64 size, int chan); - void clear(); - - void paintEvent (QPaintEvent *); - void hideEvent (QHideEvent *); - void showEvent (QShowEvent *); - -public slots: - void timeout(); - -private slots: - void updateSkin(); - -private: - void process (short *l, short *r); - void draw (QPainter *); - Skin *m_skin; - QTimer *m_timer; - QPixmap m_pixmap; - short *m_left_buffer; - short *m_right_buffer; - int m_buffer_at; - double m_l, m_r; - int m_ratio; - -}; - -#endif diff --git a/src/ui/shortcutdialog.cpp b/src/ui/shortcutdialog.cpp deleted file mode 100644 index 421c08169..000000000 --- a/src/ui/shortcutdialog.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 <QKeyEvent> -#include "shortcutdialog.h" - -ShortcutDialog::ShortcutDialog(const QString &key, QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - ui.keyLineEdit->setText(key); -} - -ShortcutDialog::~ShortcutDialog() -{ -} - -void ShortcutDialog::keyPressEvent (QKeyEvent *event) -{ - int key = event->key(); - switch (key) - { - case Qt::Key_Shift: - case Qt::Key_Control: - case Qt::Key_Meta: - case Qt::Key_Alt: - case Qt::Key_AltGr: - case Qt::Key_Super_L: - case Qt::Key_Super_R: - case Qt::Key_Menu: - case 0: - case Qt::Key_unknown: - key = 0; - ui.keyLineEdit->clear(); - QWidget::keyPressEvent(event); - return; - } - QKeySequence seq(event->modifiers() + event->key()); - ui.keyLineEdit->setText(seq.toString()); - QWidget::keyPressEvent(event); -} - -const QString ShortcutDialog::key() -{ - return ui.keyLineEdit->text(); -} diff --git a/src/ui/shortcutdialog.h b/src/ui/shortcutdialog.h deleted file mode 100644 index 62aedd5a5..000000000 --- a/src/ui/shortcutdialog.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 SHORTCUTDIALOG_H -#define SHORTCUTDIALOG_H - -#include <QDialog> -#include "ui_shortcutdialog.h" - -class QKeyEvent; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class ShortcutDialog : public QDialog -{ - Q_OBJECT -public: - ShortcutDialog(const QString &key, QWidget *parent = 0); - - ~ShortcutDialog(); - - const QString key(); - -protected: - virtual void keyPressEvent (QKeyEvent *event); - -private: - Ui::ShortcutDialog ui; - -}; - -#endif diff --git a/src/ui/shortcutitem.cpp b/src/ui/shortcutitem.cpp deleted file mode 100644 index eb8baf164..000000000 --- a/src/ui/shortcutitem.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 "actionmanager.h" -#include "shortcutitem.h" - -ShortcutItem::ShortcutItem(QTreeWidgetItem *parent, int type) : QTreeWidgetItem(parent, QStringList() - << ActionManager::instance()->action(type)->text().remove("&") - << ActionManager::instance()->action(type)->shortcut()) -{ - m_action = ActionManager::instance()->action(type); - setIcon(0, m_action->icon()); -} - -ShortcutItem::~ShortcutItem() -{} - -QAction *ShortcutItem::action() -{ - return m_action; -} diff --git a/src/ui/shortcutitem.h b/src/ui/shortcutitem.h deleted file mode 100644 index a8cbd9f7c..000000000 --- a/src/ui/shortcutitem.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 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 SHORTCUTITEM_H -#define SHORTCUTITEM_H - -#include <QTreeWidgetItem> - -class QWidget; -class QAction; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ - -class ShortcutItem : public QTreeWidgetItem -{ -public: - - ShortcutItem(QTreeWidgetItem *parent, int type); - ~ShortcutItem(); - QAction *action(); - -private: - QAction *m_action; - -}; - -#endif //SHORTCUTITEM_H diff --git a/src/ui/skin.cpp b/src/ui/skin.cpp deleted file mode 100644 index c17471d2f..000000000 --- a/src/ui/skin.cpp +++ /dev/null @@ -1,852 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * Based on Promoe, an XMMS2 Client * - * Copyright (C) 2005-2006 by XMMS2 Team * - * * - * 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 <QCoreApplication> -#include <QDir> -#include <QSettings> -#include <QPainter> -#include <QPolygon> -#include <QImage> -#include <QBuffer> -#include <QAction> -#include <qmmp/qmmp.h> -#include "actionmanager.h" -#include "skin.h" -#include "cursorimage.h" - -Skin *Skin::m_instance = 0; - -Skin *Skin::instance() -{ - if (!m_instance) - m_instance = new Skin(); - return m_instance; -} - -QPixmap Skin::getPixmap (const QString& name, QDir dir) -{ - dir.setFilter (QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = dir.entryInfoList(); - for (int j = 0; j < f.size(); ++j) - { - QFileInfo fileInfo = f.at (j); - QString fn = fileInfo.fileName().toLower(); - if (fn.section (".",0,0) == name) - { - return QPixmap (fileInfo.filePath()); - } - } - return QPixmap(); -} - -Skin::Skin (QObject *parent) : QObject (parent) -{ - m_instance = this; - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - QString path = settings.value("General/skin_path").toString(); - if (path.isEmpty() || !QDir(path).exists ()) - path = ":/default"; - m_double_size = settings.value("General/double_size", false).toBool(); - ACTION(ActionManager::WM_DOUBLE_SIZE)->setChecked(m_double_size); - setSkin (QDir::cleanPath(path)); - /* skin directory */ - QDir skinDir(QDir::homePath()+"/.qmmp"); - skinDir.mkdir ("skins"); -} - -Skin::~Skin() -{} - -void Skin::setSkin (const QString& path) -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_use_cursors = settings.value("General/skin_cursors", false).toBool(); - m_double_size = ACTION(ActionManager::WM_DOUBLE_SIZE)->isChecked(); - settings.setValue("General/skin_path",path); - qDebug ("Skin: using %s",qPrintable(path)); - m_skin_dir = QDir (path); - //clear old values - m_pledit_txt.clear(); - buttons.clear(); - titlebar.clear(); - m_numbers.clear(); - m_pl_parts.clear(); - m_eq_parts.clear(); - m_eq_bar.clear(); - m_eq_spline.clear(); - m_vis_colors.clear(); - cursors.clear(); - //load skin parts - loadPLEdit(); - loadMain(); - loadButtons(); - loadShufRep(); - loadTitleBar(); - loadPosBar(); - loadNumbers(); - loadPlayList(); - loadEq_ex(); - loadEqMain(); - loadVisColor(); - loadLetters(); - loadMonoSter(); - loadVolume(); - loadBalance(); - loadRegion(); - loadCursors(); - if(m_double_size) - { - uint key; - foreach(key, buttons.keys()) - buttons[key] = scalePixmap(buttons[key]); - foreach(key, titlebar.keys()) - titlebar[key] = scalePixmap(titlebar[key]); - foreach(key, m_pl_parts.keys()) - m_pl_parts[key] = scalePixmap(m_pl_parts[key]); - foreach(key, m_eq_parts.keys()) - m_eq_parts[key] = scalePixmap(m_eq_parts[key]); - foreach(key, m_ms_parts.keys()) - m_ms_parts[key] = scalePixmap(m_ms_parts[key]); - foreach(key, m_parts.keys()) - m_parts[key] = scalePixmap(m_parts[key]); - foreach(QChar c, m_letters.keys()) - m_letters[c] = scalePixmap(m_letters[c]); - m_main = scalePixmap(m_main); - posbar = scalePixmap(posbar); - int i; - for(i = 0; i < m_numbers.size(); ++i) - m_numbers[i] = scalePixmap(m_numbers[i]); - - for(i = 0; i < m_eq_bar.size(); ++i) - m_eq_bar[i] = scalePixmap(m_eq_bar[i]); - - for(i = 0; i < m_eq_spline.size(); ++i) - m_eq_spline[i] = scalePixmap(m_eq_spline[i]); - - for(i = 0; i < m_volume.size(); ++i) - m_volume[i] = scalePixmap(m_volume[i]); - for(i = 0; i < m_balance.size(); ++i) - m_balance[i] = scalePixmap(m_balance[i]); - } - emit skinChanged(); -} - -void Skin::reloadSkin() -{ - setSkin (m_skin_dir.absolutePath ()); -} - -void Skin::loadMain() -{ - QPixmap *pixmap = getPixmap ("main"); - if (!pixmap) - pixmap = getDummyPixmap("main"); - - m_main = pixmap->copy (0,0,275,116); - delete pixmap; -} - -void Skin::loadCursors() -{ - if(!m_use_cursors) - { - for(int i = CUR_NORMAL; i <= CUR_WSWINBUT; ++i) - cursors[i] = QCursor(Qt::ArrowCursor); - cursors[CUR_PSIZE] = QCursor(Qt::SizeFDiagCursor); - return; - } - cursors[CUR_NORMAL] = createCursor(getPath("normal")); - cursors[CUR_CLOSE] = createCursor(getPath("close")); - cursors[CUR_MAINMENU] = createCursor(getPath("mainmenu")); - cursors[CUR_MIN] = createCursor(getPath("min")); - cursors[CUR_POSBAR] = createCursor(getPath("posbar.cur")); - cursors[CUR_SONGNAME] = createCursor(getPath("songname")); - cursors[CUR_TITLEBAR] = createCursor(getPath("titlebar.cur")); - cursors[CUR_VOLBAL] = createCursor(getPath("volbal")); - cursors[CUR_WINBUT] = createCursor(getPath("winbut")); - - cursors[CUR_WSNORMAL] = createCursor(getPath("wsnormal")); - cursors[CUR_WSPOSBAR] = createCursor(getPath("wsposbar")); - - cursors[CUR_EQCLOSE] = createCursor(getPath("eqclose")); - cursors[CUR_EQNORMAL] = createCursor(getPath("eqnormal")); - cursors[CUR_EQSLID] = createCursor(getPath("eqslid")); - cursors[CUR_EQTITLE] = createCursor(getPath("eqtitle")); - - cursors[CUR_PCLOSE] = createCursor(getPath("pclose")); - cursors[CUR_PNORMAL] = createCursor(getPath("pnormal")); - cursors[CUR_PSIZE] = createCursor(getPath("psize")); - if(cursors[CUR_PSIZE].shape() == Qt::ArrowCursor) - cursors[CUR_PSIZE] = QCursor(Qt::SizeFDiagCursor); - cursors[CUR_PTBAR] = createCursor(getPath("ptbar")); - cursors[CUR_PVSCROLL] = createCursor(getPath("pvscroll")); - cursors[CUR_PWINBUT] = createCursor(getPath("pwinbut")); - - cursors[CUR_PWSNORM] = createCursor(getPath("pwsnorm")); - cursors[CUR_PWSSIZE] = createCursor(getPath("pwssize")); - - cursors[CUR_VOLBAR] = createCursor(getPath("volbar")); - cursors[CUR_WSCLOSE] = createCursor(getPath("wsclose")); - cursors[CUR_WSMIN] = createCursor(getPath("wsmin")); - cursors[CUR_WSWINBUT] = createCursor(getPath("wswinbut")); -} - -void Skin::loadButtons() -{ - - QPixmap *pixmap = getPixmap ("cbuttons"); - - if (!pixmap) - pixmap = getDummyPixmap("cbuttons"); - - buttons[BT_PREVIOUS_N] = pixmap->copy (0, 0,23,18); - buttons[BT_PREVIOUS_P] = pixmap->copy (0,18,23,18); - - buttons[BT_PLAY_N] = pixmap->copy (23, 0,23,18); - buttons[BT_PLAY_P] = pixmap->copy (23,18,23,18); - - buttons[BT_PAUSE_N] = pixmap->copy (46, 0,23,18); - buttons[BT_PAUSE_P] = pixmap->copy (46,18,23,18); - - buttons[BT_STOP_N] = pixmap->copy (69, 0,23,18); - buttons[BT_STOP_P] = pixmap->copy (69,18,23,18); - - buttons[BT_NEXT_N] = pixmap->copy (92, 0,22,18); - buttons[BT_NEXT_P] = pixmap->copy (92,18,22,18); - - buttons[BT_EJECT_N] = pixmap->copy (114, 0,22,16); - buttons[BT_EJECT_P] = pixmap->copy (114,16,22,16); - delete pixmap; -} - -void Skin::loadTitleBar() -{ - QPixmap *pixmap = getPixmap ("titlebar"); - - if (!pixmap) - pixmap = getDummyPixmap("titlebar"); - - buttons[BT_MENU_N] = pixmap->copy (0,0,9,9); - buttons[BT_MENU_P] = pixmap->copy (0,9,9,9); - buttons[BT_MINIMIZE_N] = pixmap->copy (9,0,9,9); - buttons[BT_MINIMIZE_P] = pixmap->copy (9,9,9,9); - buttons[BT_CLOSE_N] = pixmap->copy (18,0,9,9); - buttons[BT_CLOSE_P] = pixmap->copy (18,9,9,9); - buttons[BT_SHADE1_N] = pixmap->copy (0,18,9,9); - buttons[BT_SHADE1_P] = pixmap->copy (9,18,9,9); - buttons[BT_SHADE2_N] = pixmap->copy (0,27,9,9); - buttons[BT_SHADE2_P] = pixmap->copy (9,27,9,9); - titlebar[TITLEBAR_A] = pixmap->copy (27, 0,275,14); - titlebar[TITLEBAR_I] = pixmap->copy (27,15,275,14); - titlebar[TITLEBAR_SHADED_A] = pixmap->copy (27,29,275,14); - titlebar[TITLEBAR_SHADED_I] = pixmap->copy (27,42,275,14); - delete pixmap; -} - -void Skin::loadPosBar() -{ - QPixmap *pixmap = getPixmap ("posbar"); - - if (!pixmap) - pixmap = getDummyPixmap("posbar"); - - if (pixmap->width() > 249) - { - buttons[BT_POSBAR_N] = pixmap->copy (248,0,29, pixmap->height()); - buttons[BT_POSBAR_P] = pixmap->copy (278,0,29, pixmap->height()); - } - else - { - QPixmap dummy(29, pixmap->height()); - dummy.fill(Qt::transparent); - buttons[BT_POSBAR_N] = dummy; - buttons[BT_POSBAR_P] = dummy; - } - posbar = pixmap->copy (0,0,248,pixmap->height()); - delete pixmap; -} - -void Skin::loadNumbers() -{ - QPixmap *pixmap = getPixmap ("nums_ex"); - if (!pixmap) - pixmap = getPixmap ("numbers"); - if (!pixmap) - pixmap = getDummyPixmap("numbers"); - - for (uint i = 0; i < 10; i++) - m_numbers << pixmap->copy (i*9, 0, 9, pixmap->height()); - - if (pixmap->width() > 107) - m_numbers << pixmap->copy(99, 0, 9, pixmap->height()); - else - { - // We didn't find "-" symbol. So we have to extract it from "2". - // Winamp uses this method too. - QPixmap pix; - if(pixmap->width() > 98) - pix = pixmap->copy(90,0,9,pixmap->height()); - else - { - pix = QPixmap(9, pixmap->height()); - pix.fill(Qt::transparent); - } - QPixmap minus = pixmap->copy(18,pixmap->height()/2,9,1); - QPainter paint(&pix); - paint.drawPixmap(0,pixmap->height()/2, minus); - m_numbers << pix; - } - delete pixmap; -} - -void Skin::loadPlayList() -{ - QPixmap *pixmap = getPixmap ("pledit"); - - if (!pixmap) - pixmap = getDummyPixmap("pledit"); - - m_pl_parts[PL_CORNER_UL_A] = pixmap->copy (0,0,25,20); - m_pl_parts[PL_CORNER_UL_I] = pixmap->copy (0,21,25,20); - - m_pl_parts[PL_CORNER_UR_A] = pixmap->copy (153,0,25,20); - m_pl_parts[PL_CORNER_UR_I] = pixmap->copy (153,21,25,20); - - m_pl_parts[PL_TITLEBAR_A] = pixmap->copy (26,0,100,20); - m_pl_parts[PL_TITLEBAR_I] = pixmap->copy (26,21,100,20); - - m_pl_parts[PL_TFILL1_A] = pixmap->copy (127,0,25,20); - m_pl_parts[PL_TFILL1_I] = pixmap->copy (127,21,25,20); - - //m_pl_parts[PL_TFILL2_A] = pixmap->copy();//FIXME: ����� - //m_pl_parts[PL_TFILL2_I] = pixmap->copy(); - - m_pl_parts[PL_LFILL] = pixmap->copy (0,42,12,29); - m_pl_parts[PL_RFILL] = pixmap->copy (31,42,20,29); //??? - - m_pl_parts[PL_LSBAR] = pixmap->copy (0,72,125,38); - m_pl_parts[PL_RSBAR] = pixmap->copy (126,72,150,38); - m_pl_parts[PL_SFILL1] = pixmap->copy (179,0,25,38); - m_pl_parts[PL_SFILL2] = pixmap->copy (250,21,75,38); - m_pl_parts[PL_TITLEBAR_SHADED1_A] = pixmap->copy (99,42,50,14); - m_pl_parts[PL_TITLEBAR_SHADED1_I] = pixmap->copy (99,57,50,14); - m_pl_parts[PL_TITLEBAR_SHADED2] = pixmap->copy (72,42,25,14); - m_pl_parts[PL_TFILL_SHADED] = pixmap->copy (72,57,25,14); - - m_pl_parts[PL_CONTROL] = pixmap->copy(129,94,60,8); - - buttons[PL_BT_ADD] = pixmap->copy (11,80,25,18); - buttons[PL_BT_SUB] = pixmap->copy (40,80,25,18); - buttons[PL_BT_SEL] = pixmap->copy (70,80,25,18); - buttons[PL_BT_SORT] = pixmap->copy (99,80,25,18); - buttons[PL_BT_LST] = pixmap->copy(229, 80, 25, 18); - buttons[PL_BT_SCROLL_N] = pixmap->copy (52,53,8,18); - buttons[PL_BT_SCROLL_P] = pixmap->copy (61,53,8,18); - - buttons[PL_BT_CLOSE_N] = pixmap->copy (167,3,9,9); - buttons[PL_BT_CLOSE_P] = pixmap->copy (52,42,9,9); - buttons[PL_BT_SHADE1_N] = pixmap->copy (158,3,9,9); - buttons[PL_BT_SHADE1_P] = pixmap->copy (62,42,9,9); - buttons[PL_BT_SHADE2_N] = pixmap->copy (129,45,9,9); - buttons[PL_BT_SHADE2_P] = pixmap->copy (150,42,9,9); - -} - -QPixmap *Skin::getPixmap (const QString& name) -{ - m_skin_dir.setFilter (QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = m_skin_dir.entryInfoList(); - for (int j = 0; j < f.size(); ++j) - { - QFileInfo fileInfo = f.at (j); - QString fn = fileInfo.fileName().toLower(); - if (fn.section (".",0,0) == name) - { - return new QPixmap (fileInfo.filePath()); - } - } - return 0; -} - -QString Skin::getPath (const QString& name) -{ - m_skin_dir.setFilter (QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = m_skin_dir.entryInfoList(); - bool nameHasExt = name.contains('.'); - for (int j = 0; j < f.size(); ++j) - { - QFileInfo fileInfo = f.at (j); - QString fn = fileInfo.fileName().toLower(); - if (!nameHasExt && fn.section (".",0,0) == name) - { - return fileInfo.filePath(); - } else if (nameHasExt && fn == name) - { - return fileInfo.filePath(); - } - } - return QString(); -} - - -void Skin::loadPLEdit() -{ - QString path = findFile("pledit.txt", m_skin_dir); - if (path.isEmpty()) - path = findFile("pledit.txt", ":/default"); - if (path.isEmpty()) - qFatal("Skin: invalid default skin"); - - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - qFatal("Skin: unable to open %s", qPrintable(path)); - - while (!file.atEnd ()) - { - QByteArray line = file.readLine (); - QList<QByteArray> l = line.split ('='); - if (l.count () == 2) - { - m_pledit_txt[l[0].toLower () ] = l[1].trimmed(); - } - else if (line.length() == 0) - { - break; - } - } - if (!m_pledit_txt.keys().contains("mbbg")) - m_pledit_txt["mbbg"] = m_pledit_txt["normalbg"]; - if (!m_pledit_txt.keys().contains("mbfg")) - m_pledit_txt["mbfg"] = m_pledit_txt["normal"]; -} - -void Skin::loadEqMain() -{ - QPixmap *pixmap = getPixmap ("eqmain"); - - if (!pixmap) - pixmap = getDummyPixmap("eqmain"); - - m_eq_parts[ EQ_MAIN ] = pixmap->copy (0,0,275,116); - m_eq_parts[ EQ_TITLEBAR_A ] = pixmap->copy (0,134,275,14); - m_eq_parts[ EQ_TITLEBAR_I ] = pixmap->copy (0,149,275,14); - - if (pixmap->height() > 295) - m_eq_parts[ EQ_GRAPH ] = pixmap->copy (0,294,113,19); - else - m_eq_parts[ EQ_GRAPH ] = QPixmap(); - - for (int i = 0; i < 14; ++i) - { - m_eq_bar << pixmap->copy (13 + i*15,164,14,63); - } - for (int i = 0; i < 14; ++i) - { - m_eq_bar << pixmap->copy (13 + i*15,229,14,63); - } - buttons[ EQ_BT_BAR_N ] = pixmap->copy (0,164,11,11); - buttons[ EQ_BT_BAR_P ] = pixmap->copy (0,164+12,11,11); - - buttons[ EQ_BT_ON_N ] = pixmap->copy (69,119,28,12); - buttons[ EQ_BT_ON_P ] = pixmap->copy (128,119,28,12); - buttons[ EQ_BT_OFF_N ] = pixmap->copy (10, 119,28,12); - buttons[ EQ_BT_OFF_P ] = pixmap->copy (187,119,28,12); - - buttons[ EQ_BT_PRESETS_N ] = pixmap->copy (224,164,44,12); - buttons[ EQ_BT_PRESETS_P ] = pixmap->copy (224,176,44,12); - - buttons[ EQ_BT_AUTO_1_N ] = pixmap->copy (94,119,33,12); - buttons[ EQ_BT_AUTO_1_P ] = pixmap->copy (153,119,33,12); - buttons[ EQ_BT_AUTO_0_N ] = pixmap->copy (35, 119,33,12); - buttons[ EQ_BT_AUTO_0_P ] = pixmap->copy (212,119,33,12); - - buttons[ EQ_BT_CLOSE_N ] = pixmap->copy (0,116,9,9); - buttons[ EQ_BT_CLOSE_P ] = pixmap->copy (0,125,9,9); - buttons[ EQ_BT_SHADE1_N ] = pixmap->copy (254,137,9,9); - - for (int i = 0; i < 19; ++i) - { - m_eq_spline << pixmap->copy (115, 294+i, 1, 1); - } - delete pixmap; -} - -void Skin::loadEq_ex() -{ - QPixmap *pixmap = getPixmap ("eq_ex"); - - if (!pixmap) - pixmap = getDummyPixmap("eq_ex"); - - buttons[ EQ_BT_SHADE1_P ] = pixmap->copy (1,38,9,9); - buttons[ EQ_BT_SHADE2_N ] = pixmap->copy (254,3,9,9); - buttons[ EQ_BT_SHADE2_P ] = pixmap->copy (1,47,9,9); - m_eq_parts[ EQ_TITLEBAR_SHADED_A ] = pixmap->copy(0,0,275,14); - m_eq_parts[ EQ_TITLEBAR_SHADED_I ] = pixmap->copy(0,15,275,14); - m_eq_parts[ EQ_VOLUME1 ] = pixmap->copy(1,30,3,8); - m_eq_parts[ EQ_VOLUME2 ] = pixmap->copy(4,30,3,8); - m_eq_parts[ EQ_VOLUME3 ] = pixmap->copy(7,30,3,8); - m_eq_parts[ EQ_BALANCE1 ] = pixmap->copy(11,30,3,8); - m_eq_parts[ EQ_BALANCE2 ] = pixmap->copy(14,30,3,8); - m_eq_parts[ EQ_BALANCE3 ] = pixmap->copy(17,30,3,8); - - delete pixmap; -} - -void Skin::loadVisColor() -{ - QString path = findFile("viscolor.txt", m_skin_dir); - if (path.isEmpty()) - path = findFile("viscolor.txt", ":/default"); - if (path.isEmpty()) - qFatal("Skin: invalid default skin"); - - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - qFatal("Skin: unable to open %s", qPrintable(path)); - - int j = 0; - while (!file.atEnd () && j<24) - { - j++; - QByteArray line = file.readLine (); - QString tmp = QString::fromAscii (line); - tmp = tmp.trimmed (); - int i = tmp.indexOf ("//"); - if (i>0) - tmp.truncate (tmp.indexOf ("//")); - QStringList list = tmp.split (","); - if (list.count () >= 3) - { - //colors - int r = list.at (0).toInt(); - int g = list.at (1).toInt(); - int b = list.at (2).toInt(); - m_vis_colors << QColor (r,g,b); - } - else if (line.length() == 0) - { - break; - } - } - if (m_vis_colors.size() < 24) - { - qWarning ("Skin: cannot parse viscolor.txt"); - while (m_vis_colors.size() < 24) - m_vis_colors << QColor (0,0,0); - } -} - -void Skin::loadShufRep() -{ - QPixmap *pixmap = getPixmap ("shufrep"); - - if (!pixmap) - pixmap = getDummyPixmap("shufrep"); - - buttons[ BT_EQ_ON_N ] = pixmap->copy (0,73,23,12); - buttons[ BT_EQ_ON_P ] = pixmap->copy (46,73,23,12); - buttons[ BT_EQ_OFF_N ] = pixmap->copy (0,61,23,12); - buttons[ BT_EQ_OFF_P ] = pixmap->copy (46,61,23,12); - - buttons[ BT_PL_ON_N ] = pixmap->copy (23,73,23,12); - buttons[ BT_PL_ON_P ] = pixmap->copy (69,73,23,12); - buttons[ BT_PL_OFF_N ] = pixmap->copy (23,61,23,12); - buttons[ BT_PL_OFF_P ] = pixmap->copy (69,61,23,12); - - //buttons[ BT_PL_CLOSE_N ] = pixmap->copy (); - //buttons[ BT_PL_CLOSE_P ] = pixmap->copy (); - - buttons[REPEAT_ON_N] = pixmap->copy (0,30, 28, 15); - buttons[REPEAT_ON_P] = pixmap->copy (0,45, 28, 15); - - buttons[REPEAT_OFF_N] = pixmap->copy (0, 0,28,15); - buttons[REPEAT_OFF_P] = pixmap->copy (0,15,28,15); - - buttons[SHUFFLE_ON_N] = pixmap->copy (28,30,46,15); - buttons[SHUFFLE_ON_P] = pixmap->copy (28,45,46,15); - - buttons[SHUFFLE_OFF_N] = pixmap->copy (28, 0,46,15); - buttons[SHUFFLE_OFF_P] = pixmap->copy (28,15,46,15); - - delete pixmap; -} - -void Skin::loadLetters(void) -{ - QPixmap *img = getPixmap("text"); - - if (!img) - img = getDummyPixmap("text"); - - QList<QList<QPixmap> > (letters); - for (int i = 0; i < 3; i++) - { - QList<QPixmap> (l); - for (int j = 0; j < 31; j++) - { - l.append (img->copy (j*5, i*6, 5, 6)); - } - letters.append (l); - } - - delete img; - - - /* alphabet */ - for (uint i = 97; i < 123; i++) - { - m_letters.insert(i, letters[0][i-97]); - } - - /* digits */ - for (uint i = 0; i <= 9; i++) - { - m_letters.insert (i+48, letters[1][i]); - } - - /* special characters */ - m_letters.insert('"', letters[0][27]); - m_letters.insert('@', letters[0][28]); - m_letters.insert(':', letters[1][12]); - m_letters.insert('(', letters[1][13]); - m_letters.insert(')', letters[1][14]); - m_letters.insert('-', letters[1][15]); - m_letters.insert('\'', letters[1][16]); - m_letters.insert('`', letters[1][16]); - m_letters.insert('!', letters[1][17]); - m_letters.insert('_', letters[1][18]); - m_letters.insert('+', letters[1][19]); - m_letters.insert('\\', letters[1][20]); - m_letters.insert('/', letters[1][21]); - m_letters.insert('[', letters[1][22]); - m_letters.insert(']', letters[1][23]); - m_letters.insert('^', letters[1][24]); - m_letters.insert('&', letters[1][25]); - m_letters.insert('%', letters[1][26]); - m_letters.insert('.', letters[1][27]); - m_letters.insert(',', letters[1][27]); - m_letters.insert('=', letters[1][28]); - m_letters.insert('$', letters[1][29]); - m_letters.insert('#', letters[1][30]); - - m_letters.insert(229, letters[2][0]); - m_letters.insert(246, letters[2][1]); - m_letters.insert(228, letters[2][2]); - m_letters.insert('?', letters[2][3]); - m_letters.insert('*', letters[2][4]); - m_letters.insert(' ', letters[2][5]); - - /* text background */ - //m_items->insert (TEXTBG, letters[2][6]); -} - -void Skin::loadMonoSter() -{ - QPixmap *pixmap = getPixmap("monoster"); - - if (!pixmap) - pixmap = getDummyPixmap("monoster"); - - m_ms_parts.clear(); - m_ms_parts[ MONO_A ] = pixmap->copy (29,0,27,12); - m_ms_parts[ MONO_I ] = pixmap->copy (29,12,27,12); - m_ms_parts[ STEREO_A ] = pixmap->copy (0,0,27,12); - m_ms_parts[ STEREO_I ] = pixmap->copy (0,12,27,12); - - delete pixmap; - - m_parts.clear(); - QPainter paint; - pixmap = getPixmap("playpaus"); - - if (!pixmap) - pixmap = getDummyPixmap("playpaus"); - - QPixmap part(11, 9); - paint.begin(&part); - paint.drawPixmap (0, 0, 3, 9, *pixmap, 36, 0, 3, 9); - paint.drawPixmap (3, 0, 8, 9, *pixmap, 1, 0, 8, 9); - paint.end(); - m_parts [PLAY] = part.copy(); - - part = QPixmap(11, 9); - paint.begin(&part); - paint.drawPixmap (0, 0, 2, 9, *pixmap, 27, 0, 2, 9); - paint.drawPixmap (2, 0, 9, 9, *pixmap, 9, 0, 9, 9); - paint.end(); - m_parts [PAUSE] = part.copy(); - - part = QPixmap(11, 9); - paint.begin(&part); - paint.drawPixmap (0, 0, 2, 9, *pixmap, 27, 0, 2, 9); - paint.drawPixmap (2, 0, 9, 9, *pixmap, 18, 0, 9, 9); - paint.end(); - m_parts [STOP] = part.copy(); - - delete pixmap; -} - -void Skin::loadVolume() -{ - QPixmap *pixmap = getPixmap("volume"); - - if (!pixmap) - pixmap = getDummyPixmap("volume"); - - m_volume.clear(); - for (int i = 0; i < 28; ++i) - m_volume.append(pixmap->copy (0,i*15, pixmap->width(),13)); - if (pixmap->height() > 425) - { - buttons [BT_VOL_N] = pixmap->copy (15,422,14, pixmap->height() - 422); - buttons [BT_VOL_P] = pixmap->copy (0, 422,14, pixmap->height() - 422); - } - else - { - buttons [BT_VOL_N] = QPixmap(); - buttons [BT_VOL_P] = QPixmap(); - } - delete pixmap; -} - -void Skin::loadBalance() -{ - QPixmap *pixmap = getPixmap ("balance"); - if (!pixmap) - pixmap = getPixmap ("volume"); - - if (!pixmap) - pixmap = getDummyPixmap("balance"); - - m_balance.clear(); - for (int i = 0; i < 28; ++i) - m_balance.append(pixmap->copy (9,i*15,38,13)); - if (pixmap->height() > 427) - { - buttons [BT_BAL_N] = pixmap->copy (15, 422,14,pixmap->height()-422); - buttons [BT_BAL_P] = pixmap->copy (0,422,14,pixmap->height()-422); - } - else - { - buttons [BT_BAL_N] = QPixmap(); - buttons [BT_BAL_P] = QPixmap(); - } - delete pixmap; -} - -void Skin::loadRegion() -{ - m_regions.clear(); - QString path = findFile("region.txt", m_skin_dir); - - if (path.isNull ()) - { - qDebug ("Skin: cannot find region.txt. Transparency disabled"); - return; - } - m_regions[NORMAL] = createRegion(path, "Normal"); - m_regions[EQUALIZER] = createRegion(path, "Equalizer"); - m_regions[WINDOW_SHADE] = createRegion(path, "WindowShade"); - m_regions[EQUALIZER_WS] = createRegion(path, "EqualizerWS"); -} - -QRegion Skin::createRegion(const QString &path, const QString &key) -{ - QRegion region; - QSettings settings(path, QSettings::IniFormat); - QStringList numPoints = settings.value(key+"/NumPoints").toStringList(); - QStringList value = settings.value(key+"/PointList").toStringList(); - QStringList numbers; - foreach(QString str, value) - numbers << str.split(" ", QString::SkipEmptyParts); - - QList <QRegion> regions; - - QList<QString>::iterator n; - n = numbers.begin(); - int r = m_double_size ? 2 : 1; - for (int i = 0; i < numPoints.size(); ++i) - { - QList <int> lp; - for (int j = 0; j < numPoints.at(i).toInt()*2; j++) - { - lp << n->toInt(); - n ++; - } - QVector<QPoint> points; - - for (int l = 0; l < lp.size(); l+=2) - { - points << QPoint(lp.at(l)*r, lp.at(l+1)*r); - } - region = region.united(QRegion(QPolygon(points))); - } - return region; -} - -QPixmap * Skin::getDummyPixmap(const QString& name) -{ - QDir dir (":/default"); - dir.setFilter (QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = dir.entryInfoList(); - for (int j = 0; j < f.size(); ++j) - { - QFileInfo fileInfo = f.at (j); - QString fn = fileInfo.fileName().toLower(); - if (fn.section (".",0,0) == name) - { - return new QPixmap (fileInfo.filePath()); - } - } - qFatal("Skin: default skin is corrupted"); - return 0; -} - -QPixmap Skin::scalePixmap(const QPixmap &pix, int ratio) -{ - return pix.scaled(pix.width() * ratio, pix.height() * ratio, - Qt::KeepAspectRatio); -} - -const QString Skin::findFile(const QString &name, QDir dir) -{ - dir.setFilter (QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QString path; - QFileInfoList list = dir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo = list.at (i); - if (fileInfo.fileName().toLower() == name) - { - path = fileInfo.filePath (); - break; - } - } - return path; -} - -const QString Skin::findFile(const QString &name, const QString &dir) -{ - return findFile(name, QDir(dir)); -} diff --git a/src/ui/skin.h b/src/ui/skin.h deleted file mode 100644 index adb4b6c20..000000000 --- a/src/ui/skin.h +++ /dev/null @@ -1,390 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * Based on Promoe, an XMMS2 Client * - * Copyright (C) 2005-2006 by XMMS2 Team * - * * - * 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 SKIN_H -#define SKIN_H - -#include <QObject> -#include <QMap> -#include <QPixmap> -#include <QDir> -#include <QRegion> -#include <QCursor> - -class Skin : public QObject -{ - Q_OBJECT -public: - Skin(QObject *parent = 0); - - ~Skin(); - - static Skin *instance(); - static QPixmap getPixmap(const QString&, QDir); - int ratio() - { - return m_double_size ? 2 : 1; - } - const QPixmap getMain() const - { - return m_main; - } - const QPixmap getButton(uint bt) const - { - return buttons[bt]; - } - const QCursor getCursor(uint cu) const - { - return cursors[cu]; - } - const QPixmap getTitleBar(uint tb) const - { - return titlebar[tb]; - } - const QPixmap getPosBar() const - { - return posbar; - } - const QPixmap getNumber(uint n) const - { - return m_numbers[n]; - } - /*! - * Returns count of numbers in number list. - * We need this to check if we have "-" in pixmaps. - * if no we should draw it manually. - */ - uint getNumCount(void) const - { - return m_numbers.count(); - } - const QPixmap getPlPart(uint p) const - { - return m_pl_parts[p]; - } - const QPixmap getEqPart(uint p) const - { - return m_eq_parts[p]; - } - const QPixmap getEqSlider(uint n) const - { - return m_eq_bar[n]; - } - const QPixmap getEqSpline(uint n) const - { - return m_eq_spline[n]; - } - const QPixmap getMSPart(uint n) const - { - return m_ms_parts[n]; - } - const QPixmap getLetter(const QChar& ch) const - { - return m_letters[ch]; - } - const QPixmap getItem(uint n) const - { - return m_parts[n]; - } - const QPixmap getVolumeBar(int n) const - { - return m_volume[n]; - } - const QPixmap getBalanceBar(int n) const - { - return m_balance[n]; - } - const QByteArray getPLValue (QByteArray c) const - { - return m_pledit_txt[c]; - } - const QColor getVisColor(int n) const - { - return m_vis_colors[n]; - } - const QRegion getRegion(uint r) const - { - return m_regions[r]; - } - - enum Buttons - { - BT_PREVIOUS_N = 0, - BT_PREVIOUS_P, - BT_PLAY_N, - BT_PLAY_P, - BT_PAUSE_N, - BT_PAUSE_P, - BT_STOP_N, - BT_STOP_P, - BT_NEXT_N, - BT_NEXT_P, - BT_EJECT_N, - BT_EJECT_P, - /*titlebar.* */ - BT_MENU_N, - BT_MENU_P, - BT_MINIMIZE_N, - BT_MINIMIZE_P, - BT_CLOSE_N, - BT_CLOSE_P, - BT_SHADE1_N, - BT_SHADE1_P, - BT_SHADE2_N, - BT_SHADE2_P, - BT_CLOSE_SHADED_N, - BT_CLOSE_SHADED_P, - - /* posbar.* */ - BT_POSBAR_N, - BT_POSBAR_P, - /* pledit.* */ - PL_BT_ADD, - PL_BT_SUB, - PL_BT_SEL, - PL_BT_SORT, - PL_BT_LST, - PL_BT_SCROLL_N, - PL_BT_SCROLL_P, - PL_BT_CLOSE_N, - PL_BT_CLOSE_P, - PL_BT_SHADE1_N, - PL_BT_SHADE1_P, - PL_BT_SHADE2_N, - PL_BT_SHADE2_P, - - /* eqmain.* */ - EQ_BT_BAR_N, - EQ_BT_BAR_P, - EQ_BT_ON_N, - EQ_BT_ON_P, - EQ_BT_OFF_N, - EQ_BT_OFF_P, - EQ_BT_PRESETS_N, - EQ_BT_PRESETS_P, - EQ_BT_AUTO_1_N, - EQ_BT_AUTO_1_P, - EQ_BT_AUTO_0_N, - EQ_BT_AUTO_0_P, - EQ_BT_CLOSE_N, - EQ_BT_CLOSE_P, - EQ_BT_SHADE1_N, - - /* eq_ex.* */ - EQ_BT_SHADE1_P, - EQ_BT_SHADE2_N, - EQ_BT_SHADE2_P, - - /* shufrep.* */ - BT_EQ_ON_N, - BT_EQ_ON_P, - BT_EQ_OFF_N, - BT_EQ_OFF_P, - BT_PL_ON_N, - BT_PL_ON_P, - BT_PL_OFF_N, - BT_PL_OFF_P, - BT_PL_CLOSE_N, - BT_PL_CLOSE_P, - REPEAT_ON_N, - REPEAT_ON_P, - REPEAT_OFF_N, - REPEAT_OFF_P, - SHUFFLE_ON_N, - SHUFFLE_ON_P, - SHUFFLE_OFF_N, - SHUFFLE_OFF_P, - /* volume.* */ - BT_VOL_N, - BT_VOL_P, - /* balance.* */ - BT_BAL_N, - BT_BAL_P, - }; - enum TitleBar - { - TITLEBAR_A = 0, - TITLEBAR_I, - TITLEBAR_SHADED_A, - TITLEBAR_SHADED_I, - }; - enum PlayList - { - PL_CORNER_UL_A = 0, - PL_CORNER_UL_I, - PL_CORNER_UR_A, - PL_CORNER_UR_I, - PL_TITLEBAR_A, - PL_TITLEBAR_I, - PL_TFILL1_A, - PL_TFILL1_I, - PL_TFILL2_A, - PL_TFILL2_I, - PL_LFILL, - PL_RFILL, - PL_LSBAR, - PL_RSBAR, - PL_SFILL1, - PL_SFILL2, - PL_CONTROL, - PL_TITLEBAR_SHADED1_A, - PL_TITLEBAR_SHADED1_I, - PL_TITLEBAR_SHADED2, - PL_TFILL_SHADED, - }; - enum Equalizer - { - EQ_MAIN = 0, - EQ_TITLEBAR_A, - EQ_TITLEBAR_I, - EQ_GRAPH, - EQ_TITLEBAR_SHADED_A, - EQ_TITLEBAR_SHADED_I, - EQ_VOLUME1, - EQ_VOLUME2, - EQ_VOLUME3, - EQ_BALANCE1, - EQ_BALANCE2, - EQ_BALANCE3, - }; - enum MonoSter - { - MONO_A = 0, - MONO_I, - STEREO_A, - STEREO_I, - }; - enum OtherParts - { - PLAY = 0, - PAUSE, - STOP, - }; - enum Regions - { - NORMAL = 0, - EQUALIZER, - WINDOW_SHADE, - EQUALIZER_WS, - }; - enum Cursors - { - CUR_NORMAL = 0, - CUR_CLOSE, - CUR_MAINMENU, - CUR_MIN, - CUR_POSBAR, - CUR_SONGNAME, - CUR_TITLEBAR, - CUR_VOLBAL, - CUR_WINBUT, - - CUR_WSNORMAL, - CUR_WSPOSBAR, - - CUR_EQCLOSE, - CUR_EQNORMAL, - CUR_EQSLID, - CUR_EQTITLE, - - CUR_PCLOSE, - CUR_PNORMAL, - CUR_PSIZE, - CUR_PTBAR, - CUR_PVSCROLL, - CUR_PWINBUT, - - CUR_PWSNORM, - CUR_PWSSIZE, - - CUR_VOLBAR, - CUR_WSCLOSE, - CUR_WSMIN, - CUR_WSWINBUT, - }; - -public slots: - void setSkin(const QString& path); - void reloadSkin(); - -signals: - void skinChanged(); - -private: - QPixmap *getPixmap(const QString&); - QString getPath(const QString&); - const QString findFile(const QString&, QDir); - const QString findFile(const QString&, const QString&); - - /*! - * As far as there is no standard in skin making we cannot be sure - * that all needful images we can find in skin :( This will cause - * segfaults and asserts. So to prevent this we need such method - * to load pixmap from default skin. - */ - QPixmap *getDummyPixmap(const QString&); - QPixmap scalePixmap(const QPixmap &pix, int ratio = 2); - static Skin *m_instance; - QDir m_skin_dir; - QMap<uint, QPixmap> buttons; - QMap<uint, QCursor> cursors; - QMap<uint, QPixmap> titlebar; - QMap<uint, QPixmap> m_pl_parts; - QMap<uint, QPixmap> m_eq_parts; - QMap<uint, QPixmap> m_ms_parts; - QMap<uint, QPixmap> m_parts; - QMap<QChar, QPixmap> m_letters; - QMap<QByteArray, QByteArray> m_pledit_txt; - QMap<uint, QRegion> m_regions; - QPixmap m_main; - QPixmap posbar; - QList<QPixmap> m_numbers; - QList<QPixmap> m_eq_bar; - QList<QPixmap> m_eq_spline; - QList<QPixmap> m_volume; - QList<QPixmap> m_balance; - QList<QColor> m_vis_colors; - bool m_use_cursors; - bool m_double_size; - - void loadMain(); - void loadButtons(); - void loadCursors(); - void loadTitleBar(); - void loadPosBar(); - void loadNumbers(); - void loadPlayList(); - void loadPLEdit(); - void loadEqMain(); - void loadEq_ex(); - void loadVisColor(); - void loadShufRep(); - void loadLetters(); - void loadMonoSter(); - void loadVolume(); - void loadBalance(); - void loadRegion(); - QRegion createRegion(const QString &path, const QString &key); -}; - -#endif diff --git a/src/ui/skinreader.cpp b/src/ui/skinreader.cpp deleted file mode 100644 index 390ac4b8b..000000000 --- a/src/ui/skinreader.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 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 <QDir> -#include <QList> -#include <QFileInfo> -#include <QProcess> -#include <QByteArray> -#include <QApplication> -#include <QFile> - -#include "skinreader.h" - -SkinReader::SkinReader(QObject *parent) - : QObject(parent) -{ - m_process = new QProcess(this); - //create cache dir - QDir dir(QDir::homePath() +"/.qmmp/"); - dir.mkdir("cache"); - dir.cd("cache"); - dir.mkdir("thumbs"); - dir.mkdir("skin"); -} - - -SkinReader::~SkinReader() -{} - -void SkinReader::generateThumbs() -{ - m_previewMap.clear(); - QDir dir(QDir::homePath() +"/.qmmp/skins"); - dir.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = dir.entryInfoList(); - dir.setPath(qApp->applicationDirPath()+"/../share/qmmp/skins"); - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - f << dir.entryInfoList(); - QDir cache_dir(QDir::homePath() +"/.qmmp/cache/thumbs"); - cache_dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList d = cache_dir.entryInfoList(); - //clear removed skins from cache - foreach(QFileInfo thumbFile, d) - { - bool del = true; - foreach(QFileInfo fileInfo, f) - { - if (fileInfo.baseName () == thumbFile.baseName ()) - { - del = false; - break; - } - } - if (del) - { - qDebug("SkinReader: deleting %s from cache", - qPrintable(thumbFile.fileName ())); - - cache_dir.remove(thumbFile.fileName ()); - } - } - //add new skins to cache - foreach(QFileInfo fileInfo, f) - { - bool create = true; - foreach(QFileInfo thumbInfo, d) - { - if (fileInfo.baseName () == thumbInfo.baseName ()) - { - create = false; - break; - } - } - if (create) - { - qDebug("SkinReader: adding %s to cache", - qPrintable(fileInfo.fileName ())); - QString name = fileInfo.fileName ().toLower(); - - if (name.endsWith(".tgz") || name.endsWith(".tar.gz") || name.endsWith(".tar.bz2")) - untar(fileInfo.filePath (), cache_dir.absolutePath (), true); - if (name.endsWith(".zip") || name.endsWith(".wsz")) - unzip(fileInfo.filePath (), cache_dir.absolutePath (), true); - } - } - //add thumbs to map - cache_dir.refresh(); - d = cache_dir.entryInfoList(); - foreach(QFileInfo fileInfo, f) - { - foreach(QFileInfo thumbInfo, d) - { - if (fileInfo.baseName () == thumbInfo.baseName ()) - { - m_previewMap.insert(fileInfo.absoluteFilePath (), - thumbInfo.absoluteFilePath ()); - break; - } - } - } -} - -void SkinReader::unpackSkin(const QString &path) -{ - //remove old skin - QDir dir(QDir::homePath() +"/.qmmp/cache/skin"); - dir.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList f = dir.entryInfoList(); - foreach(QFileInfo file, f) - dir.remove(file.fileName()); - //unpack - if (path.endsWith(".tgz") || path.endsWith(".tar.gz") || path.endsWith(".tar.bz2")) - untar(path, QDir::homePath() +"/.qmmp/cache/skin", false); - if (path.endsWith(".zip") || path.endsWith(".wsz")) - unzip(path, QDir::homePath() +"/.qmmp/cache/skin", false); -} - -const QStringList SkinReader::skins() -{ - return m_previewMap.keys(); -} - -const QPixmap SkinReader::getPreview(const QString &skinPath) -{ - return QPixmap(m_previewMap.value(skinPath)); -} - -void SkinReader::untar(const QString &from, const QString &to, bool preview) -{ - QByteArray array; - QStringList args; - //list archive - args << "tf" <<from; - m_process->start("tar", args); - m_process->waitForFinished(); - array = m_process->readAllStandardOutput (); - QString str = QString(array); - QStringList outputList = str.split("\n", QString::SkipEmptyParts); - foreach(QString str, outputList) - { - str = str.trimmed(); - args.clear(); - if (!preview || (str.contains("/main.", Qt::CaseInsensitive) - || str.startsWith("main.", Qt::CaseInsensitive))) - { - args << "xvfk" << from << "-O" << str; - m_process->start("tar", args); - m_process->waitForStarted(); - m_process->waitForFinished(); - array = m_process->readAllStandardOutput (); - - QString name; - if (preview) - name = from.section('/',-1) + (".") + str.section('.', -1); - else - name = str.contains('/') ? str.section('/',-1).toLower() : str.toLower(); - - QFile file(to+"/"+name); - file.open(QIODevice::WriteOnly); - file.write(array); - file.close(); - } - } -} - -void SkinReader::unzip(const QString &from, const QString &to, bool preview) -{ - QStringList args; - if (preview) - { - args << "-C" << "-j" << "-o" << "-qq" << "-d" << to << from << "main.*" << "*/main.*"; - QProcess::execute("unzip", args); - QDir dir(to); - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - QFileInfoList fileList = dir.entryInfoList(); - foreach(QFileInfo thumbInfo, fileList) - { - if (thumbInfo.fileName().startsWith("main.", Qt::CaseInsensitive)) - { - dir.rename(thumbInfo.fileName(), from.section('/', -1) + - "." + thumbInfo.suffix ()); - } - } - } - else - { - args << "-j" << "-o" << "-qq" << "-d" << to << from; - QProcess::execute("unzip", args); - } -} diff --git a/src/ui/skinreader.h b/src/ui/skinreader.h deleted file mode 100644 index e12e604a1..000000000 --- a/src/ui/skinreader.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 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 SKINREADER_H -#define SKINREADER_H - -#include <QObject> -#include <QMap> -#include <QPixmap> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class QProcess; - -class SkinReader : public QObject -{ - Q_OBJECT -public: - SkinReader(QObject *parent = 0); - - ~SkinReader(); - - void generateThumbs(); - void unpackSkin(const QString &path); - const QStringList skins(); - const QPixmap getPreview(const QString &skinPath); - -private: - QProcess *m_process; - void untar(const QString &from, const QString &to, bool preview); - void unzip(const QString &from, const QString &to, bool preview); - QMap <QString, QString> m_previewMap; -}; - -#endif diff --git a/src/ui/stuff.qrc b/src/ui/stuff.qrc deleted file mode 100644 index cc1d83984..000000000 --- a/src/ui/stuff.qrc +++ /dev/null @@ -1,88 +0,0 @@ -<!DOCTYPE RCC> -<RCC version="1.0"> - <qresource> - <file>../../COPYING</file> - - <file>txt/description_en.txt</file> - <file>txt/authors_en.txt</file> - <file>txt/thanks_en.txt</file> - <file>txt/translators_en.txt</file> - - <file>txt/authors_uk_UA.txt</file> - <file>txt/thanks_uk_UA.txt</file> - <file>txt/translators_uk_UA.txt</file> - <file>txt/description_uk_UA.txt</file> - - <file>txt/authors_zh_TW.txt</file> - <file>txt/thanks_zh_TW.txt</file> - <file>txt/translators_zh_TW.txt</file> - <file>txt/description_zh_TW.txt</file> - - <file>txt/description_cs.txt</file> - <file>txt/authors_cs.txt</file> - <file>txt/thanks_cs.txt</file> - <file>txt/translators_cs.txt</file> - - <file>txt/authors_ru.txt</file> - <file>txt/thanks_ru.txt</file> - <file>txt/translators_ru.txt</file> - <file>txt/description_ru.txt</file> - - <file>txt/authors_zh_CN.txt</file> - <file>txt/thanks_zh_CN.txt</file> - <file>txt/translators_zh_CN.txt</file> - <file>txt/description_zh_CN.txt</file> - - <file>txt/authors_de.txt</file> - <file>txt/thanks_de.txt</file> - <file>txt/translators_de.txt</file> - <file>txt/description_de.txt</file> - - <file>txt/authors_it.txt</file> - <file>txt/thanks_it.txt</file> - <file>txt/translators_it.txt</file> - <file>txt/description_it.txt</file> - - <file>txt/authors_tr.txt</file> - <file>txt/thanks_tr.txt</file> - <file>txt/translators_tr.txt</file> - <file>txt/description_tr.txt</file> - - <file>txt/authors_lt.txt</file> - <file>txt/thanks_lt.txt</file> - <file>txt/translators_lt.txt</file> - <file>txt/description_lt.txt</file> - - <file>txt/authors_nl.txt</file> - <file>txt/thanks_nl.txt</file> - <file>txt/translators_nl.txt</file> - <file>txt/description_nl.txt</file> - - <file>txt/authors_ja.txt</file> - <file>txt/thanks_ja.txt</file> - <file>txt/translators_ja.txt</file> - <file>txt/description_ja.txt</file> - - <file>txt/authors_es.txt</file> - <file>txt/thanks_es.txt</file> - <file>txt/translators_es.txt</file> - <file>txt/description_es.txt</file> - - <file>default/balance.png</file> - <file>default/eqmain.png</file> - <file>default/numbers.png</file> - <file>default/pledit.txt</file> - <file>default/text.png</file> - <file>default/volume.png</file> - <file>default/cbuttons.png</file> - <file>default/main.png</file> - <file>default/playpaus.png</file> - <file>default/posbar.png</file> - <file>default/titlebar.png</file> - <file>default/eq_ex.png</file> - <file>default/monoster.png</file> - <file>default/pledit.png</file> - <file>default/shufrep.png</file> - <file>default/viscolor.txt</file> - </qresource> -</RCC> diff --git a/src/ui/symboldisplay.cpp b/src/ui/symboldisplay.cpp deleted file mode 100644 index e33533f08..000000000 --- a/src/ui/symboldisplay.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 <QPainter> -#include <math.h> - -#include "skin.h" - -#include "symboldisplay.h" - -SymbolDisplay::SymbolDisplay ( QWidget *parent, int digits ) - : PixmapWidget ( parent ), m_digits ( digits ), m_text(), m_max(0) -{ - m_alignment = Qt::AlignRight; - m_skin = Skin::instance(); - connect ( m_skin, SIGNAL ( skinChanged() ), this, SLOT (draw())); - draw(); - for (int i=0; i<m_digits; ++i) -#if defined(Q_OS_FREEBSD) || defined(Q_OS_WIN32) || defined (Q_OS_MAC) - m_max += 9 * (int) pow(10,i); -#else - m_max += 9 * (int) exp10(i); -#endif -} - - -SymbolDisplay::~SymbolDisplay() -{} - -void SymbolDisplay::display (const QString& str) -{ - m_text = str; - if (!str.isEmpty()) - draw(); -} - -void SymbolDisplay::draw() -{ - QString str = m_text; - QPixmap bg = m_skin->getLetter ( ' ' ); - int w = bg.size().width(); - int h = bg.size().height(); - QPixmap tmp ( m_digits*w,h ); - QPainter paint ( &tmp ); - int j; - for ( int i = 0; i < m_digits; ++i ) - { - if (m_alignment == Qt::AlignRight) // TODO: add align Center - { - j = str.size() -1 - i; - if ( j >= 0 ) - paint.drawPixmap ( ( m_digits-1-i ) *w,0,m_skin->getLetter ( str.at ( j ) ) ); - else - paint.drawPixmap ( ( m_digits-1-i ) *w,0,m_skin->getLetter ( ' ' ) ); - } - else - { - if (i < str.size()) - paint.drawPixmap ( i * w,0,m_skin->getLetter ( str.at ( i ) ) ); - else - paint.drawPixmap ( i * w,0,m_skin->getLetter ( ' ' ) ); - ; - } - } - setPixmap(tmp); -} - -void SymbolDisplay::display(int val) -{ - if (val < m_max) - display(QString::number(val)); - else - display(QString("%1h").arg(val/100)); -} - diff --git a/src/ui/symboldisplay.h b/src/ui/symboldisplay.h deleted file mode 100644 index 720bad315..000000000 --- a/src/ui/symboldisplay.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2008 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 SYMBOLDISPLAY_H -#define SYMBOLDISPLAY_H - -#include <QPixmap> - -#include "pixmapwidget.h" - -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> - */ - -class Skin; - -class SymbolDisplay : public PixmapWidget -{ - Q_OBJECT -public: - SymbolDisplay(QWidget *parent = 0, int digits = 3); - - ~SymbolDisplay(); - - void setAlignment(Qt::Alignment a) - { - m_alignment = a; - } - Qt::Alignment alignment()const - { - return m_alignment; - } - -public slots: - void display(const QString&); - void display(int); - -private slots: - void draw(); - -private: - Skin* m_skin; - QPixmap m_pixmap; - int m_digits; - QString m_text; - Qt::Alignment m_alignment; - int m_max; - -}; - -#endif diff --git a/src/ui/textscroller.cpp b/src/ui/textscroller.cpp deleted file mode 100644 index 1fac2a753..000000000 --- a/src/ui/textscroller.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QPainter> -#include <QTimer> -#include <QSettings> -#include <QAction> -#include <QMenu> -#include <QMouseEvent> -#include <QSettings> -#include <qmmp/qmmp.h> -#include <qmmp/soundcore.h> -#include <qmmpui/metadataformatter.h> -#include "skin.h" -#include "textscroller.h" - -#define SCROLL_SEP " *** " -#define TITLE_FORMAT "%if(%p&%t,%p - %t,%p%t)%if(%p&%t,,%f)%if(%l, - %l,)" - -TextScroller::TextScroller (QWidget *parent) - : QWidget (parent) -{ - m_pressed = false; - m_press_pos = 0; - m_metrics = 0; - m_defautText = QString("Qmmp ") + Qmmp::strVersion(); - m_core = SoundCore::instance(); - m_skin = Skin::instance(); - m_ratio = m_skin->ratio(); - - m_timer = new QTimer (this); - m_timer->setInterval(50); - m_timer->start(); - - m_menu = new QMenu(this); - m_scrollAction = m_menu->addAction(tr("Autoscroll Songname")); - m_scrollAction->setCheckable(true); - connect(m_scrollAction, SIGNAL(toggled(bool)), SLOT(updateText())); - connect(m_timer, SIGNAL (timeout()), SLOT (addOffset())); - connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin())); - connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(processState(Qmmp::State))); - connect(m_core, SIGNAL(metaDataChanged()), SLOT(processMetaData())); - //readSettings(); - updateSkin(); -} - -TextScroller::~TextScroller() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.setValue("TextScroller/autoscroll", m_scrollAction->isChecked()); - if(m_metrics) - delete m_metrics; -} - -void TextScroller::setText(const QString &text) -{ - m_sliderText = text; - updateText(); -} - -void TextScroller::clear() -{ - setText(QString()); -} - -void TextScroller::addOffset() -{ - if(!m_scroll) - { - m_timer->stop(); - return; - } - m_x1--; - m_x2--; - if(m_x1 < - m_pixmap.width()) - m_x1 = m_pixmap.width(); - if(m_x2 < - m_pixmap.width()) - m_x2 = m_pixmap.width(); - update(); -} - -void TextScroller::updateSkin() -{ - m_color.setNamedColor(m_skin->getPLValue("mbfg")); - setCursor(m_skin->getCursor(Skin::CUR_SONGNAME)); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - m_bitmap = settings.value("MainWindow/bitmap_font", false).toBool(); - m_ratio = m_skin->ratio(); - QString fontname = settings.value("MainWindow/Font").toString(); - m_font.fromString(fontname); - if (m_metrics) - delete m_metrics; - else - m_scrollAction->setChecked(settings.value("TextScroller/autoscroll", true).toBool()); - m_metrics = new QFontMetrics(m_font); - updateText(); -} - -void TextScroller::setProgress(int progress) -{ - m_bufferText = tr("Buffering: %1%").arg(progress); - updateText(); -} - -void TextScroller::hideEvent (QHideEvent *) -{ - m_timer->stop(); -} - -void TextScroller::showEvent (QShowEvent *) -{ - if (m_scroll) - m_timer->start(); -} - -inline void drawBitmapText(int x, int y, const QString &text, QPainter *paint, Skin *skin) -{ - QString lowertext = text.toLower(); - int chwidth, ypix; - { - QPixmap samplechar = skin->getLetter('a'); - chwidth = samplechar.width(); - ypix = y - samplechar.height(); - } - for (int i = 0; i < lowertext.size(); i++) - { - QPixmap pixchar = skin->getLetter(lowertext[i]); - paint->drawPixmap(x, ypix, pixchar); - x += chwidth; - } -} - -void TextScroller::paintEvent (QPaintEvent *) -{ - QPainter paint(this); - if(m_scroll) - { - paint.drawPixmap(m_x1,0, m_pixmap); - paint.drawPixmap(m_x2,0, m_pixmap); - } - else - paint.drawPixmap(4,0, m_pixmap); -} - -void TextScroller::mousePressEvent (QMouseEvent *e) -{ - if (e->button() == Qt::RightButton) - m_menu->exec(e->globalPos()); - else if (e->button() == Qt::LeftButton && m_scroll) - { - m_timer->stop(); - m_press_pos = e->x() - m_x1; - m_pressed = true; - } - else - QWidget::mousePressEvent(e); -} - -void TextScroller::mouseReleaseEvent (QMouseEvent *e) -{ - if(e->button() == Qt::RightButton) - m_menu->exec(e->globalPos()); - else if (e->button() == Qt::LeftButton && m_scroll) - m_timer->start(); - else - QWidget::mouseReleaseEvent(e); - m_pressed = false; -} - -void TextScroller::mouseMoveEvent (QMouseEvent *e) -{ - if (m_pressed) - { - int bound = m_pixmap.width(); - m_x1 = (e->x() - m_press_pos) % bound; - if (m_x1 > 0) - m_x1 -= bound; - m_x2 = m_x1 + m_pixmap.width(); - update(); - } - else - QWidget::mouseMoveEvent(e); -} - -void TextScroller::processState(Qmmp::State state) -{ - switch(state) - { - case Qmmp::Buffering: - { - connect(m_core, SIGNAL(bufferingProgress(int)), SLOT(setProgress(int))); - break; - } - case Qmmp::Playing: - { - disconnect(m_core, SIGNAL(bufferingProgress(int)), this, 0); - m_bufferText.clear(); - updateText(); - break; - } - case Qmmp::Paused: - { - break; - } - case Qmmp::Stopped: - { - m_bufferText.clear(); - m_titleText.clear(); - updateText(); - break; - } - default: - break; - } -} - -void TextScroller::processMetaData() -{ - MetaDataFormatter formater(TITLE_FORMAT); - if(m_core->state() == Qmmp::Playing) - { - m_titleText = formater.parse(m_core->metaData(), m_core->totalTime()/1000); - updateText(); - } -} - -void TextScroller::preparePixmap(const QString &text, bool scrollable) -{ - m_scroll = scrollable; - bool bitmap = m_bitmap && (text.toLatin1() == text.toLocal8Bit()); //use bitmap font if possible - if(scrollable) - { - int textWidth = m_bitmap ? QString(text + SCROLL_SEP).size() * 5 - : m_metrics->width(text + SCROLL_SEP); - int count = 150*m_ratio / textWidth + 1; - int width = count * textWidth; - QString fullText; - for(int i = 0; i < count; ++i) - { - fullText.append(text + SCROLL_SEP); - } - m_pixmap = QPixmap(width,15*m_ratio); - m_pixmap.fill(Qt::transparent); - QPainter painter(&m_pixmap); - painter.setPen(m_color); - painter.setFont(m_font); - if(m_bitmap) - drawBitmapText (0,12, fullText, &painter, m_skin); - else - painter.drawText (0,12, fullText); - m_x1 = 0; - m_x2 = m_pixmap.width(); - } - else - { - m_pixmap = QPixmap(150*m_ratio,15*m_ratio); - m_pixmap.fill(Qt::transparent); - QPainter painter(&m_pixmap); - painter.setPen(m_color); - painter.setFont(m_font); - if(bitmap) - drawBitmapText (0,12, text, &painter, m_skin); - else - painter.drawText (0,12, text); - } -} - -void TextScroller::updateText() //draw text according priority -{ - if(!m_sliderText.isEmpty()) - { - preparePixmap(m_sliderText); - m_timer->stop(); - } - else if(!m_bufferText.isEmpty()) - { - preparePixmap(m_bufferText); - m_timer->stop(); - } - else if (!m_titleText.isEmpty()) - { - preparePixmap(m_titleText, m_scrollAction->isChecked()); - m_timer->start(); - } - else if(!m_defautText.isEmpty()) - { - preparePixmap(m_defautText); - m_timer->stop(); - } - else - { - m_timer->stop(); - m_pixmap = QPixmap (150*m_ratio,15*m_ratio); - m_pixmap.fill(Qt::transparent); - m_scroll = false; - } - update(); -} diff --git a/src/ui/textscroller.h b/src/ui/textscroller.h deleted file mode 100644 index 3fe50bf7e..000000000 --- a/src/ui/textscroller.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 TEXTSCROLLER_H -#define TEXTSCROLLER_H - -#include <QWidget> -#include <qmmp/qmmp.h> - -class QTimer; -class QMenu; -class QAction; -class Skin; -class SoundCore; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class TextScroller : public QWidget -{ -Q_OBJECT -public: - TextScroller(QWidget *parent = 0); - virtual ~TextScroller(); - - void setText(const QString &text); - -public slots: - void clear(); - -private slots: - void setProgress(int); - void addOffset(); - void updateSkin(); - void processState(Qmmp::State state); - void processMetaData(); - void updateText(); - -private: - void hideEvent(QHideEvent *); - void showEvent(QShowEvent *); - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void preparePixmap(const QString &text, bool scrollable = false); - QString m_defautText; - QString m_bufferText; - QString m_sliderText; - QString m_titleText; - QPixmap m_pixmap; - int m_x1, m_x2, m_ratio; - bool m_scroll, m_bitmap, m_pressed; - int m_press_pos; - QFont m_font; - QFontMetrics *m_metrics; - Skin *m_skin; - QColor m_color; - QTimer *m_timer; - QMenu *m_menu; - QAction *m_scrollAction; - SoundCore *m_core; -}; - -#endif diff --git a/src/ui/timeindicator.cpp b/src/ui/timeindicator.cpp deleted file mode 100644 index 02c185b36..000000000 --- a/src/ui/timeindicator.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 <QPainter> -#include <QSettings> -#include <QMouseEvent> -#include <QTimer> -#include <qmmp/qmmp.h> - -#include "skin.h" -#include "timeindicator.h" - -TimeIndicator::TimeIndicator (QWidget *parent) - : PixmapWidget (parent) -{ - m_skin = Skin::instance(); - m_pixmap = QPixmap (65 * m_skin->ratio(),13 * m_skin->ratio()); - m_elapsed = true; - m_time = m_songDuration = 0; - readSettings(); - m_needToShowTime = false; - updateSkin(); - reset(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - m_timer = new QTimer(this); - m_timer->setInterval(125); - m_timer->setSingleShot (true); - connect(m_timer, SIGNAL(timeout()),SLOT(reset())); -} - -void TimeIndicator::setTime (int t) -{ - m_time = t; - m_pixmap.fill (Qt::transparent); - int r = m_skin->ratio(); - QPainter paint (&m_pixmap); - - if (!m_elapsed) - { - t = m_songDuration - t; - paint.drawPixmap(r*2,0,m_skin->getNumber(10)); - } - if (t < 0) - t = 0; - - if(t > 3600) - t /= 60; - - paint.drawPixmap(r*13,0,m_skin->getNumber(t/600%10)); - paint.drawPixmap(r*26,0,m_skin->getNumber(t/60%10)); - paint.drawPixmap(r*43,0,m_skin->getNumber(t%60/10)); - paint.drawPixmap(r*56,0,m_skin->getNumber(t%60%10)); - - setPixmap (m_pixmap); - -} - -void TimeIndicator::reset() -{ - m_pixmap.fill (Qt::transparent); - QPainter paint (&m_pixmap); - setPixmap (m_pixmap ); -} - -void TimeIndicator::mousePressEvent(QMouseEvent* e) -{ - if (m_needToShowTime && e->button() & Qt::LeftButton) - { - m_elapsed = m_elapsed ? false : true; - setTime(m_time); - } - PixmapWidget::mousePressEvent(e); -} - -void TimeIndicator::setSongDuration(int d) -{ - m_songDuration = d; -} - -TimeIndicator::~TimeIndicator() -{ - writeSettings(); -} - - -void TimeIndicator::updateSkin() -{ - m_pixmap = QPixmap (65 * m_skin->ratio(),13 * m_skin->ratio()); - if (m_needToShowTime) - setTime(m_time); -} - -void TimeIndicator::readSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("Display"); - m_elapsed = settings.value("Elapsed",true).toBool(); - settings.endGroup(); -} - -void TimeIndicator::writeSettings() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.beginGroup("Display"); - settings.setValue("Elapsed",m_elapsed); - settings.endGroup(); -} - -void TimeIndicator::setNeedToShowTime(bool need) -{ - m_needToShowTime = need; - if (!need) - m_timer->start(); - else - m_timer->stop(); -} - -void TimeIndicator::mouseMoveEvent(QMouseEvent *) -{} - -void TimeIndicator::mouseReleaseEvent(QMouseEvent *) -{} - diff --git a/src/ui/timeindicator.h b/src/ui/timeindicator.h deleted file mode 100644 index 55e74c43f..000000000 --- a/src/ui/timeindicator.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 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 TIMEINDICATOR_H -#define TIMEINDICATOR_H - -#include "pixmapwidget.h" - -class QMouseEvent; -class QTimer; - -class Skin; - - -/** Class TimeIndicator - * @author Vladimir Kuznetsov <vovanec@gmail.com> - * - * Represents time indicator in the main display. Can show elapsed - * and rest time of song (mouse press on indicator changes mode) - */ -class TimeIndicator : public PixmapWidget -{ - Q_OBJECT -public: - TimeIndicator(QWidget *parent = 0); - ~TimeIndicator(); - void setTime ( int t ); - void setSongDuration(int); - void setNeedToShowTime(bool); - -protected: - virtual void mousePressEvent(QMouseEvent*); - virtual void mouseMoveEvent(QMouseEvent*); - virtual void mouseReleaseEvent(QMouseEvent*); - void writeSettings(); - void readSettings(); - -private slots: - void updateSkin(); - void reset(); - -private: - QPixmap m_pixmap; - Skin *m_skin; - int m_time; - int m_songDuration; - bool m_elapsed; - bool m_needToShowTime; - QTimer *m_timer; -}; - -#endif diff --git a/src/ui/titlebar.cpp b/src/ui/titlebar.cpp deleted file mode 100644 index 52ba97d32..000000000 --- a/src/ui/titlebar.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 <QMainWindow> -#include <QApplication> -#include <QMouseEvent> -#include <QMenu> -#include <QSettings> - -#include "symboldisplay.h" -#include "skin.h" -#include "button.h" -#include "dock.h" -#include "titlebarcontrol.h" -#include "shadedvisual.h" -#include "display.h" -#include "titlebar.h" - -// TODO skin cursor with shade mode -TitleBar::TitleBar(QWidget *parent) - : PixmapWidget(parent) -{ - m_align = false; - m_skin = Skin::instance(); - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_A)); - m_mw = qobject_cast<MainWindow*>(parent->parent()); - m_shaded = false; - m_shade2 = 0; - m_currentTime = 0; - m_control = 0; - m_visual = 0; - //buttons - m_menu = new Button(this,Skin::BT_MENU_N,Skin::BT_MENU_P, Skin::CUR_MAINMENU); - connect(m_menu,SIGNAL(clicked()),this,SLOT(showMainMenu())); - m_menu->move(6,3); - m_minimize = new Button(this,Skin::BT_MINIMIZE_N,Skin::BT_MINIMIZE_P, Skin::CUR_MIN); - connect(m_minimize, SIGNAL(clicked()), m_mw, SLOT(showMinimized())); - m_shade = new Button(this,Skin::BT_SHADE1_N,Skin::BT_SHADE1_P, Skin::CUR_WINBUT); - connect(m_shade, SIGNAL(clicked()), SLOT(shade())); - m_close = new Button(this,Skin::BT_CLOSE_N,Skin::BT_CLOSE_P, Skin::CUR_CLOSE); - connect(m_close, SIGNAL(clicked()), m_mw, SLOT(handleCloseRequest())); - setActive(false); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - if (settings.value("Display/shaded", false).toBool()) - shade(); - m_align = true; - setCursor(m_skin->getCursor(Skin::CUR_TITLEBAR)); - updatePositions(); -} - -TitleBar::~TitleBar() -{ - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.setValue("Display/shaded", m_shaded); -} - -void TitleBar::updatePositions() -{ - int r = m_skin->ratio(); - m_menu->move(r*6, r*3); - m_minimize->move(r*244, r*3); - m_shade->move(r*254, r*3); - m_close->move(r*264, r*3); - if(m_shade2) - m_shade2->move(r*254, r*3); - if(m_currentTime) - m_currentTime->move(r*127, r*4); - if(m_control) - m_control->move(r*168, r*2); - if(m_visual) - m_visual->move(r*79,r*5); -} - -void TitleBar::mousePressEvent(QMouseEvent* event) -{ - switch ((int) event->button ()) - { - case Qt::LeftButton: - m_pos = event->pos(); - Dock::instance()->calculateDistances(); - Dock::instance()->updateDock(); - break; - case Qt::RightButton: - m_mw->menu()->exec(event->globalPos()); - } -} - -void TitleBar::mouseReleaseEvent(QMouseEvent*) -{ - Dock::instance()->updateDock(); -} -void TitleBar::mouseMoveEvent(QMouseEvent* event) -{ - if (m_pos.x() < width() - m_skin->ratio() * 37) - { - QPoint npos = (event->globalPos()-m_pos); - Dock::instance()->move(m_mw, npos); - } -} - -void TitleBar::setActive(bool a) -{ - if (a) - { - if (m_shaded) - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_SHADED_A)); - else - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_A)); - } - else - { - if (m_shaded) - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_SHADED_I)); - else - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_I)); - } -} - -void TitleBar::updateSkin() -{ - setActive(false); - setCursor(m_skin->getCursor(Skin::CUR_TITLEBAR)); - updatePositions(); -} - -void TitleBar::showMainMenu() -{ - m_mw->menu()->exec(m_menu->mapToGlobal(m_menu->pos())); -} - -void TitleBar::shade() -{ - m_shaded = !m_shaded; - int r = m_skin->ratio(); - if (m_shaded) - { - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_SHADED_A)); - m_shade->hide(); - m_shade2 = new Button(this,Skin::BT_SHADE2_N, Skin::BT_SHADE2_P, Skin::CUR_WSNORMAL); - connect(m_shade2, SIGNAL(clicked()), SLOT(shade())); - m_shade2->show(); - m_currentTime = new SymbolDisplay(this, 6); - m_currentTime->show(); - m_currentTime->display("--:--"); - m_control = new TitleBarControl(this); - m_control->show(); - connect (m_control, SIGNAL (nextClicked()), m_mw, SLOT (next())); - connect (m_control, SIGNAL (previousClicked()), m_mw, SLOT (previous())); - connect (m_control, SIGNAL (playClicked()), m_mw, SLOT (play())); - connect (m_control, SIGNAL (pauseClicked()), m_mw, SLOT (pause())); - connect (m_control, SIGNAL (stopClicked()), m_mw, SLOT (stop())); - connect (m_control, SIGNAL (ejectClicked()), m_mw, SLOT (addFile())); - m_visual = new ShadedVisual(this); - Visual::add(m_visual); - m_visual->show(); - } - else - { - setPixmap(m_skin->getTitleBar(Skin::TITLEBAR_A)); - m_shade2->deleteLater(); - m_currentTime->deleteLater(); - m_control->deleteLater(); - Visual::remove(m_visual); - m_visual->deleteLater(); - m_shade2 = 0; - m_currentTime = 0; - m_control = 0; - m_visual = 0; - m_shade->show(); - } - qobject_cast<MainDisplay *> (parent())->setMinimalMode(m_shaded); - if (m_align) - Dock::instance()->align(m_mw, m_shaded? -r*102: r*102); - updatePositions(); -} - -void TitleBar::mouseDoubleClickEvent (QMouseEvent *) -{ - TitleBar::shade(); -} - -QString TitleBar::formatTime (int sec) -{ - int minutes = sec / 60; - int seconds = sec % 60; - - QString str_minutes = QString::number (minutes); - QString str_seconds = QString::number (seconds); - - if (minutes < 10) str_minutes.prepend ("0"); - if (seconds < 10) str_seconds.prepend ("0"); - - return str_minutes + ":" + str_seconds; -} - -void TitleBar::setTime(qint64 time) -{ - if (!m_currentTime) - return; - if (time < 0) - m_currentTime->display("--:--"); - else - m_currentTime->display(formatTime(time/1000)); -} - diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h deleted file mode 100644 index 55f59f7cc..000000000 --- a/src/ui/titlebar.h +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 TITLEBAR_H -#define TITLEBAR_H - -#include <QMainWindow> -#include <QPoint> - -#include "pixmapwidget.h" -#include "playlist.h" -#include "mainwindow.h" - -class MainWindow; -class QMouseEvent; -class Skin; -class Button; -class SymbolDisplay; -class TitleBarControl; -class ShadedVisual; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class TitleBar : public PixmapWidget -{ -Q_OBJECT -public: - TitleBar(QWidget *parent = 0); - - ~TitleBar(); - - void setActive(bool); - -public slots: - void setTime(qint64 time); - -private slots: - void updateSkin(); - void showMainMenu(); - void shade(); - -private: - Skin *m_skin; - QPoint m_pos; - MainWindow *m_mw; - Button *m_menu; - Button *m_minimize; - Button *m_shade; - Button *m_shade2; - Button *m_close; - SymbolDisplay *m_currentTime; - QString formatTime (int); - bool m_shaded; - bool m_align; - TitleBarControl *m_control; - ShadedVisual *m_visual; - void updatePositions(); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void mouseDoubleClickEvent(QMouseEvent*); -}; - - - -#endif diff --git a/src/ui/titlebarcontrol.cpp b/src/ui/titlebarcontrol.cpp deleted file mode 100644 index d4f064c75..000000000 --- a/src/ui/titlebarcontrol.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 <QMouseEvent> -#include "skin.h" -#include "titlebarcontrol.h" - -TitleBarControl::TitleBarControl(QWidget *parent) : QWidget(parent) -{ - //setAutoFillBackground(true); - m_ratio = Skin::instance()->ratio(); - resize(m_ratio*57, m_ratio*10); - connect(Skin::instance(), SIGNAL(skinChanged()),SLOT(updateSkin())); -} - - -TitleBarControl::~TitleBarControl() -{ -} - -void TitleBarControl::mousePressEvent (QMouseEvent *) -{} - -void TitleBarControl::mouseReleaseEvent (QMouseEvent * event) -{ - QPoint pt = event->pos(); - if(QRect(0,0,m_ratio*8,m_ratio*10).contains(pt)) - emit previousClicked(); - else if(QRect(m_ratio*8,0,m_ratio*11,m_ratio*10).contains(pt)) - emit playClicked(); - else if(QRect(m_ratio*19,0,m_ratio*10,m_ratio*10).contains(pt)) - emit pauseClicked(); - else if(QRect(m_ratio*29,0,m_ratio*8,m_ratio*10).contains(pt)) - emit stopClicked(); - else if(QRect(m_ratio*37,0,m_ratio*10,m_ratio*10).contains(pt)) - emit nextClicked(); - else if(QRect(m_ratio*47,0,m_ratio*10,m_ratio*10).contains(pt)) - emit ejectClicked(); -} - -void TitleBarControl::mouseMoveEvent(QMouseEvent*) -{} - -void TitleBarControl::updateSkin() -{ - m_ratio = Skin::instance()->ratio(); - resize(m_ratio*57, m_ratio*10); -} diff --git a/src/ui/titlebarcontrol.h b/src/ui/titlebarcontrol.h deleted file mode 100644 index 3631cce1d..000000000 --- a/src/ui/titlebarcontrol.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2009 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 TITLEBARCONTROL_H -#define TITLEBARCONTROL_H - -#include <QWidget> - -class QMouseEvent; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class TitleBarControl : public QWidget -{ -Q_OBJECT -public: - TitleBarControl(QWidget *parent = 0); - ~TitleBarControl(); - -signals: - void previousClicked(); - void nextClicked(); - void pauseClicked(); - void playClicked(); - void stopClicked(); - void ejectClicked(); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - -private slots: - void updateSkin(); - -private: - int m_ratio; - -}; - -#endif diff --git a/src/ui/togglebutton.cpp b/src/ui/togglebutton.cpp deleted file mode 100644 index 994ac9f20..000000000 --- a/src/ui/togglebutton.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * Based on Promoe, an XMMS2 Client * - * Copyright (C) 2005-2006 by XMMS2 Team * - * * - * 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 "skin.h" -#include "togglebutton.h" -#include <QMouseEvent> - -ToggleButton::ToggleButton ( QWidget *parent,uint on_n,uint on_p,uint off_n,uint off_p ) - : PixmapWidget ( parent ) -{ - m_on_n = on_n; - m_on_p = on_p; - m_off_n = off_n; - m_off_p = off_p; - m_on = false; - skin = Skin::instance(); - setON ( false ); - connect ( skin, SIGNAL ( skinChanged() ), this, SLOT ( updateSkin() ) ); -} - - -ToggleButton::~ToggleButton() -{} - -bool ToggleButton::isChecked() -{ - return m_on; -} - -void ToggleButton::updateSkin() -{ - //setPixmap ( skin->getButton ( name_normal ) ); - setON ( m_on ); -} - -void ToggleButton::click() -{ - m_on = !m_on; - setON (m_on); - emit clicked(m_on); -} - -void ToggleButton::setON ( bool on ) -{ - m_on = on; - if ( on ) - setPixmap ( skin->getButton ( m_on_n ) ); - else - setPixmap ( skin->getButton ( m_off_n ) ); -} -void ToggleButton::mousePressEvent ( QMouseEvent* ) -{ - m_cursorin = true; - m_old_on = m_on; - if ( m_on ) - setPixmap ( skin->getButton ( m_off_p ) ); - else - setPixmap ( skin->getButton ( m_on_p ) ); -} - -void ToggleButton::mouseReleaseEvent ( QMouseEvent* ) -{ - if ( m_cursorin ) { - m_on = !m_old_on; - setON ( m_on ); - emit clicked( m_on ); - } else { - m_on = m_old_on; - setON ( m_on ); - } -} - -void ToggleButton::mouseMoveEvent (QMouseEvent *e) -{ - if ( !m_cursorin && rect().contains(e->pos()) ) { - m_cursorin = true; - if ( m_old_on ) - setPixmap ( skin->getButton ( m_off_p ) ); - else - setPixmap ( skin->getButton ( m_on_p ) ); - } else if ( m_cursorin && !rect().contains(e->pos()) ) { - m_cursorin = false; - if ( m_old_on ) - setPixmap ( skin->getButton ( m_on_n ) ); - else - setPixmap ( skin->getButton ( m_off_n ) ); - } -} diff --git a/src/ui/togglebutton.h b/src/ui/togglebutton.h deleted file mode 100644 index 220d427cc..000000000 --- a/src/ui/togglebutton.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 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 TOGGLEBUTTON_H -#define TOGGLEBUTTON_H - -#include "pixmapwidget.h" - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Skin; - -class ToggleButton : public PixmapWidget -{ -Q_OBJECT -public: - ToggleButton( QWidget *parent, uint on_n, uint on_p, uint off_n, uint off_p ); - - ~ToggleButton(); - - bool isChecked(); - -signals: - void clicked(bool); - -public slots: - void setON(bool); - void click(); - -private slots: - void updateSkin(); - -private: - Skin *skin; - bool m_cursorin, m_old_on; - uint m_on_n, m_on_p, m_off_n, m_off_p; - bool m_on; - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); -}; - - -#endif diff --git a/src/ui/ui.pro b/src/ui/ui.pro index 04478d48a..1f5b8f619 100644 --- a/src/ui/ui.pro +++ b/src/ui/ui.pro @@ -1,125 +1,16 @@ include(../../qmmp.pri) -FORMS += forms/configdialog.ui \ - forms/preseteditor.ui \ - forms/jumptotrackdialog.ui \ - forms/aboutdialog.ui \ - forms/addurldialog.ui \ - forms/playlistbrowser.ui \ - forms/popupsettings.ui \ - forms/shortcutdialog.ui -HEADERS += mainwindow.h \ - button.h \ - display.h \ - skin.h \ - titlebar.h \ - positionbar.h \ - number.h \ - playlist.h \ - listwidget.h \ - pixmapwidget.h \ - playlisttitlebar.h \ - configdialog.h \ - playlistslider.h \ - dock.h \ - eqwidget.h \ - eqtitlebar.h \ - eqslider.h \ - togglebutton.h \ - eqgraph.h \ - mainvisual.h \ - inlines.h \ - fft.h \ - textscroller.h \ - monostereo.h \ - playstatus.h \ - pluginitem.h \ - volumebar.h \ - balancebar.h \ - symboldisplay.h \ - playlistcontrol.h \ - qmmpstarter.h \ - eqpreset.h \ - preseteditor.h \ - jumptotrackdialog.h \ - aboutdialog.h \ - timeindicator.h \ - keyboardmanager.h \ - addurldialog.h \ - skinreader.h \ - visualmenu.h \ - titlebarcontrol.h \ - shadedvisual.h \ - shadedbar.h \ - builtincommandlineoption.h \ - cursorimage.h \ - playlistbrowser.h \ - playlistselector.h \ - popupwidget.h \ - popupsettings.h \ - windowsystem.h \ - lxdesupport.h \ - actionmanager.h \ - shortcutitem.h \ - shortcutdialog.h -SOURCES += mainwindow.cpp \ - mp3player.cpp \ - button.cpp \ - display.cpp \ - skin.cpp \ - titlebar.cpp \ - positionbar.cpp \ - number.cpp \ - playlist.cpp \ - listwidget.cpp \ - pixmapwidget.cpp \ - playlisttitlebar.cpp \ - configdialog.cpp \ - playlistslider.cpp \ - dock.cpp \ - eqwidget.cpp \ - eqtitlebar.cpp \ - eqslider.cpp \ - togglebutton.cpp \ - eqgraph.cpp \ - mainvisual.cpp \ - fft.c \ - textscroller.cpp \ - monostereo.cpp \ - playstatus.cpp \ - pluginitem.cpp \ - volumebar.cpp \ - balancebar.cpp \ - symboldisplay.cpp \ - playlistcontrol.cpp \ - qmmpstarter.cpp \ - eqpreset.cpp \ - preseteditor.cpp \ - jumptotrackdialog.cpp \ - aboutdialog.cpp \ - timeindicator.cpp \ - keyboardmanager.cpp \ - addurldialog.cpp \ - skinreader.cpp \ - visualmenu.cpp \ - titlebarcontrol.cpp \ - shadedvisual.cpp \ - shadedbar.cpp \ - builtincommandlineoption.cpp \ - cursorimage.cpp \ - playlistbrowser.cpp \ - playlistselector.cpp \ - popupwidget.cpp \ - popupsettings.cpp \ - windowsystem.cpp \ + +HEADERS += qmmpstarter.h \ + builtincommandlineoption.h \ + lxdesupport.h + +SOURCES += \ + qmmpstarter.cpp \ + builtincommandlineoption.cpp \ lxdesupport.cpp \ - actionmanager.cpp \ - shortcutitem.cpp \ - shortcutdialog.cpp -win32:HEADERS += ../qmmp/visual.h -unix { - HEADERS += - SOURCES += -} + main.cpp + + # Some conf to redirect intermediate stuff in separate dirs UI_DIR = ./.build/ui/ @@ -141,8 +32,7 @@ win32:LIBS += -L../../bin \ -lqmmp0 \ -lqmmpui0 INCLUDEPATH += ../ -RESOURCES = images/images.qrc \ - stuff.qrc +RESOURCES = images/images.qrc TEMPLATE = app unix { target.path = /bin @@ -182,7 +72,3 @@ TRANSLATIONS = translations/qmmp_ru.ts \ translations/qmmp_ja.ts \ translations/qmmp_es.ts \ translations/qmmp_sk.ts -x11 { - CONFIG += link_pkgconfig - PKGCONFIG += x11 -} diff --git a/src/ui/visualmenu.cpp b/src/ui/visualmenu.cpp deleted file mode 100644 index af8e936d2..000000000 --- a/src/ui/visualmenu.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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 <qmmp/visual.h> -#include <qmmp/visualfactory.h> - -#include "pluginitem.h" -#include "visualmenu.h" - -VisualMenu::VisualMenu(QWidget *parent) : QMenu(tr("Visualization"), parent) -{ - VisualFactory *factory = 0; - foreach(factory, *Visual::factories()) - { - VisualAction *act = new VisualAction(factory, this); - addAction(act); - } -} - -VisualMenu::~VisualMenu() -{ -} - -void VisualMenu::updateActions() -{ - for(int i = 0; i < Visual::factories()->size(); ++i) - { - actions()[i]->setChecked(Visual::isEnabled(Visual::factories()->at(i))); - } -} - -VisualAction::VisualAction(VisualFactory *factory, QWidget *parent) : - QAction(factory->properties().name, parent) -{ - setCheckable (true); - setChecked (Visual::isEnabled(factory)); - m_factory = factory; - connect(this, SIGNAL(triggered(bool)), SLOT(select(bool))); -} - -void VisualAction::select(bool select) -{ - Visual::setEnabled(m_factory, select); -} diff --git a/src/ui/visualmenu.h b/src/ui/visualmenu.h deleted file mode 100644 index 0039c7aaf..000000000 --- a/src/ui/visualmenu.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007-2010 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> -#include <QAction> - -class VisualFactory; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class VisualMenu : public QMenu -{ - Q_OBJECT -public: - VisualMenu(QWidget *parent = 0); - - ~VisualMenu(); - -public slots: - void updateActions(); -}; - -class VisualAction : public QAction -{ - Q_OBJECT -public: - VisualAction(VisualFactory *factory, QWidget *parent = 0); - -private slots: - void select(bool); - -private: - VisualFactory *m_factory; - -}; - -#endif diff --git a/src/ui/volumebar.cpp b/src/ui/volumebar.cpp deleted file mode 100644 index e0829e659..000000000 --- a/src/ui/volumebar.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 <QMouseEvent> -#include <QPainter> -#include <math.h> -#include "skin.h" -#include "button.h" -#include "mainwindow.h" -#include "volumebar.h" - - -VolumeBar::VolumeBar(QWidget *parent) : PixmapWidget(parent) -{ - m_skin = Skin::instance(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - setPixmap(m_skin->getVolumeBar(0)); - mw = qobject_cast<MainWindow*>(window()); - m_moving = false; - m_min = 0; - m_max = 100; - m_old = m_value = 0; - draw(false); -} - -VolumeBar::~VolumeBar() -{} - -void VolumeBar::mousePressEvent(QMouseEvent *e) -{ - m_moving = true; - press_pos = e->x(); - if(m_pos<e->x() && e->x()<m_pos+11*m_skin->ratio()) - { - press_pos = e->x()-m_pos; - emit sliderPressed(); - } - else - { - m_value = convert(qMax(qMin(width()-18*m_skin->ratio(),e->x()-6*m_skin->ratio()),0)); - press_pos = 6*m_skin->ratio(); - emit sliderPressed(); - if (m_value != m_old) - emit sliderMoved(m_value); - } - draw(); -} - -void VolumeBar::mouseMoveEvent (QMouseEvent *e) -{ - if(m_moving) - { - int po = e->x(); - po = po - press_pos; - - if(0<=po && po<=width()-18*m_skin->ratio()) - { - m_value = convert(po); - draw(); - emit sliderMoved(m_value); - } - } -} - -void VolumeBar::mouseReleaseEvent(QMouseEvent*) -{ - m_moving = false; - draw(false); - m_old = m_value; - emit sliderReleased(); -} - -void VolumeBar::setValue(int v) -{ - if (m_moving || m_max == 0) - return; - m_value = v; - draw(false); -} - -void VolumeBar::setMax(int max) -{ - m_max = max; - draw(false); -} - -void VolumeBar::updateSkin() -{ - resize(m_skin->getVolumeBar(0).size()); - draw(false); - setCursor(m_skin->getCursor(Skin::CUR_VOLBAL)); -} - -void VolumeBar::draw(bool pressed) -{ - int p=int(ceil(double(m_value-m_min)*(width()-18*m_skin->ratio())/(m_max-m_min))); - m_pixmap = m_skin->getVolumeBar(27*(m_value-m_min)/(m_max-m_min)); - QPainter paint(&m_pixmap); - if(pressed) - paint.drawPixmap(p,1,m_skin->getButton(Skin::BT_VOL_P)); - else - paint.drawPixmap(p,1,m_skin->getButton(Skin::BT_VOL_N)); - setPixmap(m_pixmap); - m_pos = p; -} - -int VolumeBar::convert(int p) -{ - return int(ceil(double(m_max-m_min)*(p)/(width()-18*m_skin->ratio())+m_min)); -} diff --git a/src/ui/volumebar.h b/src/ui/volumebar.h deleted file mode 100644 index 47d4dcb0d..000000000 --- a/src/ui/volumebar.h +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2011 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 VOLUMEBAR_H -#define VOLUMEBAR_H - -#include "pixmapwidget.h" - -class Skin; -class MainWindow; - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class VolumeBar : public PixmapWidget -{ -Q_OBJECT -public: - VolumeBar(QWidget *parent = 0); - - ~VolumeBar(); - - int value() - { - return m_value; - } - int isPressed() - { - return m_moving; - } - -public slots: - void setValue(int); - void setMax(int); - -signals: - void sliderMoved (int); - void sliderPressed(); - void sliderReleased(); - -private slots: - void updateSkin(); - -private: - Skin *m_skin; - bool m_moving; - int press_pos; - int m_max, m_min, m_pos, m_value, m_old; - QPixmap m_pixmap; - MainWindow *mw; - int convert(int); // value = convert(position); - void draw(bool pressed = true); - -protected: - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); -}; - -#endif diff --git a/src/ui/windowsystem.cpp b/src/ui/windowsystem.cpp deleted file mode 100644 index 4b66ae025..000000000 --- a/src/ui/windowsystem.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*************************************************************************** - * Based on Licq * - * Copyright (C) 2006-2009 Licq developers * - * Copyright (C) 2011 Ilya Kotov * - * * - * 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 "windowsystem.h" -#include <QCoreApplication> -#ifdef Q_WS_X11 -#include <QX11Info> -#include <X11/X.h> -#include <X11/Xatom.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#endif - -#ifdef Q_WS_X11 -void WindowSystem::ghostWindow(WId win) -{ - Display* dsp = QX11Info::display(); - Window root = DefaultRootWindow(dsp); - - Atom win_state = XInternAtom(dsp, "_NET_WM_STATE", False); - Atom win_state_add = XInternAtom(dsp, "_NET_WM_STATE_ADD", False); - Atom win_state_settings[] = - { - XInternAtom(dsp, "_NET_WM_STATE_SKIP_TASKBAR", False), - XInternAtom(dsp, "_NET_WM_STATE_SKIP_PAGER", False) - }; - XChangeProperty(dsp, win, win_state, XA_ATOM, 32, PropModeReplace, - reinterpret_cast<unsigned char*>(&win_state_settings), 2); - - XEvent xev; - xev.type = ClientMessage; - xev.xclient.type = ClientMessage; - xev.xclient.display = dsp; - xev.xclient.window = win; - xev.xclient.message_type = win_state; - xev.xclient.format = 32; - xev.xclient.data.l[0] = win_state_add; - xev.xclient.data.l[1] = win_state_settings[0]; - xev.xclient.data.l[2] = win_state_settings[1]; - - XSendEvent(dsp, root, false, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); -} - -QString WindowSystem::netWindowManagerName() -{ - Display* dsp = QX11Info::display(); - WId root = DefaultRootWindow(dsp); - - unsigned char* retValue1 = NULL; - unsigned char* retValue2 = NULL; - - retValue1 = getWindowProperty(root, "_NET_SUPPORTING_WM_CHECK"); - if (retValue1 == NULL) - return QString(); - - WId win = *(reinterpret_cast<unsigned long*>(retValue1)); - - retValue2 = getWindowProperty(win, "_NET_SUPPORTING_WM_CHECK"); - if (retValue2 == NULL) - { - XFree(retValue1); - return QString(); - } - - if (win != *(reinterpret_cast<unsigned long*>(retValue2))) - { - XFree(retValue1); - XFree(retValue2); - return QString(); - } - - XFree(retValue2); - retValue2 = NULL; - - retValue2 = getWindowProperty(win, "_NET_WM_NAME"); - XFree(retValue1); - if (retValue2 == NULL) - return QString(); - - QString name = QString((char *)retValue2); - XFree(retValue2); - return name; -} - -void WindowSystem::changeWinSticky(WId win, bool stick) -{ - qDebug("WindowSystem: setting sticky state of window 0x%lx to %s.", - static_cast<unsigned long>(win), stick ? "true" : "false"); - Display* dsp = QX11Info::display(); - Window root = DefaultRootWindow(dsp); - - unsigned long desktop = ~(0UL); - - if (!stick) - { - unsigned char* tmp = getWindowProperty(root, "_NET_CURRENT_DESKTOP"); - - if (tmp == NULL) - qWarning("WindowSystem: error reading current desktop property."); - else - { - desktop = *(reinterpret_cast<unsigned long*>(tmp)); - XFree(tmp); - } - } - - XEvent xev; - xev.type = ClientMessage; - xev.xclient.type = ClientMessage; - xev.xclient.display = dsp; - xev.xclient.window = win; - xev.xclient.message_type = XInternAtom(dsp, "_NET_WM_DESKTOP", False); - xev.xclient.format = 32; - xev.xclient.data.l[0] = desktop; - - XSendEvent(dsp, root, False, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); -} - -void WindowSystem::setWinHint(WId win, const char *res_name, const char *res_class) -{ - Display* dsp = QX11Info::display(); - XClassHint hint; - hint.res_name = strdup(res_name); - hint.res_class = strdup(res_class); - XSetClassHint(dsp, win, &hint); - free(hint.res_name); - free(hint.res_class); -} - -unsigned char* WindowSystem::getWindowProperty(WId win, const char* prop) -{ - Display* dsp = QX11Info::display(); - - // We inhibit new Atom creation since if you request for it - // then such Atom most probably exists already. - // Otherwise, no surprise we return NULL here. - Atom reqAtom = XInternAtom(dsp, prop, True); - - if (reqAtom == None) - return NULL; - - int retCheck = None; - Atom retType = None; - int retFormat = 0; - unsigned long retItems = 0UL; - unsigned long retMoreBytes = 0UL; - unsigned char* retValue = NULL; - - // Check if the property exists and calculate its length. - retCheck = XGetWindowProperty(dsp, win, - reqAtom, 0L, 0L, False, AnyPropertyType, - &retType, &retFormat, &retItems, &retMoreBytes, &retValue); - - // The value is most probably empty, since we requested to read - // only 0L length, thus, it's just useless... - if (retValue != NULL) - { - XFree(retValue); - retValue = NULL; - } - - if (retCheck != Success || - retType == None || - retMoreBytes == 0) - return NULL; - - // These are not needed for now. - retCheck = None; - retFormat = 0; - retItems = 0UL; - - // Convert the byte length into 32bit multiples. - if (retMoreBytes % 4 != 0) - retMoreBytes += 4 - retMoreBytes % 4; - retMoreBytes /= 4; - - // Now request the actual property value with correct length and type. - retCheck = XGetWindowProperty(dsp, win, - reqAtom, 0L, retMoreBytes, False, retType, - &retType, &retFormat, &retItems, &retMoreBytes, &retValue); - - if (retCheck != Success || - retMoreBytes != 0) - { - if (retValue != NULL) - XFree(retValue); - return NULL; - } - - return retValue; -} - -#endif diff --git a/src/ui/windowsystem.h b/src/ui/windowsystem.h deleted file mode 100644 index a9d8fb001..000000000 --- a/src/ui/windowsystem.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Based on Licq * - * Copyright (C) 2006-2009 Licq developers * - * Copyright (C) 2011 Ilya Kotov * - * * - * 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 WINDOWSYSTEM_H -#define WINDOWSYSTEM_H - -#include <QWidget> - -class WindowSystem -{ -public: -#ifdef Q_WS_X11 - static void ghostWindow(WId id); - static QString netWindowManagerName(); - static void changeWinSticky(WId win, bool stick); - static void setWinHint(WId win, const char *res_name, const char *res_class); -private: - static unsigned char* getWindowProperty(WId win, const char* prop); -#endif -}; -#endif // WINDOWSYSTEM_H |
