Skip to content

Commit

Permalink
Refactors code. Adds dockset icons to history menu
Browse files Browse the repository at this point in the history
  • Loading branch information
drognanar committed Aug 23, 2014
1 parent d5bd429 commit 49c9b17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
24 changes: 16 additions & 8 deletions zeal/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,12 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->webView, &SearchableWebView::urlChanged, [&](const QUrl &url) {
QString urlPath = url.path();
QString docsetName = getDocsetName(urlPath);

QIcon icon = docsetIcon(docsetName);
if (docsets->names().contains(docsetName)) {
QPixmap docsetMap = docsets->icon(docsetName).pixmap(32,32);

// paint label with the icon
loadSections(docsetName, url);
tabBar.setTabIcon(tabBar.currentIndex(), docsetMap);
} else {
tabBar.setTabIcon(tabBar.currentIndex(), QIcon());
}

tabBar.setTabIcon(tabBar.currentIndex(), icon);
displayViewActions();
});

Expand Down Expand Up @@ -327,6 +323,15 @@ void MainWindow::openDocset(const QModelIndex &index)
}
}

QIcon MainWindow::docsetIcon(QString docsetName)
{
if (docsets->names().contains(docsetName)) {
return docsets->icon(docsetName).pixmap(32,32);
} else {
return QIcon();
}
}

void MainWindow::queryCompleted()
{
treeViewClicked = true;
Expand Down Expand Up @@ -535,7 +540,10 @@ void MainWindow::forward() {

QAction *MainWindow::addHistoryAction(QWebHistory *history, QWebHistoryItem item)
{
QAction *backAction = new QAction(item.title(), ui->menu_View);
QString docsetName = getDocsetName(item.url().toString());
QIcon icon = docsetIcon(docsetName);

QAction *backAction = new QAction(icon, item.title(), ui->menu_View);
ui->menu_View->addAction(backAction);
connect(backAction, &QAction::triggered, [=](bool) {
history->goToItem(item);
Expand Down
1 change: 1 addition & 0 deletions zeal/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MainWindow : public QMainWindow
void reloadTabState();
void displayTabs();
void updateTreeView(QString text);
QIcon docsetIcon(QString docsetName);
QAction *addHistoryAction(QWebHistory *history, QWebHistoryItem item);

QList<SearchState*> tabs;
Expand Down

0 comments on commit 49c9b17

Please sign in to comment.