mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-14 01:26:00 +01:00
parent
3292db8b77
commit
8d2615547d
@ -336,6 +336,17 @@ void CollectionFilterWidget::ShowGroupingManager() {
|
||||
|
||||
}
|
||||
|
||||
bool CollectionFilterWidget::SearchFieldHasFocus() const {
|
||||
|
||||
return ui_->search_field->hasFocus();
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::FocusSearchField() {
|
||||
|
||||
ui_->search_field->setFocus();
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::FocusOnFilter(QKeyEvent *event) {
|
||||
|
||||
|
@ -82,6 +82,9 @@ class CollectionFilterWidget : public QWidget {
|
||||
|
||||
void ReloadSettings();
|
||||
|
||||
bool SearchFieldHasFocus() const;
|
||||
void FocusSearchField();
|
||||
|
||||
public slots:
|
||||
void SetQueryMode(QueryOptions::QueryMode query_mode);
|
||||
void FocusOnFilter(QKeyEvent *e);
|
||||
|
@ -980,6 +980,11 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
close_window_shortcut->setKey(Qt::CTRL | Qt::Key_W);
|
||||
QObject::connect(close_window_shortcut, &QShortcut::activated, this, &MainWindow::ToggleHide);
|
||||
|
||||
QAction *action_focus_search = new QAction(this);
|
||||
action_focus_search->setShortcuts(QList<QKeySequence>() << QKeySequence("Ctrl+F"));
|
||||
addAction(action_focus_search);
|
||||
QObject::connect(action_focus_search, &QAction::triggered, this, &MainWindow::FocusSearchField);
|
||||
|
||||
CheckFullRescanRevisions();
|
||||
|
||||
CommandlineOptionsReceived(options);
|
||||
@ -3157,3 +3162,29 @@ void MainWindow::PlaylistDelete() {
|
||||
delete_files->Start(selected_songs);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::FocusSearchField() {
|
||||
|
||||
if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(collection_view_) && !collection_view_->filter_widget()->SearchFieldHasFocus()) {
|
||||
collection_view_->filter_widget()->FocusSearchField();
|
||||
}
|
||||
#ifdef HAVE_SUBSONIC
|
||||
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(subsonic_view_) && !subsonic_view_->SearchFieldHasFocus()) {
|
||||
subsonic_view_->FocusSearchField();
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(tidal_view_) && !tidal_view_->SearchFieldHasFocus()) {
|
||||
tidal_view_->FocusSearchField();
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(qobuz_view_) && !qobuz_view_->SearchFieldHasFocus()) {
|
||||
qobuz_view_->FocusSearchField();
|
||||
}
|
||||
#endif
|
||||
else if (!ui_->playlist->SearchFieldHasFocus()) {
|
||||
ui_->playlist->FocusSearchField();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -272,6 +272,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void PlaylistDelete();
|
||||
|
||||
void FocusSearchField();
|
||||
|
||||
public slots:
|
||||
void CommandlineOptionsReceived(const quint32 instanceId, const QByteArray &string_options);
|
||||
void Raise();
|
||||
|
@ -35,12 +35,12 @@ InternetCollectionViewContainer::InternetCollectionViewContainer(QWidget *parent
|
||||
ui_(new Ui_InternetCollectionViewContainer) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
view()->SetFilter(filter_widget());
|
||||
ui_->view->SetFilter(ui_->filter_widget);
|
||||
|
||||
QObject::connect(filter_widget(), &CollectionFilterWidget::UpPressed, view(), &InternetCollectionView::UpAndFocus);
|
||||
QObject::connect(filter_widget(), &CollectionFilterWidget::DownPressed, view(), &InternetCollectionView::DownAndFocus);
|
||||
QObject::connect(filter_widget(), &CollectionFilterWidget::ReturnPressed, view(), &InternetCollectionView::FilterReturnPressed);
|
||||
QObject::connect(view(), &InternetCollectionView::FocusOnFilterSignal, filter_widget(), &CollectionFilterWidget::FocusOnFilter);
|
||||
QObject::connect(ui_->filter_widget, &CollectionFilterWidget::UpPressed, ui_->view, &InternetCollectionView::UpAndFocus);
|
||||
QObject::connect(ui_->filter_widget, &CollectionFilterWidget::DownPressed, ui_->view, &InternetCollectionView::DownAndFocus);
|
||||
QObject::connect(ui_->filter_widget, &CollectionFilterWidget::ReturnPressed, ui_->view, &InternetCollectionView::FilterReturnPressed);
|
||||
QObject::connect(ui_->view, &InternetCollectionView::FocusOnFilterSignal, ui_->filter_widget, &CollectionFilterWidget::FocusOnFilter);
|
||||
|
||||
ui_->progressbar->hide();
|
||||
|
||||
@ -51,8 +51,18 @@ InternetCollectionViewContainer::InternetCollectionViewContainer(QWidget *parent
|
||||
InternetCollectionViewContainer::~InternetCollectionViewContainer() { delete ui_; }
|
||||
|
||||
void InternetCollectionViewContainer::ReloadSettings() const {
|
||||
filter_widget()->ReloadSettings();
|
||||
view()->ReloadSettings();
|
||||
|
||||
ui_->filter_widget->ReloadSettings();
|
||||
ui_->view->ReloadSettings();
|
||||
|
||||
}
|
||||
|
||||
bool InternetCollectionViewContainer::SearchFieldHasFocus() const {
|
||||
return ui_->filter_widget->SearchFieldHasFocus();
|
||||
}
|
||||
|
||||
void InternetCollectionViewContainer::FocusSearchField() {
|
||||
ui_->filter_widget->FocusSearchField();
|
||||
}
|
||||
|
||||
void InternetCollectionViewContainer::contextMenuEvent(QContextMenuEvent *e) { Q_UNUSED(e); }
|
||||
|
@ -44,6 +44,8 @@ class InternetCollectionViewContainer : public QWidget {
|
||||
~InternetCollectionViewContainer() override;
|
||||
|
||||
void ReloadSettings() const;
|
||||
bool SearchFieldHasFocus() const;
|
||||
void FocusSearchField();
|
||||
|
||||
QStackedWidget *stacked() const { return ui_->stacked; }
|
||||
QWidget *help_page() const { return ui_->help_page; }
|
||||
|
@ -658,6 +658,12 @@ void InternetSearchView::SearchForThis() {
|
||||
StartSearch(ui_->results->selectionModel()->selectedRows().first().data().toString());
|
||||
}
|
||||
|
||||
bool InternetSearchView::SearchFieldHasFocus() const {
|
||||
|
||||
return ui_->search->hasFocus();
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::FocusSearchField() {
|
||||
|
||||
ui_->search->setFocus();
|
||||
|
@ -85,6 +85,9 @@ class InternetSearchView : public QWidget {
|
||||
|
||||
void Init(Application *app, InternetService *service);
|
||||
|
||||
bool SearchFieldHasFocus() const;
|
||||
void FocusSearchField();
|
||||
|
||||
void LazyLoadAlbumCover(const QModelIndex &proxy_index);
|
||||
|
||||
protected:
|
||||
@ -121,7 +124,6 @@ class InternetSearchView : public QWidget {
|
||||
|
||||
bool SearchKeyEvent(QKeyEvent *e);
|
||||
bool ResultsContextMenuEvent(QContextMenuEvent *e);
|
||||
void FocusSearchField();
|
||||
|
||||
MimeData *SelectedMimeData();
|
||||
|
||||
|
@ -48,6 +48,9 @@ class InternetSongsView : public QWidget {
|
||||
|
||||
InternetCollectionView *view() const { return ui_->view; }
|
||||
|
||||
bool SearchFieldHasFocus() const { return ui_->filter_widget->SearchFieldHasFocus(); }
|
||||
void FocusSearchField() { ui_->filter_widget->FocusSearchField(); }
|
||||
|
||||
private slots:
|
||||
void OpenSettingsDialog();
|
||||
void GetSongs();
|
||||
|
@ -206,6 +206,32 @@ void InternetTabsView::ReloadSettings() {
|
||||
|
||||
}
|
||||
|
||||
bool InternetTabsView::SearchFieldHasFocus() const {
|
||||
|
||||
return ((ui_->tabs->currentWidget() == ui_->artists && ui_->artists_collection->SearchFieldHasFocus()) ||
|
||||
(ui_->tabs->currentWidget() == ui_->albums && ui_->albums_collection->SearchFieldHasFocus()) ||
|
||||
(ui_->tabs->currentWidget() == ui_->songs && ui_->songs_collection->SearchFieldHasFocus()) ||
|
||||
(ui_->tabs->currentWidget() == ui_->search && ui_->search_view->SearchFieldHasFocus()));
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::FocusSearchField() {
|
||||
|
||||
if (ui_->tabs->currentWidget() == ui_->artists) {
|
||||
ui_->artists_collection->FocusSearchField();
|
||||
}
|
||||
else if (ui_->tabs->currentWidget() == ui_->albums) {
|
||||
ui_->albums_collection->FocusSearchField();
|
||||
}
|
||||
else if (ui_->tabs->currentWidget() == ui_->songs) {
|
||||
ui_->songs_collection->FocusSearchField();
|
||||
}
|
||||
else if (ui_->tabs->currentWidget() == ui_->search) {
|
||||
ui_->search_view->FocusSearchField();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::GetArtists() {
|
||||
|
||||
if (!service_->authenticated() && service_->oauth()) {
|
||||
|
@ -53,6 +53,9 @@ class InternetTabsView : public QWidget {
|
||||
InternetCollectionView *songs_collection_view() const { return ui_->songs_collection->view(); }
|
||||
InternetSearchView *search_view() const { return ui_->search_view; }
|
||||
|
||||
bool SearchFieldHasFocus() const;
|
||||
void FocusSearchField();
|
||||
|
||||
private slots:
|
||||
void OpenSettingsDialog();
|
||||
void GetArtists();
|
||||
|
@ -263,6 +263,14 @@ void PlaylistContainer::ReloadSettings() {
|
||||
|
||||
}
|
||||
|
||||
bool PlaylistContainer::SearchFieldHasFocus() const {
|
||||
return ui_->filter->hasFocus();
|
||||
}
|
||||
|
||||
void PlaylistContainer::FocusSearchField() {
|
||||
ui_->filter->setFocus();
|
||||
}
|
||||
|
||||
void PlaylistContainer::ActivePlaying() {
|
||||
UpdateActiveIcon(QIcon(":/pictures/tiny-play.png"));
|
||||
}
|
||||
@ -456,6 +464,7 @@ void PlaylistContainer::FocusOnFilter(QKeyEvent *event) {
|
||||
ui_->filter->setText(ui_->filter->text() + event->text());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::RepositionNoMatchesLabel(const bool force) {
|
||||
|
@ -57,6 +57,9 @@ class PlaylistContainer : public QWidget {
|
||||
void SetManager(PlaylistManager *manager);
|
||||
void ReloadSettings();
|
||||
|
||||
bool SearchFieldHasFocus() const;
|
||||
void FocusSearchField();
|
||||
|
||||
PlaylistView *view() const;
|
||||
|
||||
bool eventFilter(QObject *objectWatched, QEvent *event) override;
|
||||
|
@ -22,6 +22,10 @@ class QSearchField : public QWidget {
|
||||
|
||||
QString text() const;
|
||||
QString placeholderText() const;
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
bool hasFocus() const;
|
||||
#endif
|
||||
void setFocus(Qt::FocusReason);
|
||||
|
||||
public slots:
|
||||
|
@ -131,6 +131,11 @@ QString QSearchField::placeholderText() const {
|
||||
return pimpl->lineedit_->placeholderText();
|
||||
}
|
||||
|
||||
bool QSearchField::hasFocus() const {
|
||||
Q_ASSERT(pimpl && pimpl->lineedit_);
|
||||
return pimpl && pimpl->lineedit_ && pimpl->lineedit_->hasFocus();
|
||||
}
|
||||
|
||||
void QSearchField::setFocus(Qt::FocusReason reason) {
|
||||
Q_ASSERT(pimpl && pimpl->lineedit_);
|
||||
if (pimpl && pimpl->lineedit_) pimpl->lineedit_->setFocus(reason);
|
||||
|
Loading…
Reference in New Issue
Block a user