19#include "ui_historymanager.h"
47 connect(ui->clearAll, &QAbstractButton::clicked,
this, &HistoryManager::clearHistory);
49 ui->historyTree->setFocus();
55 m_window =
mApp->getWindow();
56 return m_window.data();
68 ui->historyTree->header()->restoreState(
state);
73 return ui->historyTree->header()->saveState();
76void HistoryManager::clearHistory()
78 QMessageBox::StandardButton button = QMessageBox::warning(
this, tr(
"Confirmation"),
79 tr(
"Are you sure you want to delete all history?"), QMessageBox::Yes | QMessageBox::No);
80 if (button != QMessageBox::Yes) {
84 mApp->history()->clearHistory();
87void HistoryManager::keyPressEvent(QKeyEvent *event)
89 switch (event->key()) {
91 ui->historyTree->removeSelectedItems();
95 QWidget::keyPressEvent(event);
100 ui->historyTree->search(searchText);
103void HistoryManager::urlActivated(
const QUrl &url)
108void HistoryManager::urlCtrlActivated(
const QUrl &url)
110 openUrlInNewTab(url);
113void HistoryManager::urlShiftActivated(
const QUrl &url)
115 openUrlInNewWindow(url);
118void HistoryManager::openUrl(
const QUrl &url)
120 const QUrl u = !url.isEmpty() ? url : ui->historyTree->selectedUrl();
121 m_window->weView()->load(u);
124void HistoryManager::openUrlInNewTab(
const QUrl &url)
126 const QUrl u = !url.isEmpty() ? url : ui->historyTree->selectedUrl();
127 m_window->tabWidget()->addView(u,
qzSettings->newTabPosition);
130void HistoryManager::openUrlInNewWindow(
const QUrl &url)
132 const QUrl u = !url.isEmpty() ? url : ui->historyTree->selectedUrl();
136void HistoryManager::openUrlInNewPrivateWindow(
const QUrl &url)
138 const QUrl u = !url.isEmpty() ? url : ui->historyTree->selectedUrl();
139 mApp->startPrivateBrowsing(u);
142void HistoryManager::createContextMenu(
const QPoint &pos)
150 QAction* actCopyUrl = menu.addAction(tr(
"Copy url"),
this, &HistoryManager::copyUrl);
151 QAction* actCopyTitle = menu.addAction(tr(
"Copy title"),
this, &HistoryManager::copyTitle);
154 QAction* actDelete = menu.addAction(QIcon::fromTheme(
QSL(
"edit-delete")), tr(
"Delete"));
156 connect(actNewTab, SIGNAL(triggered()),
this, SLOT(openUrlInNewTab()));
157 connect(actNewWindow, SIGNAL(triggered()),
this, SLOT(openUrlInNewWindow()));
158 connect(actNewPrivateWindow, SIGNAL(triggered()),
this, SLOT(openUrlInNewPrivateWindow()));
161 if (ui->historyTree->selectedUrl().isEmpty()) {
162 actNewTab->setDisabled(
true);
163 actNewWindow->setDisabled(
true);
164 actNewPrivateWindow->setDisabled(
true);
165 actCopyTitle->setDisabled(
true);
166 actCopyUrl->setDisabled(
true);
172void HistoryManager::copyUrl()
174 QApplication::clipboard()->setText(ui->historyTree->selectedUrl().toString());
177void HistoryManager::copyTitle()
179 QApplication::clipboard()->setText(ui->historyTree->currentIndex().data().toString());
void restoreState(const QByteArray &state)
HistoryManager(BrowserWindow *window, QWidget *parent=nullptr)
void search(const QString &searchText)
void setMainWindow(BrowserWindow *window)
~HistoryManager() override
void urlCtrlActivated(const QUrl &url)
void urlShiftActivated(const QUrl &url)
void removeSelectedItems()
void contextMenuRequested(const QPoint &point)
void urlActivated(const QUrl &url)
static QIcon privateBrowsingIcon()
static QIcon newWindowIcon()
static QIcon newTabIcon()