fix bug 163182 【文件管理器】U盘和光盘的格式化窗口可以多开

This commit is contained in:
zhouxiaofeng 2023-07-14 07:56:34 +00:00 committed by Yue-Lan
parent 8df6f0f8b5
commit 5a6380fd96
11 changed files with 172 additions and 4 deletions

View File

@ -60,6 +60,7 @@
#include "file-operation-error-dialog.h"
#include "file-enumerator.h"
#include "gerror-wrapper.h"
#include "format-dlg-create-delegate.h"
#include "global-settings.h"
#include "sound-effect.h"
@ -1089,6 +1090,8 @@ const QList<QAction *> DirectoryViewMenu::constructComputerActions()
// FIXME:// refactory Format_Dialog
Format_Dialog* fd = new Format_Dialog(info->uri(), nullptr, m_view);
fd->show();
// Format_Dialog *fd = format_dlg_create_delegate::getInstance()->createDlg(info->uri(), nullptr);
// fd->show();
});
l.last()->setObjectName(FORMAT_ACTION);

View File

@ -36,6 +36,7 @@
#include <QAction>
#include <QModelIndex>
#include "format_dialog.h"
#include "format-dlg-create-delegate.h"
#ifndef KY_UDF_BURN
#include "disccontrol.h"
@ -214,7 +215,7 @@ const QList<QAction *> SideBarMenu::constructFileSystemItemActions()
if(discControl->work()){
connect(discControl, &DiscControl::workFinished, [=](DiscControl *discCtrl){
connect(action, &QAction::triggered, [=](){
UdfFormatDialog *udfFormatDlg = new UdfFormatDialog(uri, discCtrl);
UdfFormatDialog *udfFormatDlg = FormatDlgCreateDelegate::getInstance()->createUdfDlg(uri, discCtrl);
udfFormatDlg->show();
});
qDebug()<<unixDevice<<" supported Udf values are:"<<discCtrl->supportUdf();
@ -228,7 +229,7 @@ const QList<QAction *> SideBarMenu::constructFileSystemItemActions()
if(discControl->work()){
connect(discControl, &UdfBurn::DiscControl::workFinished, [=](UdfBurn::DiscControl *discCtrl){
connect(action, &QAction::triggered, [=](){
UdfBurn::UdfFormatDialog *udfFormatDlg = new UdfFormatDialog(uri, discCtrl);
UdfBurn::UdfFormatDialogWrapper *udfFormatDlg = FormatDlgCreateDelegate::getInstance()->createUdfDlgWrapper(uri, discCtrl);
udfFormatDlg->show();
});
qDebug()<<unixDevice<<" supported Udf values are:"<<discCtrl->supportUdf();
@ -244,7 +245,7 @@ const QList<QAction *> SideBarMenu::constructFileSystemItemActions()
FileInfoJob job (uri, this);
job.querySync ();
}
Format_Dialog *fd = new Format_Dialog(uri, m_item);
Format_Dialog *fd = FormatDlgCreateDelegate::getInstance()->createUDiskDlg(uri, m_item);
fd->show();
});
}

View File

@ -81,7 +81,7 @@ unix {
# fixme:// format_dialog.h
header.path = /usr/include/peony-qt
header.files += *.h model/*.h file-operation/*.h vfs/*.h controls/ ../plugin-iface/*.h convenient-utils/*.h convenient-utils/disc/*.h windows/format_dialog.h windows/FMWindowIface.h \
libpeony-qt/usershare-manager.h windows/udfFormatDialog.h windows/udfAppendBurnDataDialog.h
libpeony-qt/usershare-manager.h windows/udfFormatDialog.h windows/udfAppendBurnDataDialog.h windows/format-dlg-create-delegate.h
# header.depends = header2
header.files += development-files/header-files/*
INSTALLS += header

View File

@ -1885,9 +1885,16 @@ UdfBurn::UdfFormatDialogWrapper::~UdfFormatDialogWrapper()
delete m_dialog;
}
void UdfBurn::UdfFormatDialogWrapper::raise()
{
m_dialog->raise();
}
void UdfBurn::UdfFormatDialogWrapper::show()
{
m_dialog->show();
}
#endif

View File

@ -292,6 +292,7 @@ public:
explicit UdfFormatDialogWrapper(const QString &uri, DiscControl *discControl, QWidget *parent = nullptr);
~UdfFormatDialogWrapper();
void raise();
void show();
private:

View File

@ -0,0 +1,85 @@
#include "format-dlg-create-delegate.h"
#include "format_dialog.h"
#ifdef KY_UDF_BURN
#include "ky-udf-format-dialog.h"
#include "volumeManager.h"
#include <libkyudfburn/disccontrol.h>
#else
#include "udfFormatDialog.h"
#include "disccontrol.h"
#endif
static FormatDlgCreateDelegate *global_instance = nullptr;
FormatDlgCreateDelegate *FormatDlgCreateDelegate::getInstance()
{
if (!global_instance) {
global_instance = new FormatDlgCreateDelegate;
}
return global_instance;
}
Format_Dialog *FormatDlgCreateDelegate::createUDiskDlg(const QString &uris, SideBarAbstractItem *item, QWidget *parent)
{
if (m_udiskDlgMap.contains(uris)) {
m_udiskDlgMap[uris]->raise();
return m_udiskDlgMap[uris];
}
Format_Dialog *dlg = new Format_Dialog(uris, item);
m_udiskDlgMap[uris] = dlg;
return dlg;
}
void FormatDlgCreateDelegate::removeFromUdiskMap(QString &uris)
{
m_udiskDlgMap.remove(uris);
}
#ifndef KY_UDF_BURN
UdfFormatDialog *FormatDlgCreateDelegate::createUdfDlg(const QString &uris, DiscControl *discControl, QWidget *parent)
{
if (m_udfDlgMap.contains(uris)) {
m_udfDlgMap[uris]->raise();
return m_udfDlgMap[uris];
}
UdfFormatDialog *dlg = new UdfFormatDialog(uris, discControl);
m_udfDlgMap[uris] = dlg;
return dlg;
}
void FormatDlgCreateDelegate::removeFromUdfMap(QString &uris)
{
m_udfDlgMap.remove(uris);
}
#else
UdfBurn::UdfFormatDialogWrapper *FormatDlgCreateDelegate::createUdfDlgWrapper(const QString &uris, UdfBurn::DiscControl *discControl, QWidget *parent)
{
if (m_udfDlgWrapperMap.contains(uris)) {
m_udfDlgWrapperMap[uris]->raise();
return m_udfDlgWrapperMap[uris];
}
UdfBurn::UdfFormatDialogWrapper *wrapper = new UdfBurn::UdfFormatDialogWrapper(uris, discControl);
m_udfDlgWrapperMap[uris] = wrapper;
return wrapper;
}
void FormatDlgCreateDelegate::removeFromUdfWrapperMap(QString &uris)
{
m_udfDlgWrapperMap.remove(uris);
}
#endif
FormatDlgCreateDelegate::FormatDlgCreateDelegate(QObject *parent)
{
}
FormatDlgCreateDelegate::~FormatDlgCreateDelegate()
{
}

View File

@ -0,0 +1,52 @@
#ifndef FORMAT_DLG_CREATE_DELEGATE_H
#define FORMAT_DLG_CREATE_DELEGATE_H
#include <QObject>
#include <QMap>
#include <QDialog>
#include "peony-core_global.h"
class Format_Dialog;
namespace Peony {
class SideBarAbstractItem;
}
#ifdef KY_UDF_BURN
namespace UdfBurn {
class UdfFormatDialog;
class DiscControl;
class UdfFormatDialogWrapper;
}
#else
class UdfFormatDialog;
class DiscControl;
#endif
class PEONYCORESHARED_EXPORT FormatDlgCreateDelegate : public QObject
{
Q_OBJECT
public:
static FormatDlgCreateDelegate *getInstance();
Format_Dialog *createUDiskDlg(const QString &uris, Peony::SideBarAbstractItem *item, QWidget *parent = nullptr);
void removeFromUdiskMap(QString &uris);
#ifndef KY_UDF_BURN
UdfFormatDialog *createUdfDlg(const QString &uris, DiscControl *discControl, QWidget *parent = nullptr);
void removeFromUdfMap(QString &uris);
#else
UdfBurn::UdfFormatDialogWrapper *createUdfDlgWrapper(const QString &uris, UdfBurn::DiscControl *discControl, QWidget *parent = nullptr);
void removeFromUdfWrapperMap(QString &uris);
#endif
private:
explicit FormatDlgCreateDelegate(QObject *parent = nullptr);
~FormatDlgCreateDelegate();
private:
QMap<QString, Format_Dialog *> m_udiskDlgMap;
#ifndef KY_UDF_BURN
QMap<QString, UdfFormatDialog *> m_udfDlgMap;
#else
QMap<QString, UdfBurn::UdfFormatDialogWrapper *> m_udfDlgWrapperMap;
#endif
};
#endif // FORMAT_DLG_CREATE_DELEGATE_H

View File

@ -31,10 +31,14 @@
#include "file-info.h"
#include "file-info-job.h"
#include "global-settings.h"
#include "format-dlg-create-delegate.h"
#ifdef KY_SDK_SOUND_EFFECTS
#include "ksoundeffects.h"
#endif
#include "format-dlg-create-delegate.h"
#include <QObject>
#include <QMessageBox>
#include <KWindowSystem>
@ -1278,6 +1282,7 @@ void Format_Dialog::kdisk_format(const gchar * device_name,const gchar *format_t
Format_Dialog::~Format_Dialog()
{
FormatDlgCreateDelegate::getInstance()->removeFromUdiskMap(this->fm_uris);
g_signal_handlers_disconnect_by_data(mVolumeMonitor, this);
// delete ui;
if (mTimer) mTimer->deleteLater();
@ -1318,6 +1323,8 @@ void Format_Dialog::closeEvent(QCloseEvent *e)
e->ignore();
return;
}
FormatDlgCreateDelegate::getInstance()->removeFromUdiskMap(this->fm_uris);
}
void Format_Dialog::resizeEvent(QResizeEvent *event)

View File

@ -24,6 +24,7 @@
#ifdef KY_UDF_BURN
#include "ky-udf-format-dialog.h"
#include "format-dlg-create-delegate.h"
#include <QMessageBox>
#include <QThread>
#include <QDebug>
@ -106,6 +107,7 @@ UdfFormatDialog::UdfFormatDialog(const QString &uri, DiscControl *discControl, Q
UdfFormatDialog::~UdfFormatDialog()
{
FormatDlgCreateDelegate::getInstance()->removeFromUdfWrapperMap(this->m_uri);
if(m_discControl){
m_discControl->deleteLater();
m_discControl = nullptr;
@ -205,6 +207,7 @@ void UdfFormatDialog::closeEvent(QCloseEvent *e)
e->ignore();
return;
}
FormatDlgCreateDelegate::getInstance()->removeFromUdfWrapperMap(this->m_uri);
}
bool UdfFormatDialog::udfFormatEnsureMsgBox()

View File

@ -22,6 +22,7 @@
#include "udfFormatDialog.h"
#include "disccontrol.h"
#include "format-dlg-create-delegate.h"
#include <QMessageBox>
#include <QThread>
#include <QDebug>
@ -100,6 +101,9 @@ UdfFormatDialog::UdfFormatDialog(const QString &uri, DiscControl *discControl, Q
UdfFormatDialog::~UdfFormatDialog()
{
#ifndef KY_UDF_BURN
FormatDlgCreateDelegate::getInstance()->removeFromUdfMap(this->m_uri);
#endif
if(m_discControl){
m_discControl->deleteLater();
m_discControl = nullptr;
@ -202,6 +206,9 @@ void UdfFormatDialog::closeEvent(QCloseEvent *e)
e->ignore();
return;
}
#ifndef KY_UDF_BURN
FormatDlgCreateDelegate::getInstance()->removeFromUdfMap(this->m_uri);
#endif
}
bool UdfFormatDialog::udfFormatEnsureMsgBox()

View File

@ -4,6 +4,7 @@ HEADERS += \
$$PWD/FMWindowIface.h \
$$PWD/fm-window-factory.h \
$$PWD/fm-window.h \
$$PWD/format-dlg-create-delegate.h \
$$PWD/format_dialog.h \
$$PWD/ky-udf-format-dialog.h \
$$PWD/properties-window.h \
@ -13,6 +14,7 @@ HEADERS += \
SOURCES += \
$$PWD/fm-window-factory.cpp \
$$PWD/fm-window.cpp \
$$PWD/format-dlg-create-delegate.cpp \
$$PWD/format_dialog.cpp \
$$PWD/ky-udf-format-dialog.cpp \
$$PWD/properties-window.cpp \