/* ******************************************************************************** * * * Class ExLineEdit * * * ******************************************************************************** */ ExLineEdit::ExLineEdit(QWidget *parent) : QWidget(parent) { m_lineEdit = new QLineEdit(this); m_lineEdit->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); // widget settings this->setFocusPolicy(m_lineEdit->focusPolicy()); this->setAttribute(Qt::WA_InputMethodEnabled); this->setSizePolicy(m_lineEdit->sizePolicy()); this->setBackgroundRole(m_lineEdit->backgroundRole()); this->setMouseTracking(true); setPalette(m_lineEdit->palette()); // line edit m_lineEdit->setFrame(false); m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu); m_lineEdit->setFocusProxy(this); m_lineEdit->setStyleSheet("background:transparent"); // clearButton m_clearButton = new ClearButton(this); //! connection QObject::connect(m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearField())); QObject::connect(m_lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotOnTextChanged(const QString&))); QObject::connect(m_lineEdit, SIGNAL(returnPressed()), this, SIGNAL(textfield_entered())); }
/******************************************************************************* slots *******************************************************************************/ void ExLineEdit::slotClearField() { m_lineEdit->clear(); this->clearFocus(); emit textfield_entered(); }
void PlaylistWidget::init(PlayqueueModel* model) { m_model = model; m_view = new PlaylistView(this, m_model); /* ------- menu & actions ------------------ */ m_menu = 0; m_actions->insert(PLAYQUEUE_JUMP_TO_TRACK, new QAction(QIcon(":/images/jump_to_32x32.png"),tr("Jump to track"), this)); m_actions->insert(PLAYQUEUE_ADD_FILE, new QAction(QIcon(":/images/track-48x48.png"),tr("&Add media to playlist"), this)); m_actions->insert(PLAYQUEUE_ADD_DIR, new QAction(QIcon(":/images/folder-48x48.png"),tr("&Add directory to playlist"), this)); m_actions->insert(PLAYQUEUE_ADD_URL, new QAction(QIcon(":/images/media-url-48x48.png"),tr("&Add Url..."), this)); m_actions->insert(PLAYQUEUE_CLEAR, new QAction(QIcon::fromTheme("edit-clear-list"), tr("&Clear playlist"), this)); m_actions->insert(PLAYQUEUE_EXPORT, new QAction(QIcon(":/images/save-32x32.png"), tr("&Export playlist to file"), this)); m_actions->insert(PLAYQUEUE_AUTOSAVE, new QAction(QIcon(":/images/save-32x32.png"), tr("&Save playlist"), this)); m_actions->insert(PLAYQUEUE_REMOVE_ITEM,new QAction(QIcon::fromTheme("edit-delete"),tr("&Remove media from playlist"), this)); m_actions->insert(PLAYQUEUE_REMOVE_DUPLICATE,new QAction(QIcon(),tr("Remove duplicate"), this)); m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE)->setCheckable(true); m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE)->setChecked( !SETTINGS()->_playqueueDuplicate ); m_actions->insert(PLAYQUEUE_TRACK_LOVE, new QAction(QIcon(":/images/lastfm.png"), tr("Send LastFm love"), this)); m_actions->insert(PLAYQUEUE_OPTION_SHOW_COVER, new QAction(tr("Show cover"), this)); m_actions->value(PLAYQUEUE_OPTION_SHOW_COVER)->setCheckable(true); m_actions->value(PLAYQUEUE_OPTION_SHOW_COVER)->setChecked( SETTINGS()->_playqueueShowCover ); m_actions->insert(PLAYQUEUE_OPTION_SHOW_RATING, new QAction(tr("Show rating"), this)); m_actions->value(PLAYQUEUE_OPTION_SHOW_RATING)->setCheckable(true); m_actions->value(PLAYQUEUE_OPTION_SHOW_RATING)->setChecked( SETTINGS()->_playqueueShowRating ); m_actions->insert(PLAYQUEUE_OPTION_SHOW_NUMBER, new QAction(tr("Show track number"), this)); m_actions->value(PLAYQUEUE_OPTION_SHOW_NUMBER)->setCheckable(true); m_actions->value(PLAYQUEUE_OPTION_SHOW_NUMBER)->setChecked( SETTINGS()->_playqueueShowNumber ); /* ------- playqueue sorter widget --------- */ m_sort_menu = new QMenu(); ui_sort_widget = 0; QToolButton *button = new QToolButton(); button->setText(tr("sort")); button->setAutoRaise(true); button->setToolTip(tr("Sort playqueue")); button->setMenu(m_sort_menu); button->setContextMenuPolicy( Qt::CustomContextMenu ); connect( button, SIGNAL( clicked ( bool ) ), this, SLOT( slot_show_sortmenu() ) ); /* ------- playqueue filter widget --------- */ ui_playqueue_filter = new ExLineEdit(); ui_playqueue_filter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); ui_playqueue_filter->setInactiveText(tr("Playqueue filter")); ui_filter_container = new QWidget(this); ui_filter_container->setMinimumHeight(30); QHBoxLayout* h1 = new QHBoxLayout(ui_filter_container); h1->setSpacing(0); h1->setContentsMargins(2, 2, 2, 2); h1->addWidget(ui_playqueue_filter); h1->addWidget(button); /* ------- main layout --------------------- */ QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setSpacing(0); main_layout->setContentsMargins(0, 0, 0, 0); main_layout->addWidget(ui_filter_container); main_layout->addWidget(m_view); /* ------- actions ------------------------- */ m_action_show_filter = new QAction(QIcon(),tr("Show filter"), this); m_action_show_filter->setCheckable(true); m_action_show_filter->setChecked( SETTINGS()->_playqueueShowFilter ); m_action_stop_after = new QAction(QIcon(),tr("Stop after this track"), this); m_action_stop_after->setCheckable(true); /* ------- signals connection -------------- */ connect(m_model, SIGNAL(updated()), this, SLOT(slot_update_playqueue_status_info())); connect(m_actions->value(PLAYQUEUE_TRACK_LOVE), SIGNAL(triggered()), m_view, SLOT(slot_lastfm_love())); connect(m_actions->value(PLAYQUEUE_JUMP_TO_TRACK), SIGNAL(triggered()), m_view, SLOT(jumpToCurrentlyPlayingTrack())); connect(m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE), SIGNAL(triggered()), SLOT(slot_removeduplicate_changed())); connect(m_actions->value(PLAYQUEUE_CLEAR), SIGNAL(triggered()), SLOT(slot_playqueue_clear())); connect(m_actions->value(PLAYQUEUE_ADD_FILE), SIGNAL(triggered()), SLOT(slot_add_to_playqueue())); connect(m_actions->value(PLAYQUEUE_ADD_DIR), SIGNAL(triggered()), SLOT(slot_add_to_playqueue())); connect(m_actions->value(PLAYQUEUE_ADD_URL), SIGNAL(triggered()), SLOT(slot_add_to_playqueue())); connect(m_actions->value(PLAYQUEUE_EXPORT), SIGNAL(triggered()), SLOT(slot_playqueue_export())); connect(m_actions->value(PLAYQUEUE_AUTOSAVE), SIGNAL(triggered()), SLOT(slot_playqueue_save_auto())); connect(m_actions->value(PLAYQUEUE_REMOVE_ITEM), SIGNAL(triggered()), this, SLOT(slot_remove_selected_tracks())); connect(ui_playqueue_filter, SIGNAL(textfield_entered()),this, SLOT(slot_update_filter())); connect(m_action_show_filter, SIGNAL(triggered()), this, SLOT(slot_show_filter_triggered())); connect(m_action_stop_after, SIGNAL(triggered()), this, SLOT(slot_stop_after_triggered())); /* ------- init state ---------------------- */ ui_filter_container->setVisible( SETTINGS()->_playqueueShowFilter ); }