同步主线0.19版本

This commit is contained in:
tiantian 2023-06-08 18:09:02 +08:00
parent 8e6e2e5232
commit c5696dbe5d
13 changed files with 223 additions and 138 deletions

View File

@ -37,7 +37,7 @@ typedef enum {downPosition = 0,upPosition,leftPosition,rightPosition}Suit;
#define FLASHDISKITEM_CONTENT_HEIGHT 45
#define FLASHDISKITEM_HEIGHT 112
#define FLASHDISKITEM_SPACE_HEIGHT 7
#define FLASHDISKITEM_SHOWDISK_MAX 10
#define FLASHDISKITEM_SHOWDISK_MAX 8
#define NEWINFO_DELAYSHOW_TIME 1500

View File

@ -199,6 +199,7 @@ QString transcodeForGbkCode(QByteArray gbkName, QString &volumeName)
return name;
}
//判断是否是当前用户的挂载
bool ifLocalUsrDev(QString mountUri)
{
QString usrName = qgetenv("USER");

View File

@ -135,6 +135,9 @@ bool baseWidget::eventFilter(QObject *watched, QEvent *event)
{
if(event->type() == QEvent::Enter) {
qDebug()<<"鼠标进入";
if(m_hideTimer->isActive()) {
m_hideTimer->stop();
}
return false;
} else if (event->type() == QEvent::WindowDeactivate) {
@ -142,6 +145,9 @@ bool baseWidget::eventFilter(QObject *watched, QEvent *event)
qDebug()<<"激活外部窗口";
this->hide();
return false;
} else if (event->type() == QEvent::Leave) {
if(m_hideTimer->isActive())
m_hideTimer->start(2000);
}
}

View File

@ -68,7 +68,6 @@ FDClickWidget::FDClickWidget(FDFrame *parent,
initFontSize();
initThemeMode();
m_hideTime = new QTimer(this);
QHBoxLayout *drivename_H_BoxLayout = new QHBoxLayout();
if (m_uDiskNo <= 1) {
image_show_label = new QLabel(this);
@ -215,7 +214,7 @@ FDClickWidget::FDClickWidget(FDFrame *parent,
//this->setStyleSheet("border:1px solid red;");//for test
connect(this, &FDClickWidget::themeFontChange, this, &FDClickWidget::onThemeFontChange);
connect(m_hideTime, SIGNAL(timeout()), this,SLOT(on_hideinterface()));
//connect(m_hideTime, SIGNAL(timeout()), this,SLOT(on_hideinterface()));
//弹出按钮滑动效果
connect(this, &FDClickWidget::hoverEjectBotton, m_frame, &FDFrame::on_updateSize);
connect(this, &FDClickWidget::leaveEjectBotton, m_frame, &FDFrame::on_cursorLeave);

View File

@ -92,7 +92,6 @@ private:
QLabel *m_driveName_label;
ClickLabel *m_nameDis1_label;
QLabel *m_capacityDis1_label;
QTimer *m_hideTime;
QWidget *disWidgetNumOne;
QVBoxLayout *main_V_BoxLayout = nullptr;
bool m_mousePressFlag = false;

View File

@ -35,6 +35,7 @@
#include "config/xatom-helper.h"
#include "fdframe.h"
#include "UnionVariable.h"
#define THEME_UKFD_TRANS "org.ukui.control-center.personalise"
#define IN_THEME_BLACKLIST 0
@ -62,7 +63,8 @@ FDFrame::FDFrame(QWidget* parent) : QFrame(parent)
m_animLabel->show();
m_ejectLabel = new QLabel(this);
m_ejectLabel->setText(tr("eject"));
QString DriveName = getElidedText(m_ejectLabel->font(), tr("eject"), 47);
m_ejectLabel->setText(DriveName);
m_ejectLabel->setStyleSheet("QLabel{color: palette(Text);}");
m_ejectLabel->setParent(this);
m_ejectLabel->move(328,35);
@ -79,8 +81,8 @@ FDFrame::FDFrame(QWidget* parent) : QFrame(parent)
m_ejectIcon->setFixedSize(16,16);
m_ejectIcon->show();
m_hideFrameTime = new QTimer(this);
connect(m_hideFrameTime, SIGNAL(timeout()), this,SLOT(on_hideframe()));
// m_hideFrameTime = new QTimer(this);
// connect(m_hideFrameTime, SIGNAL(timeout()), this,SLOT(on_hideframe()));
KWindowEffects::enableBlurBehind(winId(), true);
kdk::UkuiStyleHelper::self()->removeHeader(this);
}
@ -131,7 +133,7 @@ int FDFrame::readlabeltWidth()
void FDFrame::setlabeltWidth(int width)
{
this->m_animLabel->setFixedWidth(width);
m_ejectIcon->move(width+23,47);
m_ejectIcon->move(width+23,m_mainWindowHigh/2-11);
if(width == 288)
{
m_ejectIcon->setStyleSheet("QLabel{color: palette(Text);}");
@ -245,9 +247,9 @@ bool FDFrame::eventFilter(QObject *obj, QEvent *event)
repaint();
if (m_hideFrameTime->isActive()) {
m_hideFrameTime->stop();
}
// if (m_hideFrameTime->isActive()) {
// m_hideFrameTime->stop();
// }
return true;
}
return false;
@ -283,9 +285,18 @@ void FDFrame::showNoIcon(){
this->show();
}
void FDFrame::on_hideframe()
void FDFrame::setEjectOnCentra(int height)
{
//m_hideFrameTime->stop();
//this->hide();
m_ejectIcon->move(343,height/2-11);
m_ejectLabel->move(328,height/2-22); //减去字体高度
}
//void FDFrame::on_hideframe()
//{
// //m_hideFrameTime->stop();
// //this->hide();
//}

View File

@ -42,6 +42,7 @@ public:
void initOpacityGSettings();
void showNoIcon();
void setEjectOnCentra(int height);
protected:
@ -71,7 +72,7 @@ private:
public Q_SLOTS:
void on_updateSize();
void on_cursorLeave();
void on_hideframe();
//void on_hideframe();
};
#endif

View File

@ -101,6 +101,7 @@ int FlashDiskData::addVolumeInfoWithDrive(FDDriveInfo driveInfo, FDVolumeInfo vo
}
map<string, FDDriveInfo>::iterator itDriveInfo = m_devInfoWithDrive.find(driveInfo.strId);
if (itDriveInfo != m_devInfoWithDrive.end()) {
itDriveInfo->second.lluVolSum = driveInfo.lluVolSum;
itDriveInfo->second.listVolumes[volumeInfo.strId] = volumeInfo;
} else {
driveInfo.listVolumes.clear();
@ -193,10 +194,13 @@ int FlashDiskData::removeDriveInfo(FDDriveInfo driveInfo)
if (m_devInfoWithDrive.find(driveInfo.strId) != m_devInfoWithDrive.end()) {
map<string, FDDriveInfo>::iterator itDriveInfo = m_devInfoWithDrive.find(driveInfo.strId);
map<string, FDVolumeInfo>::iterator itVolumeInfo = itDriveInfo->second.listVolumes.begin();
qInfo()<<"m_devInfoWithVolume.size()"<<m_devInfoWithVolume.size()<<"m_devInfoWithDrive.size:"<<m_devInfoWithDrive.size()<<QString::fromStdString(itVolumeInfo->second.mountInfo.strId);
QString mountId = QString::fromStdString(itVolumeInfo->second.mountInfo.strId);
if(!mountId.isEmpty()){
emitRemoveNotify(mountId,QString::fromStdString(driveInfo.strId));
if(!itDriveInfo->second.listVolumes.empty() && !itVolumeInfo->second.mountInfo.lluTotalSize == 0 && !g_str_has_prefix (driveInfo.strId.c_str(), "/dev/sr")){
string mountId = itVolumeInfo->second.mountInfo.strId;
emitRemoveNotify(QString::fromStdString(mountId),QString::fromStdString(driveInfo.strId));
}
if((g_str_has_prefix (driveInfo.strId.c_str(), "/dev/sr"))){
Q_EMIT notifyDeviceRemoved(QString::fromStdString(driveInfo.strId));
}
// if(((itDriveInfo->second.islocalUsr == true)||(g_str_has_prefix (driveInfo.strId.c_str(), "/dev/sr")))&&(getAttachedVolumeCount(driveInfo.strId) > 0)){
// //Q_EMIT notifyDeviceRemoved(QString::fromStdString(driveInfo.strId));
@ -210,6 +214,7 @@ int FlashDiskData::removeDriveInfo(FDDriveInfo driveInfo)
int FlashDiskData::removeVolumeInfo(FDVolumeInfo volumeInfo)
{
if (volumeInfo.strId.empty()) {
return -1;
}
@ -262,6 +267,9 @@ int FlashDiskData::removeMountInfo(FDMountInfo mountInfo)
// if (ifLocalUsrDev(QString::fromStdString(mountInfo.strId.c_str()))&&getAttachedVolumeCount(itVolumeInfo->second.strId) == 1) {
// //Q_EMIT notifyDeviceRemoved(QString::fromStdString(itVolumeInfo->second.strId));
// }
Q_EMIT notifyDeviceRemoved(QString::fromStdString(itVolumeInfo->second.strId));
if((g_str_has_prefix (itVolumeInfo->second.strId.c_str(), "/dev/sr")))
emitRemoveNotify(QString::fromStdString(mountInfo.strId),QString::fromStdString(itVolumeInfo->second.strId));
//m_devInfoWithVolume.erase(itVolumeInfo);
itVolumeInfo->second.mountInfo.strId = "";
#endif
@ -284,11 +292,13 @@ int FlashDiskData::removeMountInfo(FDMountInfo mountInfo)
// qInfo()<<"非本用户啊";
// itDriveInfo->second.islocalUsr = false;
// }
// qInfo()<<"iflocal:"<<ifLocalUsrDev(QString::fromStdString(mountInfo.strId.c_str()))<<getAttachedVolumeCount(itVolumeInfo->second.strId);
qInfo()<<"mountInfo.strId:"<<mountInfo.strId.c_str();
if(g_str_has_prefix (mountInfo.strId.c_str(), "burn:///"))
Q_EMIT notifyDeviceRemoved(QString::fromStdString(itVolumeInfo->second.strId));
// if (ifLocalUsrDev(QString::fromStdString(mountInfo.strId.c_str()))&&getAttachedVolumeCount(itVolumeInfo->second.strId) == 1) {
// //Q_EMIT notifyDeviceRemoved(QString::fromStdString(itVolumeInfo->second.strId));
// Q_EMIT notifyDeviceRemoved(QString::fromStdString(itVolumeInfo->second.strId));
// }
// //itDriveInfo->second.listVolumes.erase(itVolumeInfo);
// itDriveInfo->second.listVolumes.erase(itVolumeInfo);
itVolumeInfo->second.mountInfo.strId = "";
#endif
return 0;
@ -302,19 +312,20 @@ int FlashDiskData::removeMountInfo(FDMountInfo mountInfo)
void FlashDiskData::emitRemoveNotify(QString strmountId, QString strVolumeId)
{
string strStdVolId = strVolumeId.toStdString();
qInfo()<<"mountid "<<strmountId;
if(strmountId.isEmpty()){
qInfo()<<"mounid is null";
return;
}
qInfo()<<"mountid "<<strmountId<<"volume is"<<strVolumeId;
if(g_str_has_prefix (strmountId.toLatin1().data(), "burn:///")){
Q_EMIT notifyDeviceRemoved(strVolumeId);
return;
}
if(strmountId != " "){
qInfo()<<"iflocal:"<<strVolumeId<<ifLocalUsrDev(strmountId)<<getAttachedVolumeCount(strStdVolId);
if (ifLocalUsrDev(strmountId)) {
Q_EMIT notifyDeviceRemoved(strVolumeId);
}
}else{
qInfo()<<"strmountId is null";
qInfo()<<"iflocal:"<<strVolumeId<<ifLocalUsrDev(strmountId)<<getAttachedVolumeCount(strStdVolId);
if (ifLocalUsrDev(strmountId)) {
Q_EMIT notifyDeviceRemoved(strVolumeId);
}
@ -561,6 +572,11 @@ void FlashDiskData::setClickToEject()
m_clickToEject = true;
}
bool FlashDiskData::getIfClickToEject()
{
return m_clickToEject;
}
void FlashDiskData::OutputInfos()
{
#if 0

View File

@ -69,6 +69,7 @@ typedef struct FDDriveInfo_s {
bool isCanStart = false;
bool isCanStop = false;
bool islocalUsr = true;
quint64 lluVolSum = 0;
map<string, FDVolumeInfo> listVolumes;
string strIconPath = "";
}FDDriveInfo;
@ -93,24 +94,24 @@ public:
void emitRemoveNotify(QString strMountId,QString strVolumeId);
unsigned getValidInfoCount();
void clearAllData();
void setClickToEject();
void setClickToEject();
bool getIfClickToEject();
bool isMountInfoExist(FDMountInfo mountInfo);
void resetAllNewState();
quint64 getMountTickDiff(FDMountInfo mountInfo);
bool getVolumeInfoByMount(FDMountInfo mountInfo, FDVolumeInfo& volumeInfo);
unsigned getAttachedVolumeCount(string strId);
QString getVolumeIcon(QString strVolumeId);
void OutputInfos();
bool m_clickToEject = false;
Q_SIGNALS:
void notifyDeviceRemoved(QString strDevId);
private:
FlashDiskData();
bool m_clickToEject = false;
static FlashDiskData *m_instance;
static QMutex m_mutex;

View File

@ -309,7 +309,7 @@ void interactiveDialog::paintEvent(QPaintEvent *event)
// path.addRoundedRect(rect, 12, 12);
// path.drawRoundedRect
// QRegion region(path.toFillPolygon().toPolygon());
//// this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
// this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
// QWidget::paintEvent(event);
// QStyleOption opt;

View File

@ -88,12 +88,14 @@ MainWindow::~MainWindow()
delete ifsettings;
ifsettings = nullptr;
}
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (centralWidgetList[i] ) {
delete centralWidgetList[i];
centralWidgetList[i] = nullptr;
}
}
QMap<QString, FDFrame *>().swap(centralWidgetList);
// for(int i = 0;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
// if (centralWidgetList[i] ) {
// delete centralWidgetList[i];
// centralWidgetList[i] = nullptr;
// }
// }
}
void MainWindow::initFlashDisk()
@ -158,6 +160,9 @@ void MainWindow::onRequestSendDesktopNotify(QString message, QString strIcon, QS
QDBusConnection::sessionBus());
QList<QVariant> args;
QMap <QString,QVariant> hint;
if(strIcon == ""){
strIcon = "drive-removable-media-usb"; //加密盘无法获取图标,使用默认图标
}
hint.insert("sound-name",notifySound);
args << (tr("kylin device daemon"))
<< ((unsigned int) 0)
@ -356,10 +361,17 @@ void MainWindow::getDeviceInfo()
g_free(strName);
}
getDriveIconsInfo(gdrive, driveInfo);
unsigned uVolumeSize = 0;
GList* Volumes = g_drive_get_volumes(gdrive);
if (Volumes) {
uVolumeSize = g_list_length(Volumes);
g_list_free(Volumes);
}
driveInfo.isCanEject = g_drive_can_eject(gdrive);
driveInfo.isCanStop = g_drive_can_stop(gdrive);
driveInfo.isCanStart = g_drive_can_start(gdrive);
driveInfo.isRemovable = g_drive_is_removable(gdrive);
driveInfo.lluVolSum = uVolumeSize;
if(!isSystemRootDev(driveInfo.strId.c_str()) && getDevInterface(driveInfo.strId.c_str()) && (driveInfo.isCanEject || driveInfo.isCanStop || driveInfo.isRemovable)) {
if(g_str_has_prefix(devPath,"/dev/sr") || g_str_has_prefix(devPath,"/dev/bus") || g_str_has_prefix(devPath,"/dev/sd")
|| g_str_has_prefix(devPath,"/dev/mmcblk")) {
@ -805,7 +817,7 @@ void MainWindow::onConvertUpdateWindow(QString strDevName, unsigned uDevType)
{
// uDevType: 0 drive , 1 volume, 2 mount
if (uDevType == 1) { // not drive detached
qDebug()<<"----------MainWindowShow----------";
qDebug()<<"----------onConvertUpdateWindow----------";
insertorclick = false;
MainWindowShow(true);
}else if(uDevType ==2){
@ -931,20 +943,13 @@ void MainWindow::drive_disconnected_callback (GVolumeMonitor *monitor, GDrive *d
}
}
p_this->m_dataFlashDisk->removeDriveInfo(driveInfo);
//Q_EMIT p_this->notifyDeviceRemoved(QString::fromStdString(driveInfo.strId));
if(p_this->m_dataFlashDisk->getValidInfoCount() == 0) {
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (p_this->centralWidgetList[i] && !p_this->centralWidgetList[i]->isHidden()) {
p_this->centralWidgetList[i]->hide();
delete p_this->centralWidgetList[i];
p_this->centralWidgetList[i] = nullptr;
}
}
p_this->hideAllWidget();
p_this->ui->centralWidget->hide();
p_this->m_systray->hide();
}
if(!p_this->m_basewidget->isHidden())
p_this->m_basewidget->hide();
// if(!p_this->m_basewidget->isHidden())
// p_this->m_basewidget->hide();
p_this->m_dataFlashDisk->OutputInfos();
}
@ -978,7 +983,14 @@ void MainWindow::volume_added_callback(GVolumeMonitor *monitor, GVolume *volume,
bool isNewMount = false;
char *devPath = g_drive_get_identifier(gdrive,G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE);
unsigned uVolumeSize = 0;
GList* Volumes = g_drive_get_volumes(gdrive);
if (Volumes) {
uVolumeSize = g_list_length(Volumes);
g_list_free(Volumes);
}
if((!gdrive)||(devPath == NULL)) {
qInfo()<<"gdrive or devepath is null";
FDVolumeInfo volumeInfo;
bool isValidMount = true;
char *devPath = g_volume_get_identifier(volume,G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
@ -1095,6 +1107,7 @@ void MainWindow::volume_added_callback(GVolumeMonitor *monitor, GVolume *volume,
driveInfo.isCanStop = g_drive_can_stop(gdrive);
driveInfo.isCanStart = g_drive_can_start(gdrive);
driveInfo.isRemovable = g_drive_is_removable(gdrive);
driveInfo.lluVolSum = uVolumeSize;
if(!p_this->isSystemRootDev(driveInfo.strId.c_str()) && p_this->getDevInterface(driveInfo.strId.c_str()) &&
(driveInfo.isCanEject || driveInfo.isCanStop || driveInfo.isRemovable)) {
@ -1170,7 +1183,6 @@ void MainWindow::volume_added_callback(GVolumeMonitor *monitor, GVolume *volume,
}
g_object_unref(mount);
} else {
qInfo()<<"ifGpartedBusy"<<p_this->ifGpartedBusy();
if(p_this->ifsettings->get(IFAUTOLOAD).toBool()&&p_this->ifGpartedBusy()) {
p_this->m_ismountadd = true;
if (p_this->getDevInterface(volumeInfo.strId.c_str())){
@ -1188,7 +1200,7 @@ void MainWindow::volume_added_callback(GVolumeMonitor *monitor, GVolume *volume,
}
}
if (isNewMount) {
//qInfo()<<"cd data disk has mounted!";
qInfo()<<"cd data disk has mounted!";
volumeInfo.isNewInsert = true;
p_this->m_dataFlashDisk->addVolumeInfoWithDrive(driveInfo, volumeInfo);
string strDevId = driveInfo.strId.empty()?volumeInfo.strId:driveInfo.strId;
@ -1237,8 +1249,14 @@ void MainWindow::volume_removed_callback(GVolumeMonitor *monitor, GVolume *volum
if(p_this->m_dataFlashDisk->getValidInfoCount() == 0) {
p_this->m_systray->hide();
}
if(g_str_has_prefix(volumeInfo.strId.c_str(),"/dev/sr")){
p_this->hideAllWidget(true);
}
p_this->m_dataFlashDisk->OutputInfos();
Q_EMIT p_this->convertUpdateWindow(QString::fromStdString(volumeInfo.strName), 1); //emit a signal to update the MainMainShow slot
if(FlashDiskData::getInstance()->getIfClickToEject())
Q_EMIT p_this->convertUpdateWindow(QString::fromStdString(volumeInfo.strName), 1); //emit a signal to update the MainMainShow slot
FlashDiskData::getInstance()->m_clickToEject = false;
}
// when the volumes were mounted we add its mounts number
@ -1259,6 +1277,7 @@ void MainWindow::mount_added_callback(GVolumeMonitor *monitor, GMount *mount, Ma
char *devPath = g_drive_get_identifier(gdrive,G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE);
if (devPath != NULL) {
driveInfo.strId = devPath;
qInfo()<<"drive id is"<<driveInfo.strId.c_str();
if (!(p_this->getDevInterface(driveInfo.strId.c_str()))){
qInfo() << "---------------the devpath is "<<driveInfo.strId.c_str();
isValidMount = false;
@ -1269,10 +1288,17 @@ void MainWindow::mount_added_callback(GVolumeMonitor *monitor, GMount *mount, Ma
g_free(strName);
}
p_this->getDriveIconsInfo(gdrive, driveInfo);
unsigned uVolumeSize = 0;
GList* Volumes = g_drive_get_volumes(gdrive);
if (Volumes) {
uVolumeSize = g_list_length(Volumes);
g_list_free(Volumes);
}
driveInfo.isCanEject = g_drive_can_eject(gdrive);
driveInfo.isCanStop = g_drive_can_stop(gdrive);
driveInfo.isCanStart = g_drive_can_start(gdrive);
driveInfo.isRemovable = g_drive_is_removable(gdrive);
driveInfo.lluVolSum = uVolumeSize;
g_free(devPath);
}
#if UDFAUTOMOUNT
@ -1349,6 +1375,7 @@ void MainWindow::mount_added_callback(GVolumeMonitor *monitor, GMount *mount, Ma
mountInfo.isNativeDev = g_file_is_native(root); //判断设备是本地设备or网络设备
char *mountUri = g_file_get_uri(root); //get挂载点的uri路径
if (mountUri) {
qInfo()<<"mount uri is"<<mountUri;
mountInfo.strUri = mountUri;
if (g_str_has_prefix(mountUri,"file:///data")) {
isValidMount = false;
@ -1408,7 +1435,7 @@ void MainWindow::mount_added_callback(GVolumeMonitor *monitor, GMount *mount, Ma
if(p_this->m_dataFlashDisk->getValidInfoCount() >= 1) {
if (isValidMount && isNewMount) {
//qInfo()<<"cd data disk has mounted!";
qInfo()<<"cd data disk has mounted!";
string strDevId = driveInfo.strId.empty()?volumeInfo.strId:driveInfo.strId;
if(volumeInfo.mountInfo.lluTotalSize >= 1){
Q_EMIT p_this->convertShowWindow(strDevId.c_str(), mountInfo.strUri.c_str());
@ -1473,10 +1500,7 @@ void MainWindow::mount_removed_callback(GVolumeMonitor *monitor, GMount *mount,
FDVolumeInfo volumeInfo;
p_this->m_dataFlashDisk->getVolumeInfoByMount(mountInfo, volumeInfo);
quint64 mountTickDiff = p_this->m_dataFlashDisk->getMountTickDiff(mountInfo);
p_this->m_dataFlashDisk->removeMountInfo(mountInfo);
if((g_str_has_prefix (volumeInfo.strId.c_str(), "/dev/sr")))
p_this->m_dataFlashDisk->emitRemoveNotify(QString::fromStdString(mountInfo.strId),QString::fromStdString(volumeInfo.strId));
if(p_this->m_dataFlashDisk->getValidInfoCount() == 0) {
p_this->m_systray->hide();
@ -1640,13 +1664,9 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
triggerType = 1; //It represents how we open the interface
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (centralWidgetList[i] && !centralWidgetList[i]->isHidden() && !insertorclick) {
qDebug()<<"------清除centralWidgetList-------";
centralWidgetList[i]->hide();
delete centralWidgetList[i];
centralWidgetList[i] = nullptr;
}
if (!insertorclick) {
hideAllWidget();
}
if(m_basewidget && !m_basewidget->isHidden() && !insertorclick){
@ -1784,6 +1804,7 @@ void MainWindow::showFristWindow(quint64 uVolumeSum,
hign = 112;
if(uVolumeSum >=3 ){
hign = hign+(uVolumeSum-2)*FLASHDISKITEM_TITLE_HEIGHT;
ui->centralWidget->setEjectOnCentra(hign);
}
ui->centralWidget->setFixedSize(388, hign);
@ -1797,7 +1818,8 @@ void MainWindow::showFristWindow(quint64 uVolumeSum,
if((uVolumeNum == uVolumeSum)&&(ui->centralWidget->isHidden()==true)){
m_basewidget->mainWindowVboxLayout->addWidget(ui->centralWidget);
m_basewidget->setFixedSize(388, hign);
m_basewidget->m_hideTimer->start(3000);
interfaceHideTime->start(3000);
//m_basewidget->m_hideTimer->start(3000);
ui->centralWidget->show();
m_basewidget->showBaseWindow();
moveBaseWidgetGeo();
@ -1820,34 +1842,35 @@ void MainWindow::showMainWindow(int uVolumeNum,
{
qDebug()<<"遍历第"<<uDiskCount<<"个设备的第"<<uVolumeNum<<"个卷";
int uPositonY = 0;
if(centralWidgetList[uDiskCount] == NULL){
centralWidgetList[uDiskCount%FLASHDISKITEM_SHOWDISK_MAX] = new FDFrame(this);
if(!centralWidgetList.contains(strDriveId)){
FDFrame *fdframe = new FDFrame(this);
centralWidgetList.insert(strDriveId, fdframe);
}
m_fdClickWidget = new FDClickWidget(centralWidgetList[uDiskCount],uVolumeNum, strDriveId,strVolumeId,strMountId,driveName,
m_fdClickWidget = new FDClickWidget(centralWidgetList[strDriveId],uVolumeNum, strDriveId,strVolumeId,strMountId,driveName,
volumeName, capacityDis,strMountUri, uVolumeSum);
connect(m_fdClickWidget, &FDClickWidget::clickedEject,this,&MainWindow::onClickedEject);
if (uDiskCount > 0) {
hign = 112;
if(uVolumeSum >=3 ){
hign = hign+(uVolumeSum-2)*FLASHDISKITEM_TITLE_HEIGHT;
//ui->centralWidget->setFixedSize(388, hign);
centralWidgetList[strDriveId]->setEjectOnCentra(hign);
}
} else {
hign = 0;
ui->centralWidget->setFixedSize(0, 0);
}
centralWidgetList[uDiskCount]->setFixedSize(388, hign);
centralWidgetList[uDiskCount]->m_animLabel->setFixedSize(320, hign);
centralWidgetList[strDriveId]->setFixedSize(388, hign);
centralWidgetList[strDriveId]->m_animLabel->setFixedSize(320, hign);
if (uDiskCount>2){
for (int i=2; i<=uDiskCount ;i++){
uPositonY += centralWidgetList[i]->height();
}
centralWidgetList[uDiskCount]->move(ui->centralWidget->x(),ui->centralWidget->y()-((uDiskCount-1)*FLASHDISKITEM_SPACE_HEIGHT)-uPositonY);
}else{
centralWidgetList[uDiskCount]->move(ui->centralWidget->x(),ui->centralWidget->y()-((uDiskCount-1)*(hign+FLASHDISKITEM_SPACE_HEIGHT)));
}
// if (uDiskCount>2){
// for (int i=2; i<=uDiskCount ;i++){
// uPositonY += centralWidgetList[strDriveId]->height();
// }
// centralWidgetList[strDriveId]->move(ui->centralWidget->x(),ui->centralWidget->y()-((uDiskCount-1)*FLASHDISKITEM_SPACE_HEIGHT)-uPositonY);
// }else{
// centralWidgetList[strDriveId]->move(ui->centralWidget->x(),ui->centralWidget->y()-((uDiskCount-1)*(hign+FLASHDISKITEM_SPACE_HEIGHT)));
// }
if(uVolumeNum<=2){
if(uVolumeNum == 1){
@ -1859,29 +1882,37 @@ void MainWindow::showMainWindow(int uVolumeNum,
vboxLayout1->addWidget(m_fdClickWidget);
}else{
m_fdClickWidget->m_fristClickWidget = this->m_iconClickWidget;
m_fdClickWidget->setParent(centralWidgetList[uDiskCount]);
m_fdClickWidget->setParent(centralWidgetList[strDriveId]);
m_fdClickWidget->move(5,25+uVolumeNum*15);
m_fdClickWidget->show();
}
centralWidgetList[uDiskCount]->setLayout(vboxLayout1);
centralWidgetList[strDriveId]->setLayout(vboxLayout1);
if(uVolumeNum == uVolumeSum){
centralWidgetList[uDiskCount]->m_mainWindowHigh = hign;
centralWidgetList[strDriveId]->m_mainWindowHigh = hign;
}
if ((insertorclick)&&(uVolumeSum == uVolumeNum)){
if(ui->centralWidget!=NULL&&(ui->centralWidget->isHidden()==false)){
m_basewidget->mainWindowVboxLayout->addWidget(ui->centralWidget);
}
for(int i = 0; i<FLASHDISKITEM_SHOWDISK_MAX-1; i++){
if(centralWidgetList[i]!=NULL){
centralWidgetList[i]->setProperty("useSystemStyleBlur", true);
m_basewidget->mainWindowVboxLayout->addWidget(centralWidgetList[i]);
}
// for(int i = 0; i<FLASHDISKITEM_SHOWDISK_MAX-1; i++){
// if(centralWidgetList[i]!=NULL){
// centralWidgetList[i]->setProperty("useSystemStyleBlur", true);
// m_basewidget->mainWindowVboxLayout->addWidget(centralWidgetList[i]);
// }
// }
QMap<QString, FDFrame *>::iterator iter;
int i = 0;
for (iter = centralWidgetList.begin(); iter != centralWidgetList.end(); iter++) {
if(i <= FLASHDISKITEM_SHOWDISK_MAX)
m_basewidget->mainWindowVboxLayout->addWidget(iter.value());
i++;
}
m_basewidget->setFixedSize(388, 0);
m_basewidget->showBaseWindow();
m_basewidget->m_hideTimer->start(3000);
interfaceHideTime->start(3000);
//m_basewidget->m_hideTimer->start(3000);
moveBaseWidgetGeo();
}
@ -1986,18 +2017,24 @@ bool MainWindow::ifNewInsertVol()
return true;
}
void MainWindow::hideAllWidget(){
void MainWindow::hideAllWidget(bool ifHidden)
{
if(!ui->centralWidget->isHidden()){
ui->centralWidget->hide();
}
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (centralWidgetList[i] && !centralWidgetList[i]->isHidden()) {
centralWidgetList[i]->hide();
delete centralWidgetList[i];
centralWidgetList[i] = nullptr;
if(ifHidden == false){
QMap<QString, FDFrame *>::iterator iter;
for (iter = centralWidgetList.begin(); iter != centralWidgetList.end(); iter++) {
if(!iter.value()->isHidden())
iter.value()->hide();
delete iter.value();
}
}else{
QMap<QString, FDFrame *>::iterator iter;
for (iter = centralWidgetList.begin(); iter != centralWidgetList.end(); iter++) {
iter.value()->hide();
delete iter.value();
}
}
centralWidgetList.clear();
}
void MainWindow::MainWindowShow(bool isUpdate)
@ -2055,6 +2092,9 @@ void MainWindow::MainWindowShow(bool isUpdate)
//Convenient interface layout for all drives
map<string, FDDriveInfo>& listDriveInfo = m_dataFlashDisk->getDevInfoWithDrive();
if (!listDriveInfo.empty()) {
if(!ui->centralWidget->isHidden()){
ui->centralWidget->hide();
}
hideAllWidget();
map<string, FDDriveInfo>::iterator itDriveInfo = listDriveInfo.begin();
for ( ;itDriveInfo != listDriveInfo.end(); itDriveInfo++) {
@ -2320,6 +2360,7 @@ void MainWindow::MainWindowShow(bool isUpdate)
unsigned uVolumeType = 0; // 0:normal file volume, 1: cddata, 2:tele dev
if (!itVolumeInfo->second.mountInfo.strId.empty()) {
string strMountUri = itVolumeInfo->second.mountInfo.strUri;
qInfo()<<"uri is "<<QString::fromStdString(strMountUri);
if(g_str_has_prefix(strMountUri.c_str(),"file:///")) {
uVolumeType = 0;
} else if (g_str_has_prefix(strMountUri.c_str(),"mtp://") || g_str_has_prefix(strMountUri.c_str(),"gphoto2://")){
@ -2327,6 +2368,9 @@ void MainWindow::MainWindowShow(bool isUpdate)
} else if (g_str_has_prefix(strMountUri.c_str(),"burn:///")/* || g_str_has_prefix(strMountUri.c_str(),"cdda://")*/) {
uVolumeType = 1;
}
}else{
qInfo()<<"no mount "<<strDriveId<<strVolumeId<<strMountId;
continue;
}
if (uVolumeType == 1 || uVolumeType == 2 || isCanShow) { // cd module or drive can show
if (!itVolumeInfo->second.strId.empty()) {
@ -2355,6 +2399,10 @@ void MainWindow::MainWindowShow(bool isUpdate)
showMainWindow(uVolumeNum, uDiskCount, uVolumeSum,vboxLayout2, strDriveId, strVolumeId, strMountId, realTele,
strApiName, lluTotalSize, strMountUri);
} else {
if(isUpdate && itDriveInfo->second.lluVolSum != uVolumeSum){
qDebug()<<"DriveId:"<<QString::fromStdString(itDriveInfo->second.strId)<<"DriveVolumeSum:"<<itDriveInfo->second.lluVolSum<<"volume sum is "<<uVolumeSum;
continue;
}
showMainWindow(uVolumeNum, uDiskCount,uVolumeSum ,vboxLayout2, strDriveId, strVolumeId, strMountId, strDriveName,
strApiName, lluTotalSize, strMountUri);
}
@ -2470,12 +2518,14 @@ void MainWindow::MainWindowShow(bool isUpdate)
}
}
if (!insertorclick){
for(int i = 0; i<FLASHDISKITEM_SHOWDISK_MAX-1; i++){
if(centralWidgetList[i]!=NULL){
centralWidgetList[i]->setProperty("useSystemStyleBlur", true);
kdk::UkuiStyleHelper::self()->removeHeader(centralWidgetList[i]);
m_basewidget->mainWindowVboxLayout->addWidget(centralWidgetList[i]);
QMap<QString, FDFrame *>::iterator iter;
int i = 0;
for (iter = centralWidgetList.begin(); iter != centralWidgetList.end(); iter++) {
if(i <= FLASHDISKITEM_SHOWDISK_MAX){
iter.value()->setProperty("useSystemStyleBlur", true);
m_basewidget->mainWindowVboxLayout->addWidget(iter.value());
}
i++;
}
m_basewidget->setFixedSize(388, 0); //height自动适配高度
ui->centralWidget->hide();
@ -2512,14 +2562,9 @@ void MainWindow::ifgetPinitMount()
void MainWindow::onMaininterfacehide()
{
m_basewidget->hide();
ui->centralWidget->hide();
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (centralWidgetList[i] && !centralWidgetList[i]->isHidden()) {
centralWidgetList[i]->hide();
delete centralWidgetList[i];
centralWidgetList[i] = nullptr;
}
}
hideAllWidget();
this->driveVolumeNum = 0;
interfaceHideTime->stop();
m_dataFlashDisk->resetAllNewState();
@ -2769,6 +2814,7 @@ void MainWindow::frobnitz_force_result_func(GDrive *source_object,GAsyncResult *
gboolean success = FALSE;
GError *err = nullptr;
success = g_drive_eject_with_operation_finish (source_object, res, &err);
qInfo()<<"frobnitz_force_result_func";
if (!err) {
FDDriveInfo driveInfo;
@ -2784,10 +2830,10 @@ void MainWindow::frobnitz_force_result_func(GDrive *source_object,GAsyncResult *
g_free(strName);
}
p_this->m_eject = new ejectInterface(p_this->ui->centralWidget,QString::fromStdString(driveInfo.strName),
NORMALDEVICE,QString::fromStdString(driveInfo.strId));
p_this->m_eject->show();
p_this->m_eject->moveEjectInterfaceRight();
// p_this->m_eject = new ejectInterface(p_this->ui->centralWidget,QString::fromStdString(driveInfo.strName),
// NORMALDEVICE,QString::fromStdString(driveInfo.strId));
// p_this->m_eject->show();
// p_this->m_eject->moveEjectInterfaceRight();
FlashDiskData::getInstance()->removeDriveInfo(driveInfo);
if(FlashDiskData::getInstance()->getValidInfoCount() == 0) {
p_this->m_systray->hide();
@ -2824,6 +2870,7 @@ void MainWindow::frobnitz_result_func(GDrive *source_object,GAsyncResult *res,Ma
gboolean success = FALSE;
GError *err = nullptr;
success = g_drive_eject_with_operation_finish (source_object, res, &err);
qInfo()<<"frobnitz_result_func";
if (!err) {
FDDriveInfo driveInfo;
@ -2839,10 +2886,11 @@ void MainWindow::frobnitz_result_func(GDrive *source_object,GAsyncResult *res,Ma
g_free(strName);
}
p_this->m_eject = new ejectInterface(p_this->ui->centralWidget,QString::fromStdString(driveInfo.strName),
NORMALDEVICE,QString::fromStdString(driveInfo.strId));
p_this->m_eject->show();
p_this->m_eject->moveEjectInterfaceRight();
// p_this->m_eject = new ejectInterface(p_this->ui->centralWidget,QString::fromStdString(driveInfo.strName),
// NORMALDEVICE,QString::fromStdString(driveInfo.strId));
// p_this->m_eject->show();
// p_this->m_eject->moveEjectInterfaceRight();
FlashDiskData::getInstance()->removeDriveInfo(driveInfo);
if(FlashDiskData::getInstance()->getValidInfoCount() == 0) {
p_this->m_systray->hide();
@ -2941,16 +2989,16 @@ void MainWindow::onClickedEject(EjectDeviceInfo eDeviceInfo)
m_curEjectDeviceInfo.pVoid = this;
m_curEjectDeviceInfo.uFlag = G_MOUNT_UNMOUNT_NONE;
qDebug()<<"-------- eject !----";
for(int i = 1;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
if (centralWidgetList[i]) {
qDebug()<<"-------- eject clean -----";
centralWidgetList[i]->hide();
delete centralWidgetList[i];
centralWidgetList[i] = nullptr;
}
}
// for(int i = 0;i<=FLASHDISKITEM_SHOWDISK_MAX-1;i++){
// if (centralWidgetList[i]) {
// centralWidgetList[i]->hide();
// delete centralWidgetList[i];
// centralWidgetList[i] = nullptr;
// }
// }
hideAllWidget(true);
m_basewidget->hide();
FlashDiskData::getInstance()->setClickToEject();
FlashDiskData::getInstance()->m_clickToEject = true;;
doRealEject(&m_curEjectDeviceInfo, G_MOUNT_UNMOUNT_NONE);
}
@ -2969,6 +3017,7 @@ bool MainWindow::onDeviceErrored(GDrive* drive)
GList* volumes = g_drive_get_volumes(drive);
if (!volumes && !mRepairDialog.contains(device) && !g_strrstr(name, "FT ePass3000GM")) {
RepairDialogBox* b = new RepairDialogBox(drive);
b->setAttribute(Qt::WA_DeleteOnClose);
b->connect(b, &RepairDialogBox::repairOK, this, [=] (RepairDialogBox* d) {
if (mRepairDialog.contains(d->getDeviceName())) {
b->mshowflag = false;
@ -2987,6 +3036,7 @@ bool MainWindow::onDeviceErrored(GDrive* drive)
if (!m && !g_strrstr(name, "FT ePass3000GM")) {
if (volumeName && !mRepairDialog.contains(volumeName)) {
RepairDialogBox* b = new RepairDialogBox(vv);
b->setAttribute(Qt::WA_DeleteOnClose);
b->connect(b, &RepairDialogBox::remountDevice, this, &MainWindow::remountVolume);
b->connect(b, &RepairDialogBox::repairOK, this, [=] (RepairDialogBox* d) {
if (mRepairDialog.contains(d->getDeviceName())) {
@ -3244,6 +3294,7 @@ GAsyncReadyCallback MainWindow::fileEjectMountableCB(GFile *file, GAsyncResult *
gboolean success = FALSE;
GError *err = nullptr;
success = g_file_eject_mountable_with_operation_finish(file, res, &err);
qInfo()<<"fileEjectMountableCB";
if (!err) {
FDDriveInfo driveInfo;
driveInfo.strId = peDeviceInfo->strDriveId.toStdString();
@ -3289,10 +3340,10 @@ void MainWindow::driveStopCb(GObject* object, GAsyncResult* res, EjectDeviceInfo
driveInfo.strId = peDeviceInfo->strDriveId.toStdString();
driveInfo.strName = peDeviceInfo->strDriveName.toStdString();
MainWindow* pThis = (MainWindow*)(peDeviceInfo->pVoid);
pThis->m_eject = new ejectInterface(pThis->ui->centralWidget,QString::fromStdString(driveInfo.strName),
NORMALDEVICE,QString::fromStdString(driveInfo.strId));
pThis->m_eject->show();
pThis->m_eject->moveEjectInterfaceRight();
// pThis->m_eject = new ejectInterface(pThis->ui->centralWidget,QString::fromStdString(driveInfo.strName),
// NORMALDEVICE,QString::fromStdString(driveInfo.strId));
// pThis->m_eject->show();
// pThis->m_eject->moveEjectInterfaceRight();
FlashDiskData::getInstance()->removeDriveInfo(driveInfo);
qInfo() << "driveStopCb:" <<peDeviceInfo->strMountUri<<peDeviceInfo->strVolumeId<<peDeviceInfo->strDriveId;
pThis->m_dataFlashDisk->emitRemoveNotify(peDeviceInfo->strMountUri,peDeviceInfo->strVolumeId);

View File

@ -124,7 +124,7 @@ private:
bool m_bIsMouseInCentral = false;
qint64 m_nAppStartTimestamp = 0; // 进程启动时的时间戳
QString m_strSysRootDev;
FDFrame *centralWidgetList[FLASHDISKITEM_SHOWDISK_MAX] = {0};
QMap<QString, FDFrame *> centralWidgetList;
baseWidget * m_basewidget;
bool mIsrunning = false;
@ -217,7 +217,7 @@ private:
bool ifBurnerBusy(QString strDev);
bool ifGpartedBusy();
bool ifNewInsertVol();
void hideAllWidget();
void hideAllWidget(bool ifHidden = false);
public Q_SLOTS:
void iconActivated(QSystemTrayIcon::ActivationReason reason);

View File

@ -29,8 +29,8 @@ void frobnitz_force_result_func(GDrive *source_object,GAsyncResult *res,QClickWi
if (!err)
{
findGDriveList()->removeOne(source_object);
p_this->m_eject = new ejectInterface(p_this,g_drive_get_name(source_object),NORMALDEVICE,"");
p_this->m_eject->show();
// p_this->m_eject = new ejectInterface(p_this,g_drive_get_name(source_object),NORMALDEVICE,"");
// p_this->m_eject->show();
}
else
{
@ -64,8 +64,8 @@ void frobnitz_result_func(GDrive *source_object,GAsyncResult *res,QClickWidget *
if (!err)
{
findGDriveList()->removeOne(source_object);
p_this->m_eject = new ejectInterface(p_this,g_drive_get_name(source_object),NORMALDEVICE,"");
p_this->m_eject->show();
// p_this->m_eject = new ejectInterface(p_this,g_drive_get_name(source_object),NORMALDEVICE,"");
// p_this->m_eject->show();
}
else /*if(g_drive_can_stop(source_object) == true)*/