diff options
| author | 2011-07-21 08:05:46 +0000 | |
|---|---|---|
| committer | 2011-07-21 08:05:46 +0000 | |
| commit | 1155d94b85320f64f5d530e05213ab2cb3068017 (patch) | |
| tree | 8312c8a9ca570a834dc18b6fc7428f3336066952 /src/modules/help/HelpWidget.cpp | |
| parent | fix for a crash when closing action editor (diff) | |
| download | KVIrc-1155d94b85320f64f5d530e05213ab2cb3068017.tar.gz KVIrc-1155d94b85320f64f5d530e05213ab2cb3068017.tar.bz2 KVIrc-1155d94b85320f64f5d530e05213ab2cb3068017.zip | |
help: fixed #1178 (added ctrl+c shortcut); splitted the "highlight" toolbar from the "browsing" toolbar , now it'd hidden by default , toggle it with ctrl+f
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5904 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/help/HelpWidget.cpp')
| -rw-r--r-- | src/modules/help/HelpWidget.cpp | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/src/modules/help/HelpWidget.cpp b/src/modules/help/HelpWidget.cpp index 07e6d5a27..a9b1e6997 100644 --- a/src/modules/help/HelpWidget.cpp +++ b/src/modules/help/HelpWidget.cpp @@ -46,42 +46,56 @@ extern KviPointerList<HelpWidget> * g_pHelpWidgetList; #ifdef COMPILE_WEBKIT_SUPPORT #include <QtWebKit/QWebView> +#include <QShortcut> #define HIGHLIGHT_FLAGS QWebPage::HighlightAllOccurrences HelpWidget::HelpWidget(QWidget * par,KviMainWindow *,bool bIsStandalone) : QWidget(par) { - m_pLayout = new QVBoxLayout(this); - m_pLayout->setMargin(3); - m_pLayout->setSpacing(2); - setLayout(m_pLayout); - m_pToolBar = new QToolBar(this); - m_pLayout->addWidget(m_pToolBar); setObjectName("help_widget"); setMinimumWidth(80); if(bIsStandalone)g_pHelpWidgetList->append(this); m_bIsStandalone = bIsStandalone; + new QShortcut(QKeySequence::Copy,this,SLOT(slotCopy()),0,Qt::WidgetWithChildrenShortcut); + new QShortcut(QKeySequence::Find,this,SLOT(slotShowHideFind()),0, bIsStandalone ? Qt::WidgetWithChildrenShortcut : Qt::WindowShortcut); + + // layout + m_pLayout = new QVBoxLayout(this); + m_pLayout->setMargin(0); + m_pLayout->setSpacing(0); + setLayout(m_pLayout); + + // upper toolbar + m_pToolBar = new QToolBar(this); + m_pLayout->addWidget(m_pToolBar); + + // webview m_pTextBrowser = new QWebView(this); + m_pTextBrowser->setObjectName("text_browser"); + m_pTextBrowser->setStyleSheet("QTextBrowser { background-color:white; color:black; }"); m_pLayout->addWidget(m_pTextBrowser); + connect(m_pTextBrowser,SIGNAL(loadFinished(bool)),this,SLOT(slotLoadFinished(bool))); + + // lower toolbar + m_pToolBarHighlight = new QToolBar(this); + m_pLayout->addWidget(m_pToolBarHighlight); + m_pToolBarHighlight->hide(); + QLabel *pHighlightLabel = new QLabel(); pHighlightLabel->setText(__tr2qs("Highlight: ")); - m_pToolBar->addWidget(pHighlightLabel); + m_pToolBarHighlight->addWidget(pHighlightLabel); m_pFindText = new QLineEdit(); - m_pToolBar->addWidget(m_pFindText); + m_pToolBarHighlight->addWidget(m_pFindText); connect(m_pFindText,SIGNAL(textChanged(const QString )),this,SLOT(slotTextChanged(const QString))); - connect(m_pTextBrowser,SIGNAL(loadFinished(bool)),this,SLOT(slotLoadFinished(bool))); - - m_pToolBar->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Unrecognized), __tr2qs("Reset"), this, SLOT(slotResetFind())); - m_pToolBar->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Part), __tr2qs("Find previous"), this, SLOT(slotFindPrev())); - m_pToolBar->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Join), __tr2qs("Find next"), this, SLOT(slotFindNext())); - - m_pTextBrowser->setObjectName("text_browser"); - m_pTextBrowser->setStyleSheet("QTextBrowser { background-color:white; color:black; }"); + m_pToolBarHighlight->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Unrecognized), __tr2qs("Reset"), this, SLOT(slotResetFind())); + m_pToolBarHighlight->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Part), __tr2qs("Find previous"), this, SLOT(slotFindPrev())); + m_pToolBarHighlight->addAction(*g_pIconManager->getSmallIcon(KviIconManager::Join), __tr2qs("Find next"), this, SLOT(slotFindNext())); + // upper toolbar contents (depends on webview) QLabel *pBrowsingLabel = new QLabel(); pBrowsingLabel->setText(__tr2qs("Browsing: ")); m_pToolBar->addWidget(pBrowsingLabel); @@ -102,6 +116,22 @@ HelpWidget::HelpWidget(QWidget * par,KviMainWindow *,bool bIsStandalone) } +void HelpWidget::slotCopy() +{ + m_pTextBrowser->triggerPageAction(QWebPage::Copy); +} + +void HelpWidget::slotShowHideFind() +{ + if(m_pToolBarHighlight->isVisible()) + { + m_pToolBarHighlight->hide(); + } else { + m_pToolBarHighlight->show(); + m_pFindText->setFocus(); + } +} + void HelpWidget::slotLoadFinished(bool ) { m_pTextBrowser->findText(m_pFindText->text(),HIGHLIGHT_FLAGS); |
