29 #include <QProgressBar>
30 #include <kstatusbar.h>
31 #include <kmessagebox.h>
32 #include <kseparator.h>
33 #include <kpushbutton.h>
38 #include <klocalizedstring.h>
41 #include <qcheckbox.h>
42 #include <QVBoxLayout>
48 mWebView =
new KWebView(
this);
52 connect( mWebView, SIGNAL(loadProgress(
int)),
53 browserProgress, SLOT(setValue(
int)) );
54 connect( mWebView, SIGNAL(loadFinished(
bool)) ,
this, SLOT(
slotCompleted(
bool)) );
55 connect( mWebView, SIGNAL(statusBarMessage(QString)),
this,
64 void BilboBrowser::createUi(
QWidget *parent )
66 btnGetStyle =
new KPushButton(
this );
67 btnGetStyle->setText( i18n(
"Get blog style" ) );
68 connect( btnGetStyle, SIGNAL(clicked(
bool)),
this, SLOT(
slotGetBlogStyle()) );
70 viewInBlogStyle =
new QCheckBox( i18n(
"View post in the blog style"),
this );
72 connect( viewInBlogStyle, SIGNAL(toggled(
bool)),
this, SLOT(
75 QSpacerItem *horizontalSpacer =
new QSpacerItem( 40, 20,
76 QSizePolicy::Expanding, QSizePolicy::Minimum );
77 KSeparator *separator =
new KSeparator(
this );
79 QVBoxLayout *vlayout =
new QVBoxLayout( parent );
80 QHBoxLayout *hlayout =
new QHBoxLayout();
82 hlayout->addWidget( viewInBlogStyle );
83 hlayout->addItem( horizontalSpacer );
84 hlayout->addWidget( btnGetStyle );
86 vlayout->addLayout( hlayout );
87 vlayout->addWidget( separator );
88 vlayout->addWidget( mWebView );
90 browserProgress =
new QProgressBar(
this );
91 browserProgress->setFixedSize(120, 17);
93 browserStatus =
new KStatusBar(
this );
94 browserStatus->setFixedHeight( 20 );
95 browserStatus->addPermanentWidget( browserProgress );
96 vlayout->addWidget( browserStatus );
101 currentTitle = title;
102 currentContent = content;
104 if ( browserProgress->isHidden() ) {
105 browserProgress->show();
107 browserProgress->reset();
108 browserStatus->showMessage( i18n(
"loading page items..." ) );
110 if ( viewInBlogStyle->isChecked() ) {
114 mWebView->setHtml( QLatin1String(
"<html><body><h2 align='center'>") + title + QLatin1String(
"</h2>") + content + QLatin1String(
"</html>") );
127 KMessageBox::information(
this,
128 i18n(
"Please select a blog, then try again." ),
129 i18n(
"Select a blog" ) );
133 browserStatus->showMessage( i18n(
"Fetching blog style from the web..." ) );
134 if ( browserProgress->isHidden() ) {
135 browserProgress->show();
137 browserProgress->reset();
140 connect( styleGetter, SIGNAL(sigGetStyleProgress(
int)), browserProgress,
141 SLOT(setValue(
int)) );
142 connect( styleGetter, SIGNAL(sigStyleFetched()),
this, SLOT(
slotSetBlogStyle()) );
147 browserStatus->showMessage( i18n(
"Blog style fetched." ), 2000 );
150 if ( qobject_cast< StyleGetter* >( sender() ) ) {
151 sender()->deleteLater();
157 QTimer::singleShot( 1500, browserProgress, SLOT(hide()) );
159 browserStatus->showMessage( i18n(
"An error occurred in the latest transaction." ), 5000 );
165 QString statusText = text;
166 statusText.remove( QLatin1String(
"<qt>") );
167 browserStatus->showMessage( statusText );
173 setHtml( currentTitle, currentContent );
176 #include "composer/bilbobrowser.moc"
void slotSetStatusBarText(const QString &text)
static DBMan * self()
Retrieve the instance of DataBase Manager.
void sigSetBlogStyle()
This signal is emmited when the browser finishes getting blog style.
static QString styledHtml(const int blogid, const QString &title, const QString &content)
Looks for a file named style.html for the requested blog in blogilo data directory, then writes the file content into a buffer, inserts given post title and content in the buffer, and returns it.
BilboBrowser(QWidget *parent=0)
BilboBrowser constructor.
int __currentBlogId
Global variables.
void setHtml(const QString &title, const QString &content)
Shows a post with given title and content in the browser.
static bool previewInBlogStyle()
Get previewInBlogStyle.
~BilboBrowser()
BilboBrowser destructor.
void slotViewModeChanged()