void MainWindow::createCentralWidget() { mWebView = new EnView(this); mWebView->setContextMenuPolicy(Qt::NoContextMenu); if(isFirstRun) mWebView->setHtml(defaultPage(false)); else mWebView->setHtml(defaultPage(true)); connect(mWebView, SIGNAL(noteClicked(QString)), &mEnExport, SLOT(openNote(QString))); //connect(mWebView, SIGNAL(linkClicked(QUrl)), SLOT(openUrl(QUrl))); QPalette navigationPalette; navigationPalette.setColor(QPalette::Window, QColor(mBgColor)); mToolBar = new QToolBar(this); addToolBar(Qt::TopToolBarArea, mToolBar); mToolBar->setBackgroundRole(QPalette::Window); mToolBar->setAutoFillBackground(true); mToolBar->setPalette(navigationPalette); mToolBar->setMovable(false); mToolBar->setIconSize(QSize(30, 30)); //mPageNumberLabel = new QLabel("4 / 7", this); //mPageNumberLabel->setFont(QFont("Times", 18)); QAction* settingsAction = new QAction(QIcon(":/images/gear2.png"), tr("Settings"), mToolBar); QAction* prevAction = new QAction(QIcon(":/images/prev.png"), tr("Prev"), mToolBar); QAction* nextAction = new QAction(QIcon(":/images/next.png"), tr("Next"), mToolBar); mToolBar->addAction(settingsAction); mToolBar->addAction(prevAction); mToolBar->addAction(nextAction); mNavigationLabel = new QLabel(mToolBar); mNavigationLabel->setFont(QFont("Times", 18)); mToolBar->addWidget(mNavigationLabel); connect(settingsAction, SIGNAL(triggered()), SLOT(loadDialogSettings())); //connect(settingsAction, SIGNAL(triggered()), mDialog, SLOT(show())); connect(prevAction, SIGNAL(triggered()), SLOT(prevNote())); connect(nextAction, SIGNAL(triggered()), SLOT(nextNote())); setCentralWidget(mWebView); }
void MainWindow::displayNotes(){ qDebug() << "displayNotes"; mEnDisplay.setBgColor(mBgColor); mEnDisplay.setPageWidth(mPageWidth); QTime time; time.start(); const QString& page = mEnDisplay.display(mEnNotes.value(mCurrentNoteIndex, 0), defaultPage()); qDebug("timer: mEnDisplay.display() %d ms", time.elapsed()); time.start(); mWebView->setHtml(page); qDebug("timer: mWebView->setHtml %d ms", time.elapsed()); refreshNavigationLabel(); }
void ParserCWHandler::updateRequest( MC2String& urlStr, LangTypes::language_t clientLang ) const { const char* instance = Properties::getProperty( "WF_INSTANCE", "eu" ); for ( repmap::const_iterator it = m_repurls.begin() ; it != m_repurls.end() ; ++it ) { if ( urlStr.find( (*it).first ) != MC2String::npos ) { MC2String rstr( (*it).second.replaceWith ); STLStringUtility::replaceString( rstr, "[INSTANCE]", instance ); STLStringUtility::replaceString( urlStr, (*it).first, rstr.c_str() ); if ( (*it).second.defaultPage != "" ) { // Check if no page then replace with defaultPage URL url( urlStr ); MC2String file( url.getFile() ); if ( file.size() > 0 && file[ file.size() -1 ] == '/' ) { MC2String path( url.getPath() ); MC2String::size_type qPos = path.find( '?' ); if ( qPos == MC2String::npos ) { qPos = path.find( '#' ); } MC2String params; if ( qPos != MC2String::npos ) { params = path.substr( qPos ); } MC2String defaultPage( url.getFile() ); defaultPage.append( (*it).second.defaultPage ); defaultPage.append( params ); // ?u=... // TODO: Convert clientLang to languageCode and back // to get only translated languages (There is a webpage). STLStringUtility::replaceString( defaultPage, "[ISO639-1]", LangTypes::getLanguageAsISO639( clientLang ) ); URL newUrl( url.getProto(), url.getHost(), url.getPort(), defaultPage.c_str() ); urlStr = newUrl.getSpec(); } } } } }
void MainWindow::setTagAndReload(const QString& newTag){ mTag = newTag; mWebView->setHtml(defaultPage()); reloadNotes(); }