mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 03:45:56 +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_libraryfilterwidget.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
#include "ui/settingsdialog.h"
|
#include "ui/settingsdialog.h"
|
||||||
#include "widgets/maclineedit.h"
|
|
||||||
|
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -41,7 +40,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent)
|
|||||||
delay_behaviour_(DelayedOnLargeLibraries)
|
delay_behaviour_(DelayedOnLargeLibraries)
|
||||||
{
|
{
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
|
//connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
|
||||||
connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));
|
connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));
|
||||||
|
|
||||||
filter_delay_->setInterval(kFilterDelay);
|
filter_delay_->setInterval(kFilterDelay);
|
||||||
@ -93,18 +92,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent)
|
|||||||
library_menu_->addSeparator();
|
library_menu_->addSeparator();
|
||||||
ui_->options->setMenu(library_menu_);
|
ui_->options->setMenu(library_menu_);
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString)));
|
||||||
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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryFilterWidget::~LibraryFilterWidget() {
|
LibraryFilterWidget::~LibraryFilterWidget() {
|
||||||
@ -144,7 +132,7 @@ QAction* LibraryFilterWidget::CreateGroupByAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LibraryFilterWidget::FocusOnFilter(QKeyEvent *event) {
|
void LibraryFilterWidget::FocusOnFilter(QKeyEvent *event) {
|
||||||
ui_->filter->set_focus();
|
ui_->filter->setFocus();
|
||||||
QApplication::sendEvent(ui_->filter, event);
|
QApplication::sendEvent(ui_->filter, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,12 +202,12 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LibraryFilterWidget::SetFilterHint(const QString& hint) {
|
void LibraryFilterWidget::SetFilterHint(const QString& hint) {
|
||||||
filter_->set_hint(hint);
|
ui_->filter->setPlaceholderText(hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryFilterWidget::SetQueryMode(QueryOptions::QueryMode query_mode) {
|
void LibraryFilterWidget::SetQueryMode(QueryOptions::QueryMode query_mode) {
|
||||||
filter_->clear();
|
ui_->filter->clear();
|
||||||
filter_->set_enabled(query_mode == QueryOptions::QueryMode_All);
|
ui_->filter->setEnabled(query_mode == QueryOptions::QueryMode_All);
|
||||||
|
|
||||||
model_->SetFilterQueryMode(query_mode);
|
model_->SetFilterQueryMode(query_mode);
|
||||||
}
|
}
|
||||||
@ -249,7 +237,7 @@ void LibraryFilterWidget::keyReleaseEvent(QKeyEvent* e) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
filter_->clear();
|
ui_->filter->clear();
|
||||||
e->accept();
|
e->accept();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -276,8 +264,8 @@ void LibraryFilterWidget::FilterTextChanged(const QString& text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LibraryFilterWidget::FilterDelayTimeout() {
|
void LibraryFilterWidget::FilterDelayTimeout() {
|
||||||
emit Filter(filter_->text());
|
emit Filter(ui_->filter->text());
|
||||||
if (filter_applies_to_model_) {
|
if (filter_applies_to_model_) {
|
||||||
model_->SetFilterText(filter_->text());
|
model_->SetFilterText(ui_->filter->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "librarymodel.h"
|
#include "librarymodel.h"
|
||||||
|
|
||||||
class GroupByDialog;
|
class GroupByDialog;
|
||||||
class LineEditInterface;
|
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
class Ui_LibraryFilterWidget;
|
class Ui_LibraryFilterWidget;
|
||||||
|
|
||||||
@ -107,11 +106,6 @@ class LibraryFilterWidget : public QWidget {
|
|||||||
DelayBehaviour delay_behaviour_;
|
DelayBehaviour delay_behaviour_;
|
||||||
|
|
||||||
QString settings_group_;
|
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
|
#endif // LIBRARYFILTERWIDGET_H
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="LineEdit" name="filter">
|
<widget class="QSearchField" name="filter">
|
||||||
<property name="hint" stdset="0">
|
<property name="hint" stdset="0">
|
||||||
<string>Enter search terms here</string>
|
<string>Enter search terms here</string>
|
||||||
</property>
|
</property>
|
||||||
@ -98,9 +98,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>LineEdit</class>
|
<class>QSearchField</class>
|
||||||
<extends>QLineEdit</extends>
|
<extends>QWidget</extends>
|
||||||
<header>widgets/lineedit.h</header>
|
<header>3rdparty/qocoa/qsearchfield.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
Reference in New Issue
Block a user