mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-08-03 12:46:29 -04:00
Add reading list export
Added Menu button to export reading list to file
This commit is contained in:
parent
9418f64d5a
commit
b4bbefa5af
@ -173,5 +173,7 @@
|
||||
"file-not-found-text": "ZIM file doesn't exist or is not readable",
|
||||
"zim-id": "Zim Id",
|
||||
"zim-name": "Zim Name",
|
||||
"zim-path": "Zim File Path"
|
||||
"zim-path": "Zim File Path",
|
||||
"export-reading-list": "Export reading list",
|
||||
"export-reading-list-error": "An error has occured during export of the reading list."
|
||||
}
|
||||
|
@ -180,5 +180,7 @@
|
||||
"file-not-found-text": "Error description text for when the desktop application cannot find the Zim file needed to display the web page.",
|
||||
"zim-id": "The term for the unique identifier of a zim file.",
|
||||
"zim-name": "The term for the name of a Zim file",
|
||||
"zim-path": "The term for the path of a Zim file"
|
||||
"zim-path": "The term for the path of a Zim file",
|
||||
"export-reading-list": "Represents the action of exporting the reading list to a file.",
|
||||
"export-reading-list-error": "Error description text for when exporting the reading list to a file failed."
|
||||
}
|
||||
|
@ -461,6 +461,8 @@ void KiwixApp::createActions()
|
||||
|
||||
CREATE_ACTION_ONOFF_ICON_SHORTCUT(ToggleReadingListAction, "reading-list-active", "reading-list", gt("reading-list"), QKeySequence(Qt::CTRL | Qt::Key_B));
|
||||
|
||||
CREATE_ACTION(ExportReadingListAction, gt("export-reading-list"));
|
||||
|
||||
CREATE_ACTION_ONOFF_ICON_SHORTCUT(ToggleAddBookmarkAction, "star-active", "star", gt("add-bookmark"), QKeySequence(Qt::CTRL | Qt::Key_D));
|
||||
|
||||
CREATE_ACTION_SHORTCUTS(ZoomInAction, gt("zoom-in"), QList<QKeySequence>({QKeySequence::ZoomIn, QKeySequence(Qt::CTRL | Qt::Key_Equal)}));
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
SettingAction,
|
||||
DonateAction,
|
||||
ExitAction,
|
||||
ExportReadingListAction,
|
||||
MAX_ACTION
|
||||
};
|
||||
|
||||
|
@ -24,6 +24,7 @@ MainMenu::MainMenu(QWidget *parent) :
|
||||
m_fileMenu.ADD_ACTION(BrowseLibraryAction);
|
||||
m_fileMenu.ADD_ACTION(OpenFileAction);
|
||||
m_fileMenu.ADD_ACTION(OpenRecentAction);
|
||||
m_fileMenu.ADD_ACTION(ExportReadingListAction);
|
||||
|
||||
/* TODO See https://github.com/kiwix/kiwix-desktop/issues/77
|
||||
m_fileMenu.ADD_ACTION(SavePageAsAction);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "zim/item.h"
|
||||
|
||||
#include <QListWidgetItem>
|
||||
#include <QFileDialog>
|
||||
|
||||
ReadingListBar::ReadingListBar(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -28,6 +29,9 @@ ReadingListBar::ReadingListBar(QWidget *parent) :
|
||||
|
||||
setupList();
|
||||
|
||||
auto app = KiwixApp::instance();
|
||||
auto exportAction = app->getAction(KiwixApp::ExportReadingListAction);
|
||||
connect(exportAction, &QAction::triggered, this, &ReadingListBar::onExport);
|
||||
ui->label->setText(gt("reading-list-title"));
|
||||
}
|
||||
|
||||
@ -104,6 +108,20 @@ void ReadingListBar::onItemActivated(QListWidgetItem* item, Qt::MouseButtons but
|
||||
}
|
||||
}
|
||||
|
||||
void ReadingListBar::onExport()
|
||||
{
|
||||
auto app = KiwixApp::instance();
|
||||
auto kiwixLibrary = app->getLibrary()->getKiwixLibrary();
|
||||
QString fileName = QFileDialog::getSaveFileName(app->getMainWindow(),
|
||||
gt("save-file-as-window-title"),
|
||||
"kiwix_readinglist.xml", "(*.xml)");
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
if (!kiwixLibrary->writeBookmarksToFile(fileName.toStdString()))
|
||||
app->showMessage(gt("export-reading-list-error"), gt("error-title"), QMessageBox::Information);
|
||||
}
|
||||
|
||||
void ReadingListBar::openUrl(QListWidgetItem* item, bool newTab)
|
||||
{
|
||||
int index = ui->listWidget->row(item);
|
||||
|
@ -22,6 +22,7 @@ public slots:
|
||||
void onItemDoubleClicked(QListWidgetItem *item);
|
||||
void onItemPressed(QListWidgetItem* item, Qt::MouseButtons buttons);
|
||||
void onItemActivated(QListWidgetItem *item, Qt::MouseButtons buttons);
|
||||
void onExport();
|
||||
private:
|
||||
Ui::readinglistbar *ui;
|
||||
int clickKind;
|
||||
|
Loading…
x
Reference in New Issue
Block a user