From 7b17a2848b62d30f25771529566a61f4dd40131e Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Mon, 23 Nov 2009 20:39:29 +0000 Subject: added popup information git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1399 90c681e8-e032-0410-971d-27865f9a5e38 --- src/ui/CMakeLists.txt | 5 + src/ui/configdialog.cpp | 11 +- src/ui/configdialog.h | 1 + src/ui/cursorimage.cpp | 19 +++ src/ui/cursorimage.h | 19 +++ src/ui/forms/configdialog.ui | 312 ++++++++++++++++++++++++------------------ src/ui/forms/popupsettings.ui | 234 +++++++++++++++++++++++++++++++ src/ui/listwidget.cpp | 81 ++++++----- src/ui/listwidget.h | 4 + src/ui/popupsettings.cpp | 84 ++++++++++++ src/ui/popupsettings.h | 52 +++++++ src/ui/popupwidget.cpp | 116 ++++++++++++++++ src/ui/popupwidget.h | 61 +++++++++ src/ui/ui.pro | 11 +- 14 files changed, 844 insertions(+), 166 deletions(-) create mode 100644 src/ui/forms/popupsettings.ui create mode 100644 src/ui/popupsettings.cpp create mode 100644 src/ui/popupsettings.h create mode 100644 src/ui/popupwidget.cpp create mode 100644 src/ui/popupwidget.h (limited to 'src') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 172b2a3ab..010845a98 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -78,6 +78,8 @@ SET(ui_SRCS cursorimage.cpp playlistbrowser.cpp playlistselector.cpp + popupwidget.cpp + popupsettings.cpp ) SET(ui_MOC_HDRS @@ -130,6 +132,8 @@ SET(ui_MOC_HDRS cursorimage.h playlistbrowser.h playlistselector.h + popupwidget.h + popupsettings.h ) SET(ui_RCCS images/images.qrc stuff.qrc translations/qmmp_locales.qrc) @@ -149,6 +153,7 @@ SET(ui_UIS forms/jumptotrackdialog.ui forms/preseteditor.ui forms/playlistbrowser.ui + forms/popupsettings.ui ) QT4_WRAP_UI(ui_UIS_H ${ui_UIS}) diff --git a/src/ui/configdialog.cpp b/src/ui/configdialog.cpp index eeae7cb3b..491ca617d 100644 --- a/src/ui/configdialog.cpp +++ b/src/ui/configdialog.cpp @@ -43,7 +43,7 @@ #include #include - +#include "popupsettings.h" #include "skin.h" #include "pluginitem.h" #include "configdialog.h" @@ -113,6 +113,7 @@ void ConfigDialog::readSettings() ui.protocolCheckBox->setChecked(settings.value ("PlayList/show_protocol", FALSE).toBool()); ui.numbersCheckBox->setChecked(settings.value ("PlayList/show_numbers", TRUE).toBool()); ui.playlistsCheckBox->setChecked(settings.value("PlayList/show_plalists", FALSE).toBool()); + ui.popupCheckBox->setChecked(settings.value("PlayList/show_popup", FALSE).toBool()); //proxy settings ui.enableProxyCheckBox->setChecked(Qmmp::useProxy()); ui.authProxyCheckBox->setChecked(Qmmp::useProxyAuth()); @@ -618,6 +619,7 @@ void ConfigDialog::saveSettings() settings.setValue ("PlayList/show_protocol", ui.protocolCheckBox->isChecked()); settings.setValue ("PlayList/show_numbers", ui.numbersCheckBox->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())); Qmmp::setProxyEnabled(ui.enableProxyCheckBox->isChecked()); @@ -734,3 +736,10 @@ void ConfigDialog::installSkin() } loadSkins(); } + +void ConfigDialog::on_popupCustomizeButton_clicked() +{ + PopupSettings *p = new PopupSettings(this); + p->exec(); + p->deleteLater(); +} diff --git a/src/ui/configdialog.h b/src/ui/configdialog.h index 74232502b..fbec0850f 100644 --- a/src/ui/configdialog.h +++ b/src/ui/configdialog.h @@ -62,6 +62,7 @@ private slots: void showFileDialogInfo(); void installSkin(); void loadSkins(); + void on_popupCustomizeButton_clicked(); private: void readSettings(); diff --git a/src/ui/cursorimage.cpp b/src/ui/cursorimage.cpp index 904a0568a..96637728d 100644 --- a/src/ui/cursorimage.cpp +++ b/src/ui/cursorimage.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 #include diff --git a/src/ui/cursorimage.h b/src/ui/cursorimage.h index 575335c37..cde27d62d 100644 --- a/src/ui/cursorimage.h +++ b/src/ui/cursorimage.h @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 diff --git a/src/ui/forms/configdialog.ui b/src/ui/forms/configdialog.ui index f008d856d..6a0cedd95 100644 --- a/src/ui/forms/configdialog.ui +++ b/src/ui/forms/configdialog.ui @@ -7,7 +7,7 @@ 0 0 601 - 402 + 424 @@ -367,17 +367,91 @@ - - - Qt::Vertical - - - - 20 - 160 - + + + Transparency - + + + + + Main window + + + + + + + 90 + + + Qt::Horizontal + + + + + + + + 25 + 0 + + + + 0 + + + + + + + Equalizer + + + + + + + 90 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + Playlist + + + + + + + 90 + + + Qt::Horizontal + + + + + + + 0 + + + + + @@ -435,53 +509,87 @@ - + Convert underscores to blanks - + Convert %20 to blanks - + Show protocol - + Show song numbers - + Show playlists + + + + + + Show popup information + + + + + + + false + + + Customize + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - + Qt::Vertical - 387 - 101 + 20 + 54 @@ -747,91 +855,17 @@ - - - Transparency + + + Qt::Vertical - - - - - Main window - - - - - - - 90 - - - Qt::Horizontal - - - - - - - - 25 - 0 - - - - 0 - - - - - - - Equalizer - - - - - - - 90 - - - Qt::Horizontal - - - - - - - 0 - - - - - - - Playlist - - - - - - - 90 - - - Qt::Horizontal - - - - - - - 0 - - - - - + + + 20 + 40 + + + @@ -1019,12 +1053,12 @@ setEnabled(bool) - 305 - 52 + 276 + 39 - 424 - 82 + 276 + 39 @@ -1035,12 +1069,12 @@ setEnabled(bool) - 506 - 56 + 276 + 39 - 506 - 116 + 276 + 39 @@ -1051,12 +1085,12 @@ setEnabled(bool) - 318 - 142 + 276 + 39 - 326 - 163 + 276 + 39 @@ -1067,12 +1101,28 @@ setEnabled(bool) - 264 - 138 + 276 + 39 + + + 276 + 39 + + + + + popupCheckBox + toggled(bool) + popupCustomizeButton + setEnabled(bool) + + + 276 + 39 - 580 - 197 + 276 + 39 @@ -1083,12 +1133,12 @@ setNum(int) - 489 - 285 + 397 + 294 - 553 - 284 + 540 + 289 @@ -1099,12 +1149,12 @@ setNum(int) - 519 - 305 + 496 + 315 - 549 - 309 + 550 + 315 @@ -1115,12 +1165,12 @@ setNum(int) - 511 - 327 + 494 + 333 - 549 - 330 + 542 + 332 diff --git a/src/ui/forms/popupsettings.ui b/src/ui/forms/popupsettings.ui new file mode 100644 index 000000000..7a2517299 --- /dev/null +++ b/src/ui/forms/popupsettings.ui @@ -0,0 +1,234 @@ + + + PopupSettings + + + + 0 + 0 + 292 + 300 + + + + Popup Information Settings + + + + 6 + + + 6 + + + 6 + + + + + 32 + + + 128 + + + 1 + + + 16 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + Transparency: + + + + + + + 90 + + + Qt::Horizontal + + + + + + + + 18 + 0 + + + + 0 + + + + + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + Cover size: + + + + + + + Template + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 138 + 20 + + + + + + + + Reset + + + + + + + Insert + + + + + + + + + + + + buttonBox + accepted() + PopupSettings + accept() + + + 281 + 286 + + + 62 + 299 + + + + + buttonBox + rejected() + PopupSettings + reject() + + + 281 + 286 + + + 95 + 299 + + + + + transparencySlider + valueChanged(int) + trasparencyLabel + setNum(int) + + + 258 + 251 + + + 282 + 251 + + + + + coverSizeSlider + valueChanged(int) + coverSizeLabel + setNum(int) + + + 258 + 223 + + + 282 + 223 + + + + + diff --git a/src/ui/listwidget.cpp b/src/ui/listwidget.cpp index 1ad27c50b..120f049ea 100644 --- a/src/ui/listwidget.cpp +++ b/src/ui/listwidget.cpp @@ -33,6 +33,7 @@ #include "textscroller.h" #include "listwidget.h" #include "skin.h" +#include "popupwidget.h" #include "playlist.h" #define INVALID_ROW -1 @@ -42,6 +43,7 @@ ListWidget::ListWidget(QWidget *parent) { m_update = FALSE; m_skin = Skin::instance(); + m_popupWidget = 0; loadColors(); m_menu = new QMenu(this); m_scroll_direction = NONE; @@ -56,6 +58,7 @@ ListWidget::ListWidget(QWidget *parent) readSettings(); connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); setAcceptDrops(true); + setMouseTracking(true); } @@ -68,6 +71,7 @@ void ListWidget::readSettings() m_font.fromString(settings.value("PlayList/Font", QApplication::font().toString()).toString()); m_show_protocol = settings.value ("PlayList/show_protocol", FALSE).toBool(); m_show_number = settings.value ("PlayList/show_numbers", TRUE).toBool(); + bool show_popup = settings.value("PlayList/show_popup", FALSE).toBool(); if (m_update) { @@ -75,12 +79,19 @@ void ListWidget::readSettings() m_metrics = new QFontMetrics(m_font); m_rows = (height() - 10) / m_metrics->ascent (); updateList(); + if(m_popupWidget) + { + m_popupWidget->deleteLater(); + m_popupWidget = 0; + } } else { m_update = TRUE; m_metrics = new QFontMetrics(m_font); } + if(show_popup) + m_popupWidget = new PlayListPopup::PopupWidget(this); } void ListWidget::loadColors() @@ -154,6 +165,8 @@ void ListWidget::mouseDoubleClickEvent (QMouseEvent *e) void ListWidget::mousePressEvent(QMouseEvent *e) { + if(m_popupWidget) + m_popupWidget->hide(); m_scroll = TRUE; int y = e->y(); int row = rowAt(y); @@ -236,12 +249,17 @@ bool ListWidget::event (QEvent *e) { if(e->type() == QEvent::ToolTip) { - e->accept(); QHelpEvent *helpEvent = (QHelpEvent *) e; int row = rowAt(helpEvent->y()); - qDebug("==== %d", row); + if(row < 0) + return QWidget::event(e); + e->accept(); + if(m_popupWidget) + m_popupWidget->popup(m_model->item(row), helpEvent->globalPos() + QPoint(15,10)); return TRUE; } + else if(e->type() == QEvent::Leave && m_popupWidget) + m_popupWidget->hide(); return QWidget::event(e); } @@ -257,11 +275,7 @@ void ListWidget::updateList() emit positionChanged(0,0); } else - { - //int pos = m_first*99/(m_model->count() - m_rows); - //emit positionChanged(pos); emit positionChanged(m_first, m_model->count() - m_rows); - } if (m_model->count() <= m_first) { m_first = 0; @@ -375,34 +389,39 @@ const QString ListWidget::getExtraString(int i) void ListWidget::mouseMoveEvent(QMouseEvent *e) { - 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; - - int row = rowAt(e->y()); - - if (INVALID_ROW != row) + if(e->buttons() == Qt::LeftButton) { - 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; + 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 (row + 1 == m_first + m_rows && m_scroll_direction == DOWN) - (m_first + m_rows < m_model->count() ) ? m_first ++ : m_first; - else if (row == m_first && m_scroll_direction == TOP) - (m_first > 0) ? m_first -- : 0; + int row = rowAt(e->y()); - m_model->moveItems(m_pressed_row,row); - m_prev_y = e->y(); - m_scroll = false; - m_pressed_row = row; + if (INVALID_ROW != row) + { + 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 (row + 1 == m_first + m_rows && m_scroll_direction == DOWN) + (m_first + m_rows < m_model->count() ) ? m_first ++ : m_first; + else if (row == m_first && m_scroll_direction == TOP) + (m_first > 0) ? m_first -- : 0; + + m_model->moveItems(m_pressed_row,row); + m_prev_y = e->y(); + m_scroll = false; + m_pressed_row = row; + } } + else if(e->buttons() == Qt::NoButton && m_popupWidget && m_popupWidget->isVisible()) + m_popupWidget->move(e->globalPos() + QPoint(15,10)); } void ListWidget::mouseReleaseEvent(QMouseEvent *e) @@ -425,7 +444,7 @@ int ListWidget::rowAt(int y) const if (y <= 14 && y >= 2 && m_model->count()) return m_first; - for (int i = 0; i < qMin(m_rows, m_model->count() - m_first); ++i ) + for (int i = 0; i < qMin(m_rows, m_model->count() - m_first) - 1; ++i ) { if ((y >= 14 + i * m_metrics->ascent ()) && (y <= 14 + (i+1) * m_metrics->ascent())) return m_first + i + 1; diff --git a/src/ui/listwidget.h b/src/ui/listwidget.h index 7c581f4ce..d17b380c2 100644 --- a/src/ui/listwidget.h +++ b/src/ui/listwidget.h @@ -33,6 +33,9 @@ class PlayListModel; class Skin; class PlayListItem; class MediaPlayer; +namespace PlayListPopup{ +class PopupWidget; +} /** @author Ilya Kotov @@ -148,6 +151,7 @@ private: bool m_show_protocol; bool m_show_number; MediaPlayer *m_player; + PlayListPopup::PopupWidget *m_popupWidget; }; #endif diff --git a/src/ui/popupsettings.cpp b/src/ui/popupsettings.cpp new file mode 100644 index 000000000..ceb9ad34d --- /dev/null +++ b/src/ui/popupsettings.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#include +#include +#include +#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()); + 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.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 new file mode 100644 index 000000000..ed7dde6c4 --- /dev/null +++ b/src/ui/popupsettings.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * 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 +#include "ui_popupsettings.h" + +class Action; + +/** + @author Ilya Kotov +*/ +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 m_buttons; +}; + +#endif diff --git a/src/ui/popupwidget.cpp b/src/ui/popupwidget.cpp new file mode 100644 index 000000000..0494f6bb0 --- /dev/null +++ b/src/ui/popupwidget.cpp @@ -0,0 +1,116 @@ +/*************************************************************************** + * Copyright (C) 2008-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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "popupwidget.h" + +using namespace PlayListPopup; + +PopupWidget::PopupWidget(QWidget *parent) + : QFrame(parent) +{ + setWindowFlags(Qt::X11BypassWindowManagerHint | + Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::FramelessWindowHint); + setFrameStyle(QFrame::Box | QFrame::Plain); + setAttribute(Qt::WA_QuitOnClose, FALSE); + m_lastItem = 0; + QHBoxLayout *hlayout = new QHBoxLayout(this); //layout + m_pixlabel = new QLabel(this); + m_pixlabel->setPixmap(QPixmap(":/32x32/qmmp.png")); + m_pixlabel->setFixedSize(32,32); + 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(); + settings.endGroup(); + //timer + m_timer = new QTimer(this); + m_timer->setInterval(10000); + m_timer->setSingleShot (TRUE); + connect(m_timer, SIGNAL(timeout ()), SLOT(hide())); +} + +PopupWidget::~PopupWidget() +{} + +void PopupWidget::mousePressEvent (QMouseEvent *) +{ + deleteLater(); +} + +void PopupWidget::popup(PlayListItem *item, QPoint pos) +{ + if(m_lastItem == item) + { + show(); + m_timer->start(); + return; + } + m_timer->stop(); + m_lastItem = item; + move(pos); + QString title = m_template; + + if (item->length() > 0) + { + int l = item->length(); + title.replace("%l",QString("%1:%2").arg(l/60).arg(l%60, 2, 10, QChar('0'))); + } + else + title.replace("%l",""); + MetaDataFormatter f(title); + title = f.parse(item->metaData()); + + m_label1->setText(title); + + QPixmap pix = MetaDataManager::instance()->getCover(item->url()); + if(!pix.isNull()) + { + m_pixlabel->setFixedSize(m_coverSize,m_coverSize); + m_pixlabel->setPixmap(pix.scaled(m_coverSize,m_coverSize)); + } + else + { + m_pixlabel->setPixmap(QPixmap(":/notifier_icon.png")); + m_pixlabel->setFixedSize(32,32); + } + qApp->processEvents(); + resize(sizeHint()); + qApp->processEvents(); + show(); + m_timer->start(); +} diff --git a/src/ui/popupwidget.h b/src/ui/popupwidget.h new file mode 100644 index 000000000..c88ee3176 --- /dev/null +++ b/src/ui/popupwidget.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2008-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 POPUPWIDGET_H +#define POPUPWIDGET_H + +#include +#include + +#define DEFAULT_TEMPLATE "%if(%t,%t,%f)\n%if(%p,
%p,)\n%if(%a,
%a,)" + +class QTimer; +class QLabel; +class PlayListItem; + +namespace PlayListPopup { +/** + @author Ilya Kotov +*/ +class PopupWidget : public QFrame +{ + Q_OBJECT +public: + PopupWidget(QWidget *parent = 0); + + ~PopupWidget(); + + void popup(PlayListItem *item, QPoint pos); + +protected: + virtual void mousePressEvent (QMouseEvent *); + +private: + QTimer *m_timer; + QLabel *m_label1; + QLabel *m_pixlabel; + QString m_template; + uint m_pos; + int m_coverSize; + PlayListItem *m_lastItem; + +}; +} + +#endif diff --git a/src/ui/ui.pro b/src/ui/ui.pro index d4ab1eb7b..6820fdc35 100644 --- a/src/ui/ui.pro +++ b/src/ui/ui.pro @@ -8,7 +8,8 @@ FORMS += ./forms/configdialog.ui \ ./forms/jumptotrackdialog.ui \ ./forms/aboutdialog.ui \ ./forms/addurldialog.ui \ - ./forms/playlistbrowser.ui + ./forms/playlistbrowser.ui \ + ./forms/popupsettings.ui HEADERS += mainwindow.h \ button.h \ display.h \ @@ -56,7 +57,9 @@ HEADERS += mainwindow.h \ builtincommandlineoption.h \ cursorimage.h \ playlistbrowser.h \ - playlistselector.h + playlistselector.h \ + popupwidget.h \ + popupsettings.h SOURCES += mainwindow.cpp \ mp3player.cpp \ button.cpp \ @@ -104,7 +107,9 @@ SOURCES += mainwindow.cpp \ builtincommandlineoption.cpp \ cursorimage.cpp \ playlistbrowser.cpp \ - playlistselector.cpp + playlistselector.cpp \ + popupwidget.cpp \ + popupsettings.cpp win32:HEADERS += ../qmmp/visual.h unix { HEADERS += unixdomainsocket.h -- cgit v1.2.3-13-gbd6f