Fixed #108.
This commit is contained in:
parent
7b34434195
commit
f96c70b71d
@ -7,6 +7,7 @@ Added:
|
||||
|
||||
Fixed:
|
||||
<ul>
|
||||
<li>Target directory settings is now used for all kinds of downloading + when prompt for each download destination is set, then previously used folder is saved. (issue #108)</li>
|
||||
<li>Fixed solarized skin. (issue #111)</li>
|
||||
<li>Keyboard shorcuts and toolbar editors now have alphabetically sorted actions. Toolbar editor switched from drag/drop to buttons. (issue
|
||||
#110)</li>
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <QColorDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QKeyEvent>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings) {
|
||||
@ -168,16 +169,16 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current,
|
||||
}
|
||||
|
||||
void FormSettings::loadDownloads() {
|
||||
m_ui->m_txtDownloadsTargetDirectory->setText(qApp->settings()->value(GROUP(Downloads),
|
||||
SETTING(Downloads::TargetDirectory)).toString());
|
||||
m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(qApp->settings()->value(GROUP(Downloads),
|
||||
SETTING(Downloads::TargetDirectory)).toString()));
|
||||
m_ui->m_rbDownloadsAskEachFile->setChecked(qApp->settings()->value(GROUP(Downloads),
|
||||
SETTING(Downloads::AlwaysPromptForFilename)).toBool());
|
||||
}
|
||||
|
||||
void FormSettings::saveDownloads() {
|
||||
qApp->settings()->setValue(GROUP(Downloads), Downloads::TargetDirectory, m_ui->m_txtDownloadsTargetDirectory->text());
|
||||
qApp->settings()->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename,
|
||||
m_ui->m_rbDownloadsAskEachFile->isChecked());
|
||||
qApp->settings()->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename, m_ui->m_rbDownloadsAskEachFile->isChecked());
|
||||
qApp->downloadManager()->setDownloadDirectory(m_ui->m_txtDownloadsTargetDirectory->text());
|
||||
}
|
||||
|
||||
void FormSettings::selectDownloadsDirectory() {
|
||||
|
@ -162,6 +162,9 @@ DVALUE(QString) Downloads::TargetDirectoryDef = IOFactory::getSystemFold
|
||||
DKEY Downloads::RemovePolicy = "remove_policy";
|
||||
DVALUE(int) Downloads::RemovePolicyDef = DownloadManager::Never;
|
||||
|
||||
KEY Downloads::TargetExplicitDirectory = "target_explicit_directory";
|
||||
VALUE(QString) Downloads::TargetExplicitDirectoryDef = IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::DesktopLocation);
|
||||
|
||||
DKEY Downloads::ItemUrl = "download_%1_url";
|
||||
DKEY Downloads::ItemLocation = "download_%1_location";
|
||||
DKEY Downloads::ItemDone = "download_%1_done";
|
||||
|
@ -177,6 +177,9 @@ namespace Downloads {
|
||||
KEY RemovePolicy;
|
||||
VALUE(int) RemovePolicyDef;
|
||||
|
||||
KEY TargetExplicitDirectory;
|
||||
VALUE(QString) TargetExplicitDirectoryDef;
|
||||
|
||||
KEY ItemUrl;
|
||||
KEY ItemLocation;
|
||||
KEY ItemDone;
|
||||
|
@ -99,12 +99,15 @@ void DownloadItem::getFileName() {
|
||||
}
|
||||
|
||||
QString download_directory = qApp->downloadManager()->downloadDirectory();
|
||||
QString default_filename = saveFileName(download_directory);
|
||||
QString chosen_filename = default_filename;
|
||||
QString chosen_filename = saveFileName(download_directory);
|
||||
QString filename_for_prompt = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetExplicitDirectory)).toString() +
|
||||
QDir::separator() +
|
||||
QFileInfo(chosen_filename).fileName();
|
||||
|
||||
if (m_requestFileName) {
|
||||
// User must provide the path where he wants to save downloaded file in.
|
||||
m_gettingFileName = true;
|
||||
chosen_filename = QFileDialog::getSaveFileName(this, tr("Select destination for downloaded file"), default_filename);
|
||||
chosen_filename = QFileDialog::getSaveFileName(this, tr("Select destination for downloaded file"), filename_for_prompt);
|
||||
m_gettingFileName = false;
|
||||
|
||||
if (chosen_filename.isEmpty()) {
|
||||
@ -118,6 +121,8 @@ void DownloadItem::getFileName() {
|
||||
|
||||
QFileInfo file_info = QFileInfo(chosen_filename);
|
||||
|
||||
qApp->settings()->setValue(GROUP(Downloads), Downloads::TargetExplicitDirectory,
|
||||
QDir::toNativeSeparators(QFileInfo(chosen_filename).absolutePath()));
|
||||
qApp->downloadManager()->setDownloadDirectory(file_info.absoluteDir().absolutePath());
|
||||
m_ui->m_lblFilename->setText(file_info.fileName());
|
||||
}
|
||||
@ -686,8 +691,8 @@ void DownloadManager::cleanup() {
|
||||
void DownloadManager::setDownloadDirectory(const QString &directory) {
|
||||
m_downloadDirectory = directory;
|
||||
|
||||
if (!m_downloadDirectory.isEmpty() && !m_downloadDirectory.endsWith(QLatin1Char('/'))) {
|
||||
m_downloadDirectory += QLatin1Char('/');
|
||||
if (!m_downloadDirectory.isEmpty() && !m_downloadDirectory.endsWith(QDir::separator())) {
|
||||
m_downloadDirectory += QDir::separator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,16 +80,35 @@ void WebView::openImageInNewTab() {
|
||||
}
|
||||
|
||||
void WebView::saveCurrentPageToFile() {
|
||||
QString filter_html = tr("HTML web pages (*.html)");
|
||||
QString selected_file;
|
||||
|
||||
QString filter;
|
||||
QString selected_filter;
|
||||
if (qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::AlwaysPromptForFilename)).toBool()) {
|
||||
QString filter_html = tr("HTML web pages (*.html)");
|
||||
|
||||
// Add more filters here.
|
||||
filter += filter_html;
|
||||
QString filter;
|
||||
QString selected_filter;
|
||||
QString filename_for_prompt = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetExplicitDirectory)).toString() +
|
||||
QDir::separator() + tr("source_page.html");
|
||||
|
||||
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select destination file for web page"),
|
||||
qApp->homeFolderPath(), filter, &selected_filter);
|
||||
// Add more filters here.
|
||||
filter += filter_html;
|
||||
selected_file = QFileDialog::getSaveFileName(this, tr("Select destination file for web page"),
|
||||
filename_for_prompt, filter, &selected_filter);
|
||||
|
||||
if (!selected_file.isEmpty()) {
|
||||
qApp->settings()->setValue(GROUP(Downloads), Downloads::TargetExplicitDirectory,
|
||||
QDir::toNativeSeparators(QFileInfo(selected_file).absolutePath()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
selected_file = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetDirectory)).toString();
|
||||
|
||||
if (!selected_file.endsWith(QDir::separator())) {
|
||||
selected_file += QDir::separator();
|
||||
}
|
||||
|
||||
selected_file += tr("source_page.html");
|
||||
}
|
||||
|
||||
if (!selected_file.isEmpty()) {
|
||||
QFile selected_file_handle(selected_file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user