<default>1.00</default>
</entry>
- <entry name="downloadLocation" type="String">
+ <entry name="downloadDirectory" type="String">
<default>System Download Directory</default>
</entry>
+ <entry name="autoUpateDownloadDirectory" type="Bool">
+ <default>true</default>
+ </entry>
+
<entry name="tabsOnTop" type="Bool">
<default>true</default>
</entry>
Singleton=true
# List of variables that can be manually changed.
-Mutators=spellCheckLanguages
+Mutators=spellCheckLanguages,downloadDirectory
</layout>
</item>
- <!-- Download location. -->
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QLabel">
- <property name="text">
- <string>Download Location</string>
- </property>
-
- <property name="toolTip">
- <string>The default is System Download Directory.</string>
- </property>
- </widget>
- </item>
-
- <item>
- <widget class="QComboBox" name="kcfg_downloadLocation">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
-
- <property name="editable">
- <bool>true</bool>
- </property>
-
- <item>
- <property name="text">
- <string>System Download Directory</string>
- </property>
- </item>
- </widget>
- </item>
-
- <item>
- <widget class="QPushButton" name="browseButton">
- <property name="text">
- <string>Browse</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
-
<!-- Tabs on top. -->
<item>
<widget class="QCheckBox" name="kcfg_tabsOnTop">
</property>
<property name="toolTip">
- <string>Spatial navigation allows the moving between links and input fields using the keyboard arrow keys. The default is enabled.</string>
+ <string>Allow moving between links and input fields using the keyboard arrow keys. The default is enabled.</string>
+ </property>
+ </widget>
+ </item>
+
+ <!-- Download location. -->
+ <item>
+ <widget class="QGroupBox">
+ <property name="title">
+ <string>Download Location</string>
</property>
+
+ <layout class="QVBoxLayout">
+ <!-- Download directory. -->
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QComboBox" name="kcfg_downloadDirectory">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+
+ <item>
+ <property name="text">
+ <string>System Download Directory</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QPushButton" name="browseButton">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+
+ <!-- Auto update download directory. -->
+ <item>
+ <widget class="QCheckBox" name="kcfg_autoUpateDownloadDirectory">
+ <property name="text">
+ <string>Auto update the download directory</string>
+ </property>
+
+ <property name="toolTip">
+ <string>Automatically update the download directory to be whatever was used for the last download. The default is enabled.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
QString suggestedFileName = currentPrivacyWebEngineViewPointer->title() + ".mht";
// Get the download directory.
- QString downloadDirectory = Settings::downloadLocation();
+ QString downloadDirectory = Settings::downloadDirectory();
// Resolve the system download directory if specified.
if (downloadDirectory == QLatin1String("System Download Directory"))
// Save the webpage as an archive if the file save path is populated.
if (!saveFilePath.isEmpty())
{
+ // Update the download directory if specified.
+ if (Settings::autoUpateDownloadDirectory())
+ updateDownloadDirectory(saveFilePath);
+
// Set the saving archive flag. Otherwise, a second download tries to run.
savingArchive = true;
if (saveDialogResult == QDialog::Accepted) // Save was selected.
{
// Get the download directory.
- QString downloadDirectory = Settings::downloadLocation();
+ QString downloadDirectory = Settings::downloadDirectory();
// Resolve the system download directory if specified.
if (downloadDirectory == QLatin1String("System Download Directory"))
// Process the save file path.
if (!saveFilePath.isEmpty()) // The file save path is populated.
{
+ // Update the download directory if specified.
+ if (Settings::autoUpateDownloadDirectory())
+ updateDownloadDirectory(saveFilePath);
+
// Create a save file path file info.
QFileInfo saveFilePathFileInfo = QFileInfo(saveFilePath);
currentPrivacyWebEngineViewPointer->reload();
}
+void TabWidget::updateDownloadDirectory(QString newDownloadDirectory) const
+{
+ // Remove the file name from the save file path.
+ newDownloadDirectory.truncate(newDownloadDirectory.lastIndexOf(QLatin1Char('/')));
+
+ // Update the download location.
+ Settings::setDownloadDirectory(newDownloadDirectory);
+
+ // Get a handle for the KConfig skeleton.
+ KConfigSkeleton *kConfigSkeletonPointer = Settings::self();
+
+ // Write the settings to disk.
+ kConfigSkeletonPointer->save();
+}
+
void TabWidget::updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWebEngineViewPointer) const
{
// Only update the UI if the signal was emitted from the current privacy WebEngine.
void TabWidget::useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName)
{
// Get the download directory.
- QString downloadDirectory = Settings::downloadLocation();
+ QString downloadDirectory = Settings::downloadDirectory();
// Resolve the system download directory if specified.
if (downloadDirectory == QLatin1String("System Download Directory"))
saveFileDialogPointer->setWindowModality(Qt::WindowModal);
// Process the saving of the file. The save file dialog pointer must be captured directly instead of by reference or nasty crashes occur.
- auto saveFile = [saveFileDialogPointer, downloadUrl] ()
+ auto saveFile = [saveFileDialogPointer, downloadUrl, this] ()
{
// Get the save location. The dialog box should only allow the selecting of one file location.
QUrl saveLocation = saveFileDialogPointer->selectedUrls().value(0);
+ // Update the download directory if specified.
+ if (Settings::autoUpateDownloadDirectory())
+ updateDownloadDirectory(saveLocation.toLocalFile());
+
// Create a file copy job. `-1` creates the file with default permissions.
KIO::FileCopyJob *fileCopyJobPointer = KIO::file_copy(downloadUrl, saveLocation, -1, KIO::Overwrite);
void useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName);
private:
+ // The private functions.
+ void updateDownloadDirectory(QString newDownloadDirectory) const;
+
// The private variables.
PrivacyWebEngineView *currentPrivacyWebEngineViewPointer;
QWebEngineCookieStore *currentWebEngineCookieStorePointer;
connect(cookiesDialogPointer, SIGNAL(deleteCookie(QNetworkCookie)), tabWidgetPointer, SLOT(deleteCookieFromStore(QNetworkCookie)));
}
-void BrowserWindow::showDownloadLocationBrowseDialog() const
+void BrowserWindow::showDownloadDirectoryBrowseDialog() const
{
- // Get the current download location.
- QString currentDownloadLocation = downloadLocationComboBoxPointer->currentText();
+ // Get the current download directory.
+ QString currentDownloadDirectory = downloadDirectoryComboBoxPointer->currentText();
// Resolve the system download directory if specified.
- if (currentDownloadLocation == QStringLiteral("System Download Directory"))
- currentDownloadLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
+ if (currentDownloadDirectory == QStringLiteral("System Download Directory"))
+ currentDownloadDirectory = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
- // Get the new download location.
- QString newDownloadLocation = QFileDialog::getExistingDirectory(configDialogPointer, i18nc("Select download location dialog caption", "Select Download Location"), currentDownloadLocation);
+ // Get the new download directory.
+ QString newDownloadDirectory = QFileDialog::getExistingDirectory(configDialogPointer, i18nc("Select download directory dialog caption", "Select Download Directory"),
+ currentDownloadDirectory);
- // Populate the download location combo box according to the new download location.
- if (newDownloadLocation == QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) // The default download location was selected.
+ // Populate the download directory combo box according to the new download location.
+ if (newDownloadDirectory == QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) // The default download location was selected.
{
// Populate the download location with the default text.
- downloadLocationComboBoxPointer->setCurrentText("System Download Directory");
+ downloadDirectoryComboBoxPointer->setCurrentText("System Download Directory");
}
- else if (newDownloadLocation != QStringLiteral("")) // A different directory was selected.
+ else if (newDownloadDirectory != QStringLiteral("")) // A different directory was selected.
{
// Populate the download location.
- downloadLocationComboBoxPointer->setCurrentText(newDownloadLocation);
+ downloadDirectoryComboBoxPointer->setCurrentText(newDownloadDirectory);
}
}
userAgentLabelPointer = privacySettingsUi.userAgentLabel;
QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
- downloadLocationComboBoxPointer = generalSettingsUi.kcfg_downloadLocation;
+ downloadDirectoryComboBoxPointer = generalSettingsUi.kcfg_downloadDirectory;
QPushButton *browseButtonPointer = generalSettingsUi.browseButton;
QListWidget *spellCheckListWidgetPointer = spellCheckSettingsUi.spellCheckListWidget;
connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateUserAgentLabel(const QString)));
connect(searchEngineComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateSearchEngineLabel(const QString)));
- // Connect the download location directory browse button.
- connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadLocationBrowseDialog()));
+ // Connect the download directory directory browse button.
+ connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadDirectoryBrowseDialog()));
// Create a dictionaries QDir from the `QTWEBENGINE_DICTIONARIES_PATH` environment variable.
QDir dictionariesDir = QDir(qEnvironmentVariable("QTWEBENGINE_DICTIONARIES_PATH"));
void reloadAndBypassCache() const;
void showBookmarkContextMenu(const QPoint &point);
void showCookiesDialog();
- void showDownloadLocationBrowseDialog() const;
+ void showDownloadDirectoryBrowseDialog() const;
void showDomainSettingsDialog() const;
void showFindTextActions() const;
void showProgressBar(const int &progress) const;
double defaultZoomFactor;
QAction *developerToolsActionPointer;
QAction *domStorageActionPointer;
- QComboBox *downloadLocationComboBoxPointer;
+ QComboBox *downloadDirectoryComboBoxPointer;
QList<QPair<QMenu *, QAction *> *> finalBookmarkFolderMenuActionList;
QAction *findCaseSensitiveActionPointer;
QAction *findNextActionPointer;