Show "executable" screenshots in the screenshot manager
Since the readable/writable filter was removed to do this, extra code was added to enable/disable certain buttons based on whether the screenshot is readable or writable.
This commit is contained in:
parent
f7f39854f8
commit
40e0252d7d
@ -251,7 +251,7 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
|
|||||||
m_model.reset(new QFileSystemModel());
|
m_model.reset(new QFileSystemModel());
|
||||||
m_filterModel.reset(new FilterModel());
|
m_filterModel.reset(new FilterModel());
|
||||||
m_filterModel->setSourceModel(m_model.get());
|
m_filterModel->setSourceModel(m_model.get());
|
||||||
m_model->setFilter(QDir::Files | QDir::Writable | QDir::Readable);
|
m_model->setFilter(QDir::Files);
|
||||||
m_model->setReadOnly(false);
|
m_model->setReadOnly(false);
|
||||||
m_model->setNameFilters({"*.png"});
|
m_model->setNameFilters({"*.png"});
|
||||||
m_model->setNameFilterDisables(false);
|
m_model->setNameFilterDisables(false);
|
||||||
@ -343,6 +343,29 @@ void ScreenshotsPage::onItemActivated(QModelIndex index)
|
|||||||
DesktopServices::openFile(info.absoluteFilePath());
|
DesktopServices::openFile(info.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenshotsPage::onCurrentSelectionChanged(const QItemSelection &selected)
|
||||||
|
{
|
||||||
|
bool allReadable = !selected.isEmpty();
|
||||||
|
bool allWritable = !selected.isEmpty();
|
||||||
|
|
||||||
|
for (auto index : selected.indexes())
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
break;
|
||||||
|
auto info = m_model->fileInfo(index);
|
||||||
|
if (!info.isReadable())
|
||||||
|
allReadable = false;
|
||||||
|
if (!info.isWritable())
|
||||||
|
allWritable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->actionUpload->setEnabled(allReadable);
|
||||||
|
ui->actionCopy_Image->setEnabled(allReadable);
|
||||||
|
ui->actionCopy_File_s->setEnabled(allReadable);
|
||||||
|
ui->actionDelete->setEnabled(allWritable);
|
||||||
|
ui->actionRename->setEnabled(allWritable);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenshotsPage::on_actionView_Folder_triggered()
|
void ScreenshotsPage::on_actionView_Folder_triggered()
|
||||||
{
|
{
|
||||||
DesktopServices::openDirectory(m_folder, true);
|
DesktopServices::openDirectory(m_folder, true);
|
||||||
@ -503,6 +526,8 @@ void ScreenshotsPage::openedImpl()
|
|||||||
if(idx.isValid())
|
if(idx.isValid())
|
||||||
{
|
{
|
||||||
ui->listView->setModel(m_filterModel.get());
|
ui->listView->setModel(m_filterModel.get());
|
||||||
|
connect(ui->listView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ScreenshotsPage::onCurrentSelectionChanged);
|
||||||
|
onCurrentSelectionChanged(ui->listView->selectionModel()->selection()); // set initial button enable states
|
||||||
ui->listView->setRootIndex(m_filterModel->mapFromSource(idx));
|
ui->listView->setRootIndex(m_filterModel->mapFromSource(idx));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -100,6 +100,7 @@ private slots:
|
|||||||
void on_actionRename_triggered();
|
void on_actionRename_triggered();
|
||||||
void on_actionView_Folder_triggered();
|
void on_actionView_Folder_triggered();
|
||||||
void onItemActivated(QModelIndex);
|
void onItemActivated(QModelIndex);
|
||||||
|
void onCurrentSelectionChanged(const QItemSelection &selected);
|
||||||
void ShowContextMenu(const QPoint &pos);
|
void ShowContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user