mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Fix compilation errors on Qt 4.5
This commit is contained in:
parent
0db2ae6e57
commit
99526b98d3
|
@ -1,5 +1,7 @@
|
|||
#include "articleinspector.hh"
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using std::list;
|
||||
|
@ -49,3 +51,5 @@ void ArticleInspector::showEvent( QShowEvent * event )
|
|||
|
||||
QWebInspector::showEvent( event );
|
||||
}
|
||||
|
||||
#endif // QT_VERSION
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef ARTICLEINSPECTOR_HH
|
||||
#define ARTICLEINSPECTOR_HH
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include <QWebInspector>
|
||||
#include <list>
|
||||
#include "config.hh"
|
||||
|
@ -28,4 +32,6 @@ private:
|
|||
static std::list< ArticleInspector * > openedInspectors;
|
||||
};
|
||||
|
||||
#endif // QT_VERSION
|
||||
|
||||
#endif // ARTICLEINSPECTOR_HH
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
#include "dprintf.hh"
|
||||
#include "ffmpegaudio.hh"
|
||||
#include <QDebug>
|
||||
#include <QWebElement>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
#include <QWebElement>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
@ -1236,6 +1239,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
|||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
QWebElement el = r.element();
|
||||
QUrl imageUrl;
|
||||
if( !popupView && el.tagName().compare( "img", Qt::CaseInsensitive ) == 0 )
|
||||
|
@ -1255,6 +1259,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
|||
saveSoundAction = new QAction( tr( "Save s&ound..." ), &menu );
|
||||
menu.addAction( saveSoundAction );
|
||||
}
|
||||
#endif
|
||||
|
||||
QString selectedText = ui.definition->selectedText();
|
||||
|
||||
|
@ -1432,6 +1437,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
|||
else
|
||||
if( result == saveImageAction || result == saveSoundAction )
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
QUrl url = ( result == saveImageAction ) ? imageUrl : targetUrl;
|
||||
QString savePath;
|
||||
QString fileName;
|
||||
|
@ -1480,6 +1486,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
|||
emit storeResourceSavePath( QDir::toNativeSeparators( fileInfo.absoluteDir().absolutePath() ) );
|
||||
saveResource( url, ui.definition->url(), fileName );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1777,8 +1784,9 @@ void ArticleView::performFindOperation( bool restart, bool backwards, bool check
|
|||
|
||||
if ( ui.searchCaseSensitive->isChecked() )
|
||||
f |= QWebPage::FindCaseSensitively;
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
f |= QWebPage::HighlightAllOccurrences;
|
||||
#endif
|
||||
|
||||
ui.definition->findText( "", f );
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
#include <QApplication>
|
||||
#include "articleinspector.hh"
|
||||
|
||||
|
||||
ArticleWebView::ArticleWebView( QWidget *parent ):
|
||||
QWebView( parent ),
|
||||
#if QT_VERSION >= 0x040600
|
||||
inspector( NULL ),
|
||||
#endif
|
||||
midButtonPressed( false ),
|
||||
selectionBySingleClick( false ),
|
||||
showInspectorDirectly( true )
|
||||
|
@ -19,8 +20,10 @@ ArticleWebView::ArticleWebView( QWidget *parent ):
|
|||
|
||||
ArticleWebView::~ArticleWebView()
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
if ( inspector )
|
||||
inspector->deleteLater();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArticleWebView::setUp( Config::Class * cfg )
|
||||
|
@ -30,6 +33,7 @@ void ArticleWebView::setUp( Config::Class * cfg )
|
|||
|
||||
void ArticleWebView::triggerPageAction( QWebPage::WebAction action, bool checked )
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
if ( action == QWebPage::InspectElement )
|
||||
{
|
||||
// Get or create inspector instance for current view.
|
||||
|
@ -50,6 +54,7 @@ void ArticleWebView::triggerPageAction( QWebPage::WebAction action, bool checked
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QWebView::triggerPageAction( action, checked );
|
||||
}
|
||||
|
@ -102,9 +107,13 @@ void ArticleWebView::mouseReleaseEvent( QMouseEvent * event )
|
|||
void ArticleWebView::mouseDoubleClickEvent( QMouseEvent * event )
|
||||
{
|
||||
QWebView::mouseDoubleClickEvent( event );
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
int scrollBarWidth = page()->mainFrame()->scrollBarGeometry( Qt::Vertical ).width();
|
||||
int scrollBarHeight = page()->mainFrame()->scrollBarGeometry( Qt::Horizontal ).height();
|
||||
#else
|
||||
int scrollBarWidth = 0;
|
||||
int scrollBarHeight = 0;
|
||||
#endif
|
||||
|
||||
// emit the signal only if we are not double-clicking on scrollbars
|
||||
if ( ( event->x() < width() - scrollBarWidth ) &&
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
#include <QPainter>
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
#include <QPropertyAnimation>
|
||||
#endif
|
||||
|
||||
ExtLineEdit::ExtLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent)
|
||||
{
|
||||
|
@ -95,10 +99,9 @@ void ExtLineEdit::updateMargins()
|
|||
int leftMargin = iconButtons[realLeft]->pixmap().width() + 8;
|
||||
int rightMargin = iconButtons[realRight]->pixmap().width() + 8;
|
||||
|
||||
QMargins margins((iconEnabled[realLeft] ? leftMargin : 0), 1,
|
||||
setTextMargins(
|
||||
(iconEnabled[realLeft] ? leftMargin : 0), 1,
|
||||
(iconEnabled[realRight] ? rightMargin : 0), 1);
|
||||
|
||||
setTextMargins(margins);
|
||||
}
|
||||
|
||||
void ExtLineEdit::updateButtonPositions()
|
||||
|
@ -110,10 +113,14 @@ void ExtLineEdit::updateButtonPositions()
|
|||
iconPos = (iconPos == Left ? Right : Left);
|
||||
|
||||
if (iconPos == ExtLineEdit::Right) {
|
||||
const int iconoffset = textMargins().right() + 4;
|
||||
int right;
|
||||
getTextMargins(0, 0, &right, 0);
|
||||
const int iconoffset = right + 4;
|
||||
iconButtons[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0));
|
||||
} else {
|
||||
const int iconoffset = textMargins().left() + 4;
|
||||
int left;
|
||||
getTextMargins(&left, 0, 0, 0);
|
||||
const int iconoffset = left + 4;
|
||||
iconButtons[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0));
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +179,7 @@ void IconButton::paintEvent(QPaintEvent *)
|
|||
|
||||
void IconButton::animate(bool visible)
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "opacity");
|
||||
animation->setDuration(250);
|
||||
if (visible)
|
||||
|
@ -183,4 +191,7 @@ void IconButton::animate(bool visible)
|
|||
animation->setEndValue(0.0);
|
||||
}
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
#else
|
||||
setOpacity(visible ? 1.0 : 0.0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractButton>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
class IconButton: public QAbstractButton
|
||||
{
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "gdappstyle.hh"
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include "dictionarybar.hh"
|
||||
|
||||
#include <QWidget>
|
||||
|
@ -44,3 +47,5 @@ bool GdAppStyle::dictionaryBarButton(const QWidget * widget) const {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // QT_VERSION
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
#ifndef GDAPPSTYLE_HH
|
||||
#define GDAPPSTYLE_HH
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include <QStyle>
|
||||
#include <QProxyStyle>
|
||||
#include <QStyleOption>
|
||||
|
||||
|
@ -25,4 +30,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif // QT_VERSION
|
||||
|
||||
#endif // GDAPPSTYLE_HH
|
||||
|
|
2
main.cc
2
main.cc
|
@ -113,7 +113,9 @@ int main( int argc, char ** argv )
|
|||
|
||||
app.setApplicationName( "GoldenDict" );
|
||||
app.setOrganizationDomain( "http://goldendict.org/" );
|
||||
#if QT_VERSION >= 0x040600
|
||||
app.setStyle(new GdAppStyle);
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
app.setWindowIcon( QIcon( ":/icons/programicon.png" ) );
|
||||
|
|
25
xdxf.cc
25
xdxf.cc
|
@ -678,12 +678,27 @@ QString readXhtmlData( QXmlStreamReader & stream )
|
|||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/// Deal with Qt 4.5 incompatibility
|
||||
QString readElementText( QXmlStreamReader & stream )
|
||||
{
|
||||
#if QT_VERSION >= 0x040600
|
||||
return stream.readElementText( QXmlStreamReader::SkipChildElements );
|
||||
#else
|
||||
return stream.readElementText();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void addAllKeyTags( QXmlStreamReader & stream, list< QString > & words )
|
||||
{
|
||||
// todo implement support for tag <srt>, that overrides the article sorting order
|
||||
if ( stream.name() == "k" )
|
||||
{
|
||||
words.push_back( stream.readElementText( QXmlStreamReader::SkipChildElements ) );
|
||||
words.push_back( readElementText( stream ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1156,12 +1171,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
stream.readNext();
|
||||
if ( stream.isStartElement() && stream.name() == "abbr_k" )
|
||||
{
|
||||
s = stream.readElementText( QXmlStreamReader::SkipChildElements );
|
||||
s = readElementText( stream );
|
||||
keys.push_back( gd::toWString( s ) );
|
||||
}
|
||||
else if ( stream.isStartElement() && stream.name() == "abbr_v" )
|
||||
{
|
||||
s = stream.readElementText( QXmlStreamReader::SkipChildElements );
|
||||
s = readElementText( stream );
|
||||
value = Utf8::encode( Folding::trimWhitespace( gd::toWString( s ) ) );
|
||||
for( list< wstring >::iterator i = keys.begin(); i != keys.end(); ++i )
|
||||
{
|
||||
|
@ -1180,12 +1195,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
stream.readNext();
|
||||
if ( stream.isStartElement() && stream.name() == "k" )
|
||||
{
|
||||
s = stream.readElementText( QXmlStreamReader::SkipChildElements );
|
||||
s = readElementText( stream );
|
||||
keys.push_back( gd::toWString( s ) );
|
||||
}
|
||||
else if ( stream.isStartElement() && stream.name() == "v" )
|
||||
{
|
||||
s = stream.readElementText( QXmlStreamReader::SkipChildElements );
|
||||
s = readElementText( stream );
|
||||
value = Utf8::encode( Folding::trimWhitespace( gd::toWString( s ) ) );
|
||||
for( list< wstring >::iterator i = keys.begin(); i != keys.end(); ++i )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue