@@ -676,6 +676,44 @@ QString FileHander::toLegalFile(const QString &filePath)
676676 return result;
677677}
678678
679+ bool FileHander::pathControl (const QString &sPath )
680+ {
681+ static QStringList tmpDocLocation = QStandardPaths::standardLocations (QStandardPaths::DocumentsLocation);
682+ static QStringList tmpPicLocation = QStandardPaths::standardLocations (QStandardPaths::PicturesLocation);
683+
684+ QDBusMessage reply;
685+ QDBusInterface iface (" com.deepin.FileArmor1" , " /com/deepin/FileArmor1" , " com.deepin.FileArmor1" , QDBusConnection::systemBus ());
686+ if (!iface.isValid ()) {
687+ qWarning () << " Failed to connect to D-Bus interface" ;
688+ return false ;
689+ }
690+
691+ if (tmpDocLocation.size () > 0 ) {
692+ QString docPath = tmpDocLocation.first ();
693+ if (sPath .startsWith (docPath)) {
694+ reply = iface.call (" GetApps" , docPath);
695+ } else {
696+ if (tmpPicLocation.size () > 0 ) {
697+ QString picPath = tmpPicLocation.first ();
698+ if (sPath .startsWith (picPath)) {
699+ reply = iface.call (" GetApps" , picPath);
700+ }
701+ }
702+ }
703+ }
704+
705+ if (reply.type () == QDBusMessage::ReplyMessage) {
706+ QList<QString> lValue = reply.arguments ().takeFirst ().toStringList ();
707+ QString strApp = QStandardPaths::findExecutable (" deepin-draw" );
708+ // 此路径对画板进行了权限禁用
709+ if (lValue.contains (strApp)) {
710+ return true ;
711+ }
712+ }
713+
714+ return false ;
715+ }
716+
679717PageContext *FileHander::loadDdf (const QString &file)
680718{
681719 qDebug () << " Loading DDF file:" << file;
@@ -738,9 +776,14 @@ QImage FileHander::loadImage(const QString &file)
738776 if (checkFileBeforeLoad (file, false )) {
739777 auto legalPath = toLegalFile (file);
740778 QImage img = loadImage_helper (legalPath, this );
741- if (img.isNull ()) {
779+ if (pathControl (legalPath)){
780+ qWarning () << " Failed to load image: No permissions" ;
781+ d_pri ()->setError (EFileNotExist, tr (" No permissions to open it" ));
782+ return QImage ();
783+ } else if (img.isNull ()) {
742784 qWarning () << " Failed to load image, file may be damaged" ;
743785 d_pri ()->setError (EDamagedImageFile, tr (" Damaged file, unable to open it" ));
786+ return QImage ();
744787 }
745788#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
746789 // 应用颜色空间转换,解决CMYK等格式的颜色显示问题 (仅Qt6)
0 commit comments