Use the same icon for selecting folders/files

As stated in Qt doc, the `QStyle::SP_DialogOpenButton` is only for a
button within QDialogButtonBox which means it isn't suitable elsewhere.
This commit is contained in:
Chocobo1 2021-08-09 12:42:32 +08:00
parent 4ed99ba851
commit b29a52dfa8
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -155,26 +155,21 @@ QString FileSystemPathEdit::FileSystemPathEditPrivate::dialogCaptionOrDefault()
void FileSystemPathEdit::FileSystemPathEditPrivate::modeChanged()
{
QStyle::StandardPixmap pixmap = QStyle::SP_DialogOpenButton;
bool showDirsOnly = false;
switch (m_mode)
{
case FileSystemPathEdit::Mode::FileOpen:
case FileSystemPathEdit::Mode::FileSave:
#ifdef Q_OS_WIN
pixmap = QStyle::SP_DirOpenIcon;
#endif
showDirsOnly = false;
break;
case FileSystemPathEdit::Mode::DirectoryOpen:
case FileSystemPathEdit::Mode::DirectorySave:
pixmap = QStyle::SP_DirOpenIcon;
showDirsOnly = true;
break;
default:
throw std::logic_error("Unknown FileSystemPathEdit mode");
}
m_browseAction->setIcon(QApplication::style()->standardIcon(pixmap));
m_browseAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon));
m_editor->completeDirectoriesOnly(showDirsOnly);
m_validator->setExistingOnly(m_mode != FileSystemPathEdit::Mode::FileSave);