From: Nikolay Tischenko Date: Sat, 30 Oct 2010 08:41:44 +0000 (+0700) Subject: Imroved custom menu request X-Git-Tag: 1.4.0~14 X-Git-Url: http://git.maemo.org/git/?p=someplayer;a=commitdiff_plain;h=d310b1f58a2661c62b1fef33a05118385119b08a Imroved custom menu request --- diff --git a/resources/black/arrow_r.png b/resources/black/arrow_r.png new file mode 100644 index 0000000..ecaa5d3 Binary files /dev/null and b/resources/black/arrow_r.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index b7b4393..b2a926e 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -67,5 +67,7 @@ white/update-pls.png black/update-all.png black/update-pls.png + white/arrow_r.png + black/arrow_r.png diff --git a/resources/white/arrow_r.png b/resources/white/arrow_r.png new file mode 100644 index 0000000..1ed8f53 Binary files /dev/null and b/resources/white/arrow_r.png differ diff --git a/src/playerform.cpp b/src/playerform.cpp index cfe5b1e..a7b67f9 100644 --- a/src/playerform.cpp +++ b/src/playerform.cpp @@ -46,7 +46,6 @@ inline void __fill_list(QStandardItemModel *_model, Playlist playlist) { time.setHMS(0, meta.length()/60, meta.length() % 60); QString t = meta.title()+"#_#"+meta.artist()+"#_#"+meta.album()+"#_#"+time.toString("mm:ss"); _model->setItem(i, 1, new QStandardItem(t)); - _model->setItem(i, 0, new QStandardItem("")); } } @@ -113,7 +112,6 @@ PlayerForm::PlayerForm(Library* lib, QWidget *parent) : connect(ui->libraryButton, SIGNAL(clicked()), this, SLOT(_library())); connect(ui->viewButton, SIGNAL(clicked()), this, SLOT(_toggle_view())); connect(ui->playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(_process_click(QModelIndex))); - connect(ui->playlistView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(_process_dbl_click(QModelIndex))); connect(ui->playpauseButton, SIGNAL(clicked()), _player, SLOT(toggle())); connect(ui->nextButton, SIGNAL(clicked()), _player, SLOT(next())); connect(ui->stopButton, SIGNAL(clicked()), _player, SLOT(stop())); @@ -197,8 +195,6 @@ void PlayerForm::_process_click(QModelIndex index) { } else { _custom_context_menu_requested(ui->playlistView->rect().center()); } -// ui->playlistView->hide(); -// ui->playlistView->show(); } void PlayerForm::_track_changed(Track track) { @@ -314,15 +310,15 @@ void PlayerForm::search(QString pattern) { } void PlayerForm::nextItem() { - QString data = _model->index(_search_current_id, 0).data().toString(); + QString data = _model->index(_search_current_id, 1).data().toString(); for (int i = _search_current_id+1; i < _model->rowCount(); i++) { - data = _model->index(i, 0).data().toString(); + data = _model->index(i, 1).data().toString(); if (data.contains(_search_pattern, Qt::CaseInsensitive)) { _search_current_id = i; break; } } - QModelIndex id = _model->index(_search_current_id, 0); + QModelIndex id = _model->index(_search_current_id, 1); _track_renderer->setSearchRow(_search_current_id); ui->playlistView->scrollTo(id); ui->playlistView->hide(); @@ -330,15 +326,15 @@ void PlayerForm::nextItem() { } void PlayerForm::prevItem() { - QString data = _model->index(_search_current_id, 0).data().toString(); + QString data = _model->index(_search_current_id, 1).data().toString(); for (int i = _search_current_id-1; i >= 0; i--) { - data = _model->index(i, 0).data().toString(); + data = _model->index(i, 1).data().toString(); if (data.contains(_search_pattern, Qt::CaseInsensitive)) { _search_current_id = i; break; } } - QModelIndex id = _model->index(_search_current_id, 0); + QModelIndex id = _model->index(_search_current_id, 1); _track_renderer->setSearchRow(_search_current_id); ui->playlistView->scrollTo(id); ui->playlistView->hide(); @@ -348,7 +344,7 @@ void PlayerForm::prevItem() { void PlayerForm::cancelSearch() { _search_pattern = ""; _track_renderer->setSearchRow(-1); - ui->playlistView->scrollTo(_model->index(_track_renderer->activeRow(), 0)); + ui->playlistView->scrollTo(_model->index(_track_renderer->activeRow(), 1)); ui->playlistView->hide(); ui->playlistView->show(); } @@ -525,6 +521,7 @@ void PlayerForm::updateIcons() { Config config; _icons_theme = config.getValue("ui/iconstheme").toString(); _tools_widget->updateIcons(); + _track_renderer->updateIcons(); ui->libraryButton->setIcon(QIcon(":/icons/"+_icons_theme+"/library.png")); if (_tools_widget->isVisible()) { ui->moreButton->setIcon(QIcon(landscape ? ":/icons/" + _icons_theme + "/unmore.png" : ":/icons/" + _icons_theme + "/more.png")); @@ -578,7 +575,3 @@ void PlayerForm::play(Track track) { _player->play(); } } - -void PlayerForm::_process_dbl_click(QModelIndex) { - _custom_context_menu_requested(ui->playlistView->rect().center()); -} diff --git a/src/playerform.h b/src/playerform.h index 05555ca..8ed8da2 100644 --- a/src/playerform.h +++ b/src/playerform.h @@ -83,7 +83,6 @@ private slots: void _library(); void _toggle_view(); void _process_click(QModelIndex); - void _process_dbl_click(QModelIndex); void _track_changed(Track); void _tick(int, int); void _slider_released(); diff --git a/src/trackrenderer.cpp b/src/trackrenderer.cpp index 18aa89c..e443d3b 100644 --- a/src/trackrenderer.cpp +++ b/src/trackrenderer.cpp @@ -32,13 +32,25 @@ TrackRenderer::TrackRenderer(QObject *parent) : { Config config; _icons_theme = config.getValue("ui/iconstheme").toString(); + _apen = QPen(QColor::fromRgb(255, 255, 255, 128)); + _spen = QPen(QColor::fromRgb(100, 150, 220)); + _sspen = QPen(QColor::fromRgb(100, 220, 150)); + +} + +void TrackRenderer::updateIcons() { + Config config; + _icons_theme = config.getValue("ui/iconstheme").toString(); } void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == 0) { int x1, y1, x2, y2; option.rect.getCoords(&x1, &y1, &x2, &y2); - painter->drawImage(x1, y1 + 5, QImage(":/icons/"+_icons_theme+"/more_l.png")); + QImage image(":/icons/"+_icons_theme+"/arrow_r.png"); + x1 += (x2 - x1 - image.width())/2; + y1 += (y2 - y1 - image.width())/2; + painter->drawImage(x1, y1, image); } else { QString value = index.data().toString(); QStringList meta = value.split("#_#"); @@ -50,20 +62,13 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, option.rect.getCoords(&x1, &y1, &x2, &y2); QPen pen = painter->pen(); - QPen npen (QColor::fromRgb(80, 130, 255, 50)); - QPen apen (QColor::fromRgb(255, 255, 255, 128)); - QPen spen (QColor::fromRgb(100, 150, 220)); - QPen sspen (QColor::fromRgb(100, 220, 150)); - f.setBold(false); - painter->setPen(npen); - painter->drawLine(x1, y1, x2, y1); if (index.row() == _search_row) { f.setBold(true); - painter->setPen(sspen); + painter->setPen(_sspen); } else if (index.row() == _active_row) { f.setBold(true); - painter->setPen(spen); + painter->setPen(_spen); } else { painter->setPen(pen); } @@ -72,11 +77,9 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, fp.setBold(false); fp.setPointSize(f.pointSize()*3/4); painter->setFont(fp); - painter->setPen(apen); + painter->setPen(_apen); painter->drawText(x1+10, y1 + 3*(y2-y1)/5, (x2-x1)-100, 2*fp.pointSize(), Qt::AlignAbsolute, QString("%1 (%2)").arg(meta[2]).arg(meta[1])); painter->drawText(x2-60, y1 + 3*(y2-y1)/5, 55, 2*fp.pointSize(), Qt::AlignAbsolute, QString("%1").arg(meta[3])); - painter->setPen(npen); - painter->drawLine(x1, y2, x2, y2); painter->setFont(f); painter->setPen(pen); } diff --git a/src/trackrenderer.h b/src/trackrenderer.h index 620ac98..8909a76 100644 --- a/src/trackrenderer.h +++ b/src/trackrenderer.h @@ -23,6 +23,7 @@ #include #include "abstractitemrenderer.h" #include +#include #include "someplayer.h" class TrackRenderer : public AbstractItemRenderer @@ -35,9 +36,13 @@ public: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void updateIcons(); private: QString _icons_theme; + QPen _apen; + QPen _spen; + QPen _sspen; }; #endif // TRACKRENDERER_H