コード例 #1
0
ファイル: downloadpathbox.cpp プロジェクト: 4ker/tdesktop
void DownloadPathBox::onEditPath() {
	filedialogInit();
	QString path, lastPath = cDialogLastPath();
	if (!cDownloadPath().isEmpty() && cDownloadPath() != qstr("tmp")) {
		cSetDialogLastPath(cDownloadPath().left(cDownloadPath().size() - (cDownloadPath().endsWith('/') ? 1 : 0)));
	}
	if (filedialogGetDir(path, lang(lng_download_path_choose))) {
		if (!path.isEmpty()) {
			_path = path + '/';
			_pathBookmark = psDownloadPathBookmark(_path);
			setPathText(QDir::toNativeSeparators(_path));
		}
	}
	cSetDialogLastPath(lastPath);
}
コード例 #2
0
void DownloadPathBox::onEditPath() {
	_dirInput.clearFocus();

	filedialogInit();
	QString path, lastPath = cDialogLastPath();
	if (!cDownloadPath().isEmpty()) cSetDialogLastPath(cDownloadPath());
	if (filedialogGetDir(path, lang(lng_download_path_choose))) {
		if (!path.isEmpty()) {
			_path = path + '/';
			_dirInput.setText(QDir::toNativeSeparators(_path));
			_dirInput.setCursorPosition(0);
		}
	}
	cSetDialogLastPath(lastPath);
}
コード例 #3
0
ファイル: filedialog.cpp プロジェクト: banditkroot/tdesktop
void filedialogInit() {
	if (cDialogLastPath().isEmpty()) {
#ifdef Q_OS_WIN
		// hack to restore previous dir without hurting performance
		QSettings settings(QSettings::UserScope, qstr("QtProject"));
		settings.beginGroup(qstr("Qt"));
		QByteArray sd = settings.value(qstr("filedialog")).toByteArray();
		QDataStream stream(&sd, QIODevice::ReadOnly);
		if (!stream.atEnd()) {
			int version = 3, _QFileDialogMagic = 190;
			QByteArray splitterState;
			QByteArray headerData;
			QList<QUrl> bookmarks;
			QStringList history;
			QString currentDirectory;
			qint32 marker;
			qint32 v;
			qint32 viewMode;
			stream >> marker;
			stream >> v;
			if (marker == _QFileDialogMagic && v == version) {
				stream >> splitterState
						>> bookmarks
						>> history
						>> currentDirectory
						>> headerData
						>> viewMode;
				cSetDialogLastPath(currentDirectory);
			}
コード例 #4
0
ファイル: file_utilities.cpp プロジェクト: Emadpres/tdesktop
bool GetDefault(
		QPointer<QWidget> parent,
		QStringList &files,
		QByteArray &remoteContent,
		const QString &caption,
		const QString &filter,
		FileDialog::internal::Type type,
		QString startFile = QString()) {
	if (cDialogLastPath().isEmpty()) {
		Platform::FileDialog::InitLastPath();
	}

    remoteContent = QByteArray();
	if (startFile.isEmpty() || startFile.at(0) != '/') {
		startFile = cDialogLastPath() + '/' + startFile;
	}
	QString file;
	if (type == Type::ReadFiles) {
		files = QFileDialog::getOpenFileNames(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
		QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath();
		if (!path.isEmpty() && path != cDialogLastPath()) {
			cSetDialogLastPath(path);
			Local::writeUserSettings();
		}
		return !files.isEmpty();
    } else if (type == Type::ReadFolder) {
		file = QFileDialog::getExistingDirectory(Messenger::Instance().getFileDialogParent(), caption, startFile);
    } else if (type == Type::WriteFile) {
		file = QFileDialog::getSaveFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
    } else {
		file = QFileDialog::getOpenFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
    }
    if (file.isEmpty()) {
        files = QStringList();
        return false;
    }
	if (type != Type::ReadFolder) {
		// Save last used directory for all queries except directory choosing.
		auto path = QFileInfo(file).absoluteDir().absolutePath();
		if (!path.isEmpty() && path != cDialogLastPath()) {
			cSetDialogLastPath(path);
			Local::writeUserSettings();
		}
	}
	files = QStringList(file);
	return true;
}
コード例 #5
0
ファイル: file_utilities.cpp プロジェクト: Emadpres/tdesktop
void InitLastPathDefault() {
	cSetDialogLastPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
}