mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-20 18:33:38 -04:00
Merge pull request #1125 from sgourdas/feature/settings_dir
Download path setting QOL improvements
This commit is contained in:
commit
1623d8729c
@ -43,6 +43,17 @@ QPushButton:hover {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#downloadDirPathCopy {
|
||||
background-color: none;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
#downloadDirPathCopy:hover {
|
||||
background-color: #D9E9FF;
|
||||
border: 1px solid #3366CC;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#monitorDirLabel {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
@ -135,6 +135,7 @@
|
||||
"monitor-dir-dialog-title":"Are you sure you want to change the monitor directory?",
|
||||
"monitor-dir-dialog-msg":"The new monitor directory path will be:\n{{DIRECTORY}}",
|
||||
"monitor-clear-dir-dialog-title":"Are you sure you want to clear the monitor directory?",
|
||||
"path-was-copied": "Path was copied",
|
||||
"monitor-clear-dir-dialog-msg":"This will stop checking the monitor directory for new ZIM files.",
|
||||
"monitor-directory-tooltip":"All ZIM files in this directory will be automatically added to the library.",
|
||||
"next-tab":"Move to next tab",
|
||||
|
@ -174,5 +174,6 @@
|
||||
"clear-filter": "Represents the action of clearing the filters selected for a filter type.",
|
||||
"no-details": "A content type for Zim files representing it only has an introduction.",
|
||||
"no-pictures": "A content type for Zim files that does not contain pictures.",
|
||||
"no-videos": "A content type for Zim files that does not contain videos."
|
||||
"no-videos": "A content type for Zim files that does not contain videos.",
|
||||
"path-was-copied": "Tooltip confirming that the download path from settings was copied."
|
||||
}
|
||||
|
7
resources/icons/copy.svg
Normal file
7
resources/icons/copy.svg
Normal file
@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copy" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z"/>
|
||||
<rect x="8" y="8" width="12" height="12" rx="2" />
|
||||
<path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" />
|
||||
</svg>
|
||||
|
||||
|
After Width: | Height: | Size: 404 B |
@ -16,6 +16,7 @@
|
||||
<file>icons/star.svg</file>
|
||||
<file>icons/search.svg</file>
|
||||
<file>icons/close.svg</file>
|
||||
<file>icons/copy.svg</file>
|
||||
<file>icons/star-active.svg</file>
|
||||
<file>icons/search-inactive.svg</file>
|
||||
<file>icons/checkbox-indeterminate.svg</file>
|
||||
|
@ -2,8 +2,24 @@
|
||||
#include "ui_settings.h"
|
||||
#include "kiwixapp.h"
|
||||
#include <kiwix/tools.h>
|
||||
#include <QClipboard>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QToolTip>
|
||||
|
||||
namespace
|
||||
{
|
||||
QString formatDownloadDir(const QString& input) {
|
||||
const int maxLength = 40;
|
||||
if (input.length() > maxLength) {
|
||||
QString suffix = input.right(maxLength);
|
||||
int directoryIndex = suffix.indexOf('/');
|
||||
return "..." + suffix.mid(directoryIndex != -1 ? directoryIndex : 0);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
SettingsView::SettingsView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Settings)
|
||||
@ -14,6 +30,7 @@ SettingsView::SettingsView(QWidget *parent)
|
||||
connect(ui->moveToTrashToggle, &QCheckBox::clicked, this, &SettingsView::setMoveToTrash);
|
||||
connect(ui->reopenTabToggle, &QCheckBox::clicked, this, &SettingsView::setReopenTab);
|
||||
connect(ui->browseButton, &QPushButton::clicked, this, &SettingsView::browseDownloadDir);
|
||||
connect(ui->downloadDirPathCopy, &QPushButton::clicked, this, &SettingsView::copyDownloadPathToClipboard);
|
||||
connect(ui->resetButton, &QPushButton::clicked, this, &SettingsView::resetDownloadDir);
|
||||
connect(ui->monitorBrowse, &QPushButton::clicked, this, &SettingsView::browseMonitorDir);
|
||||
connect(ui->monitorClear, &QPushButton::clicked, this, &SettingsView::clearMonitorDir);
|
||||
@ -30,6 +47,9 @@ SettingsView::SettingsView(QWidget *parent)
|
||||
ui->browseButton->setText(gt("browse"));
|
||||
ui->monitorClear->setText(gt("clear"));
|
||||
ui->monitorBrowse->setText(gt("browse"));
|
||||
QIcon copyIcon(":/icons/copy.svg");
|
||||
ui->downloadDirPathCopy->setIcon(copyIcon);
|
||||
ui->downloadDirPathCopy->setIconSize(QSize(24, 24));
|
||||
ui->monitorHelp->setText("<b>?</b>");
|
||||
ui->monitorHelp->setToolTip(gt("monitor-directory-tooltip"));
|
||||
ui->moveToTrashLabel->setText(gt("move-files-to-trash"));
|
||||
@ -47,7 +67,7 @@ void SettingsView::init(int zoomPercent, const QString &downloadDir,
|
||||
bool reopentab)
|
||||
{
|
||||
ui->zoomPercentSpinBox->setValue(zoomPercent);
|
||||
ui->downloadDirPath->setText(downloadDir);
|
||||
SettingsView::onDownloadDirChanged(downloadDir);
|
||||
if (monitorDir == QString()) {
|
||||
ui->monitorClear->hide();
|
||||
}
|
||||
@ -156,7 +176,17 @@ void SettingsView::setReopenTab(bool reopen)
|
||||
|
||||
void SettingsView::onDownloadDirChanged(const QString &dir)
|
||||
{
|
||||
ui->downloadDirPath->setText(dir);
|
||||
ui->downloadDirPath->setText(formatDownloadDir(dir));
|
||||
ui->downloadDirPath->setToolTip(dir);
|
||||
}
|
||||
|
||||
void SettingsView::copyDownloadPathToClipboard()
|
||||
{
|
||||
QString downloadPath = KiwixApp::instance()->getSettingsManager()->getDownloadDir();
|
||||
QApplication::clipboard()->setText(downloadPath);
|
||||
|
||||
QPoint globalPos = ui->downloadDirPathCopy->mapToGlobal(QPoint(0, -ui->downloadDirPathCopy->height()));
|
||||
QToolTip::showText(globalPos, gt("path-was-copied"), ui->downloadDirPathCopy);
|
||||
}
|
||||
|
||||
void SettingsView::onMonitorDirChanged(const QString &dir)
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
void setMoveToTrash(bool moveToTrash);
|
||||
void setReopenTab(bool reopen);
|
||||
void onDownloadDirChanged(const QString &dir);
|
||||
void copyDownloadPathToClipboard();
|
||||
void onMonitorDirChanged(const QString &dir);
|
||||
void onZoomChanged(qreal zoomFactor);
|
||||
void onMoveToTrashChanged(bool moveToTrash);
|
||||
|
@ -142,6 +142,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="downloadDirPathCopy">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user