aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Noldor2011-03-13 12:20:32 +0000
committerGravatar Noldor2011-03-13 12:20:32 +0000
commitcba5b65658676e2817ef72bf2c6b66e42a801ca9 (patch)
tree2f1ab6a389bdfafd9e2ad41e684386a8b0a3d186 /src/modules
parentFix the webView preview painting (diff)
downloadKVIrc-cba5b65658676e2817ef72bf2c6b66e42a801ca9.tar.gz
KVIrc-cba5b65658676e2817ef72bf2c6b66e42a801ca9.tar.bz2
KVIrc-cba5b65658676e2817ef72bf2c6b66e42a801ca9.zip
Code improvements in help window when using webkit(wip)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5570 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/help/HelpIndex.cpp1
-rw-r--r--src/modules/help/HelpWidget.cpp132
-rw-r--r--src/modules/help/HelpWidget.h35
-rw-r--r--src/modules/help/HelpWindow.cpp29
-rw-r--r--src/modules/help/HelpWindow.h13
-rw-r--r--src/modules/help/libkvihelp.cpp14
6 files changed, 215 insertions, 9 deletions
diff --git a/src/modules/help/HelpIndex.cpp b/src/modules/help/HelpIndex.cpp
index 5d9ddc062..325d57bf6 100644
--- a/src/modules/help/HelpIndex.cpp
+++ b/src/modules/help/HelpIndex.cpp
@@ -264,6 +264,7 @@ void HelpIndex::parseDocument( const QString &filename, int docNum )
void HelpIndex::writeDict()
{
QFile f( dictFile );
+ qDebug ("Write dict to %s",f.fileName().toUtf8().data());
if ( !f.open(QFile::WriteOnly ) )
return;
QDataStream s( &f );
diff --git a/src/modules/help/HelpWidget.cpp b/src/modules/help/HelpWidget.cpp
index e7f5d53f3..8a90f66a8 100644
--- a/src/modules/help/HelpWidget.cpp
+++ b/src/modules/help/HelpWidget.cpp
@@ -43,10 +43,135 @@
extern HelpIndex * g_pDocIndex;
extern KviPointerList<HelpWindow> * g_pHelpWindowList;
extern KviPointerList<HelpWidget> * g_pHelpWidgetList;
+#ifdef COMPILE_WEBKIT_SUPPORT
+#include <QtWebKit/QWebView>
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;
+
+ m_pTextBrowser = new QWebView(this);
+ m_pLayout->addWidget(m_pTextBrowser);
+ QLabel *pHighlightLabel = new QLabel();
+ pHighlightLabel->setText(__tr2qs("Highlight: "));
+ m_pToolBar->addWidget(pHighlightLabel);
+
+
+ m_pFindText = new QLineEdit();
+ m_pToolBar->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_pBtnResetFind = new QToolButton();
+ m_pBtnResetFind->setIcon(*g_pIconManager->getImage("41"));
+ m_pToolBar->addWidget(m_pBtnResetFind);
+ connect(m_pBtnResetFind ,SIGNAL(clicked()),this,SLOT(slotResetFind()));
+
+
+ m_pBtnFindPrev = new QToolButton();
+ m_pBtnFindPrev->setIcon(*g_pIconManager->getImage("40"));
+ m_pToolBar->addWidget(m_pBtnFindPrev);
+ connect(m_pBtnFindPrev,SIGNAL(clicked()),this,SLOT(slotFindPrev()));
+
+ m_pBtnFindNext = new QToolButton();
+ m_pBtnFindNext->setIcon(*g_pIconManager->getImage("39"));
+ m_pToolBar->addWidget(m_pBtnFindNext);
+ connect(m_pBtnFindNext,SIGNAL(clicked()),this,SLOT(slotFindNext()));
+
+ m_pTextBrowser->setObjectName("text_browser");
+ m_pTextBrowser->setStyleSheet("QTextBrowser { background-color:white; color:black; }");
+
+ QLabel *pBrowsingLabel = new QLabel();
+ pBrowsingLabel->setText(__tr2qs("Browsing: "));
+ m_pToolBar->addWidget(pBrowsingLabel);
+
+ m_pBtnIndex = new QToolButton();
+ m_pBtnIndex->setIcon(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPINDEX));
+
+ connect(m_pBtnIndex,SIGNAL(clicked()),this,SLOT(showIndex()));
+ m_pToolBar->addWidget(m_pBtnIndex);
+
+ m_pToolBar->addAction(m_pTextBrowser->pageAction(QWebPage::Back));
+ m_pToolBar->addAction(m_pTextBrowser->pageAction(QWebPage::Forward));
+
+ m_pBtnZoomIn = new QToolButton();
+ m_pBtnZoomIn->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Plus)));
+ m_pToolBar->addWidget(m_pBtnZoomIn);
+
+ connect(m_pBtnZoomIn,SIGNAL(clicked()),this,SLOT(slotZoomIn()));
+
+ m_pBtnZoomOut = new QToolButton();
+ m_pBtnZoomOut->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Minus)));
+ m_pToolBar->addWidget(m_pBtnZoomOut);
+
+ connect(m_pBtnZoomOut,SIGNAL(clicked()),this,SLOT(slotZoomOut()));
+ if(bIsStandalone)
+ {
+ QToolButton * b = new QToolButton();
+ m_pToolBar->addWidget(b);
+ b->setIcon(*g_pIconManager->getBigIcon(KVI_BIGICON_HELPCLOSE));
+ connect(b,SIGNAL(clicked()),this,SLOT(doClose()));
+ }
+
+}
+
+void HelpWidget::slotLoadFinished(bool )
+{
+
+ m_pTextBrowser->findText(m_pFindText->text(),QWebPage::HighlightAllOccurrences);
+}
+void HelpWidget::slotTextChanged(const QString szFind)
+{
+ m_pTextBrowser->findText("",QWebPage::HighlightAllOccurrences);
+ m_pTextBrowser->findText(szFind,QWebPage::HighlightAllOccurrences);
+}
+
+void HelpWidget::slotResetFind()
+{
+ m_pFindText->setText("");
+ m_pTextBrowser->findText("",QWebPage::HighlightAllOccurrences);
+}
+
+void HelpWidget::slotFindPrev()
+{
+ m_pTextBrowser->findText(m_pFindText->text(),QWebPage::FindBackward);
+}
+
+void HelpWidget::slotFindNext()
+{
+ m_pTextBrowser->findText(m_pFindText->text());
+}
+void HelpWidget::slotZoomIn()
+{
+ kvs_real_t dZoom=m_pTextBrowser->zoomFactor();
+ if(dZoom>=2) return;
+ dZoom+= 0.05;
+ m_pTextBrowser->setZoomFactor(dZoom);
+}
+
+void HelpWidget::slotZoomOut()
+{
+ kvs_real_t dZoom=m_pTextBrowser->zoomFactor();
+ if(dZoom<=0.5) return;
+ dZoom-= 0.05;
+ m_pTextBrowser->setZoomFactor(dZoom);
+}
+#else
+HelpWidget::HelpWidget(QWidget * par,KviMainWindow *,bool bIsStandalone)
+: QWidget(par)
+{
setObjectName("help_widget");
setMinimumWidth(80);
if(bIsStandalone)g_pHelpWidgetList->append(this);
@@ -85,7 +210,7 @@ HelpWidget::HelpWidget(QWidget * par,KviMainWindow *,bool bIsStandalone)
connect(m_pTextBrowser,SIGNAL(backwardAvailable(bool)),m_pBtnBackward,SLOT(setEnabled(bool)));
connect(m_pTextBrowser,SIGNAL(forwardAvailable(bool)),m_pBtnForward,SLOT(setEnabled(bool)));
}
-
+#endif
HelpWidget::~HelpWidget()
{
if(m_bIsStandalone)g_pHelpWidgetList->removeRef(this);
@@ -98,8 +223,11 @@ void HelpWidget::showIndex()
g_pApp->getGlobalKvircDirectory(szHelpDir,KviApplication::Help);
dirHelp = QDir(szHelpDir);
-
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ m_pTextBrowser->load(QUrl::fromLocalFile(dirHelp.absoluteFilePath("index.html")));
+ #else
m_pTextBrowser->setSource(QUrl::fromLocalFile(dirHelp.absoluteFilePath("index.html")));
+ #endif
}
void HelpWidget::resizeEvent(QResizeEvent *)
diff --git a/src/modules/help/HelpWidget.h b/src/modules/help/HelpWidget.h
index e94225f17..dca1b0c7a 100644
--- a/src/modules/help/HelpWidget.h
+++ b/src/modules/help/HelpWidget.h
@@ -25,10 +25,16 @@
//=============================================================================
#include "HelpIndex.h"
+#include "kvi_settings.h"
+#ifdef COMPILE_WEBKIT_SUPPORT
+#include <QtWebKit/QWebView>
+#include <QToolBar>
+#include <QVBoxLayout>
+#else
#include "KviTalHBox.h"
-
#include <QTextBrowser>
+#endif
#include <QProgressBar>
class QToolButton;
@@ -43,11 +49,25 @@ public:
HelpWidget(QWidget *par,KviMainWindow * lpFrm,bool bIsStandalone = false);
~HelpWidget();
private:
+#ifdef COMPILE_WEBKIT_SUPPORT
+ QToolButton * m_pBtnIndex;
+ QToolButton * m_pBtnFindPrev;
+ QToolButton * m_pBtnFindNext;
+ QToolButton * m_pBtnResetFind;
+ QToolButton * m_pBtnZoomIn;
+ QToolButton * m_pBtnZoomOut;
+
+ QToolBar * m_pToolBar;
+ QLineEdit * m_pFindText;
+ QVBoxLayout *m_pLayout;
+ QWebView * m_pTextBrowser;
+#else
QToolButton * m_pBtnIndex;
QToolButton * m_pBtnBackward;
QToolButton * m_pBtnForward;
KviTalHBox * m_pToolBar;
QTextBrowser * m_pTextBrowser;
+#endif
bool m_bIsStandalone;
protected:
virtual void resizeEvent(QResizeEvent *e);
@@ -55,9 +75,22 @@ protected slots:
void doClose();
void showIndex();
void suicide();
+#ifdef COMPILE_WEBKIT_SUPPORT
+ void slotLoadFinished(bool ok);
+ void slotFindNext();
+ void slotFindPrev();
+ void slotResetFind();
+ void slotZoomIn();
+ void slotZoomOut();
+ void slotTextChanged(const QString);
+#endif
public:
virtual QSize sizeHint() const;
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ QWebView * textBrowser() { return m_pTextBrowser; }
+ #else
QTextBrowser * textBrowser() { return m_pTextBrowser; }
+#endif
};
diff --git a/src/modules/help/HelpWindow.cpp b/src/modules/help/HelpWindow.cpp
index 8adc29c70..21b5192d7 100644
--- a/src/modules/help/HelpWindow.cpp
+++ b/src/modules/help/HelpWindow.cpp
@@ -25,6 +25,7 @@
#include "HelpWindow.h"
#include "HelpWidget.h"
+#include "kvi_settings.h"
#include "KviApplication.h"
#include "KviIconManager.h"
#include "KviOptions.h"
@@ -46,7 +47,7 @@ extern HelpIndex * g_pDocIndex;
extern KviPointerList<HelpWindow> * g_pHelpWindowList;
extern KviPointerList<HelpWidget> * g_pHelpWidgetList;
-bool g_bIndexingDone = FALSE;
+//bool g_bIndexingDone = FALSE;
HelpWindow::HelpWindow(KviMainWindow * lpFrm,const char * name)
: KviWindow(KviWindow::Help,lpFrm,name)
{
@@ -117,9 +118,9 @@ void HelpWindow::initialSetup()
{
m_pIndexSearch->setFocus();
- if(!g_bIndexingDone)
+/* if(!g_bIndexingDone)
{
- g_bIndexingDone=TRUE;
+ g_bIndexingDone=true;*/
QString szDoclist,szDict;
g_pApp->getLocalKvircDirectory(szDoclist,KviApplication::Help,"help.doclist." KVI_SOURCES_DATE);
@@ -134,8 +135,9 @@ void HelpWindow::initialSetup()
m_pBtnRefreshIndex->setEnabled(true);
} else {
g_pDocIndex->makeIndex();
- }
- }
+
+ }
+ //}
}
void HelpWindow::indexingStart( int iNum )
@@ -258,7 +260,12 @@ void HelpWindow::startSearch()
setCursor( Qt::ArrowCursor );
}
+
+#ifdef COMPILE_WEBKIT_SUPPORT
+QWebView * HelpWindow::textBrowser()
+#else
QTextBrowser * HelpWindow::textBrowser()
+#endif
{
return m_pHelpWidget->textBrowser();
}
@@ -267,7 +274,11 @@ void HelpWindow::showIndexTopic()
{
if (m_pIndexSearch->text().isEmpty()|| !m_pIndexListWidget->selectedItems().count()) return;
int i=g_pDocIndex->titlesList().indexOf(m_pIndexListWidget->selectedItems().at(0)->text());
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ textBrowser()->load(QUrl(g_pDocIndex->documentList()[ i ]));
+ #else
textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ]));
+ #endif
}
void HelpWindow::searchInIndex( const QString &s )
@@ -291,14 +302,22 @@ void HelpWindow::indexSelected ( QListWidgetItem *item )
{
if (!item) return;
int i=g_pDocIndex->titlesList().indexOf(item->text());
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ textBrowser()->load(QUrl(g_pDocIndex->documentList()[ i ]));
+ #else
textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ]));
+ #endif
}
void HelpWindow::searchSelected ( QListWidgetItem *item )
{
if (!item) return;
int i=g_pDocIndex->titlesList().indexOf(item->text());
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ textBrowser()->load(QUrl(g_pDocIndex->documentList()[ i ]));
+ #else
textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ]));
+ #endif
}
QPixmap * HelpWindow::myIconPtr()
diff --git a/src/modules/help/HelpWindow.h b/src/modules/help/HelpWindow.h
index 94eacc347..ff5c1468f 100644
--- a/src/modules/help/HelpWindow.h
+++ b/src/modules/help/HelpWindow.h
@@ -28,13 +28,20 @@
#include "KviCString.h"
#include "KviTalVBox.h"
#include "KviTalListWidget.h"
+#include "kvi_settings.h"
#include <QTabWidget>
+#ifdef COMPILE_WEBKIT_SUPPORT
+#include <QtWebKit/QWebView>
+#else
+class QTextBrowser;
+#endif
+
#include <QLineEdit>
class QProgressBar;
class QPushButton;
-class QTextBrowser;
+
class HelpWidget;
class HelpWindow : public KviWindow
@@ -69,7 +76,11 @@ protected:
virtual void saveProperties(KviConfigurationFile * cfg);
virtual void loadProperties(KviConfigurationFile * cfg);
public:
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ QWebView * textBrowser();
+ #else
QTextBrowser * textBrowser();
+ #endif
public slots:
void indexSelected ( QListWidgetItem * );
void searchInIndex( const QString &s );
diff --git a/src/modules/help/libkvihelp.cpp b/src/modules/help/libkvihelp.cpp
index 039d4fbef..d276f4a39 100644
--- a/src/modules/help/libkvihelp.cpp
+++ b/src/modules/help/libkvihelp.cpp
@@ -181,21 +181,34 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c)
if(w)
{
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #else
w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #endif
return true;
}
}
if(c->switches()->find('m',"mdi"))
{
HelpWindow *w = new HelpWindow(c->window()->frame(),"Help browser");
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #else
w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #endif
c->window()->frame()->addWindow(w);
} else {
HelpWidget *w = new HelpWidget(c->window()->frame()->splitter(),
c->window()->frame(),true);
+ #ifdef COMPILE_WEBKIT_SUPPORT
+ w->textBrowser()->load(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #else
w->textBrowser()->setSource(QUrl::fromLocalFile(f.absoluteFilePath()));
+ #endif
w->show();
}
+#include <QtWebKit/QWebView>
return true;
}
@@ -221,6 +234,7 @@ static bool help_module_init(KviModule * m)
KVSM_REGISTER_SIMPLE_COMMAND(m,"open",help_kvs_cmd_open);
+
return true;
}