DocumentPage::DocumentPage(const QString& filePath, QGraphicsItem *parent) : MApplicationPage(parent) , currentPage(1) , m_pinchInProgress(false) , m_endScale(1.0) , m_blockRecenter(false) , pageLoaded(false) , m_defaultZoomLevelAction(ActionPool::ZoomFitToWidth) , pageIndicator(0) , m_infoBanner(0) , shareIf(0) , searchstring("") , searchingTimeout(false) , zoomAction(0) , indicatorAction(0) , zoomCombobox(0) , indicatorCombobox(0) , searchStarted(false) , noMatches(false) , totalPage(1) , liveDocument(0) , bounceAnimation(0) , jumpToPageOverlay(0) , findtoolbar(0) , quickViewToolbar(0) , quickViewer(false) , m_pageView(new ZoomBackground(this)) , m_lastZoomFactor(1.0) { setView(m_pageView); documentName = filePath; setObjectName("documentpage"); // double click interval setting to 325ms QApplication::setDoubleClickInterval(DOUBLETAP_INTERVAL); setAutoMarginsForComponentsEnabled(false); setComponentsDisplayMode(MApplicationPage::AllComponents, MApplicationPageModel::Hide); setEscapeMode(MApplicationPageModel::EscapeCloseWindow); qRegisterMetaType<ZoomLevel>("ZoomLevel"); m_autoHideTimer.setSingleShot(true); m_autoHideTimer.setInterval(NAVI_BAR_TIMEOUT); m_shortTapTimer.setSingleShot(true); m_shortTapTimer.setInterval(QApplication::doubleClickInterval()); searchTimer.setSingleShot(true); searchTimer.setInterval(searchDelay); connect(&searchTimer, SIGNAL(timeout()), this, SLOT(searchTimeout())); connect(&m_shortTapTimer, SIGNAL(timeout()), this, SLOT(shortTapEvent())); connect(&m_autoHideTimer, SIGNAL(timeout()), this, SLOT(autoHideToolbar())); connect(this, SIGNAL(backButtonClicked()), this, SLOT(onClose())); connect(ActionPool::instance(), SIGNAL(destroyed(QObject *)), this, SLOT(removeActions())); connect(this, SIGNAL(loadSuccess(QString)), SLOT(updateViewerType())); connect(MInputMethodState::instance(), SIGNAL(inputMethodAreaChanged(const QRect &)), this, SLOT(sendVisibleAreayChanged())); }
SwAcctEditPage::SwAcctEditPage(SwClientService *swService, QGraphicsItem *parent) : MApplicationPage(parent), mService(swService), mServiceConfig(mService->getServiceConfig()), mFlickrClicked(false) { int adj = 0; setEscapeMode(MApplicationPageModel::EscapeManualBack); connect(this, SIGNAL(backButtonClicked()), this, SLOT(dismiss())); connect(mService, SIGNAL(CredsStateChanged(SwClientService*,SwClientService::CredsState)), this, SLOT(onCredsStateChanged(SwClientService *, SwClientService::CredsState))); if (!mServiceConfig->isValid()) dismiss(); mParams = mServiceConfig->getConfigParams(); MLayout *layout = new MLayout; MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout); QString link = mServiceConfig->getLink(); MLabel *lblServiceName = new MLabel(); if (!link.isEmpty()) lblServiceName->setText(QString("<a href=\"%1\">%2</a>").arg(link, mServiceConfig->getDisplayName())); else lblServiceName->setText(mServiceConfig->getDisplayName()); lblServiceName->setObjectName("SwAcctEditPageServiceNameLabel"); policy->addItem(lblServiceName, 0, 0, 1, 2, Qt::AlignHCenter); connect(lblServiceName, SIGNAL(linkActivated(QString)), this, SLOT(onLinkClicked(QString))); QString desc = mServiceConfig->getDescription(); if (!desc.isEmpty()) { MLabel *lblServiceDesc = new MLabel(); lblServiceDesc->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); lblServiceDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //Have to insert a random HTML tag to make word wrap actually work... //Should be able to remove at some point once MTF word wrap works properly lblServiceDesc->setText(QString("<b></b>").append(desc)); lblServiceDesc->setObjectName("SwAcctEditPageServiceDescLabel"); policy->addItem(lblServiceDesc, 1, 0, 1, 2, Qt::AlignLeft); } else { adj -= 1; } //This is *ugly* if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypeFlickr) { if (!mParams.value(USER_KEY).isEmpty()) { //% "User %1" MLabel *lblUsername = new MLabel(qtTrId("label_flickr_username").arg(mParams.value(USER_KEY))); lblUsername->setObjectName("SwAcctEditPageFlickrUserLabel"); policy->addItem(lblUsername, 2+adj, 0, 1, 2, Qt::AlignHCenter); adj += 1; } mFlickrButton = new MButton(); mFlickrButton->setObjectName("SwAcctEditPageFlickrButton"); policy->addItem(mFlickrButton, 2+adj, 0, 1, 2, Qt::AlignHCenter); connect(mFlickrButton, SIGNAL(clicked()), this, SLOT(onFlickrClicked())); adj += 1; } else { MLabel *lblUsername = new MLabel(); lblUsername->setObjectName("SwAcctEditPageUsernameLabel"); lblUsername->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //% "Username:"******"label_username")); policy->addItem(lblUsername, 2+adj, 0); mEdtUsername = new MTextEdit(MTextEditModel::SingleLine); mEdtUsername->setObjectName("SwAcctEditPageUsernameButton"); mEdtUsername->setText(mParams.value(USER_KEY)); //qDebug() << QString("Set username to %1").arg(mParams.value(USER_KEY)); policy->addItem(mEdtUsername, 2+adj, 1); if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypePassword) { MLabel *lblPassword = new MLabel(); lblPassword->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //% "Password:"******"label_password")); lblPassword->setObjectName("SwAcctEditPagePasswordLabel"); policy->addItem(lblPassword, 3+adj, 0); mEdtPassword = new MTextEdit(MTextEditModel::SingleLine); mEdtPassword->setText(mParams.value(PASS_KEY)); mEdtPassword->setEchoMode(MTextEditModel::Password); mEdtPassword->setObjectName("SwAcctEditPagePasswordButton"); // qDebug() << QString("Set password to %1").arg(mParams.value(PASS_KEY)); policy->addItem(mEdtPassword, 3+adj, 1); connect(mEdtPassword, SIGNAL(textChanged()), this, SLOT(onLoginChanged())); adj += 1; } } mLblStatus = new MLabel(STATUS_TEXT_UNCONFIGURED); mLblStatus->setObjectName("SwAcctEditPageStatusLabel"); policy->addItem(mLblStatus, 3+adj, 0, 1, 2, Qt::AlignHCenter); onCredsStateChanged(mService, mService->credsState()); MLabel *lblServiceHint = new MLabel(); lblServiceHint->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); lblServiceHint->setObjectName("SwAcctEditPageServiceHintLabel"); lblServiceHint->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); lblServiceHint->setText(SERVICE_HINT_TEXT.arg(mService->getDisplayName())); policy->addItem(lblServiceHint, 4+adj, 0, 1, 2); //This, also, is *ugly* if (mServiceConfig->getAuthtype() != SwClientServiceConfig::AuthTypeFlickr) { //% "Apply" mBtnApply = new MButton(qtTrId("button_apply")); mBtnApply->setObjectName("SwAcctEditPageApplyButton"); policy->addItem(mBtnApply, 5+adj, 0, 1, 2, Qt::AlignHCenter); //% "Cancel" mBtnCancel = new MButton(qtTrId("button_cancel")); mBtnCancel->setObjectName("SwAcctEditPageCancelButton"); policy->addItem(mBtnCancel, 6+adj, 0, 1, 2, Qt::AlignHCenter); connect(mEdtUsername, SIGNAL(textChanged()), this, SLOT(onLoginChanged())); connect(mBtnApply, SIGNAL(clicked()), this, SLOT(onApplyClicked())); connect(mBtnCancel, SIGNAL(clicked()), this, SLOT(dismiss())); } layout->setPolicy(policy); centralWidget()->setLayout(layout); }