void HistoryManager::createContextMenu(const QPoint &pos) { QMenu menu; QAction* actNewTab = menu.addAction(IconProvider::newTabIcon(), tr("Open in new tab")); QAction* actNewWindow = menu.addAction(IconProvider::newWindowIcon(), tr("Open in new window")); QAction* actNewPrivateWindow = menu.addAction(IconProvider::privateBrowsingIcon(), tr("Open in new private window")); menu.addSeparator(); QAction* actCopyUrl = menu.addAction(tr("Copy url"), this, SLOT(copyUrl())); QAction* actCopyTitle = menu.addAction(tr("Copy title"), this, SLOT(copyTitle())); menu.addSeparator(); QAction* actDelete = menu.addAction(QIcon::fromTheme(QSL("edit-delete")), tr("Delete")); connect(actNewTab, SIGNAL(triggered()), this, SLOT(openUrlInNewTab())); connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openUrlInNewWindow())); connect(actNewPrivateWindow, SIGNAL(triggered()), this, SLOT(openUrlInNewPrivateWindow())); connect(actDelete, SIGNAL(triggered()), ui->historyTree, SLOT(removeSelectedItems())); if (ui->historyTree->selectedUrl().isEmpty()) { actNewTab->setDisabled(true); actNewWindow->setDisabled(true); actNewPrivateWindow->setDisabled(true); actCopyTitle->setDisabled(true); actCopyUrl->setDisabled(true); } menu.exec(pos); }
KonqHistoryDialog::KonqHistoryDialog(KonqMainWindow *parent) : KDialog(parent), m_mainWindow(parent) { setCaption(i18nc("@title:window", "History")); setButtons(KDialog::Close); QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget()); mainLayout->setMargin(0); m_historyView = new KonqHistoryView(mainWidget()); connect(m_historyView->treeView(), SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotOpenWindowForIndex(QModelIndex))); connect(m_historyView, SIGNAL(openUrlInNewWindow(KUrl)), this, SLOT(slotOpenWindow(KUrl))); connect(m_historyView, SIGNAL(openUrlInNewTab(KUrl)), this, SLOT(slotOpenTab(KUrl))); KActionCollection* collection = m_historyView->actionCollection(); QToolBar *toolBar = new QToolBar(mainWidget()); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QToolButton *sortButton = new QToolButton(toolBar); sortButton->setText(i18nc("@action:inmenu Parent of 'By Name' and 'By Date'", "Sort")); sortButton->setIcon(KIcon("view-sort-ascending")); sortButton->setPopupMode(QToolButton::InstantPopup); sortButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QMenu *sortMenu = new QMenu(sortButton); sortMenu->addAction(collection->action("byName")); sortMenu->addAction(collection->action("byDate")); sortButton->setMenu(sortMenu); toolBar->addWidget(sortButton); toolBar->addSeparator(); toolBar->addAction(collection->action("preferences")); mainLayout->addWidget(toolBar); mainLayout->addWidget(m_historyView); restoreDialogSize(KGlobal::config()->group("History Dialog")); // give focus to the search line edit when opening the dialog (#240513) m_historyView->lineEdit()->setFocus(); }
void HistoryManager::urlShiftActivated(const QUrl &url) { openUrlInNewWindow(url); }