mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:17:28 +00:00
UI: Programs: Tweak "Filters" menu
This commit is contained in:
parent
272a4e74a7
commit
d981ebf1a9
@ -143,7 +143,7 @@ void ProgramsWindow::retranslateUi()
|
|||||||
m_btRemoveApp->setText(tr("Remove"));
|
m_btRemoveApp->setText(tr("Remove"));
|
||||||
m_editSearch->setPlaceholderText(tr("Search"));
|
m_editSearch->setPlaceholderText(tr("Search"));
|
||||||
m_btFilter->setToolTip(tr("Filters"));
|
m_btFilter->setToolTip(tr("Filters"));
|
||||||
m_btClearFilter->setToolTip(tr("Clear Filters"));
|
m_btClearFilter->setText(tr("Clear Filters"));
|
||||||
m_cbFilterWildcard->setText(tr("Wildcard Paths"));
|
m_cbFilterWildcard->setText(tr("Wildcard Paths"));
|
||||||
|
|
||||||
m_btGroups->setText(tr("Groups"));
|
m_btGroups->setText(tr("Groups"));
|
||||||
@ -213,7 +213,6 @@ QLayout *ProgramsWindow::setupHeader()
|
|||||||
|
|
||||||
// Filter button
|
// Filter button
|
||||||
setupFilter();
|
setupFilter();
|
||||||
setupClearFilter();
|
|
||||||
|
|
||||||
// Groups button
|
// Groups button
|
||||||
m_btGroups = ControlUtil::createFlatToolButton(":/icons/application_double.png");
|
m_btGroups = ControlUtil::createFlatToolButton(":/icons/application_double.png");
|
||||||
@ -240,7 +239,6 @@ QLayout *ProgramsWindow::setupHeader()
|
|||||||
layout->addWidget(ControlUtil::createVSeparator());
|
layout->addWidget(ControlUtil::createVSeparator());
|
||||||
layout->addWidget(m_editSearch);
|
layout->addWidget(m_editSearch);
|
||||||
layout->addWidget(m_btFilter);
|
layout->addWidget(m_btFilter);
|
||||||
layout->addWidget(m_btClearFilter);
|
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
layout->addWidget(m_btGroups);
|
layout->addWidget(m_btGroups);
|
||||||
layout->addWidget(m_btServices);
|
layout->addWidget(m_btServices);
|
||||||
@ -320,6 +318,34 @@ void ProgramsWindow::setupEditSearch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProgramsWindow::setupFilter()
|
void ProgramsWindow::setupFilter()
|
||||||
|
{
|
||||||
|
setupFilterWildcard();
|
||||||
|
setupFilterClear();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->addWidget(m_cbFilterWildcard);
|
||||||
|
layout->addWidget(ControlUtil::createHSeparator());
|
||||||
|
layout->addWidget(m_btClearFilter, 0, Qt::AlignCenter);
|
||||||
|
|
||||||
|
auto menu = ControlUtil::createMenuByLayout(layout, this);
|
||||||
|
|
||||||
|
m_btFilter = ControlUtil::createButton(":/icons/filter.png");
|
||||||
|
m_btFilter->setMenu(menu);
|
||||||
|
|
||||||
|
const auto refreshFilter = [&] {
|
||||||
|
const auto isEmpty = (appListModel()->filters() == AppListModel::FilterNone);
|
||||||
|
|
||||||
|
m_btFilter->setIcon(isEmpty
|
||||||
|
? IconCache::icon(":/icons/filter.png")
|
||||||
|
: GuiUtil::overlayIcon(":/icons/filter.png", ":/icons/tick.png"));
|
||||||
|
};
|
||||||
|
|
||||||
|
refreshFilter();
|
||||||
|
|
||||||
|
connect(appListModel(), &AppListModel::filtersChanged, this, refreshFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramsWindow::setupFilterWildcard()
|
||||||
{
|
{
|
||||||
m_cbFilterWildcard = new QCheckBox();
|
m_cbFilterWildcard = new QCheckBox();
|
||||||
m_cbFilterWildcard->setIcon(IconCache::icon(":/icons/coding.png"));
|
m_cbFilterWildcard->setIcon(IconCache::icon(":/icons/coding.png"));
|
||||||
@ -331,34 +357,15 @@ void ProgramsWindow::setupFilter()
|
|||||||
appListModel()->setFilterValue(
|
appListModel()->setFilterValue(
|
||||||
AppListModel::FilterWildcard, m_cbFilterWildcard->checkState());
|
AppListModel::FilterWildcard, m_cbFilterWildcard->checkState());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto layout = ControlUtil::createVLayoutByWidgets({ m_cbFilterWildcard });
|
|
||||||
|
|
||||||
auto menu = ControlUtil::createMenuByLayout(layout, this);
|
|
||||||
|
|
||||||
m_btFilter = ControlUtil::createButton(":/icons/filter.png");
|
|
||||||
m_btFilter->setMenu(menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramsWindow::setupClearFilter()
|
void ProgramsWindow::setupFilterClear()
|
||||||
{
|
{
|
||||||
m_btClearFilter = new QPushButton(
|
m_btClearFilter = ControlUtil::createFlatToolButton(":/icons/recycle.png", [&] {
|
||||||
GuiUtil::overlayIcon(":/icons/filter.png", ":/icons/cross.png"), QString());
|
|
||||||
|
|
||||||
connect(m_btClearFilter, &QPushButton::clicked, this, [&] {
|
|
||||||
appListModel()->clearFilters();
|
appListModel()->clearFilters();
|
||||||
|
|
||||||
m_cbFilterWildcard->setCheckState(Qt::PartiallyChecked);
|
m_cbFilterWildcard->setCheckState(Qt::PartiallyChecked);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto refreshClearFilter = [&] {
|
|
||||||
const auto isEmpty = (appListModel()->filters() == AppListModel::FilterNone);
|
|
||||||
m_btClearFilter->setVisible(!isEmpty);
|
|
||||||
};
|
|
||||||
|
|
||||||
refreshClearFilter();
|
|
||||||
|
|
||||||
connect(appListModel(), &AppListModel::filtersChanged, this, refreshClearFilter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramsWindow::setupTableApps()
|
void ProgramsWindow::setupTableApps()
|
||||||
|
@ -65,7 +65,8 @@ private:
|
|||||||
void setupEditMenu();
|
void setupEditMenu();
|
||||||
void setupEditSearch();
|
void setupEditSearch();
|
||||||
void setupFilter();
|
void setupFilter();
|
||||||
void setupClearFilter();
|
void setupFilterWildcard();
|
||||||
|
void setupFilterClear();
|
||||||
void setupTableApps();
|
void setupTableApps();
|
||||||
void setupTableAppsHeader();
|
void setupTableAppsHeader();
|
||||||
void setupAppInfoRow();
|
void setupAppInfoRow();
|
||||||
@ -109,7 +110,7 @@ private:
|
|||||||
QToolButton *m_btRemoveApp = nullptr;
|
QToolButton *m_btRemoveApp = nullptr;
|
||||||
QLineEdit *m_editSearch = nullptr;
|
QLineEdit *m_editSearch = nullptr;
|
||||||
QPushButton *m_btFilter = nullptr;
|
QPushButton *m_btFilter = nullptr;
|
||||||
QPushButton *m_btClearFilter = nullptr;
|
QToolButton *m_btClearFilter = nullptr;
|
||||||
QCheckBox *m_cbFilterWildcard = nullptr;
|
QCheckBox *m_cbFilterWildcard = nullptr;
|
||||||
QToolButton *m_btGroups = nullptr;
|
QToolButton *m_btGroups = nullptr;
|
||||||
QToolButton *m_btServices = nullptr;
|
QToolButton *m_btServices = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user