fix filedialog path error

This commit is contained in:
likehomedream 2023-12-15 17:53:18 +08:00
parent 33be23b581
commit b7b83e53bf
6 changed files with 10 additions and 10 deletions

View File

@ -245,7 +245,7 @@ void CursorThemeWidget::initRightWidget()
// 如果获取的对象是合法的CursorEditWidget对象
if (clickedWidget) {
// 弹出文件选择对话框让用户选择一个SVG文件
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), QDir::homePath(), tr("SVG file (*.svg)"));
// 如果用户选择了文件,且文件路径不为空
if (!newFilePath.isEmpty()) {
// 将widgetName和newFilePath插入到m_customiconpathmap中以便后续可以通过widgetName找到自定义图标路径
@ -305,7 +305,7 @@ void CursorThemeWidget::initRightWidget()
// 判断获取的CursorEditWidget对象是否为空如果不为空则继续执行下面的代码
if (clickedWidget) {
// 使用QFileDialog::getOpenFileName函数打开一个文件选择对话框选择一个SVG文件
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), QDir::homePath(), tr("SVG file (*.svg)"));
// 判断选择的文件路径是否为空,如果不为空,则执行下面的代码
if (!newFilePath.isEmpty()) {

View File

@ -232,7 +232,7 @@ void GlobalThemeWidget::initCoverWidget()
coverlayout->addWidget(tip);
cover->setLayout(coverlayout);
connect(m_coverbtn, &QPushButton::clicked, this, [=]() {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), "", tr("Picture file (*.png *.jpg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), QDir::homePath(), tr("Picture file (*.png *.jpg)"));
if (newFilePath.isEmpty()) {
newFilePath = m_coverpath;
}else{
@ -299,7 +299,7 @@ void GlobalThemeWidget::initWallPaperWidget()
wallpaperbtn->setIconSize(QSize(130,80));
connect(wallpaperbtn, &QPushButton::clicked, this, [=]() {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), "", tr("Picture file (*.png *.jpg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), QDir::homePath(), tr("Picture file (*.png *.jpg)"));
if (!newFilePath.isEmpty()) {
if(FileCheck::isLegalWallPaperFile(newFilePath,"wallpaper")){

View File

@ -97,7 +97,7 @@ void GrubThemeWidget::initEditWidget()
connect(m_showBtn, &QPushButton::clicked, this, [=]() {
// 弹出文件选择对话框,选择图片文件
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), "", tr("Picture file (*.png)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), QDir::homePath(), tr("Picture file (*.png)"));
// 如果选择的文件路径不为空
if (!newFilePath.isEmpty()) {

View File

@ -110,7 +110,7 @@ void IconThemeWidget::initEditWidget()
clickedWidget = qobject_cast<IconEditWidget*>(widget);
if (clickedWidget) {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), QDir::homePath(), tr("SVG file (*.svg)"));
if (!newFilePath.isEmpty()) {
m_customiconpathmap->insert(widgetName, newFilePath);
@ -282,7 +282,7 @@ void IconThemeWidget::initSystemEditWidget()
if (clickedWidget) {
// 显示一个文件选择对话框让用户选择一个SVG文件。将文件路径保存到newFilePath变量中。
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), QDir::homePath(), tr("SVG file (*.svg)"));
if (!newFilePath.isEmpty()) {
//check
if(FileCheck::isLegalIconFile(newFilePath)){

View File

@ -106,7 +106,7 @@ void PlymouthThemeWidget::initEditWidget()
addButton->setFixedSize(36,36);
connect(addButton, &QPushButton::clicked, this, [=]() {
if(pic->isChecked()){
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select Png file"), "", tr("Png file (*.png)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select Png file"), QDir::homePath(), tr("Png file (*.png)"));
if (!newFilePath.isEmpty()) {
if(FileCheck::isLegalPlymouthPicFile(newFilePath)){
QPixmap pixmap(newFilePath);
@ -121,7 +121,7 @@ void PlymouthThemeWidget::initEditWidget()
}
}
else{
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select MP4 file"), "", tr("MP4 file (*.mp4)"));
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select MP4 file"), QDir::homePath(), tr("MP4 file (*.mp4)"));
if (!newFilePath.isEmpty()) {
if(FileCheck::isLegalMP4File(newFilePath)){
QPixmap pixmap(newFilePath);

View File

@ -51,7 +51,7 @@ QString SavePathDialog::getSavePath()
void SavePathDialog::onModifyBtnClicked()
{
QString newFilePath = QFileDialog::getExistingDirectory(this);
QString newFilePath = QFileDialog::getExistingDirectory(this, tr("Select Directory"),QDir::homePath());
if(newFilePath != nullptr){
m_savepath = newFilePath;
emit savePathUpdate(newFilePath);