NOISSUE add an 'open folder' button to the icon dialog

This commit is contained in:
Petr Mrázek 2018-02-05 02:01:12 +01:00
parent 83649b5d52
commit 41aef8414a
4 changed files with 20 additions and 5 deletions

View File

@ -401,4 +401,9 @@ int IconList::getIconIndex(const QString &key) const
return -1;
}
QString IconList::getDirectory() const
{
return m_dir.absolutePath();
}
//#include "IconList.moc"

View File

@ -39,6 +39,7 @@ public:
QIcon getIcon(const QString &key) const;
int getIconIndex(const QString &key) const;
QString getDirectory() const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;

View File

@ -25,6 +25,7 @@
#include "groupview/InstanceDelegate.h"
#include "icons/IconList.h"
#include <DesktopServices.h>
IconPickerDialog::IconPickerDialog(QWidget *parent)
: QDialog(parent), ui(new Ui::IconPickerDialog)
@ -59,19 +60,21 @@ IconPickerDialog::IconPickerDialog(QWidget *parent)
contentsWidget->setModel(MMC->icons().get());
// NOTE: ResetRole forces the button to be on the left, while the OK/Cancel ones are on the right. We win.
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole);
auto buttonRemove =
ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole);
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole);
connect(buttonAdd, SIGNAL(clicked(bool)), SLOT(addNewIcon()));
connect(buttonRemove, SIGNAL(clicked(bool)), SLOT(removeSelectedIcon()));
connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)));
connect(contentsWidget->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
SLOT(selectionChanged(QItemSelection, QItemSelection)));
connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(selectionChanged(QItemSelection, QItemSelection)));
auto buttonFolder = ui->buttonBox->addButton(tr("Open Folder"), QDialogButtonBox::ResetRole);
connect(buttonFolder, &QPushButton::clicked, this, &IconPickerDialog::openFolder);
}
bool IconPickerDialog::eventFilter(QObject *obj, QEvent *evt)
{
if (obj != ui->iconView)
@ -152,3 +155,8 @@ IconPickerDialog::~IconPickerDialog()
{
delete ui;
}
void IconPickerDialog::openFolder()
{
DesktopServices::openDirectory(MMC->icons()->getDirectory(), true);
}

View File

@ -45,4 +45,5 @@ slots:
void delayed_scroll(QModelIndex);
void addNewIcon();
void removeSelectedIcon();
void openFolder();
};