Fix some remaining UI issues with global search:
- Add a "Configure global search" item to the context menu, and show the context menu when right clicking in the help screen as well. - Don't crash when nothing is selected. - Add Ctrl+F and Ctrl+L shortcuts to focus the search field. - Switch to the search tab when clicking one of the tags in Artist Info.
This commit is contained in:
parent
b427fc8a24
commit
45a8b3af59
|
@ -62,7 +62,7 @@ GlobalSearchView::GlobalSearchView(Application* app, QWidget* parent)
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
ui_->search->installEventFilter(this);
|
ui_->search->installEventFilter(this);
|
||||||
ui_->results->installEventFilter(this);
|
ui_->results_stack->installEventFilter(this);
|
||||||
|
|
||||||
// Must be a queued connection to ensure the GlobalSearch handles it first.
|
// Must be a queued connection to ensure the GlobalSearch handles it first.
|
||||||
connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()), Qt::QueuedConnection);
|
connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()), Qt::QueuedConnection);
|
||||||
|
@ -77,7 +77,7 @@ GlobalSearchView::GlobalSearchView(Application* app, QWidget* parent)
|
||||||
ui_->results->setStyleSheet("QTreeView::item{padding-top:1px;}");
|
ui_->results->setStyleSheet("QTreeView::item{padding-top:1px;}");
|
||||||
|
|
||||||
// Show the help page initially
|
// Show the help page initially
|
||||||
ui_->stack->setCurrentWidget(ui_->help_page);
|
ui_->results_stack->setCurrentWidget(ui_->help_page);
|
||||||
ui_->help_frame->setBackgroundRole(QPalette::Base);
|
ui_->help_frame->setBackgroundRole(QPalette::Base);
|
||||||
QVBoxLayout* enabled_layout = new QVBoxLayout(ui_->enabled_list);
|
QVBoxLayout* enabled_layout = new QVBoxLayout(ui_->enabled_list);
|
||||||
QVBoxLayout* disabled_layout = new QVBoxLayout(ui_->disabled_list);
|
QVBoxLayout* disabled_layout = new QVBoxLayout(ui_->disabled_list);
|
||||||
|
@ -255,9 +255,9 @@ void GlobalSearchView::SwapModels() {
|
||||||
ui_->results->setModel(front_proxy_);
|
ui_->results->setModel(front_proxy_);
|
||||||
|
|
||||||
if (ui_->search->text().trimmed().isEmpty()) {
|
if (ui_->search->text().trimmed().isEmpty()) {
|
||||||
ui_->stack->setCurrentWidget(ui_->help_page);
|
ui_->results_stack->setCurrentWidget(ui_->help_page);
|
||||||
} else {
|
} else {
|
||||||
ui_->stack->setCurrentWidget(ui_->results_page);
|
ui_->results_stack->setCurrentWidget(ui_->results_page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +315,9 @@ void GlobalSearchView::ArtLoaded(int id, const QPixmap& pixmap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeData* GlobalSearchView::SelectedMimeData() {
|
MimeData* GlobalSearchView::SelectedMimeData() {
|
||||||
|
if (!ui_->results->selectionModel())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Get all selected model indexes
|
// Get all selected model indexes
|
||||||
QModelIndexList indexes = ui_->results->selectionModel()->selectedRows();
|
QModelIndexList indexes = ui_->results->selectionModel()->selectedRows();
|
||||||
if (indexes.isEmpty()) {
|
if (indexes.isEmpty()) {
|
||||||
|
@ -349,7 +352,7 @@ bool GlobalSearchView::eventFilter(QObject* object, QEvent* event) {
|
||||||
if (SearchKeyEvent(static_cast<QKeyEvent*>(event))) {
|
if (SearchKeyEvent(static_cast<QKeyEvent*>(event))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (object == ui_->results && event->type() == QEvent::ContextMenu) {
|
} else if (object == ui_->results_stack && event->type() == QEvent::ContextMenu) {
|
||||||
if (ResultsContextMenuEvent(static_cast<QContextMenuEvent*>(event))) {
|
if (ResultsContextMenuEvent(static_cast<QContextMenuEvent*>(event))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -383,16 +386,28 @@ bool GlobalSearchView::SearchKeyEvent(QKeyEvent* event) {
|
||||||
bool GlobalSearchView::ResultsContextMenuEvent(QContextMenuEvent* event) {
|
bool GlobalSearchView::ResultsContextMenuEvent(QContextMenuEvent* event) {
|
||||||
if (!context_menu_) {
|
if (!context_menu_) {
|
||||||
context_menu_ = new QMenu(this);
|
context_menu_ = new QMenu(this);
|
||||||
context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
context_actions_ << context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||||
tr("Append to current playlist"), this, SLOT(AddSelectedToPlaylist()));
|
tr("Append to current playlist"), this, SLOT(AddSelectedToPlaylist()));
|
||||||
context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
context_actions_ << context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||||
tr("Replace current playlist"), this, SLOT(LoadSelected()));
|
tr("Replace current playlist"), this, SLOT(LoadSelected()));
|
||||||
context_menu_->addAction(IconLoader::Load("document-new"),
|
context_actions_ << context_menu_->addAction(IconLoader::Load("document-new"),
|
||||||
tr("Open in new playlist"), this, SLOT(OpenSelectedInNewPlaylist()));
|
tr("Open in new playlist"), this, SLOT(OpenSelectedInNewPlaylist()));
|
||||||
|
|
||||||
context_menu_->addSeparator();
|
context_menu_->addSeparator();
|
||||||
context_menu_->addAction(IconLoader::Load("go-next"),
|
context_actions_ << context_menu_->addAction(IconLoader::Load("go-next"),
|
||||||
tr("Queue track"), this, SLOT(AddSelectedToPlaylistEnqueue()));
|
tr("Queue track"), this, SLOT(AddSelectedToPlaylistEnqueue()));
|
||||||
|
|
||||||
|
context_menu_->addSeparator();
|
||||||
|
context_menu_->addAction(IconLoader::Load("configure"),
|
||||||
|
tr("Configure global search..."), this, SLOT(OpenSettingsDialog()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool enable_context_actions =
|
||||||
|
ui_->results->selectionModel() &&
|
||||||
|
ui_->results->selectionModel()->hasSelection();
|
||||||
|
|
||||||
|
foreach (QAction* action, context_actions_) {
|
||||||
|
action->setEnabled(enable_context_actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
context_menu_->popup(event->globalPos());
|
context_menu_->popup(event->globalPos());
|
||||||
|
@ -406,18 +421,27 @@ void GlobalSearchView::AddSelectedToPlaylist() {
|
||||||
|
|
||||||
void GlobalSearchView::LoadSelected() {
|
void GlobalSearchView::LoadSelected() {
|
||||||
MimeData* data = SelectedMimeData();
|
MimeData* data = SelectedMimeData();
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
data->clear_first_ = true;
|
data->clear_first_ = true;
|
||||||
emit AddToPlaylist(data);
|
emit AddToPlaylist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchView::AddSelectedToPlaylistEnqueue() {
|
void GlobalSearchView::AddSelectedToPlaylistEnqueue() {
|
||||||
MimeData* data = SelectedMimeData();
|
MimeData* data = SelectedMimeData();
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
data->enqueue_now_ = true;
|
data->enqueue_now_ = true;
|
||||||
emit AddToPlaylist(data);
|
emit AddToPlaylist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchView::OpenSelectedInNewPlaylist() {
|
void GlobalSearchView::OpenSelectedInNewPlaylist() {
|
||||||
MimeData* data = SelectedMimeData();
|
MimeData* data = SelectedMimeData();
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
data->open_in_new_playlist_ = true;
|
data->open_in_new_playlist_ = true;
|
||||||
emit AddToPlaylist(data);
|
emit AddToPlaylist(data);
|
||||||
}
|
}
|
||||||
|
@ -428,6 +452,13 @@ void GlobalSearchView::showEvent(QShowEvent* e) {
|
||||||
update_suggestions_timer_->start();
|
update_suggestions_timer_->start();
|
||||||
}
|
}
|
||||||
QWidget::showEvent(e);
|
QWidget::showEvent(e);
|
||||||
|
|
||||||
|
FocusSearchField();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSearchView::FocusSearchField() {
|
||||||
|
ui_->search->set_focus();
|
||||||
|
ui_->search->selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchView::hideEvent(QHideEvent* e) {
|
void GlobalSearchView::hideEvent(QHideEvent* e) {
|
||||||
|
@ -439,3 +470,7 @@ void GlobalSearchView::FocusOnFilter(QKeyEvent* event) {
|
||||||
ui_->search->set_focus();
|
ui_->search->set_focus();
|
||||||
QApplication::sendEvent(ui_->search, event);
|
QApplication::sendEvent(ui_->search, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobalSearchView::OpenSettingsDialog() {
|
||||||
|
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_GlobalSearch);
|
||||||
|
}
|
||||||
|
|
|
@ -59,10 +59,11 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
void StartSearch(const QString& query);
|
void StartSearch(const QString& query);
|
||||||
|
void FocusSearchField();
|
||||||
|
void OpenSettingsDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void AddToPlaylist(QMimeData* data);
|
void AddToPlaylist(QMimeData* data);
|
||||||
void OpenSettingsAtPage(SettingsDialog::Page page);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void UpdateSuggestions();
|
void UpdateSuggestions();
|
||||||
|
@ -91,6 +92,7 @@ private:
|
||||||
Ui_GlobalSearchView* ui_;
|
Ui_GlobalSearchView* ui_;
|
||||||
|
|
||||||
QMenu* context_menu_;
|
QMenu* context_menu_;
|
||||||
|
QList<QAction*> context_actions_;
|
||||||
|
|
||||||
int last_search_id_;
|
int last_search_id_;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stack">
|
<widget class="QStackedWidget" name="results_stack">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>435</width>
|
<width>435</width>
|
||||||
<height>604</height>
|
<height>605</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
|
|
@ -222,7 +222,6 @@ MainWindow::MainWindow(Application* app,
|
||||||
global_search_view_->ReloadSettings();
|
global_search_view_->ReloadSettings();
|
||||||
|
|
||||||
connect(global_search_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
connect(global_search_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
||||||
connect(global_search_view_, SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)), SLOT(OpenSettingsDialogAtPage(SettingsDialog::Page)));
|
|
||||||
|
|
||||||
// Add tabs to the fancy tab widget
|
// Add tabs to the fancy tab widget
|
||||||
ui_->tabs->AddTab(global_search_view_, IconLoader::Load("search"), tr("Search"));
|
ui_->tabs->AddTab(global_search_view_, IconLoader::Load("search"), tr("Search"));
|
||||||
|
@ -510,6 +509,15 @@ MainWindow::MainWindow(Application* app,
|
||||||
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)),
|
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)),
|
||||||
playlist_copy_to_device_, SLOT(setDisabled(bool)));
|
playlist_copy_to_device_, SLOT(setDisabled(bool)));
|
||||||
|
|
||||||
|
// Global search shortcut
|
||||||
|
QAction* global_search_action = new QAction(this);
|
||||||
|
global_search_action->setShortcuts(QList<QKeySequence>()
|
||||||
|
<< QKeySequence("Ctrl+F")
|
||||||
|
<< QKeySequence("Ctrl+L"));
|
||||||
|
addAction(global_search_action);
|
||||||
|
connect(global_search_action, SIGNAL(triggered()),
|
||||||
|
SLOT(FocusGlobalSearchField()));
|
||||||
|
|
||||||
// Internet connections
|
// Internet connections
|
||||||
connect(app_->internet_model(), SIGNAL(StreamError(QString)), SLOT(ShowErrorDialog(QString)));
|
connect(app_->internet_model(), SIGNAL(StreamError(QString)), SLOT(ShowErrorDialog(QString)));
|
||||||
connect(app_->internet_model(), SIGNAL(StreamMetadataFound(QUrl,Song)), app_->playlist_manager(), SLOT(SetActiveStreamMetadata(QUrl,Song)));
|
connect(app_->internet_model(), SIGNAL(StreamMetadataFound(QUrl,Song)), app_->playlist_manager(), SLOT(SetActiveStreamMetadata(QUrl,Song)));
|
||||||
|
@ -2025,7 +2033,7 @@ void MainWindow::ConnectInfoView(SongInfoBase* view) {
|
||||||
|
|
||||||
connect(view, SIGNAL(ShowSettingsDialog()), SLOT(ShowSongInfoConfig()));
|
connect(view, SIGNAL(ShowSettingsDialog()), SLOT(ShowSongInfoConfig()));
|
||||||
connect(view, SIGNAL(DoGlobalSearch(QString)),
|
connect(view, SIGNAL(DoGlobalSearch(QString)),
|
||||||
global_search_view_, SLOT(StartSearch(QString)));
|
SLOT(DoGlobalSearch(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddSongInfoGenerator(smart_playlists::GeneratorPtr gen) {
|
void MainWindow::AddSongInfoGenerator(smart_playlists::GeneratorPtr gen) {
|
||||||
|
@ -2236,3 +2244,13 @@ void MainWindow::ScrollToInternetIndex(const QModelIndex& index) {
|
||||||
void MainWindow::AddPodcast() {
|
void MainWindow::AddPodcast() {
|
||||||
app_->internet_model()->Service<PodcastService>()->AddPodcast();
|
app_->internet_model()->Service<PodcastService>()->AddPodcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::FocusGlobalSearchField() {
|
||||||
|
ui_->tabs->SetCurrentWidget(global_search_view_);
|
||||||
|
global_search_view_->FocusSearchField();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::DoGlobalSearch(const QString& query) {
|
||||||
|
FocusGlobalSearchField();
|
||||||
|
global_search_view_->StartSearch(query);
|
||||||
|
}
|
||||||
|
|
|
@ -248,6 +248,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||||
void HandleNotificationPreview(OSD::Behaviour type, QString line1, QString line2);
|
void HandleNotificationPreview(OSD::Behaviour type, QString line1, QString line2);
|
||||||
|
|
||||||
void ScrollToInternetIndex(const QModelIndex& index);
|
void ScrollToInternetIndex(const QModelIndex& index);
|
||||||
|
void FocusGlobalSearchField();
|
||||||
|
void DoGlobalSearch(const QString& query);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ConnectInfoView(SongInfoBase* view);
|
void ConnectInfoView(SongInfoBase* view);
|
||||||
|
|
Loading…
Reference in New Issue