Skip to content

Commit

Permalink
fix: the album permission control problem
Browse files Browse the repository at this point in the history
fix the album permission control problem  when import photo

Log: fix the album permission control problem  when import photo
Bug: https://pms.uniontech.com/bug-view-270731.html
  • Loading branch information
add-uos authored and deepin-bot[bot] committed Sep 24, 2024
1 parent 87e2695 commit 87af323
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
42 changes: 39 additions & 3 deletions src/album/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,16 +1332,22 @@ void MainWindow::onImprotBtnClicked()
const QStringList &file_list = dialog.selectedFiles();
if (file_list.isEmpty())
return;
QStringList filtered_list;
for (auto it : file_list) {
if (!pathControl(it)) {
filtered_list.append(it);
}
}
if (m_iCurrentView == VIEW_ALBUM) {
if (m_pAlbumview->m_currentType == ALBUM_PATHTYPE_BY_PHONE ||
m_pAlbumview->m_currentItemType == 0 ||
DBManager::instance()->getAlbumDBTypeFromUID(m_pAlbumview->m_currentUID) == AutoImport) { //外部设备、特定类型、自动导入走常规导入,不得导入进目标相册
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, "", -1, this, true);
ImageEngineApi::instance()->ImportImagesFromFileList(filtered_list, "", -1, this, true);
} else {
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, m_pAlbumview->m_currentAlbum, m_pAlbumview->m_currentUID, this, true);
ImageEngineApi::instance()->ImportImagesFromFileList(filtered_list, m_pAlbumview->m_currentAlbum, m_pAlbumview->m_currentUID, this, true);
}
} else {
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, "", -1, this, true);
ImageEngineApi::instance()->ImportImagesFromFileList(filtered_list, "", -1, this, true);
}
}

Expand Down Expand Up @@ -1763,6 +1769,36 @@ void MainWindow::adjustTitleContent()
}
}

bool MainWindow::pathControl(const QString &sPath)
{
QDBusMessage reply;
QDBusInterface iface("com.deepin.FileArmor1", "/com/deepin/FileArmor1", "com.deepin.FileArmor1", QDBusConnection::systemBus());
if (iface.isValid()) {
QStringList tmpDocLocation = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
if (tmpDocLocation.size() > 0) {
QString docPath = tmpDocLocation.first();
if (sPath.startsWith(docPath)) {
reply = iface.call("GetApps", docPath);
}
}
QStringList tmpPicLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
if (tmpPicLocation.size() > 0) {
QString picPath = tmpPicLocation.first();
if (sPath.startsWith(picPath)) {
reply = iface.call("GetApps", picPath);
}
}
}
if (reply.type() == QDBusMessage::ReplyMessage) {
QList<QString> lValue = reply.arguments().takeFirst().toStringList();
QString strApp = QStandardPaths::findExecutable("deepin-album");
if (lValue.contains(strApp)) {
return true;
}
}
return false;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
saveWindowState();
Expand Down
6 changes: 5 additions & 1 deletion src/album/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QStackedWidget>
#include <QStatusBar>
#include <QButtonGroup>
#include <QDBusInterface>

#include <DMainWindow>
#include <DTitlebar>
Expand Down Expand Up @@ -136,7 +137,10 @@ class MainWindow : public DMainWindow, public ImageEngineImportObject

// 字体改变、尺寸改变,同步调整标题栏区域控件显示大小
void adjustTitleContent();

/**
* @brief pathControl 返回输入sPath文件是否被读写权限管控
*/
bool pathControl(const QString &sPath);
protected:
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
Expand Down

0 comments on commit 87af323

Please sign in to comment.