QString CSaveLoadFileDialog::getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, const QString &strDefaultSuffix, QString *selectedFilter, QFileDialog::Options options) { if (lastPath().isEmpty()) setLastPath(dir); QPointer<QFileDialog> pDlg = new QFileDialog(parent, caption, lastPath(), filter); pDlg->setFileMode(QFileDialog::AnyFile); pDlg->setAcceptMode(QFileDialog::AcceptSave); pDlg->setDefaultSuffix(strDefaultSuffix); pDlg->setOptions(options); if (selectedFilter) pDlg->selectNameFilter(*selectedFilter); if (pDlg->exec() == QDialog::Accepted) { if (!pDlg.isNull()) { QString strFilename = pDlg->selectedFiles().value(0); if (!strFilename.isEmpty()) setLastPath(strFilename); return strFilename; } } if (pDlg) delete pDlg; return QString(); }
QString CSaveLoadFileDialog::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { if (lastPath().isEmpty()) setLastPath(dir); QString strFilename = QFileDialog::getOpenFileName(parent, caption, lastPath(), filter, selectedFilter, options); if (!strFilename.isEmpty()) setLastPath(strFilename); return strFilename; }
void PatMainWindow::readSettings() { QString organizationName = QCoreApplication::organizationName(); QString applicationName = QCoreApplication::applicationName(); QSettings settings(organizationName, applicationName); QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); QSize size = settings.value("size", QSize(600, 400)).toSize(); setLastPath(settings.value("lastPath", QDir::homePath()).toString()); resize(size); move(pos); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("state").toByteArray()); }