Skip to content

Commit

Permalink
格式化工具支持更多格式;支持格式化本地磁盘
Browse files Browse the repository at this point in the history
  • Loading branch information
gfdgd-xi committed Nov 10, 2024
1 parent 51e2ff3 commit 9351407
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 30 deletions.
2 changes: 1 addition & 1 deletion dde-file-manager-lib/deviceinfo/udiskdeviceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ QVector<MenuAction> UDiskDeviceInfo::menuActionList(DAbstractFileInfo::MenuType
actionKeys << MenuAction::Mount;
}

if (getMediaType() == removable) {
if (getMediaType() == removable || getMediaType() == native) {
actionKeys << MenuAction::FormatDevice;
}

Expand Down
6 changes: 5 additions & 1 deletion dde-file-manager-lib/views/dfmsidebardeviceitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ QMenu *DFMSideBarDeviceItem::createStandardContextMenu() const
menu->addAction(QObject::tr("Unmount"), this, SLOT(doUnmountOrEject()));
}

if (info.value("mediaType", 0).toInt() == UDiskDeviceInfo::MediaType::removable && !info.value("optical", false).toBool()) {
// 只允许分区和可移动设备格式化
if ((info.value("mediaType", 0).toInt() == UDiskDeviceInfo::MediaType::native
|| info.value("mediaType", 0).toInt() == UDiskDeviceInfo::MediaType::removable
) &&
!info.value("optical", false).toBool()) {
menu->addAction(QObject::tr("Format"), [this, info, deviceIdUrl]() {
AppController::instance()->actionFormatDevice(dMakeEventPointer<DFMUrlBaseEvent>(this, deviceIdUrl));
});
Expand Down
9 changes: 5 additions & 4 deletions usb-device-formatter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ int main(int argc, char *argv[])
a.installTranslator(translator);

a.setTheme("light");
a.setOrganizationName("deepin");
a.setApplicationName("Deepin usb device formatter");
a.setOrganizationName("GXDE");
a.setApplicationName("GXDE device formatter");
a.setApplicationVersion("1.0");
a.setWindowIcon(QIcon(":/app/usb-device-formatter.png"));
a.setQuitOnLastWindowClosed(true);
Expand All @@ -112,14 +112,15 @@ int main(int argc, char *argv[])
return 0;
}

// 解除只允许格式化可移动设备的限制
//Check if is a removable device
PartMan::Partition p = PartMan::Partition::getPartitionByDevicePath(path);
/*PartMan::Partition p = PartMan::Partition::getPartitionByDevicePath(path);
if(!p.getIsRemovable()){
QString message = QObject::tr("Cannot format local device");
MessageDialog d(message, 0);
d.exec();
return 0;
}
}*/

MainWindow* w = new MainWindow(path);
w->show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<vendor>LinuxDeepin</vendor>
<vendor_url>https://www.deepin.com/</vendor_url>
<vendor_url>https://www.gxde.org/</vendor_url>
<action id="com.deepin.pkexec.usb-device-formatter">
<message>Authentication is required to run the USB Device Formatter</message>
<message>Authentication is required to run the Device Formatter</message>
<icon_name>usb-device-formatter</icon_name>
<defaults>
<allow_any>no</allow_any>
Expand All @@ -14,24 +14,24 @@
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/usb-device-formatter</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
<message xml:lang="ast">Ríquese l'autenticación pa executar el formatiador de preseos USB</message>
<message xml:lang="ca">Cal autenticació per executar el Formatador de dispositius USB</message>
<message xml:lang="cs">Pro běh formátovače zařízení USB je požadováno ověření</message>
<message xml:lang="de">Um USB Speicher zu formatieren ist eine Authentifizierung erforderlich.</message>
<message xml:lang="en_AU">Authentication-required to run the "USB Device formatter"</message>
<message xml:lang="fr">L'authentification est obligatoire pour exécuter le formatage du périphérique USB</message>
<message xml:lang="ast">Ríquese l'autenticación pa executar el formatiador de preseos</message>
<message xml:lang="ca">Cal autenticació per executar el Formatador de dispositius</message>
<message xml:lang="cs">Pro běh formátovače zařízení je požadováno ověření</message>
<message xml:lang="de">Um Speicher zu formatieren ist eine Authentifizierung erforderlich.</message>
<message xml:lang="en_AU">Authentication-required to run the "Device formatter"</message>
<message xml:lang="fr">L'authentification est obligatoire pour exécuter le formatage du périphérique</message>
<message xml:lang="hu">A művelethez hitelesítés szükséges.</message>
<message xml:lang="it">Autenticazione richiesta per eseguire la formattazione del dispositivo</message>
<message xml:lang="ja">USBデバイスフォーマッターを実行するには認証が必要です</message>
<message xml:lang="lt">Norint paleisti USB įrenginio formatavimo programą, reikalingas tapatybės nustatymas</message>
<message xml:lang="nl">Authenticatie vereist om USB-apparaatformattering uit te voeren</message>
<message xml:lang="pt">A autenticação é necessária para executar o Formatador de dispositivo USB</message>
<message xml:lang="pt_BR">A autenticação é necessária para executar a Formatação do Dispositivo USB</message>
<message xml:lang="ru">Требуется аутентификация для запуска форматирования устройства USB</message>
<message xml:lang="ja">デバイスフォーマッターを実行するには認証が必要です</message>
<message xml:lang="lt">Norint paleisti įrenginio formatavimo programą, reikalingas tapatybės nustatymas</message>
<message xml:lang="nl">Authenticatie vereist om apparaatformattering uit te voeren</message>
<message xml:lang="pt">A autenticação é necessária para executar o Formatador de dispositivo</message>
<message xml:lang="pt_BR">A autenticação é necessária para executar a Formatação do Dispositivo</message>
<message xml:lang="ru">Требуется аутентификация для запуска форматирования устройства</message>
<message xml:lang="sr">Аутентификација је неопходна за покретање форматирања УСБ уређаја</message>
<message xml:lang="tr">USB Aygıt Biçimlendirici çalışması için kimlik doğrulaması gerekli</message>
<message xml:lang="uk">Щоб мати змогу запускати засіб форматування пристроїв USB, слід пройти розпізнавання</message>
<message xml:lang="zh_CN">运行USB格式化工具需要认证</message>
<message xml:lang="zh_TW">執行 USB 裝置格式化工具需要身份驗證</message>
<message xml:lang="tr">Aygıt Biçimlendirici çalışması için kimlik doğrulaması gerekli</message>
<message xml:lang="uk">Щоб мати змогу запускати засіб форматування пристроїв, слід пройти розпізнавання</message>
<message xml:lang="zh_CN">运行格式化工具需要认证</message>
<message xml:lang="zh_TW">執行裝置格式化工具需要身份驗證</message>
</action>
</policyconfig>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>LinuxDeepin</vendor>
<vendor_url>https://www.deepin.com/</vendor_url>
<vendor_url>https://www.gxde.org/</vendor_url>
<action id="com.deepin.pkexec.usb-device-formatter">
<message>Authentication is required to run the USB Device Formatter</message>
<message xml:lang="zh_CN">运行 U 盘格式化工具需要输入密码</message>
<message>Authentication is required to run the Device Formatter</message>
<message xml:lang="zh_CN">运行格式化工具需要输入密码</message>
<icon_name>usb-device-formatter</icon_name>
<defaults>
<allow_any>no</allow_any>
Expand Down
4 changes: 2 additions & 2 deletions usb-device-formatter/view/mainpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void MainPage::initUI()
QLabel* labelText = new QLabel(tr("Label"),this);
labelText->setObjectName("TagLabel");
m_labelLineEdit = new QLineEdit(this);
m_labelLineEdit->setText(m_typeCombo->currentText());
m_labelLineEdit->setText("GXDE-" + m_typeCombo->currentText());
m_labelLineEdit->setFixedSize(160, 22);

QCheckBox* fastFormatCheckBox = new QCheckBox(this);
Expand Down Expand Up @@ -178,7 +178,7 @@ QString MainPage::getLabel()

void MainPage::onCurrentSelectedTypeChanged(const QString &type)
{
m_labelLineEdit->setText(type);
m_labelLineEdit->setText("GXDE-" + type);
m_maxLabelNameLength = PartMan::PartitionManager::getMaxNameLengthByTypeString(type);
m_labelLineEdit->setMaxLength(m_maxLabelNameLength);
}
Expand Down
15 changes: 14 additions & 1 deletion usb-device-formatter/view/mainpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@ class MainPage : public QWidget
Fat32,
Ntfs,
Exfat,
Btrfs,
Efi,
Ext2,
Ext3,
Ext4,
Xfs
F2fs,
Hfs,
Hfsplus,
Jfs,
Linuxswap,
Lvm2pv,
Nilfs2,
Reiser4,
Reiserfs,
Xfs,
};
Q_ENUM(FsType)

Expand Down

0 comments on commit 9351407

Please sign in to comment.