*! Awlays set definition's (QWebView) style using Html css, not Qt css.

This commit is contained in:
Konstantin Isakov 2009-05-11 15:33:57 +00:00
parent 8c40c6d50a
commit dc96e29174
7 changed files with 62 additions and 96 deletions

View file

@ -203,6 +203,20 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeNotFoundTextFor(
return r;
}
sptr< Dictionary::DataRequest > ArticleMaker::makeEmptyPage() const
{
string result = makeHtmlHeader( tr( "(untitled)" ), QString() ) +
"</body></html>";
sptr< Dictionary::DataRequestInstant > r =
new Dictionary::DataRequestInstant( true );
r->getData().resize( result.size() );
memcpy( &( r->getData().front() ), result.data(), result.size() );
return r;
}
//////// ArticleRequest
ArticleRequest::ArticleRequest(

View file

@ -47,6 +47,9 @@ public:
/// known that there's no translation.
sptr< Dictionary::DataRequest > makeNotFoundTextFor( QString const & word, QString const & group ) const;
/// Creates an 'untitled' page. The result is guaranteed to be instant.
sptr< Dictionary::DataRequest > makeEmptyPage() const;
private:
/// Makes everything up to and including the opening body tag.

View file

@ -53,13 +53,16 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
if ( url.scheme() == "gdlookup" )
{
contentType = "text/html";
if ( url.queryItemValue( "blank" ) == "1" )
return articleMaker.makeEmptyPage();
bool groupIsValid = false;
QString word = url.queryItemValue( "word" );
unsigned group = url.queryItemValue( "group" ).toUInt( &groupIsValid );
contentType = "text/html";
if ( groupIsValid && word.size() ) // Require group and word to be passed
return articleMaker.makeDefinitionFor( word, group );
}

View file

@ -53,6 +53,17 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
connect( ui.definition, SIGNAL( linkClicked( QUrl const & ) ),
this, SLOT( linkClicked( QUrl const & ) ) );
// Load the default blank page instantly, so there would be no flicker.
QString contentType;
QUrl blankPage( "gdlookup://localhost?blank=1" );
sptr< Dictionary::DataRequest > r = articleNetMgr.getResource( blankPage,
contentType );
ui.definition->setHtml( QByteArray( &( r->getFullData().front() ),
r->getFullData().size() ), blankPage );
}
ArticleView::~ArticleView()

View file

@ -1,7 +1,8 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ArticleView</class>
<widget class="QWidget" name="ArticleView" >
<property name="geometry" >
<widget class="QWidget" name="ArticleView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,92 +10,28 @@
<height>634</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<property name="margin" >
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<property name="margin" >
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWebView" name="definition" >
<property name="palette" >
<palette>
<active>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="url" >
<widget class="QWebView" name="definition">
<property name="url">
<url>
<string>about:blank</string>
</url>
@ -105,40 +42,40 @@
</widget>
</item>
<item>
<widget class="QFrame" name="searchFrame" >
<property name="frameShape" >
<widget class="QFrame" name="searchFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="margin" >
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="searchCloseButton" >
<property name="text" >
<widget class="QToolButton" name="searchCloseButton">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<widget class="QLabel" name="label">
<property name="text">
<string>Find:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchText" />
<widget class="QLineEdit" name="searchText"/>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>

View file

@ -1,5 +1,4 @@
MainWindow #searchPane #translateLine, MainWindow #searchPane #wordList,
ArticleView #definition
MainWindow #searchPane #translateLine, MainWindow #searchPane #wordList
{
background: white;
}

View file

@ -1,5 +1,4 @@
MainWindow #searchPane #translateLine, MainWindow #searchPane #wordList,
ArticleView #definition
MainWindow #searchPane #translateLine, MainWindow #searchPane #wordList
{
background: #fefdeb;
}