diff options
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/Ui/skinned/playlist.cpp | 27 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/playlist.h | 3 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/playlistheader.cpp | 147 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/playlistheader.h | 62 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/skinned.pro | 6 |
5 files changed, 239 insertions, 6 deletions
diff --git a/src/plugins/Ui/skinned/playlist.cpp b/src/plugins/Ui/skinned/playlist.cpp index a7ef07d3d..cb1956d4f 100644 --- a/src/plugins/Ui/skinned/playlist.cpp +++ b/src/plugins/Ui/skinned/playlist.cpp @@ -46,6 +46,7 @@ #include "playlistselector.h" #include "windowsystem.h" #include "actionmanager.h" +#include "playlistheader.h" #include "playlist.h" PlayList::PlayList (PlayListManager *manager, QWidget *parent) @@ -62,6 +63,7 @@ PlayList::PlayList (PlayListManager *manager, QWidget *parent) m_shaded = false; m_pl_browser = 0; m_pl_selector = 0; + m_pl_header = 0; resize (275*m_ratio, 116*m_ratio); setSizeIncrement (25*m_ratio, 29*m_ratio); @@ -146,15 +148,28 @@ void PlayList::updatePositions() m_titleBar->resize (275*m_ratio+25*sx, 20*m_ratio); m_plslider->resize (20*m_ratio, 58*m_ratio+sy*29); + int pl_x = 12*m_ratio; + int pl_y = 20*m_ratio; + int pl_w = 243*m_ratio+25*sx; + int pl_h = 58*m_ratio+29*sy; + 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()); + pl_h -= 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); + + /*if(m_pl_header) + { + m_pl_header->resize(243*m_ratio+25*sx, m_pl_header->height()); + m_pl_header->move(pl_x, pl_y); + pl_y += m_pl_selector->height(); + pl_h -= m_pl_selector->height(); + }*/ + + m_listWidget->resize (pl_w, pl_h); + m_listWidget->move (pl_x, pl_y); m_buttonAdd->move (11*m_ratio, 86*m_ratio+29*sy); m_buttonSub->move (40*m_ratio, 86*m_ratio+29*sy); @@ -453,6 +468,10 @@ void PlayList::readSettings() } m_pl_selector = 0; } + + if(!m_pl_header) + m_pl_header = new PlayListHeader(this); + if (m_update) { m_listWidget->readSettings(); diff --git a/src/plugins/Ui/skinned/playlist.h b/src/plugins/Ui/skinned/playlist.h index db3250dba..7528b1277 100644 --- a/src/plugins/Ui/skinned/playlist.h +++ b/src/plugins/Ui/skinned/playlist.h @@ -41,6 +41,7 @@ class PlayListManager; class PlayListBrowser; class PlayListSelector; class QmmpUiSettings; +class PlayListHeader; /** @author Ilya Kotov <forkotov02@hotmail.ru> @@ -129,6 +130,8 @@ class PlayList : public QWidget KeyboardManager* m_keyboardManager; QPointer <PlayListBrowser> m_pl_browser; PlayListSelector *m_pl_selector; + PlayListHeader *m_pl_header; + }; #endif diff --git a/src/plugins/Ui/skinned/playlistheader.cpp b/src/plugins/Ui/skinned/playlistheader.cpp new file mode 100644 index 000000000..6ceec3d38 --- /dev/null +++ b/src/plugins/Ui/skinned/playlistheader.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** + * Copyright (C) 2015 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 "playlistheader.h" + +PlayListHeader::PlayListHeader(QWidget *parent) : + QWidget(parent) +{ + m_scrollable = false; + m_metrics = 0; + m_skin = Skin::instance(); + connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); + loadColors(); + readSettings(); +} + +PlayListHeader::~PlayListHeader() +{ + if (m_metrics) + delete m_metrics; + m_metrics = 0; +} + +void PlayListHeader::readSettings() +{ + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + m_font.fromString(settings.value("Skinned/pl_font", QApplication::font().toString()).toString()); + if (m_metrics) + { + delete m_metrics; + m_metrics = 0; + } + m_metrics = new QFontMetrics(m_font); + resize(width(), m_metrics->height () +1); + //drawButtons(); +} + +void PlayListHeader::updateSkin() +{ + loadColors(); + //drawButtons(); +} + +void PlayListHeader::paintEvent(QPaintEvent *) +{ + /*QPainter painter(this); + painter.setFont(m_font); + painter.setBrush(QBrush(m_normal_bg)); + painter.drawRect(-1,-1,width()+1,height()+1); + + if(m_moving) + { + painter.setBrush(QBrush(m_normal_bg)); + painter.setPen(m_current); + painter.drawRect(m_rects.at(selected).x() - 2 - m_offset, 0, + m_rects.at(selected).width() + 3, height()-1); + } + else + { + painter.setBrush(QBrush(m_selected_bg)); + painter.setPen(m_selected_bg); + painter.drawRect(m_rects.at(selected).x() - 2 - m_offset, 0, + m_rects.at(selected).width() + 3, height()-1); + } + + for (int i = 0; i < m_rects.size(); ++i) + { + if(i == current) + painter.setPen(m_current); + else + painter.setPen(m_normal); + + if(!m_moving || i != selected) + 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(), + m_pl_separator); + } + } + + + for(int i = 0; i < m_extra_rects.size(); ++i) + { + painter.setPen(m_pressed_button == BUTTON_NEW_PL ? m_current : m_normal); + painter.drawText(m_extra_rects[i].x() - m_offset, m_metrics->ascent(), m_pl_button); + } + + + if(m_moving) + { + painter.setBrush(QBrush(m_selected_bg)); + painter.setPen(m_selected_bg); + painter.drawRect(m_mouse_pos.x() - m_press_offset - 2, 0, + m_rects.at(selected).width() + 3, height()); + + painter.setPen(selected == current ? m_current : m_normal); + painter.drawText(m_mouse_pos.x() - m_press_offset, + m_metrics->ascent(), names.at(selected)); + } + + 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 PlayListHeader::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")); +} diff --git a/src/plugins/Ui/skinned/playlistheader.h b/src/plugins/Ui/skinned/playlistheader.h new file mode 100644 index 000000000..acd03b104 --- /dev/null +++ b/src/plugins/Ui/skinned/playlistheader.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (C) 2015 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef PLAYLISTHEADER_H +#define PLAYLISTHEADER_H + +#include <QWidget> + +class QFontMetrics; +class QFont; +class QMouseEvent; +class QMenu; +class PlayListManager; +class PlayList; +class Skin; + +/** + @author Ilya Kotov <forkotov02@hotmail.ru> +*/ +class PlayListHeader : public QWidget +{ + Q_OBJECT +public: + explicit PlayListHeader(QWidget *parent = 0); + ~PlayListHeader(); + + void readSettings(); + +private slots: + void updateSkin(); + +private: + void paintEvent(QPaintEvent *); + void loadColors(); + + Skin *m_skin; + QFontMetrics *m_metrics; + QFont m_font; + bool m_scrollable; + QColor m_normal, m_current, m_normal_bg, m_selected_bg; + + +}; + +#endif // PLAYLISTHEADER_H diff --git a/src/plugins/Ui/skinned/skinned.pro b/src/plugins/Ui/skinned/skinned.pro index 687121b59..8cc555780 100644 --- a/src/plugins/Ui/skinned/skinned.pro +++ b/src/plugins/Ui/skinned/skinned.pro @@ -55,7 +55,8 @@ HEADERS += mainwindow.h \ skinnedfactory.h \ skinnedsettings.h \ hotkeyeditor.h \ - listwidgetdrawer.h + listwidgetdrawer.h \ + playlistheader.h SOURCES += mainwindow.cpp \ button.cpp \ display.cpp \ @@ -104,7 +105,8 @@ SOURCES += mainwindow.cpp \ skinnedfactory.cpp \ skinnedsettings.cpp \ hotkeyeditor.cpp \ - listwidgetdrawer.cpp + listwidgetdrawer.cpp \ + playlistheader.cpp TEMPLATE = lib unix:QMAKE_LIBDIR += ../../../../lib |
