mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Add help system
This commit is contained in:
parent
ec0db9bfee
commit
d4c68d3c49
26
config.cc
26
config.cc
|
@ -122,6 +122,7 @@ Preferences::Preferences():
|
||||||
enableWebPlugins( false ),
|
enableWebPlugins( false ),
|
||||||
hideGoldenDictHeader( false ),
|
hideGoldenDictHeader( false ),
|
||||||
zoomFactor( 1 ),
|
zoomFactor( 1 ),
|
||||||
|
helpZoomFactor( 1 ),
|
||||||
wordsZoomLevel( 0 ),
|
wordsZoomLevel( 0 ),
|
||||||
maxStringsInHistory( 500 ),
|
maxStringsInHistory( 500 ),
|
||||||
storeHistory( 1 ),
|
storeHistory( 1 ),
|
||||||
|
@ -707,6 +708,9 @@ Class load() throw( exError )
|
||||||
if ( !preferences.namedItem( "zoomFactor" ).isNull() )
|
if ( !preferences.namedItem( "zoomFactor" ).isNull() )
|
||||||
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
|
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
|
||||||
|
|
||||||
|
if ( !preferences.namedItem( "helpZoomFactor" ).isNull() )
|
||||||
|
c.preferences.helpZoomFactor = preferences.namedItem( "helpZoomFactor" ).toElement().text().toDouble();
|
||||||
|
|
||||||
if ( !preferences.namedItem( "wordsZoomLevel" ).isNull() )
|
if ( !preferences.namedItem( "wordsZoomLevel" ).isNull() )
|
||||||
c.preferences.wordsZoomLevel = preferences.namedItem( "wordsZoomLevel" ).toElement().text().toInt();
|
c.preferences.wordsZoomLevel = preferences.namedItem( "wordsZoomLevel" ).toElement().text().toInt();
|
||||||
|
|
||||||
|
@ -866,6 +870,16 @@ Class load() throw( exError )
|
||||||
if ( !mainWindowGeometry.isNull() )
|
if ( !mainWindowGeometry.isNull() )
|
||||||
c.mainWindowGeometry = QByteArray::fromBase64( mainWindowGeometry.toElement().text().toLatin1() );
|
c.mainWindowGeometry = QByteArray::fromBase64( mainWindowGeometry.toElement().text().toLatin1() );
|
||||||
|
|
||||||
|
QDomNode helpWindowGeometry = root.namedItem( "helpWindowGeometry" );
|
||||||
|
|
||||||
|
if ( !helpWindowGeometry.isNull() )
|
||||||
|
c.helpWindowGeometry = QByteArray::fromBase64( helpWindowGeometry.toElement().text().toLatin1() );
|
||||||
|
|
||||||
|
QDomNode helpSplitterState = root.namedItem( "helpSplitterState" );
|
||||||
|
|
||||||
|
if ( !helpSplitterState.isNull() )
|
||||||
|
c.helpSplitterState = QByteArray::fromBase64( helpSplitterState.toElement().text().toLatin1() );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QDomNode maximizedMainWindowGeometry = root.namedItem( "maximizedMainWindowGeometry" );
|
QDomNode maximizedMainWindowGeometry = root.namedItem( "maximizedMainWindowGeometry" );
|
||||||
|
|
||||||
|
@ -1480,6 +1494,10 @@ void save( Class const & c ) throw( exError )
|
||||||
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "helpZoomFactor" );
|
||||||
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.helpZoomFactor ) ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
opt = dd.createElement( "wordsZoomLevel" );
|
opt = dd.createElement( "wordsZoomLevel" );
|
||||||
opt.appendChild( dd.createTextNode( QString::number( c.preferences.wordsZoomLevel ) ) );
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.wordsZoomLevel ) ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
@ -1738,6 +1756,14 @@ void save( Class const & c ) throw( exError )
|
||||||
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowGeometry.toBase64() ) ) );
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowGeometry.toBase64() ) ) );
|
||||||
root.appendChild( opt );
|
root.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "helpWindowGeometry" );
|
||||||
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.helpWindowGeometry.toBase64() ) ) );
|
||||||
|
root.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "helpSplitterState" );
|
||||||
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.helpSplitterState.toBase64() ) ) );
|
||||||
|
root.appendChild( opt );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
{
|
{
|
||||||
QDomElement maximizedMainWindowGeometry = dd.createElement( "maximizedMainWindowGeometry" );
|
QDomElement maximizedMainWindowGeometry = dd.createElement( "maximizedMainWindowGeometry" );
|
||||||
|
|
|
@ -225,6 +225,7 @@ struct Preferences
|
||||||
bool hideGoldenDictHeader;
|
bool hideGoldenDictHeader;
|
||||||
|
|
||||||
qreal zoomFactor;
|
qreal zoomFactor;
|
||||||
|
qreal helpZoomFactor;
|
||||||
int wordsZoomLevel;
|
int wordsZoomLevel;
|
||||||
|
|
||||||
unsigned maxStringsInHistory;
|
unsigned maxStringsInHistory;
|
||||||
|
@ -520,6 +521,8 @@ struct Class
|
||||||
QByteArray popupWindowGeometry; // Geometry saved by QMainWindow
|
QByteArray popupWindowGeometry; // Geometry saved by QMainWindow
|
||||||
QByteArray dictInfoGeometry; // Geometry of "Dictionary info" window
|
QByteArray dictInfoGeometry; // Geometry of "Dictionary info" window
|
||||||
QByteArray inspectorGeometry; // Geometry of WebKit inspector window
|
QByteArray inspectorGeometry; // Geometry of WebKit inspector window
|
||||||
|
QByteArray helpWindowGeometry; // Geometry of help window
|
||||||
|
QByteArray helpSplitterState; // Geometry of help splitter
|
||||||
|
|
||||||
QString historyExportPath; // Path for export/import history
|
QString historyExportPath; // Path for export/import history
|
||||||
QString resourceSavePath; // Path to save images/audio
|
QString resourceSavePath; // Path to save images/audio
|
||||||
|
|
|
@ -20,9 +20,11 @@ QT += webkit
|
||||||
QT += xml
|
QT += xml
|
||||||
QT += network
|
QT += network
|
||||||
QT += svg
|
QT += svg
|
||||||
|
QT += sql
|
||||||
CONFIG += exceptions \
|
CONFIG += exceptions \
|
||||||
rtti \
|
rtti \
|
||||||
stl
|
stl \
|
||||||
|
help
|
||||||
OBJECTS_DIR = build
|
OBJECTS_DIR = build
|
||||||
UI_DIR = build
|
UI_DIR = build
|
||||||
MOC_DIR = build
|
MOC_DIR = build
|
||||||
|
@ -139,6 +141,9 @@ unix:!mac {
|
||||||
desktops.path = $$PREFIX/share/applications
|
desktops.path = $$PREFIX/share/applications
|
||||||
desktops.files = redist/*.desktop
|
desktops.files = redist/*.desktop
|
||||||
INSTALLS += desktops
|
INSTALLS += desktops
|
||||||
|
helps.path = $$PREFIX/share/goldendict/help/
|
||||||
|
helps.files = help/*.qch
|
||||||
|
INSTALLS += helps
|
||||||
}
|
}
|
||||||
mac {
|
mac {
|
||||||
TARGET = GoldenDict
|
TARGET = GoldenDict
|
||||||
|
@ -171,7 +176,9 @@ mac {
|
||||||
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \
|
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \
|
||||||
cp -nR $${PWD}/maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \
|
cp -nR $${PWD}/maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \
|
||||||
mkdir -p GoldenDict.app/Contents/MacOS/locale & \
|
mkdir -p GoldenDict.app/Contents/MacOS/locale & \
|
||||||
cp -R locale/*.qm GoldenDict.app/Contents/MacOS/locale/
|
cp -R locale/*.qm GoldenDict.app/Contents/MacOS/locale/ & \
|
||||||
|
mkdir -p GoldenDict.app/Contents/MacOS/help & \
|
||||||
|
cp -R help/*.qch GoldenDict.app/Contents/MacOS/help/
|
||||||
|
|
||||||
CONFIG += zim_support
|
CONFIG += zim_support
|
||||||
}
|
}
|
||||||
|
@ -285,7 +292,8 @@ HEADERS += folding.hh \
|
||||||
dictheadwords.hh \
|
dictheadwords.hh \
|
||||||
fulltextsearch.hh \
|
fulltextsearch.hh \
|
||||||
ftshelpers.hh \
|
ftshelpers.hh \
|
||||||
dictserver.hh
|
dictserver.hh \
|
||||||
|
helpwindow.hh
|
||||||
|
|
||||||
FORMS += groups.ui \
|
FORMS += groups.ui \
|
||||||
dictgroupwidget.ui \
|
dictgroupwidget.ui \
|
||||||
|
@ -405,7 +413,8 @@ SOURCES += folding.cc \
|
||||||
dictheadwords.cc \
|
dictheadwords.cc \
|
||||||
fulltextsearch.cc \
|
fulltextsearch.cc \
|
||||||
ftshelpers.cc \
|
ftshelpers.cc \
|
||||||
dictserver.cc
|
dictserver.cc \
|
||||||
|
helpwindow.cc
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
FORMS += texttospeechsource.ui
|
FORMS += texttospeechsource.ui
|
||||||
|
|
BIN
help/gdhelp_en.qch
Normal file
BIN
help/gdhelp_en.qch
Normal file
Binary file not shown.
BIN
help/gdhelp_ru.qch
Normal file
BIN
help/gdhelp_ru.qch
Normal file
Binary file not shown.
252
helpwindow.cc
Normal file
252
helpwindow.cc
Normal file
|
@ -0,0 +1,252 @@
|
||||||
|
/* This file is (c) 2014 Abs62
|
||||||
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QHelpContentWidget>
|
||||||
|
#include <QHelpIndexWidget>
|
||||||
|
#include <QLayout>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
#include "helpwindow.hh"
|
||||||
|
#include "gddebug.hh"
|
||||||
|
|
||||||
|
namespace Help {
|
||||||
|
|
||||||
|
HelpBrowser::HelpBrowser( QHelpEngineCore * engine, QWidget *parent ) :
|
||||||
|
QTextBrowser( parent ),
|
||||||
|
helpEngine( engine )
|
||||||
|
{
|
||||||
|
connect( this, SIGNAL( anchorClicked( QUrl ) ), this, SLOT( linkClicked( QUrl ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpBrowser::showHelpForKeyword( QString const & id )
|
||||||
|
{
|
||||||
|
if ( helpEngine )
|
||||||
|
{
|
||||||
|
QMap< QString, QUrl > links = helpEngine->linksForIdentifier( id );
|
||||||
|
if( !links.isEmpty() )
|
||||||
|
setSource( links.constBegin().value() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant HelpBrowser::loadResource( int type, QUrl const & name )
|
||||||
|
{
|
||||||
|
QByteArray ba;
|
||||||
|
if( type < 4 && helpEngine )
|
||||||
|
{
|
||||||
|
QUrl url(name);
|
||||||
|
if( name.isRelative() )
|
||||||
|
url = source().resolved( url );
|
||||||
|
|
||||||
|
ba = helpEngine->fileData(url );
|
||||||
|
}
|
||||||
|
return ba;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpBrowser::linkClicked( QUrl const & url )
|
||||||
|
{
|
||||||
|
if( url.scheme() == "http" || url.scheme() == "https" )
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl( url );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setSource( url );
|
||||||
|
}
|
||||||
|
|
||||||
|
HelpWindow::HelpWindow( QWidget * parent, Config::Class & cfg_ ) :
|
||||||
|
QDialog( parent ),
|
||||||
|
cfg( cfg_ ),
|
||||||
|
helpEngine( 0 )
|
||||||
|
{
|
||||||
|
resize( QSize( 600, 450 ) );
|
||||||
|
setWindowTitle( tr( "GoldenDict help" ) );
|
||||||
|
setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
|
||||||
|
|
||||||
|
QVBoxLayout * mainLayout = new QVBoxLayout( this );
|
||||||
|
setLayout( mainLayout );
|
||||||
|
|
||||||
|
navToolBar = new QToolBar( this );
|
||||||
|
navHome = navToolBar->addAction( QIcon( ":/icons/home.png" ), tr( "Home" ) );
|
||||||
|
navToolBar->widgetForAction( navHome )->setObjectName( "helpHomeButton" );
|
||||||
|
navBack = navToolBar->addAction( QIcon( ":/icons/previous.png" ), tr( "Back" ) );
|
||||||
|
navToolBar->widgetForAction( navBack )->setObjectName( "helpBackButton" );
|
||||||
|
navForward = navToolBar->addAction( QIcon( ":/icons/next.png" ), tr( "Forward" ) );
|
||||||
|
navToolBar->widgetForAction( navForward )->setObjectName( "helpForwardButton" );
|
||||||
|
|
||||||
|
navToolBar->addSeparator();
|
||||||
|
|
||||||
|
zoomInAction = navToolBar->addAction( QIcon( ":/icons/icon32_zoomin" ), tr( "Zoom In" ) );
|
||||||
|
navToolBar->widgetForAction( zoomInAction )->setObjectName( "zoomInButton" );
|
||||||
|
zoomOutAction = navToolBar->addAction( QIcon( ":/icons/icon32_zoomout" ), tr( "Zoom Out" ) );
|
||||||
|
navToolBar->widgetForAction( zoomInAction )->setObjectName( "zoomOutButton" );
|
||||||
|
zoomBaseAction = navToolBar->addAction( QIcon( ":/icons/icon32_zoombase" ), tr( "Normal Size" ) );
|
||||||
|
navToolBar->widgetForAction( zoomBaseAction )->setObjectName( "zoomBaseButton" );
|
||||||
|
|
||||||
|
navForward->setEnabled( false );
|
||||||
|
navBack->setEnabled( false );
|
||||||
|
|
||||||
|
mainLayout->addWidget( navToolBar );
|
||||||
|
|
||||||
|
QString localeName = cfg.preferences.interfaceLanguage;
|
||||||
|
if( localeName.isEmpty() )
|
||||||
|
localeName = QLocale::system().name();
|
||||||
|
|
||||||
|
helpFile = QDir::toNativeSeparators( Config::getProgramDataDir() + "/help/gdhelp_"
|
||||||
|
+ localeName.left( 2 ) + ".qch" );
|
||||||
|
|
||||||
|
if( !QFileInfo( helpFile ).isFile() )
|
||||||
|
helpFile = QDir::toNativeSeparators( Config::getProgramDataDir() + "/help/gdhelp_en.qch" );
|
||||||
|
|
||||||
|
helpCollectionFile = QDir::toNativeSeparators( Config::getConfigDir() + "gdhelp.qhc" );
|
||||||
|
|
||||||
|
helpEngine = new QHelpEngine( helpCollectionFile );
|
||||||
|
|
||||||
|
if( !helpEngine->setupData() )
|
||||||
|
{
|
||||||
|
gdWarning( "Help engine initialization error: %s", helpEngine->error().toUtf8().data() );
|
||||||
|
delete helpEngine;
|
||||||
|
helpEngine = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( !helpEngine->registerDocumentation( helpFile ) )
|
||||||
|
{
|
||||||
|
gdWarning( "Help engine set file error: %s", helpEngine->error().toUtf8().data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
tabWidget = new QTabWidget( this );
|
||||||
|
tabWidget->addTab( helpEngine->contentWidget(), tr( "Content" ) );
|
||||||
|
tabWidget->addTab( helpEngine->indexWidget(), tr( "Index" ) );
|
||||||
|
|
||||||
|
helpBrowser = new HelpBrowser( helpEngine, this );
|
||||||
|
|
||||||
|
helpBrowser->setOpenLinks( false );
|
||||||
|
|
||||||
|
connect( helpEngine->contentWidget(), SIGNAL( linkActivated( QUrl ) ),
|
||||||
|
helpBrowser, SLOT( setSource( QUrl ) ) );
|
||||||
|
connect( helpEngine->indexWidget(), SIGNAL( linkActivated( QUrl, QString ) ),
|
||||||
|
helpBrowser, SLOT( setSource( QUrl ) ) );
|
||||||
|
|
||||||
|
connect( navHome, SIGNAL( triggered() ), helpBrowser, SLOT( home() ) );
|
||||||
|
connect( navForward, SIGNAL( triggered() ), helpBrowser, SLOT( forward() ) );
|
||||||
|
connect( navBack, SIGNAL( triggered() ), helpBrowser, SLOT( backward() ) );
|
||||||
|
|
||||||
|
connect( helpBrowser, SIGNAL( forwardAvailable( bool ) ),
|
||||||
|
this, SLOT( forwardEnabled( bool ) ) );
|
||||||
|
|
||||||
|
connect( helpBrowser, SIGNAL( backwardAvailable( bool ) ),
|
||||||
|
this, SLOT( backwardEnabled( bool ) ) );
|
||||||
|
|
||||||
|
connect( helpEngine->contentWidget(), SIGNAL( clicked( QModelIndex ) ),
|
||||||
|
this, SLOT( contentsItemClicked( QModelIndex ) ) );
|
||||||
|
|
||||||
|
connect( zoomInAction, SIGNAL( triggered( ) ), this, SLOT( zoomIn() ) );
|
||||||
|
connect( zoomOutAction, SIGNAL( triggered( ) ), this, SLOT( zoomOut() ) );
|
||||||
|
connect( zoomBaseAction, SIGNAL( triggered( ) ), this, SLOT( zoomBase() ) );
|
||||||
|
|
||||||
|
splitter = new QSplitter( this );
|
||||||
|
splitter->addWidget( tabWidget );
|
||||||
|
splitter->addWidget( helpBrowser );
|
||||||
|
|
||||||
|
splitter->setStretchFactor( 0, 1 );
|
||||||
|
splitter->setStretchFactor( 1, 4 );
|
||||||
|
mainLayout->addWidget( splitter );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !cfg.helpWindowGeometry.isEmpty() )
|
||||||
|
restoreGeometry( cfg.helpWindowGeometry );
|
||||||
|
if( !cfg.helpSplitterState.isEmpty() )
|
||||||
|
splitter->restoreState( cfg.helpSplitterState );
|
||||||
|
|
||||||
|
QFont f = helpBrowser->font();
|
||||||
|
fontSize = f.pointSize();
|
||||||
|
if( fontSize < 10 )
|
||||||
|
{
|
||||||
|
fontSize = 10;
|
||||||
|
f.setPointSize( fontSize );
|
||||||
|
helpBrowser->setFont( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
applyZoomFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
HelpWindow::~HelpWindow()
|
||||||
|
{
|
||||||
|
if( helpEngine )
|
||||||
|
delete helpEngine;
|
||||||
|
|
||||||
|
QFile f( helpCollectionFile );
|
||||||
|
f.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::reject()
|
||||||
|
{
|
||||||
|
cfg.helpWindowGeometry = saveGeometry();
|
||||||
|
cfg.helpSplitterState = splitter->saveState();
|
||||||
|
emit needClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::accept()
|
||||||
|
{
|
||||||
|
cfg.helpWindowGeometry = saveGeometry();
|
||||||
|
cfg.helpSplitterState = splitter->saveState();
|
||||||
|
emit needClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::forwardEnabled( bool enabled )
|
||||||
|
{
|
||||||
|
navForward->setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::backwardEnabled( bool enabled )
|
||||||
|
{
|
||||||
|
navBack->setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::contentsItemClicked( QModelIndex const & index )
|
||||||
|
{
|
||||||
|
QHelpContentItem * item = helpEngine->contentModel()->contentItemAt( index );
|
||||||
|
if( !item->url().isEmpty() )
|
||||||
|
helpBrowser->setSource( item->url() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::zoomIn()
|
||||||
|
{
|
||||||
|
cfg.preferences.helpZoomFactor += 0.2;
|
||||||
|
applyZoomFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::zoomOut()
|
||||||
|
{
|
||||||
|
cfg.preferences.helpZoomFactor -= 0.2;
|
||||||
|
applyZoomFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::zoomBase()
|
||||||
|
{
|
||||||
|
cfg.preferences.helpZoomFactor = 1;
|
||||||
|
applyZoomFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWindow::applyZoomFactor()
|
||||||
|
{
|
||||||
|
if ( cfg.preferences.helpZoomFactor >= 5 )
|
||||||
|
cfg.preferences.helpZoomFactor = 5;
|
||||||
|
else if ( cfg.preferences.helpZoomFactor <= 0.2 )
|
||||||
|
cfg.preferences.helpZoomFactor = 0.2;
|
||||||
|
|
||||||
|
zoomInAction->setEnabled( cfg.preferences.helpZoomFactor < 5 );
|
||||||
|
zoomOutAction->setEnabled( cfg.preferences.helpZoomFactor > 0.2 );
|
||||||
|
zoomBaseAction->setEnabled( cfg.preferences.helpZoomFactor != 1.0 );
|
||||||
|
|
||||||
|
if( fontSize > 0 )
|
||||||
|
{
|
||||||
|
QFont f = helpBrowser->font();
|
||||||
|
f.setPointSize( fontSize * cfg.preferences.helpZoomFactor );
|
||||||
|
helpBrowser->setFont( f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Help
|
77
helpwindow.hh
Normal file
77
helpwindow.hh
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#ifndef __HELPWINDOW_HH_INCLUDED__
|
||||||
|
#define __HELPWINDOW_HH_INCLUDED__
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QtHelp/QHelpEngine>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextBrowser>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QSplitter>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#include "config.hh"
|
||||||
|
|
||||||
|
namespace Help {
|
||||||
|
|
||||||
|
class HelpBrowser : public QTextBrowser
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
HelpBrowser( QHelpEngineCore * engine, QWidget *parent );
|
||||||
|
void showHelpForKeyword( QString const & id );
|
||||||
|
private:
|
||||||
|
QVariant loadResource( int type, QUrl const & name );
|
||||||
|
QHelpEngineCore * helpEngine;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void linkClicked( QUrl const & url );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HelpWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Config::Class & cfg;
|
||||||
|
QToolBar * navToolBar;
|
||||||
|
QHelpEngine * helpEngine;
|
||||||
|
QTabWidget * tabWidget;
|
||||||
|
HelpBrowser * helpBrowser;
|
||||||
|
QAction * navForward, * navBack, * navHome;
|
||||||
|
QAction * zoomInAction, * zoomOutAction, * zoomBaseAction;
|
||||||
|
QSplitter * splitter;
|
||||||
|
|
||||||
|
QString helpFile, helpCollectionFile;
|
||||||
|
|
||||||
|
int fontSize;
|
||||||
|
|
||||||
|
void applyZoomFactor();
|
||||||
|
|
||||||
|
public:
|
||||||
|
HelpWindow( QWidget * parent, Config::Class & cfg_ );
|
||||||
|
~HelpWindow();
|
||||||
|
|
||||||
|
QHelpEngine const * getHelpEngine()
|
||||||
|
{ return helpEngine; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void reject();
|
||||||
|
virtual void accept();
|
||||||
|
void forwardEnabled( bool enabled );
|
||||||
|
void backwardEnabled( bool enabled );
|
||||||
|
void contentsItemClicked( QModelIndex const & index );
|
||||||
|
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
|
void zoomBase();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void needClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Help
|
||||||
|
|
||||||
|
#endif // __HELPWINDOW_HH_INCLUDED__
|
BIN
icons/home.png
Normal file
BIN
icons/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -116,6 +116,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
, headwordsDlg( 0 )
|
, headwordsDlg( 0 )
|
||||||
, ftsIndexing( dictionaries )
|
, ftsIndexing( dictionaries )
|
||||||
, ftsDlg( 0 )
|
, ftsDlg( 0 )
|
||||||
|
, helpWindow( 0 )
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
, gdAskMessage( 0xFFFFFFFF )
|
, gdAskMessage( 0xFFFFFFFF )
|
||||||
#endif
|
#endif
|
||||||
|
@ -610,6 +611,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
this, SLOT( openConfigFolder() ) );
|
this, SLOT( openConfigFolder() ) );
|
||||||
connect( ui.about, SIGNAL( triggered() ),
|
connect( ui.about, SIGNAL( triggered() ),
|
||||||
this, SLOT( showAbout() ) );
|
this, SLOT( showAbout() ) );
|
||||||
|
connect( ui.showReference, SIGNAL( triggered() ),
|
||||||
|
this, SLOT( showGDHelp() ) );
|
||||||
|
|
||||||
connect( groupListInDock, SIGNAL( currentIndexChanged( QString const & ) ),
|
connect( groupListInDock, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||||
this, SLOT( currentGroupChanged( QString const & ) ) );
|
this, SLOT( currentGroupChanged( QString const & ) ) );
|
||||||
|
@ -1900,6 +1903,7 @@ void MainWindow::editPreferences()
|
||||||
|
|
||||||
// These parameters are not set in dialog
|
// These parameters are not set in dialog
|
||||||
p.zoomFactor = cfg.preferences.zoomFactor;
|
p.zoomFactor = cfg.preferences.zoomFactor;
|
||||||
|
p.helpZoomFactor = cfg.preferences.helpZoomFactor;
|
||||||
p.wordsZoomLevel = cfg.preferences.wordsZoomLevel;
|
p.wordsZoomLevel = cfg.preferences.wordsZoomLevel;
|
||||||
p.hideMenubar = cfg.preferences.hideMenubar;
|
p.hideMenubar = cfg.preferences.hideMenubar;
|
||||||
p.searchInDock = cfg.preferences.searchInDock;
|
p.searchInDock = cfg.preferences.searchInDock;
|
||||||
|
@ -2702,6 +2706,9 @@ void MainWindow::toggleMainWindow( bool onlyShow )
|
||||||
|
|
||||||
if( ftsDlg )
|
if( ftsDlg )
|
||||||
ftsDlg->hide();
|
ftsDlg->hide();
|
||||||
|
|
||||||
|
if( helpWindow )
|
||||||
|
helpWindow->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( shown )
|
if ( shown )
|
||||||
|
@ -4039,6 +4046,29 @@ void MainWindow::closeFullTextSearchDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::showGDHelp()
|
||||||
|
{
|
||||||
|
if( !helpWindow )
|
||||||
|
helpWindow = new Help::HelpWindow( this, cfg );
|
||||||
|
|
||||||
|
if( helpWindow->getHelpEngine() )
|
||||||
|
{
|
||||||
|
connect( helpWindow, SIGNAL( needClose() ), this, SLOT( hideGDHelp() ) );
|
||||||
|
helpWindow->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete helpWindow;
|
||||||
|
helpWindow = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::hideGDHelp()
|
||||||
|
{
|
||||||
|
if( helpWindow )
|
||||||
|
helpWindow->hide();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
|
||||||
bool MainWindow::handleGDMessage( MSG * message, long * result )
|
bool MainWindow::handleGDMessage( MSG * message, long * result )
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "wordlist.hh"
|
#include "wordlist.hh"
|
||||||
#include "dictheadwords.hh"
|
#include "dictheadwords.hh"
|
||||||
#include "fulltextsearch.hh"
|
#include "fulltextsearch.hh"
|
||||||
|
#include "helpwindow.hh"
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <fixx11h.h>
|
#include <fixx11h.h>
|
||||||
|
@ -168,6 +169,8 @@ private:
|
||||||
|
|
||||||
FTS::FullTextSearchDialog * ftsDlg;
|
FTS::FullTextSearchDialog * ftsDlg;
|
||||||
|
|
||||||
|
Help::HelpWindow * helpWindow;
|
||||||
|
|
||||||
/// Applies the qt's stylesheet, given the style's name.
|
/// Applies the qt's stylesheet, given the style's name.
|
||||||
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle );
|
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle );
|
||||||
|
|
||||||
|
@ -427,6 +430,9 @@ private slots:
|
||||||
void showFullTextSearchDialog();
|
void showFullTextSearchDialog();
|
||||||
void closeFullTextSearchDialog();
|
void closeFullTextSearchDialog();
|
||||||
|
|
||||||
|
void showGDHelp();
|
||||||
|
void hideGDHelp();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Set optional parts expand mode for all tabs
|
/// Set optional parts expand mode for all tabs
|
||||||
void setExpandOptionalParts( bool expand );
|
void setExpandOptionalParts( bool expand );
|
||||||
|
|
|
@ -101,6 +101,8 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Help</string>
|
<string>&Help</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="showReference"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="visitHomepage"/>
|
<addaction name="visitHomepage"/>
|
||||||
<addaction name="visitForum"/>
|
<addaction name="visitForum"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -372,9 +374,6 @@
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>About GoldenDict</string>
|
<string>About GoldenDict</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
|
||||||
<string>F1</string>
|
|
||||||
</property>
|
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::AboutRole</enum>
|
<enum>QAction::AboutRole</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -587,6 +586,14 @@
|
||||||
<enum>QAction::TextHeuristicRole</enum>
|
<enum>QAction::TextHeuristicRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="showReference">
|
||||||
|
<property name="text">
|
||||||
|
<string>GoldenDict reference</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>F1</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<file>icons/addtab.png</file>
|
<file>icons/addtab.png</file>
|
||||||
<file>icons/next.png</file>
|
<file>icons/next.png</file>
|
||||||
<file>icons/previous.png</file>
|
<file>icons/previous.png</file>
|
||||||
|
<file>icons/home.png</file>
|
||||||
<file>icons/reload.png</file>
|
<file>icons/reload.png</file>
|
||||||
<file>icons/programicon.png</file>
|
<file>icons/programicon.png</file>
|
||||||
<file>icons/programicon_scan.png</file>
|
<file>icons/programicon_scan.png</file>
|
||||||
|
|
Loading…
Reference in a new issue