NSRAboutDialog::NSRAboutDialog (QWidget *parent) :
    NSRTouchDialog (parent),
    ui (new Ui::NSRAboutDialog)
{
	const NSRLanguageData *lang = NSRLanguage::instance()->getLanguage();

	QWidget *widget = new QWidget (this);
	ui->setupUi (widget);

	setTitleIcon (QPixmap(":/icons/icons/about.png"));
	setTitle (NSRLanguage::instance()->getLanguage()->frameAbout);
	setContentsWidget (widget);

	ui->developerLabel->setText (lang->aboutDeveloperName);
	ui->contactsLabel->setText (lang->aboutContacts + " <*****@*****.**>");
	ui->iconsCreditLabel->setText (lang->aboutIconsNote + " Stuttgart pack, Axialis Team");
	ui->licenseLabel->setText (lang->aboutLicense);
	ui->facebookLabel->setText (lang->aboutFacebookNote);
	ui->versionLabel->setText (QString("NSR Reader %1").arg(NSRSettings::getVersion()));

	QString style = "QLabel {"
			"background-color: white; "
			"border: 1px solid rgba(180, 180, 180, 255); "
			"border-right: none; "
			"border-left: none; "
			"border-top: none; "
			"color: rgb(0, 0, 0); "
#ifdef Q_OS_SYMBIAN
			"font-size: 16px; "
			"font-weight: bold; "
#else
			"font-size: 22px; "
#endif
			"}";

	ui->developerLabel->setStyleSheet (style);
	ui->contactsLabel->setStyleSheet (style);
	ui->iconsCreditLabel->setStyleSheet (style);
	ui->facebookLabel->setStyleSheet (style);
	ui->versionLabel->setStyleSheet (style);
}
UINetworkRequestWidget::UINetworkRequestWidget(UINetworkManagerDialog *pParent, UINetworkRequest *pNetworkRequest)
    : QIWithRetranslateUI<UIPopupBox>(pParent)
    , m_pContentWidget(new QWidget(this))
    , m_pMainLayout(new QGridLayout(m_pContentWidget))
    , m_pProgressBar(new QProgressBar(m_pContentWidget))
    , m_pRetryButton(new QIToolButton(m_pContentWidget))
    , m_pCancelButton(new QIToolButton(m_pContentWidget))
    , m_pErrorPane(new QIRichTextLabel(m_pContentWidget))
    , m_pNetworkRequest(pNetworkRequest)
    , m_pTimer(new QTimer(this))
{
    /* Setup self: */
    setTitleIcon(UIIconPool::iconSet(":/nw_16px.png"));
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    setContentWidget(m_pContentWidget);
    setOpen(true);

    /* Prepare listeners for m_pNetworkRequest: */
    connect(m_pNetworkRequest, SIGNAL(sigProgress(qint64, qint64)), this, SLOT(sltSetProgress(qint64, qint64)));
    connect(m_pNetworkRequest, SIGNAL(sigStarted()), this, SLOT(sltSetProgressToStarted()));
    connect(m_pNetworkRequest, SIGNAL(sigFinished()), this, SLOT(sltSetProgressToFinished()));
    connect(m_pNetworkRequest, SIGNAL(sigFailed(const QString&)), this, SLOT(sltSetProgressToFailed(const QString&)));

    /* Setup timer: */
    m_pTimer->setInterval(5000);
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltTimeIsOut()));

    /* Setup main-layout: */
    m_pMainLayout->setContentsMargins(6, 6, 6, 6);

    /* Setup progress-bar: */
    m_pProgressBar->setRange(0, 0);
    m_pProgressBar->setMaximumHeight(16);

    /* Setup retry-button: */
    m_pRetryButton->setHidden(true);
    m_pRetryButton->removeBorder();
    m_pRetryButton->setFocusPolicy(Qt::NoFocus);
    m_pRetryButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
    connect(m_pRetryButton, SIGNAL(clicked(bool)), this, SIGNAL(sigRetry()));

    /* Setup cancel-button: */
    m_pCancelButton->removeBorder();
    m_pCancelButton->setFocusPolicy(Qt::NoFocus);
    m_pCancelButton->setIcon(UIIconPool::iconSet(":/delete_16px.png"));
    connect(m_pCancelButton, SIGNAL(clicked(bool)), this, SIGNAL(sigCancel()));

    /* Setup error-label: */
    m_pErrorPane->setHidden(true);
    m_pErrorPane->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    /* Calculate required width: */
    int iMinimumWidth = pParent->minimumWidth();
    int iLeft, iTop, iRight, iBottom;
    /* Take into account content-widget layout margins: */
    m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Take into account this layout margins: */
    layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Take into account parent layout margins: */
    QLayout *pParentLayout = qobject_cast<QMainWindow*>(parent())->centralWidget()->layout();
    pParentLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Set minimum text width: */
    m_pErrorPane->setMinimumTextWidth(iMinimumWidth);

    /* Layout content: */
    m_pMainLayout->addWidget(m_pProgressBar, 0, 0);
    m_pMainLayout->addWidget(m_pRetryButton, 0, 1);
    m_pMainLayout->addWidget(m_pCancelButton, 0, 2);
    m_pMainLayout->addWidget(m_pErrorPane, 1, 0, 1, 3);

    /* Retranslate UI: */
    retranslateUi();
}