mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Mostly port LibraryFilterWidget to qocoa.
This commit is contained in:
parent
c415db1524
commit
f97fe9c69b
@ -22,7 +22,6 @@
|
||||
#include "ui_libraryfilterwidget.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "ui/settingsdialog.h"
|
||||
#include "widgets/maclineedit.h"
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QKeyEvent>
|
||||
@ -41,7 +40,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent)
|
||||
delay_behaviour_(DelayedOnLargeLibraries)
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
|
||||
//connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
|
||||
connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));
|
||||
|
||||
filter_delay_->setInterval(kFilterDelay);
|
||||
@ -93,18 +92,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent)
|
||||
library_menu_->addSeparator();
|
||||
ui_->options->setMenu(library_menu_);
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
QString hint = ui_->filter->hint();
|
||||
delete ui_->filter;
|
||||
MacLineEdit* lineedit = new MacLineEdit(this);
|
||||
ui_->horizontalLayout->insertWidget(1, lineedit);
|
||||
filter_ = lineedit;
|
||||
filter_->set_hint(hint);
|
||||
#else
|
||||
filter_ = ui_->filter;
|
||||
#endif
|
||||
|
||||
connect(filter_->widget(), SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString)));
|
||||
connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString)));
|
||||
}
|
||||
|
||||
LibraryFilterWidget::~LibraryFilterWidget() {
|
||||
@ -144,7 +132,7 @@ QAction* LibraryFilterWidget::CreateGroupByAction(
|
||||
}
|
||||
|
||||
void LibraryFilterWidget::FocusOnFilter(QKeyEvent *event) {
|
||||
ui_->filter->set_focus();
|
||||
ui_->filter->setFocus();
|
||||
QApplication::sendEvent(ui_->filter, event);
|
||||
}
|
||||
|
||||
@ -214,12 +202,12 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) {
|
||||
}
|
||||
|
||||
void LibraryFilterWidget::SetFilterHint(const QString& hint) {
|
||||
filter_->set_hint(hint);
|
||||
ui_->filter->setPlaceholderText(hint);
|
||||
}
|
||||
|
||||
void LibraryFilterWidget::SetQueryMode(QueryOptions::QueryMode query_mode) {
|
||||
filter_->clear();
|
||||
filter_->set_enabled(query_mode == QueryOptions::QueryMode_All);
|
||||
ui_->filter->clear();
|
||||
ui_->filter->setEnabled(query_mode == QueryOptions::QueryMode_All);
|
||||
|
||||
model_->SetFilterQueryMode(query_mode);
|
||||
}
|
||||
@ -249,7 +237,7 @@ void LibraryFilterWidget::keyReleaseEvent(QKeyEvent* e) {
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
filter_->clear();
|
||||
ui_->filter->clear();
|
||||
e->accept();
|
||||
break;
|
||||
}
|
||||
@ -276,8 +264,8 @@ void LibraryFilterWidget::FilterTextChanged(const QString& text) {
|
||||
}
|
||||
|
||||
void LibraryFilterWidget::FilterDelayTimeout() {
|
||||
emit Filter(filter_->text());
|
||||
emit Filter(ui_->filter->text());
|
||||
if (filter_applies_to_model_) {
|
||||
model_->SetFilterText(filter_->text());
|
||||
model_->SetFilterText(ui_->filter->text());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "librarymodel.h"
|
||||
|
||||
class GroupByDialog;
|
||||
class LineEditInterface;
|
||||
class SettingsDialog;
|
||||
class Ui_LibraryFilterWidget;
|
||||
|
||||
@ -107,11 +106,6 @@ class LibraryFilterWidget : public QWidget {
|
||||
DelayBehaviour delay_behaviour_;
|
||||
|
||||
QString settings_group_;
|
||||
|
||||
// Since on Mac ui_->filter is nonexistent and on other platforms
|
||||
// filter_ == ui_->filter, make sure to always use this field and
|
||||
// not the one in the ui_ object!
|
||||
LineEditInterface* filter_;
|
||||
};
|
||||
|
||||
#endif // LIBRARYFILTERWIDGET_H
|
||||
|
@ -21,7 +21,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="LineEdit" name="filter">
|
||||
<widget class="QSearchField" name="filter">
|
||||
<property name="hint" stdset="0">
|
||||
<string>Enter search terms here</string>
|
||||
</property>
|
||||
@ -98,9 +98,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>widgets/lineedit.h</header>
|
||||
<class>QSearchField</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>3rdparty/qocoa/qsearchfield.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
Loading…
Reference in New Issue
Block a user