#include "playlistwidget.h" #include "ui_playlistwidget.h" #include #include #include class PlaylistWidgetPrivate { public: QString name; QString description; bool isActive; QTimer* timerSlide; int targetWidth; bool isRemovable; }; PlaylistWidget::PlaylistWidget(QWidget* parent) : QWidget(parent) , ui(new Ui::PlaylistWidget) { ui->setupUi(this); ui->lblDesciption->setText(QString::null); ui->widgetClose->setMinimumWidth(0); ui->widgetClose->setMaximumWidth(0); setFocusPolicy(Qt::ClickFocus); p = new PlaylistWidgetPrivate; p->isActive = false; p->isRemovable = true; QFont font = ui->lblDesciption->font(); #if defined(Q_OS_DARWIN) int newSize = font.pointSize() - 4; #else int newSize = font.pointSize() - 1; #endif font.setPointSize(newSize); ui->lblDesciption->setFont(font); p->timerSlide = new QTimer(this); p->timerSlide->setInterval(10); connect(p->timerSlide, SIGNAL(timeout()), SLOT(timerSlide_timeOut())); } PlaylistWidget::~PlaylistWidget() { delete ui; delete p; } // auto connect slot void PlaylistWidget::on_lblName_linkActivated(const QString& link) { Q_UNUSED(link); Q_EMIT activated(); } bool PlaylistWidget::isRemovable() { return p->isRemovable; } void PlaylistWidget::setRemovable(bool value) { p->isRemovable = value; ui->pushClose->setVisible(value); // if (!value) // r ui->horizontalSpacer->changeSize(42,0); } QString PlaylistWidget::name() { return p->name; } void PlaylistWidget::setName(QString value) { p->name = value; updateView(); } QString PlaylistWidget::description() { return p->description; } void PlaylistWidget::setDescription(QString value) { p->description = value; updateView(); } void PlaylistWidget::activate() { p->isActive = true; updateView(); } void PlaylistWidget::deactivate() { p->isActive = false; updateView(); } void PlaylistWidget::mousePressEvent(QMouseEvent* event) { if (ui->widgetClose->geometry().contains(event->pos())) { Q_EMIT deleted(); } else { slideCloseWidget(false); Q_EMIT activated(); } } void PlaylistWidget::updateView() { // update Labels ui->lblDesciption->setText(p->description); // active/passive look differentiation QString activeStyle; if (p->isActive) { activeStyle = "color:#ff6464;'>"; ui->framePlaylistWidget->setStyleSheet( "#framePlaylistWidget { background: qlineargradient(" "x1:0, y1:0, x2:0, y2:1," "stop: 0.01 #202020," "stop:0.11 #505050," "stop:1 #505050" ");}"); } else { activeStyle = "color:#eeeeee;'>"; ui->framePlaylistWidget->setStyleSheet( "#framePlaylistWidget { background: qlineargradient(" "x1:0, y1:0, x2:0, y2:1," "stop: 0.01 #202020," "stop:0.11 #404040," "stop:1 #404040" ");}"); } ui->lblName->setText( "" "

" "