Pref: wb: Add contextual menu to sort alphabetically. (#10363)
Co-authored-by: Paddle <PaddleStroke@users.noreply.github.com>
This commit is contained in:
@@ -24,9 +24,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QAction>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
@@ -234,6 +236,16 @@ DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp( QWidget* parent )
|
||||
ui->wbList->setDragEnabled(true);
|
||||
ui->wbList->setDefaultDropAction(Qt::MoveAction);
|
||||
|
||||
QAction* sortAction = new QAction(tr("Sort alphabetically"), this);
|
||||
connect(sortAction, &QAction::triggered, this, &DlgSettingsWorkbenchesImp::sortEnabledWorkbenches);
|
||||
|
||||
QMenu* contextMenu = new QMenu(ui->wbList);
|
||||
contextMenu->addAction(sortAction);
|
||||
ui->wbList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->wbList, &QListWidget::customContextMenuRequested, this, [this, contextMenu](const QPoint& pos) {
|
||||
contextMenu->exec(ui->wbList->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
connect(ui->wbList->model(), &QAbstractItemModel::rowsMoved, this, &DlgSettingsWorkbenchesImp::wbItemMoved);
|
||||
connect(ui->AutoloadModuleCombo, qOverload<int>(&QComboBox::activated), this, &DlgSettingsWorkbenchesImp::onStartWbChanged);
|
||||
connect(ui->WorkbenchSelectorPosition, qOverload<int>(&QComboBox::activated), this, &DlgSettingsWorkbenchesImp::onWbSelectorChanged);
|
||||
@@ -345,6 +357,8 @@ void DlgSettingsWorkbenchesImp::buildWorkbenchList()
|
||||
{
|
||||
QSignalBlocker sigblk(ui->wbList);
|
||||
|
||||
ui->wbList->clear();
|
||||
|
||||
QStringList enabledWbs = getEnabledWorkbenches();
|
||||
QStringList disabledWbs = getDisabledWorkbenches();
|
||||
|
||||
@@ -584,5 +598,14 @@ void DlgSettingsWorkbenchesImp::onWbByTabToggled(bool val)
|
||||
requireRestart();
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::sortEnabledWorkbenches()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp->SetASCII("Ordered", "");
|
||||
|
||||
buildWorkbenchList();
|
||||
}
|
||||
#include "moc_DlgSettingsWorkbenchesImp.cpp"
|
||||
#include "DlgSettingsWorkbenchesImp.moc"
|
||||
|
||||
@@ -64,6 +64,7 @@ protected:
|
||||
|
||||
private:
|
||||
void addWorkbench(const QString& it, bool enabled);
|
||||
void sortEnabledWorkbenches();
|
||||
|
||||
void setStartWorkbenchComboItems();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user