1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

History menu submenus for recently visited and most visited

This commit is contained in:
Mladen Pejaković 2012-01-23 00:14:01 +01:00
parent 79762d8b41
commit 4a4111161c
2 changed files with 64 additions and 19 deletions

View File

@ -458,6 +458,12 @@ void QupZilla::setupMenu()
m_menuClosedTabs = new QMenu(tr("Closed Tabs"));
connect(m_menuClosedTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowClosedTabsMenu()));
m_menuHistoryRecent = new QMenu(tr("Recently Visited"));
connect(m_menuHistoryRecent, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryRecentMenu()));
m_menuHistoryMost = new QMenu(tr("Most Visited"));
connect(m_menuHistoryMost, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMostMenu()));
aboutToShowToolsMenu();
aboutToShowHelpMenu();
@ -761,25 +767,8 @@ void QupZilla::aboutToShowHistoryMenu(bool loadHistory)
m_menuHistory->addAction(QIcon(":/icons/menu/history.png"), tr("Show &All History"), this, SLOT(showHistoryManager()))->setShortcut(QKeySequence("Ctrl+Shift+H"));
m_menuHistory->addSeparator();
if (loadHistory) {
QSqlQuery query;
query.exec("SELECT title, url FROM history ORDER BY date DESC LIMIT 10");
while (query.next()) {
QUrl url = query.value(1).toUrl();
QString title = query.value(0).toString();
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
Action* act = new Action(_iconForUrl(url), title);
act->setData(url);
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
m_menuHistory->addAction(act);
}
m_menuHistory->addSeparator();
}
m_menuHistory->addMenu(m_menuHistoryRecent);
m_menuHistory->addMenu(m_menuHistoryMost);
m_menuHistory->addMenu(m_menuClosedTabs);
}
@ -816,6 +805,58 @@ void QupZilla::aboutToShowClosedTabsMenu()
}
}
void QupZilla::aboutToShowHistoryRecentMenu()
{
m_menuHistoryRecent->clear();
QSqlQuery query;
if (query.isNull(false)) {
query.exec("SELECT title, url FROM history ORDER BY date DESC LIMIT 15");
while (query.next()) {
QUrl url = query.value(1).toUrl();
QString title = query.value(0).toString();
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
Action* act = new Action(_iconForUrl(url), title);
act->setData(url);
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
m_menuHistoryRecent->addAction(act);
}
}
else {
m_menuHistoryRecent->addAction(tr("Empty"))->setEnabled(false);
}
}
void QupZilla::aboutToShowHistoryMostMenu()
{
m_menuHistoryMost->clear();
QSqlQuery query;
if (query.isNull(false)) {
query.exec("SELECT title, url FROM history ORDER BY count DESC LIMIT 15");
while (query.next()) {
QUrl url = query.value(1).toUrl();
QString title = query.value(0).toString();
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
Action* act = new Action(_iconForUrl(url), title);
act->setData(url);
connect(act, SIGNAL(triggered()), this, SLOT(loadActionUrl()));
connect(act, SIGNAL(middleClicked()), this, SLOT(loadActionUrlInNewNotSelectedTab()));
m_menuHistoryMost->addAction(act);
}
}
else {
m_menuHistoryMost->addAction(tr("Empty"))->setEnabled(false);
}
}
void QupZilla::aboutToShowHelpMenu()
{
m_menuHelp->clear();

View File

@ -178,6 +178,8 @@ private slots:
void showNavigationToolbar();
void showStatusbar();
void showClearPrivateData();
void aboutToShowHistoryRecentMenu();
void aboutToShowHistoryMostMenu();
void showPreferences();
void showBookmarkImport();
@ -233,6 +235,8 @@ private:
Menu* m_menuBookmarks;
Menu* m_menuHistory;
QMenu* m_menuClosedTabs;
QMenu* m_menuHistoryRecent;
QMenu* m_menuHistoryMost;
QMenu* m_menuEncoding;
QAction* m_menuBookmarksAction;
#ifdef Q_WS_MAC