diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2007-11-18 19:39:47 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2007-11-18 19:39:47 +0000 |
| commit | bdfdce7315b4db7b6d2a5c8f3ce418a747dfc9c6 (patch) | |
| tree | 1574d5189c8dfbd2e325d1e92026f76fdbf51894 /src | |
| parent | 967db4498a7a1fc85f0865f6266482b2c92e1476 (diff) | |
| download | qmmp-bdfdce7315b4db7b6d2a5c8f3ce418a747dfc9c6.tar.gz qmmp-bdfdce7315b4db7b6d2a5c8f3ce418a747dfc9c6.tar.bz2 qmmp-bdfdce7315b4db7b6d2a5c8f3ce418a747dfc9c6.zip | |
added shaded mode for the playlist window
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@188 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/listwidget.cpp | 94 | ||||
| -rw-r--r-- | src/playlist.cpp | 25 | ||||
| -rw-r--r-- | src/playlistmodel.h | 181 | ||||
| -rw-r--r-- | src/playlisttitlebar.cpp | 224 | ||||
| -rw-r--r-- | src/playlisttitlebar.h | 17 | ||||
| -rw-r--r-- | src/skin.cpp | 8 | ||||
| -rw-r--r-- | src/skin.h | 11 |
7 files changed, 385 insertions, 175 deletions
diff --git a/src/listwidget.cpp b/src/listwidget.cpp index a21508b5f..fb2173b33 100644 --- a/src/listwidget.cpp +++ b/src/listwidget.cpp @@ -46,7 +46,7 @@ ListWidget::ListWidget(QWidget *parent) m_menu = new QMenu(this); m_scroll_direction = NONE; m_prev_y = 0; - m_anchor_row = INVALID_ROW; + m_anchor_row = INVALID_ROW; m_first = 0; m_rows = 0; @@ -176,69 +176,69 @@ void ListWidget::mousePressEvent(QMouseEvent *e) if (m_model->isSelected(row) && (e->modifiers() == Qt::NoModifier)) m_select_on_release = TRUE; - - //qWarning("m_prev_clicked_row: %d",m_prev_clicked_row); - + + //qWarning("m_prev_clicked_row: %d",m_prev_clicked_row); + m_pressed_row = row; if ((Qt::ShiftModifier & e->modifiers())) { - - if(m_pressed_row > m_anchor_row) - { - //int upper_selected = m_model->firstSelectedUpper(m_anchor_row); - //if (INVALID_ROW != upper_selected) - //{ - /*for (int j = upper_selected;j < m_anchor_row;j++) - { - m_model->setSelected(j, false); - }*/ - m_model->clearSelection(); - for (int j = m_anchor_row;j <= m_pressed_row;j++) - { - m_model->setSelected(j, true); - } - //} - } - else - { - m_model->clearSelection(); - for (int j = m_anchor_row;j >= m_pressed_row;j--) - { - m_model->setSelected(j, true); - } - } - - /* - int upper_selected = m_model->firstSelectedUpper(row); - int lower_selected = m_model->firstSelectedLower(row); - if (INVALID_ROW != upper_selected) + + if (m_pressed_row > m_anchor_row) { - for (int j = upper_selected;j <= row;j++) + //int upper_selected = m_model->firstSelectedUpper(m_anchor_row); + //if (INVALID_ROW != upper_selected) + //{ + /*for (int j = upper_selected;j < m_anchor_row;j++) + { + m_model->setSelected(j, false); + }*/ + m_model->clearSelection(); + for (int j = m_anchor_row;j <= m_pressed_row;j++) { m_model->setSelected(j, true); } + //} } - else if (INVALID_ROW != lower_selected) + else { - for (int j = row;j <= lower_selected;j++) + m_model->clearSelection(); + for (int j = m_anchor_row;j >= m_pressed_row;j--) { m_model->setSelected(j, true); } } - else - m_model->setSelected(row, true); - */ + + /* + int upper_selected = m_model->firstSelectedUpper(row); + int lower_selected = m_model->firstSelectedLower(row); + if (INVALID_ROW != upper_selected) + { + for (int j = upper_selected;j <= row;j++) + { + m_model->setSelected(j, true); + } + } + else if (INVALID_ROW != lower_selected) + { + for (int j = row;j <= lower_selected;j++) + { + m_model->setSelected(j, true); + } + } + else + m_model->setSelected(row, true); + */ } else { if (!m_model->isSelected(row) || (Qt::ControlModifier & e->modifiers())) m_model->setSelected(row, !m_model->isSelected(row)); } - - if(m_model->getSelection(m_pressed_row).count() == 1) - m_anchor_row = m_pressed_row; - //qWarning("m_anchor_row: %d",m_anchor_row); - + + if (m_model->getSelection(m_pressed_row).count() == 1) + m_anchor_row = m_pressed_row; + //qWarning("m_anchor_row: %d",m_anchor_row); + update(); } QWidget::mousePressEvent(e); @@ -441,8 +441,8 @@ void ListWidget::mouseReleaseEvent(QMouseEvent *e) { m_model->clearSelection(); m_model->setSelected(m_pressed_row,true); - //if(e->modifiers() != Qt::ShiftModifier) - m_anchor_row = m_pressed_row; + //if(e->modifiers() != Qt::ShiftModifier) + m_anchor_row = m_pressed_row; m_select_on_release = FALSE; } m_pressed_row = INVALID_ROW; diff --git a/src/playlist.cpp b/src/playlist.cpp index e759e85c4..282463ef0 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -56,9 +56,6 @@ PlayList::PlayList ( QWidget *parent ) resize ( 275,116 ); setMinimumSize ( 275,116 ); setBaseSize ( 275,116 ); - m_titleBar = new PlayListTitleBar ( this ); - m_titleBar->show(); - m_titleBar->move ( 0,0 ); m_listWidget = new ListWidget ( this ); m_listWidget->show(); m_listWidget->setGeometry ( 12,20,243,58 ); @@ -110,6 +107,8 @@ PlayList::PlayList ( QWidget *parent ) connect ( m_pl_control, SIGNAL ( pauseClicked() ), SIGNAL ( pause() ) ); connect ( m_pl_control, SIGNAL ( stopClicked() ), SIGNAL ( stop() ) ); connect ( m_pl_control, SIGNAL ( ejectClicked() ), SIGNAL ( eject() ) ); + m_titleBar = new PlayListTitleBar ( this ); + m_titleBar->move ( 0,0 ); readSettings(); } @@ -310,6 +309,8 @@ void PlayList::resizeEvent ( QResizeEvent *e ) { int sx = ( e->size().width()-275 ) /25; int sy = ( e->size().height()-116 ) /29; + if (sx < 0 || sy < 0) + return; m_titleBar->resize ( 275+25*sx,20 ); m_plslider->resize ( 20,58+sy*29 ); @@ -359,8 +360,9 @@ void PlayList::mouseReleaseEvent ( QMouseEvent * ) void PlayList::setModel ( PlayListModel *model ) { m_playListModel = model; - m_listWidget->setModel ( model ); - m_keyboardManager->setModel ( model ); + m_listWidget->setModel (model); + m_keyboardManager->setModel (model); + m_titleBar->setModel (model); createActions(); } @@ -377,14 +379,14 @@ void PlayList::readSettings() if ( m_update ) { m_listWidget->readSettings(); + m_titleBar->readSettings(); } else { - QSettings settings ( QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat ); + QSettings settings (QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat); settings.beginGroup ( "PlayList" ); - //geometry - resize ( settings.value ( "size", QSize ( 275, 116 ) ).toSize() ); - move ( settings.value ( "pos", QPoint ( 100, 332 ) ).toPoint() ); + //position + move ( settings.value ("pos", QPoint ( 100, 332 ) ).toPoint()); settings.endGroup(); m_update = TRUE; } @@ -395,8 +397,7 @@ void PlayList::writeSettings() { QSettings settings ( QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat ); settings.beginGroup ( "PlayList" ); - //geometry - settings.setValue ( "size", size() ); + //position settings.setValue ( "pos", this->pos() ); settings.endGroup(); } @@ -437,7 +438,7 @@ QString PlayList::formatTime ( int sec ) return str_minutes + ":" + str_seconds; } -void PlayList::setInfo ( const OutputState &st,int length_current, int length_total ) +void PlayList::setInfo (const OutputState &st,int length_current, int length_total) { if ( st.type() == OutputState::Info ) { diff --git a/src/playlistmodel.h b/src/playlistmodel.h index 40849b7e8..b3ac19c04 100644 --- a/src/playlistmodel.h +++ b/src/playlistmodel.h @@ -43,7 +43,7 @@ struct SimpleSelection { SimpleSelection() { - ; + ; } inline bool isValid()const { @@ -60,7 +60,7 @@ struct SimpleSelection int m_bottom; int m_top; int m_anchor; - QList<int>m_selected_rows; + QList<int>m_selected_rows; }; /*! @@ -69,7 +69,7 @@ struct SimpleSelection */ class TagUpdater : public QObject { -Q_OBJECT + Q_OBJECT QObject* m_observable; MediaFile* m_file; public: @@ -77,7 +77,7 @@ public: protected slots: void updateTag(); }; - + class PlayListModel : public QObject { @@ -115,7 +115,10 @@ public: */ bool isQueued(MediaFile* f) const; - bool isRepeatableList()const{return is_repeatable_list;} + bool isRepeatableList()const + { + return is_repeatable_list; + } /*! * Sets current song to the file that is nex in queue, if queue is empty - does nothing @@ -150,7 +153,10 @@ public: */ QList<MediaFile*> getSelectedItems()const; - QList<MediaFile*> items()const{return m_files;} + QList<MediaFile*> items()const + { + return m_files; + } /*! * Returns number of first item that selected upper the \b row item. @@ -162,49 +168,61 @@ public: */ int firstSelectedLower(int row); - /*! - * Returns total lenght in seconds of all songs. - */ - int totalLength()const{return m_total_length;} + /*! + * Returns total lenght in seconds of all songs. + */ + int totalLength()const + { + return m_total_length; + } - /*! - * Registers playlist format parser. - */ - bool registerPlaylistFormat(PlaylistFormat* p); + /*! + * Registers playlist format parser. + */ + bool registerPlaylistFormat(PlaylistFormat* p); - /*! - * Checks and loads external playlist format plugins - */ - void loadExternalPlaylistFormats(); + /*! + * Checks and loads external playlist format plugins + */ + void loadExternalPlaylistFormats(); - /*! - * Returns vector of reistered format parsers. - */ - const QList<PlaylistFormat*> registeredPlaylistFormats()const{return m_registered_pl_formats.values();} + /*! + * Returns vector of reistered format parsers. + */ + const QList<PlaylistFormat*> registeredPlaylistFormats()const + { + return m_registered_pl_formats.values(); + } - const QStringList registeredPlaylistFormatNames()const{return m_registered_pl_formats.keys();} + const QStringList registeredPlaylistFormatNames()const + { + return m_registered_pl_formats.keys(); + } - /*! - * Loads playlist with \b f_name name. - */ - void loadPlaylist(const QString& f_name); + /*! + * Loads playlist with \b f_name name. + */ + void loadPlaylist(const QString& f_name); - /*! - * Saves current songs to the playlist with \b f_name name. - */ - void savePlaylist(const QString& f_name); + /*! + * Saves current songs to the playlist with \b f_name name. + */ + void savePlaylist(const QString& f_name); /*! * Enum of available sort modes */ - enum SortMode{ TITLE,FILENAME,PATH_AND_FILENAME,DATE }; + enum SortMode + { + TITLE,FILENAME,PATH_AND_FILENAME,DATE + }; signals: void listChanged(); void currentChanged(); public slots: - void load(MediaFile *); + void load(MediaFile *); void clear(); void clearSelection(); void removeSelected(); @@ -212,26 +230,26 @@ public slots: void invertSelection(); void selectAll(); void showDetails(); - void doCurrentVisibleRequest(); + void doCurrentVisibleRequest(); void addFile(const QString&); - /*! - * Adds the list \b l of files to the model. - */ + /*! + * Adds the list \b l of files to the model. + */ void addFiles(const QStringList& l); - /*! - * Adds \b dir to the model. - */ + /*! + * Adds \b dir to the model. + */ void addDirectory(const QString& dir); - /*! - * Loads list of files (regular files or directories), - * returns \b TRUE if at least one file has been successfully loaded, - * otherwise \b FALSE - */ - bool setFileList(const QStringList&); + /*! + * Loads list of files (regular files or directories), + * returns \b TRUE if at least one file has been successfully loaded, + * otherwise \b FALSE + */ + bool setFileList(const QStringList&); void addFileList(const QStringList &l); @@ -263,12 +281,12 @@ public slots: */ void addToQueue(); - /*! - * Sets \b f media file to queue. - */ - void setQueued(MediaFile* f); + /*! + * Sets \b f media file to queue. + */ + void setQueued(MediaFile* f); - void preparePlayState(); + void preparePlayState(); private: @@ -286,36 +304,39 @@ private: */ int bottommostInSelection(int); - /*! - * Creates and initializes file loader object. - */ - FileLoader* createFileLoader(); + /*! + * Creates and initializes file loader object. + */ + FileLoader* createFileLoader(); - /*! - * Is someone of file loaders is running? - */ - bool isFileLoaderRunning()const; + /*! + * Is someone of file loaders is running? + */ + bool isFileLoaderRunning()const; - /*! - * Removes items from model. If \b inverted is \b false - - * selected items will be removed, else - unselected. - */ - void removeSelection(bool inverted = false); + /*! + * Removes items from model. If \b inverted is \b false - + * selected items will be removed, else - unselected. + */ + void removeSelection(bool inverted = false); private: - + QList <MediaFile*> m_files; QList <MediaFile*> m_editing_files; MediaFile* m_currentItem; int m_current; - void readSettings(); + void readSettings(); void writeSettings(); - void setUpdatesEnabled(bool); + void setUpdatesEnabled(bool); - bool updatesEnabled()const{return !m_block_update_signals;} + bool updatesEnabled()const + { + return !m_block_update_signals; + } /*! * This flyweight object represents current selection. @@ -327,29 +348,29 @@ private: */ QList<MediaFile*>m_queued_songs; - QMap<QString,PlaylistFormat* > m_registered_pl_formats; + QMap<QString,PlaylistFormat* > m_registered_pl_formats; /*! * Is playlist repeatable? */ bool is_repeatable_list; - /// Current playing state (Normal or Shuffle) - PlayState* m_play_state; + /// Current playing state (Normal or Shuffle) + PlayState* m_play_state; - bool m_block_update_signals; + bool m_block_update_signals; - int m_total_length; + int m_total_length; - typedef QPointer<FileLoader> GuardedFileLoader; + typedef QPointer<FileLoader> GuardedFileLoader; - /*! Vector of currently running file loaders. - * All loaders are automatically sheduled for deletion - * when finished. - */ - QVector<GuardedFileLoader> m_running_loaders; + /*! Vector of currently running file loaders. + * All loaders are automatically sheduled for deletion + * when finished. + */ + QVector<GuardedFileLoader> m_running_loaders; - friend class MainWindow; + friend class MainWindow; }; diff --git a/src/playlisttitlebar.cpp b/src/playlisttitlebar.cpp index 777a4b6b8..a583065ca 100644 --- a/src/playlisttitlebar.cpp +++ b/src/playlisttitlebar.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -20,9 +20,11 @@ #include <QPainter> #include <QResizeEvent> #include <QMenu> +#include <QSettings> #include "dock.h" #include "button.h" +#include "playlistmodel.h" #include "playlisttitlebar.h" #include "skin.h" @@ -30,8 +32,12 @@ 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::getPointer(); - setSizeIncrement(25,1); connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); m_pl = qobject_cast<PlayList*>(parent); @@ -40,41 +46,99 @@ PlayListTitleBar::PlayListTitleBar(QWidget *parent) m_close = new Button(this,Skin::PL_BT_CLOSE_N, Skin::PL_BT_CLOSE_P); connect (m_close, SIGNAL(clicked()), m_pl, SIGNAL(closed())); m_close->move(264,3); + m_shade = new Button(this, Skin::PL_BT_SHADE1_N, Skin::PL_BT_SHADE1_P); + connect(m_shade, SIGNAL(clicked()), SLOT(shade())); + m_shade->move(255,3); resize(275,20); - //setActive(FALSE); + setMinimumWidth(275); + readSettings(); + QSettings settings (QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat); + m_pl->resize (settings.value ("PlayList/size", QSize (275, 116)).toSize()); + if (settings.value ("PlayList/shaded", FALSE).toBool()) + shade(); + resize(m_pl->width(),height()); + m_align = TRUE; } PlayListTitleBar::~PlayListTitleBar() -{} +{ + QSettings settings (QDir::homePath() +"/.qmmp/qmmprc", 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::drawPixmap(int sx) { m_close->move(264+sx*25,3); + m_shade->move(255+sx*25,3); + if (m_shade2) + m_shade2->move(255+sx*25,3); QPixmap pixmap(275+sx*25,20); pixmap.fill("black"); 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; i++) + { + paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL_SHADED)); + } + } + if (m_active) { - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_A)); - for (int i = 1; i<sx+10; i++) + if (m_shaded) + { + m_shade2->show(); + paint.drawPixmap(225+sx*25,0,m_skin->getPlPart(Skin::PL_TITLEBAR_SHADED1_A)); + } + else { - paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_A)); + paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_A)); + for (int i = 1; i<sx+10; i++) + { + paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_A)); + } + paint.drawPixmap(100-12+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_A)); + paint.drawPixmap(250+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_A)); + m_close->show(); + m_shade->show(); } - paint.drawPixmap(100-12+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_A)); - paint.drawPixmap(250+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_A)); - m_close->show(); } else { - paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_I)); - for (int i = 1; i<sx+10; i++) + if (m_shaded) + { + m_shade2->hide(); + paint.drawPixmap(275-50+sx*25,0,m_skin->getPlPart(Skin::PL_TITLEBAR_SHADED1_I)); + } + else { - paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_I)); + paint.drawPixmap(0,0,m_skin->getPlPart(Skin::PL_CORNER_UL_I)); + for (int i = 1; i<sx+10; i++) + { + paint.drawPixmap(25*i,0,m_skin->getPlPart(Skin::PL_TFILL1_I)); + } + paint.drawPixmap(100-12+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_I)); + paint.drawPixmap(250+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_I)); + m_close->hide(); + m_shade->hide(); } - paint.drawPixmap(100-12+12*sx,0,m_skin->getPlPart(Skin::PL_TITLEBAR_I)); - paint.drawPixmap(250+sx*25,0,m_skin->getPlPart(Skin::PL_CORNER_UR_I)); - m_close->hide(); + } + if (m_shaded) + { + //draw text background + for (int i = 0; i < 47 + sx*5; ++i) + { + paint.drawPixmap(8+i*5,2,m_skin->getLetter(' ')); + paint.drawPixmap(8+i*5,6,m_skin->getLetter(' ')); + } + //draw text + paint.setFont(m_font); + paint.setPen(QString(m_skin->getPLValue("normal"))); + paint.drawText(9, 11, m_truncatedText); } paint.end(); setPixmap(pixmap); @@ -82,47 +146,139 @@ void PlayListTitleBar::drawPixmap(int sx) void PlayListTitleBar::resizeEvent(QResizeEvent *e) { - int m_sx = (e->size().width()-275)/25; - drawPixmap(m_sx); - + truncate(); + drawPixmap((e->size().width()-275)/25); } void PlayListTitleBar::mousePressEvent(QMouseEvent* event) { - switch((int) event->button ()) + switch ((int) event->button ()) { - case Qt::LeftButton: - { - pos = event->pos(); - break; - } - case Qt::RightButton: - { - m_mw->menu()->exec(event->globalPos()); - } + case Qt::LeftButton: + { + pos = event->pos(); + + if (m_shaded && (width() - 30) < pos.x() && pos.x() < (width() - 22)) + { + m_resize = TRUE; + m_pl->setCursor (Qt::SizeHorCursor); + } + + + break; + } + case Qt::RightButton: + { + m_mw->menu()->exec(event->globalPos()); + } } } void PlayListTitleBar::mouseReleaseEvent(QMouseEvent*) { - Dock::getPointer()->updateDock(); + Dock::getPointer()->updateDock(); + m_resize = FALSE; + m_pl->setCursor (Qt::ArrowCursor); } void PlayListTitleBar::mouseMoveEvent(QMouseEvent* event) -{ +{ QPoint npos = (event->globalPos()-pos); QPoint oldpos = npos; - Dock::getPointer()->move(m_pl, npos); + if (m_shaded && m_resize) + { + m_pl->resize((event->x() + 25), m_pl->height()); + resize((event->x() + 25), height()); + } + else + Dock::getPointer()->move(m_pl, npos); } void PlayListTitleBar::setActive(bool a) { m_active = a; - int m_sx = (width()-275)/25; - drawPixmap(m_sx); + drawPixmap((width()-275)/25); +} + + +void PlayListTitleBar::setModel(PlayListModel *model) +{ + m_model = model; + connect (m_model, SIGNAL(listChanged()), SLOT(showCurrent())); +} + +void PlayListTitleBar::readSettings() +{ + QSettings settings (QDir::homePath() +"/.qmmp/qmmprc", QSettings::IniFormat); + QString fontname = settings.value("PlayList/Font","").toString(); + if (fontname.isEmpty ()) + fontname = QFont("Helvetica [Cronyx]", 8).toString(); + m_font.fromString(fontname); + m_font.setPointSize(8); } void PlayListTitleBar::updateSkin() { drawPixmap((width()-275)/25); } + +void PlayListTitleBar::shade() +{ + m_shaded = !m_shaded; + + if (m_shaded) + { + m_height = m_pl->height(); + m_pl->setFixedHeight(14); + m_shade->hide(); + m_shade2 = new Button(this, Skin::PL_BT_SHADE2_N, Skin::PL_BT_SHADE2_P); + m_shade2->move(254,3); + connect(m_shade2, SIGNAL(clicked()), SLOT(shade())); + m_shade2->show(); + } + else + { + m_pl->setMinimumSize (275,116); + m_pl->setMaximumSize (10000,10000); + m_pl->resize(width(),m_height); + delete m_shade2; + m_shade2 = 0; + m_shade->show(); + } + showCurrent(); + update(); + if (m_align) + Dock::getPointer()->align(m_pl, m_shaded? -m_height+14: m_height-14); +} + +void PlayListTitleBar::showCurrent() +{ + if (m_model) + { + MediaFile* info = m_model->currentItem(); + if (info) + { + m_text = QString("%1. ").arg(m_model->currentRow()+1); + m_text.append(info->title()); + m_text.append(QString(" (%1:%2)").arg(info->length()/60).arg(info->length()%60)); + } + else + m_text.clear(); + } + truncate(); + drawPixmap((width()-275)/25); +} + +void PlayListTitleBar::truncate() +{ + m_truncatedText = m_text; + QFontMetrics metrics(m_font); + bool truncate = FALSE; + while (metrics.width(m_truncatedText) > (this->width() - 35)) + { + truncate = TRUE; + m_truncatedText = m_truncatedText.left(m_truncatedText.length()-1); + } + if (truncate) + m_truncatedText = m_truncatedText.left(m_truncatedText.length()-3).trimmed()+"..."; +} diff --git a/src/playlisttitlebar.h b/src/playlisttitlebar.h index d70202946..f50018371 100644 --- a/src/playlisttitlebar.h +++ b/src/playlisttitlebar.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2007 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -30,6 +30,7 @@ class Skin; class MainWindow; class Button; +class PlayListModel; class PlayListTitleBar : public PixmapWidget { @@ -40,18 +41,32 @@ public: ~PlayListTitleBar(); void setActive(bool); + void setModel(PlayListModel *model); + void readSettings(); private slots: void updateSkin(); + void shade(); + void showCurrent(); private: void drawPixmap(int); + void truncate(); 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_height; + PlayListModel* m_model; + QString m_text; + QString m_truncatedText; + QFont m_font; protected: void resizeEvent(QResizeEvent*); diff --git a/src/skin.cpp b/src/skin.cpp index 40760365b..8bb4a63ad 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -254,6 +254,10 @@ void Skin::loadPlayList() 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); @@ -267,6 +271,10 @@ void Skin::loadPlayList() 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); } diff --git a/src/skin.h b/src/skin.h index 116f79487..d981c4613 100644 --- a/src/skin.h +++ b/src/skin.h @@ -169,6 +169,11 @@ public: 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, @@ -242,7 +247,11 @@ public: PL_RSBAR, PL_SFILL1, PL_SFILL2, - PL_CONTROL + PL_CONTROL, + PL_TITLEBAR_SHADED1_A, + PL_TITLEBAR_SHADED1_I, + PL_TITLEBAR_SHADED2, + PL_TFILL_SHADED, }; enum Equalizer { |
