diff options
| -rw-r--r-- | src/ui/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/ui/configdialog.cpp | 11 | ||||
| -rw-r--r-- | src/ui/configdialog.h | 1 | ||||
| -rw-r--r-- | src/ui/cursorimage.cpp | 19 | ||||
| -rw-r--r-- | src/ui/cursorimage.h | 19 | ||||
| -rw-r--r-- | src/ui/forms/configdialog.ui | 312 | ||||
| -rw-r--r-- | src/ui/forms/popupsettings.ui | 234 | ||||
| -rw-r--r-- | src/ui/listwidget.cpp | 81 | ||||
| -rw-r--r-- | src/ui/listwidget.h | 4 | ||||
| -rw-r--r-- | src/ui/popupsettings.cpp | 84 | ||||
| -rw-r--r-- | src/ui/popupsettings.h | 52 | ||||
| -rw-r--r-- | src/ui/popupwidget.cpp | 116 | ||||
| -rw-r--r-- | src/ui/popupwidget.h | 61 | ||||
| -rw-r--r-- | src/ui/ui.pro | 11 |
14 files changed, 844 insertions, 166 deletions
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 <qmmpui/mediaplayer.h> #include <qmmpui/playlistmodel.h> - +#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 <QCursor> #include <QString> 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 @@ <x>0</x> <y>0</y> <width>601</width> - <height>402</height> + <height>424</height> </rect> </property> <property name="windowTitle"> @@ -367,17 +367,91 @@ </widget> </item> <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>160</height> - </size> + <widget class="QGroupBox" name="groupBox_7"> + <property name="title"> + <string>Transparency</string> </property> - </spacer> + <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> </layout> </widget> @@ -435,53 +509,87 @@ </property> </widget> </item> - <item row="1" column="0" colspan="3"> + <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="3"> + <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="3"> + <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="3"> + <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="5" column="0" colspan="3"> + <item row="5" column="0" colspan="2"> <widget class="QCheckBox" name="playlistsCheckBox"> <property name="text"> <string>Show playlists</string> </property> </widget> </item> + <item row="6" 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="popupCustomizeButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Customize</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> </layout> </widget> </item> <item> - <spacer> + <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>387</width> - <height>101</height> + <width>20</width> + <height>54</height> </size> </property> </spacer> @@ -747,91 +855,17 @@ </widget> </item> <item row="3" column="0" colspan="2"> - <widget class="QGroupBox" name="groupBox_7"> - <property name="title"> - <string>Transparency</string> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </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> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> </item> </layout> </widget> @@ -1019,12 +1053,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>305</x> - <y>52</y> + <x>276</x> + <y>39</y> </hint> <hint type="destinationlabel"> - <x>424</x> - <y>82</y> + <x>276</x> + <y>39</y> </hint> </hints> </connection> @@ -1035,12 +1069,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>506</x> - <y>56</y> + <x>276</x> + <y>39</y> </hint> <hint type="destinationlabel"> - <x>506</x> - <y>116</y> + <x>276</x> + <y>39</y> </hint> </hints> </connection> @@ -1051,12 +1085,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>318</x> - <y>142</y> + <x>276</x> + <y>39</y> </hint> <hint type="destinationlabel"> - <x>326</x> - <y>163</y> + <x>276</x> + <y>39</y> </hint> </hints> </connection> @@ -1067,12 +1101,28 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>264</x> - <y>138</y> + <x>276</x> + <y>39</y> + </hint> + <hint type="destinationlabel"> + <x>276</x> + <y>39</y> + </hint> + </hints> + </connection> + <connection> + <sender>popupCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>popupCustomizeButton</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>276</x> + <y>39</y> </hint> <hint type="destinationlabel"> - <x>580</x> - <y>197</y> + <x>276</x> + <y>39</y> </hint> </hints> </connection> @@ -1083,12 +1133,12 @@ <slot>setNum(int)</slot> <hints> <hint type="sourcelabel"> - <x>489</x> - <y>285</y> + <x>397</x> + <y>294</y> </hint> <hint type="destinationlabel"> - <x>553</x> - <y>284</y> + <x>540</x> + <y>289</y> </hint> </hints> </connection> @@ -1099,12 +1149,12 @@ <slot>setNum(int)</slot> <hints> <hint type="sourcelabel"> - <x>519</x> - <y>305</y> + <x>496</x> + <y>315</y> </hint> <hint type="destinationlabel"> - <x>549</x> - <y>309</y> + <x>550</x> + <y>315</y> </hint> </hints> </connection> @@ -1115,12 +1165,12 @@ <slot>setNum(int)</slot> <hints> <hint type="sourcelabel"> - <x>511</x> - <y>327</y> + <x>494</x> + <y>333</y> </hint> <hint type="destinationlabel"> - <x>549</x> - <y>330</y> + <x>542</x> + <y>332</y> </hint> </hints> </connection> 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 @@ +<?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>292</width> + <height>300</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="1" column="2"> + <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="1" column="3"> + <widget class="QLabel" name="coverSizeLabel"> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Transparency:</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <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="3"> + <widget class="QLabel" name="trasparencyLabel"> + <property name="minimumSize"> + <size> + <width>18</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + <item row="5" column="0" colspan="4"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>131</width> + <height>31</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" rowspan="2"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Cover size:</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="4"> + <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> + </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/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 <forkotov02@hotmail.ru> @@ -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 <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()); + 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 <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 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 <QVBoxLayout> +#include <QLabel> +#include <QApplication> +#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) + : 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 <QWidget> +#include <QFrame> + +#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 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 |
