# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1278414229 -10800 # Node ID 1c3b8676e58c712645b29856410ddd5462384295 # Parent 0f2326c2a3250d1e516b1a33a0fd3f6704564f40 Revision: 201026 Kit: 2010127 diff -r 0f2326c2a325 -r 1c3b8676e58c 50_layers.sysdef.xml --- a/50_layers.sysdef.xml Wed Jun 23 17:59:43 2010 +0300 +++ b/50_layers.sysdef.xml Tue Jul 06 14:03:49 2010 +0300 @@ -7,8 +7,7 @@ - - + diff -r 0f2326c2a325 -r 1c3b8676e58c bedrockProvisioning/bedrockprovisioning.cpp --- a/bedrockProvisioning/bedrockprovisioning.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/bedrockProvisioning/bedrockprovisioning.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -95,7 +95,7 @@ } if (!QSettings::contains("ChromeBaseDirectory")) { - QString chromeBaseDir = QSettings::value("ROMBaseDirectory").toString() + "chrome/"; + QString chromeBaseDir = ":/chrome/"; #ifndef Q_OS_SYMBIAN // Maemo, Linux, Windows can override using an env var static const QString envChromeBaseDir = QProcessEnvironment::systemEnvironment().value("BROWSER_CHROME"); // allow env var overriding for dev @@ -105,6 +105,19 @@ QSettings::setValue("ChromeBaseDirectory", chromeBaseDir); } + if (!QSettings::contains("LocalPagesBaseDirectory")) { +#ifdef Q_OS_SYMBIAN + QString localpagesBaseDir = QSettings::value("ROMBaseDirectory").toString() + "localpages/"; +#else + QString localpagesBaseDir = QSettings::value("ChromeBaseDirectory").toString() + "localpages/"; + // Maemo, Linux, Windows can override using an env var + static const QString envBaseDir = QProcessEnvironment::systemEnvironment().value("BROWSER_LOCALPAGES"); // allow env var overriding for dev + if (envBaseDir != "") + localpagesBaseDir = envBaseDir; +#endif + QSettings::setValue("LocalPagesBaseDirectory", localpagesBaseDir); + } + if (!QSettings::contains("StartUpChrome")) { QSettings::setValue("StartUpChrome", "bedrockchrome/chrome.html"); } @@ -124,6 +137,16 @@ #endif } + if (!QSettings::contains("NetworkPort")) { +// For s60 arm and maemo arm (i.e. not x86 emulator build) we need to set no proxy +#if (defined(Q_OS_SYMBIAN) && !defined(Q_CC_NOKIAX86)) || (defined(Q_WS_MAEMO_5) && !defined(QT_ARCH_I386)) + // empty proxy only for ARMV5 Symbian targets + QSettings::setValue("NetworkPort", QString()); +// everything else, linux, win, s60 emulator, maemo emulator needs proxy +#else + QSettings::setValue("NetworkPort", "8080"); +#endif + } if (!QSettings::contains("DiskCacheEnabled")) QSettings::setValue("DiskCacheEnabled", "1"); @@ -152,9 +175,9 @@ if (!QSettings::contains("StartPage")) { #ifdef PLAT_101 - QSettings::setValue("StartPage", "localpages/startpage_101.html"); + QSettings::setValue("StartPage", "startpage_101.html"); #else - QSettings::setValue("StartPage", "localpages/startpage.html"); + QSettings::setValue("StartPage", "startpage.html"); #endif } @@ -201,7 +224,42 @@ QString maxSize = QString::number(200 * 1024 * 1024); QSettings::setValue("Html5ApplicationCacheMaxSize", maxSize); } + + // reserved entries for local bookmarks + if (!QSettings::contains("Bookmark0Title")) { + QSettings::setValue("Bookmark0Title", "Browser Welcome Page"); + } + + if (!QSettings::contains("Bookmark0Url")) { +#ifdef PLAT_101 + QSettings::setValue("Bookmark0Url", "startpage_101.html"); +#else + QSettings::setValue("Bookmark0Url", "startpage.html"); +#endif + } + + if (!QSettings::contains("Bookmark1Title")) { + QSettings::setValue("Bookmark1Title", ""); + } + + if (!QSettings::contains("Bookmark1Url")) { + QSettings::setValue("Bookmark1Url", ""); + } + + if (!QSettings::contains("Bookmark2Title")) { + QSettings::setValue("Bookmark2Title", ""); + } + + if (!QSettings::contains("Bookmark2Url")) { + QSettings::setValue("Bookmark2Url", ""); + } } + + // userAgentStringSetup, default empty. + if (!QSettings::contains("UserAgentString")) + { + QSettings::setValue("UserAgentString", QString()); + } endGroup(); // m_appuid sync(); } diff -r 0f2326c2a325 -r 1c3b8676e58c bedrockProvisioning/template/200267EA.ini --- a/bedrockProvisioning/template/200267EA.ini Wed Jun 23 17:59:43 2010 +0300 +++ b/bedrockProvisioning/template/200267EA.ini Tue Jul 06 14:03:49 2010 +0300 @@ -1,4 +1,4 @@ [200267EA] Version=BedrockInternal -BedrockVersion=8.0.34453 +BedrockVersion=8.0.36010 DiskCacheEnabled=0 diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Dialogs/WebDialogProvider.cpp --- a/browsercore/appfw/Api/Dialogs/WebDialogProvider.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Dialogs/WebDialogProvider.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -413,8 +413,10 @@ { QGroupBox* groupBox = new QGroupBox; QLineEdit* usernameWidget = new QLineEdit(groupBox); + usernameWidget->setInputMethodHints(Qt::ImhNoAutoUppercase); QLineEdit* passwordWidget = new QLineEdit(groupBox); passwordWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); + passwordWidget->setInputMethodHints(Qt::ImhNoAutoUppercase); QGridLayout* gLayout = new QGridLayout(groupBox); groupBox->setLayout(gLayout); gLayout->addWidget(new QLabel(tr("User Name : "), groupBox), 0, 0); diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/BookmarksManager.cpp --- a/browsercore/appfw/Api/Managers/BookmarksManager.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/BookmarksManager.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -45,11 +45,6 @@ BookmarksManagerPrivate::BookmarksManagerPrivate(BookmarksManager * mgr, QWidget *parent) : q(mgr), m_connectedToBookmarks(false), - m_loadedBookmarks(false), - m_loadedHistory(false), - m_bookmarkRootNode(0), - m_historyRootNode(0), - m_historyRootNodeProxy(0), m_maxUrls(10) // TODO: read from settings { m_import = false; @@ -82,9 +77,6 @@ BookmarksManagerPrivate::~BookmarksManagerPrivate() { - delete m_bookmarkRootNode; - delete m_historyRootNode; - delete m_historyRootNodeProxy; delete m_bookmarkSession; delete m_actionClearHistory; delete m_actionClearJSO; @@ -174,48 +166,44 @@ } #endif - // always add Bedrock Browser Welcome Page - QString chromeBaseDir(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory")); - QString welcomeUrl(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("StartPage")); - QString welcomePage = chromeBaseDir + welcomeUrl; - addBookmark("Bedrock Welcome Page",welcomePage,0); - + // add local bookmarks + QString localPagesBaseDir(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("LocalPagesBaseDirectory")); + QString indexStr; + for (int index = 2; index >= 0; index--) { + indexStr.setNum(index); + QString bookmarkTitle = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString(tr("Bookmark")+indexStr+tr("Title")); + if (bookmarkTitle == "") + continue; + QString bookmarkUrl = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString(tr("Bookmark")+indexStr+tr("Url")); + if (bookmarkUrl == "") + continue; + if (bookmarkUrl.contains("://") || bookmarkUrl.contains("www.")) + addBookmark(bookmarkTitle, bookmarkUrl, 0); + else { + QString localBookmarkUrl = QFileInfo(localPagesBaseDir + bookmarkUrl).absoluteFilePath(); + addBookmark(bookmarkTitle, tr("file:///") + localBookmarkUrl, 0); + } + } } QString BookmarksManager::getBookmarksJSON() { if(m_isBookmarkDbreadRequired==true) { - m_bookmakrData=d->m_bookmarkSession->FetchSerializedBookmarks(); + m_bookmakrData=d->m_bookmarkSession->fetchSerializedBookmarks(); m_isBookmarkDbreadRequired=false; } return m_bookmakrData; } -int BookmarksManager::addBookmark(const QString &title, const QString &url,int index) -{ - QString updatedTitle = title; - QString updatedUrl = url; - //Setting title as url string if title is not available - if(url.isEmpty()) - return ErrBookmarkUrlEmpty; - - QVector nodes; - d->m_bookmarkSession->FetchAllBookmarkTitles(nodes); - for (int iter = 0 ; iter < nodes.size() ; ++iter) { - if(nodes.at(iter) == title) { - //Node already exists no need to add, just return - return ErrBookmarkAllReadyPresent; - } - } - - - nodes.clear(); - +QString BookmarksManager::normalizeUrl(const QString& url) + { // If the URL is relative, add http in front // so that qt doesn't make it absolute using the // local file path + QString updatedUrl = url; + if (!url.contains("://")) { if (!url.startsWith("www", Qt::CaseInsensitive)) { updatedUrl.prepend("http://www."); @@ -223,10 +211,35 @@ updatedUrl.prepend("http://"); } } + return updatedUrl; + + } +int BookmarksManager::addBookmark(const QString &title, const QString &url,int index) +{ + QString updatedTitle = title; + updatedTitle = updatedTitle.trimmed(); //Setting title as url string if title is not available - if(title.isEmpty()) - updatedTitle = updatedUrl; + if(url.isEmpty()) + return ErrBookmarkUrlEmpty; + + QVector nodes; + d->m_bookmarkSession->fetchAllBookmarkTitles(nodes); + for (int iter = 0 ; iter < nodes.size() ; ++iter) { + if(0==updatedTitle.compare(nodes.at(iter),Qt::CaseInsensitive)){ + //Node already exists delete existing + deleteBookmark(updatedTitle); + } + } + + + nodes.clear(); + + QString updatedUrl = normalizeUrl(url); + + //Setting title as url string if title is not available + if(title.isEmpty()) + updatedTitle = updatedUrl; BookmarkLeaf* leaf=new BookmarkLeaf(); leaf->setTitle(updatedTitle); @@ -235,7 +248,7 @@ leaf->setTag("unknown"); leaf->setIndex(index); - if(ErrNone == d->m_bookmarkSession->AddBookmark(leaf)) { + if(ErrNone == d->m_bookmarkSession->addBookmark(leaf)) { emit bookmarkEntryAdded(updatedTitle,updatedUrl); delete leaf; m_isBookmarkDbreadRequired=true; @@ -247,7 +260,7 @@ void BookmarksManager::deleteBookmark(QString title) { - d->m_bookmarkSession->DeleteBookmark(title); + d->m_bookmarkSession->deleteBookmark(title); m_isBookmarkDbreadRequired=true; } @@ -255,6 +268,7 @@ { d->m_bookmarkSession->clearBookmarks(); m_isBookmarkDbreadRequired=true; + emit bookmarksCleared(); } int BookmarksManager::reorderBokmarks(QString title,int new_index) @@ -267,29 +281,33 @@ int BookmarksManager::modifyBookmark(QString orgTitle, QString newTitle, QString newUrl) { QString updatedTitle = newTitle; + updatedTitle = updatedTitle.trimmed(); //Setting title as url string if title is not available if(newUrl.isEmpty()) return ErrBookmarkUrlEmpty; QList nodes; - nodes = d->m_bookmarkSession->FetchAllBookmarks(); + nodes = d->m_bookmarkSession->fetchAllBookmarks(); for (int iter = 0 ; iter < nodes.count() ; ++iter) { - if((nodes.at(iter)->getTitle() == newTitle) && (nodes.at(iter)->getTitle() != orgTitle)) { - //Node already exists no need to add, just return - return ErrBookmarkAllReadyPresent; + if((0==updatedTitle.compare(nodes.at(iter)->getTitle(),Qt::CaseInsensitive)) + && (0 != orgTitle.compare(nodes.at(iter)->getTitle(),Qt::CaseInsensitive))){ + //Node already exists delete existing + deleteBookmark(updatedTitle); } } qDeleteAll(nodes); nodes.clear(); + QString updatedUrl = normalizeUrl(newUrl); + //Setting title as url string if title is not available if(newTitle.isEmpty()) - updatedTitle = newUrl; + updatedTitle = updatedUrl; - if(ErrNone == d->m_bookmarkSession->modifyBookmark(orgTitle, newTitle, newUrl)) { - emit bookmarkEntryModified(newTitle, newUrl); + if(ErrNone == d->m_bookmarkSession->modifyBookmark(orgTitle, updatedTitle, updatedUrl)) { + emit bookmarkEntryModified(updatedTitle, updatedUrl); m_isBookmarkDbreadRequired=true; return ErrNone; } @@ -301,87 +319,23 @@ emit launchBookmarkEditDailog(title,url); } -/*! - * Load history from database - */ -void BookmarksManager::loadHistory() -{ - if (d->m_loadedHistory) - return; - - d->m_loadedHistory = true; - - if(d->m_historyRootNode) { - delete d->m_historyRootNode; - d->m_historyRootNode = NULL; - } - - d->m_historyRootNode = new BookmarkNode(BookmarkNode::Root, NULL); - - if (d->m_connectedToBookmarks) { - QList nodes; - nodes = d->m_bookmarkSession->FetchHistory(); - - for(int i=nodes.count()-1;i>=0;i--) { - BookmarkNode* node = new BookmarkNode(BookmarkNode::Bookmark, NULL); - node->title=nodes[i]->getTitle(); - node->url=nodes[i]->getUrl(); - node->date=nodes[i]->getDate(); - node->lastVisited =nodes[i]->getLastVisited(); - d->m_historyRootNode->add(node, 0); - } - - qDeleteAll(nodes); - nodes.clear(); - } - - loadHistoryProxy(); -} - -/*! - * Load history proxy from existing database - * This creates new Model class based on existing Model and arranges the items in to groups - * "Today", "YesterDay", "This Week", "This Month" ......... - */ -void BookmarksManager::loadHistoryProxy() -{ - if(d->m_historyRootNodeProxy) { - delete d->m_historyRootNodeProxy; - d->m_historyRootNodeProxy = NULL; - } - - d->m_historyRootNodeProxy = new BookmarkNode(BookmarkNode::Root, NULL); - - //Loop through the root elements and find the folder in proxy to which the elements belong - for (int i = d->m_historyRootNode->children().count() - 1; i >= 0; --i) { - - BookmarkNode *node = d->m_historyRootNode->children()[i]; - int daysToCurrentDate = node->date.daysTo(QDate::currentDate()); - - if(daysToCurrentDate < 0) { - continue; - } - //Find the Folder name to which this node belongs - QString strFoldername = findFolderForDate(node->date); - //Add the node to proxy model - addToHistoryProxy(strFoldername,node); - } -} - QString BookmarksManager::getHistoryFoldersJSON(QString folderName) { - QVector folderVector; - QMap mymap; + bool flag = true; - mymap.clear(); - folderVector.clear(); - d->m_bookmarkSession->FetchSerializedHistory(folderVector, mymap); + QString historyFolders = "["; - for (int i = folderVector.size() - 1; i >= 0; i--) + if (folderName == "") + { + m_historyMap.clear(); + m_folderVector.clear(); + d->m_bookmarkSession->fetchSerializedHistory(m_folderVector, m_historyMap); + + for (int i = m_folderVector.size() - 1; i >= 0; i--) { //check for folder nodes historyFolders.append("\""); - historyFolders.append(folderVector[i]); + historyFolders.append(m_folderVector[i]); historyFolders.append("\""); @@ -389,7 +343,7 @@ historyFolders.append(","); if (flag) { - if (folderVector[i].count() > 0) + if (m_folderVector[i].count() > 0) { d->m_actionClearHistory->setEnabled(true); flag=false; @@ -402,7 +356,8 @@ d->m_actionClearHistory->setEnabled(false); } historyFolders.append("]"); - folderVector.clear(); + m_folderVector.clear(); + } if (folderName == "") { return historyFolders; @@ -410,7 +365,7 @@ } else { - return mymap[folderName]; + return m_historyMap[folderName]; } } @@ -418,121 +373,6 @@ * Add the node to the folder in proxy model. If the folder doesnt exist in proxy, create * the folder and add the node to it */ -void BookmarksManager::addToHistoryProxy(QString &strFoldername, BookmarkNode*node) -{ - bool bFound = false; - BookmarkNode *folderNode= NULL; - - //Check if the folder exist with name $strFoldername - for (int i = d->m_historyRootNodeProxy->children().count() - 1; i >= 0; --i) { - folderNode = d->m_historyRootNodeProxy->children()[i]; - QString title = folderNode->title ; - if(folderNode->title == strFoldername){ - //folder exist - bFound = true; - break; - } - } - - if(!bFound){ - //Folder doesnt exist. create new folder with name $strFoldername - folderNode = new BookmarkNode(BookmarkNode::Folder, d->m_historyRootNodeProxy); - folderNode->title = strFoldername; - folderNode->date = node->date; - - int index=0; - //Find the index to where the folder needs to be inserted - for (; index < d->m_historyRootNodeProxy->children().count(); index++) { - BookmarkNode* tmpNode = d->m_historyRootNodeProxy->children()[index]; - if(folderNode->date > tmpNode->date){ - break; - } - } - d->m_historyRootNodeProxy->add(folderNode,index); - } - - - - BookmarkNode *newNode = new BookmarkNode(BookmarkNode::Bookmark,folderNode); - newNode->date = node->date; - newNode->title = node->title; - newNode->lastVisited = node->lastVisited; - newNode->favicon = node->favicon; - newNode->url = node->url; - - //Find the index to where the node needs to be inserted in to the foder - int index=0; - for (; index < folderNode->children().count() ; index++) { - BookmarkNode* tmpNode = folderNode->children()[index]; - if(newNode->lastVisited > tmpNode->lastVisited){ - break; - } - } - - folderNode->add(newNode,index); -} - - -/*! - * Finds the folder to which the date belongs - * - */ -//QString BookmarksManager::findFolderForDate( BookmarkNode *aNode) -QString BookmarksManager::findFolderForDate( QDate& nodeDate)const -{ - QDateTime currentDateTime = QDateTime::currentDateTime(); - int currentDayOfWeek = currentDateTime.date().dayOfWeek(); - - int nodeDayOfWeek = nodeDate.dayOfWeek(); - - int daysToCurrentDate = nodeDate.daysTo(currentDateTime.date()); - - //Check if date to belongs to "ToDay" Folder - if(nodeDate == currentDateTime.date()){ - QString folder = qtTrId("txt_browser_history_today"); - return folder; - } - //Check if date to belongs to "YesterDay" Folder - if(nodeDate.addDays(1) == currentDateTime.date() ){ - QString folder = qtTrId("txt_browser_history_yesterday"); - return folder; - } - - //Check if date to belongs to current week folder - //Should disply the day for the current week - if(daysToCurrentDate < 7 && currentDayOfWeek > nodeDayOfWeek ){ - - QString folder = qtTrId("txt_browser_history_this_week"); - return folder; - } - - if(dateInThisMonth(nodeDate)){ - QString folder = qtTrId("txt_browser_history_this_month"); - return folder; - } - - QString folder = nodeDate.toString("dd.MM.yyyy"); - return folder; - -} - - - -bool BookmarksManager::dateInThisMonth(QDate &date)const -{ - QDate currentDate = QDateTime::currentDateTime().date(); - int daysToCurrentDate = currentDate.daysTo(date); - - int currentMonth = currentDate.month(); - int nodeMonth = date.month(); - - if(daysToCurrentDate <= 31 && currentMonth == nodeMonth) { - return true; - } - return false; - -} - /*! * Add to recent urls @@ -542,8 +382,6 @@ */ Q_DECL_EXPORT void BookmarksManager::addHistory(const QString &url, const QString &title) { - if (!d->m_loadedHistory) - loadHistory(); //Check for a valid history entry if (url.isEmpty() || title.isEmpty()) @@ -562,9 +400,8 @@ leaf->setLastVisited(currentDateTime.time()); if (d->m_connectedToBookmarks){ - if(ErrNone == d->m_bookmarkSession->AddHistory(leaf)){ + if(ErrNone == d->m_bookmarkSession->addHistory(leaf)){ d->m_actionClearHistory->setEnabled(true); - d->m_loadedHistory = false; } } delete leaf; @@ -589,19 +426,10 @@ */ void BookmarksManager::clearHistory() { - if (!d->m_loadedHistory) - loadHistory(); - //Undo Redo is not required for history(recent urls) - for (int i = d->m_historyRootNode->children().count() - 1; i >= 0; --i) { - BookmarkNode *node = d->m_historyRootNode->children()[i]; - d->m_historyRootNode->remove(node); - } - if (d->m_connectedToBookmarks) { d->m_bookmarkSession->clearHistory(); } - d->m_loadedHistory = false; d->m_actionClearHistory->setEnabled(false); @@ -615,20 +443,21 @@ int BookmarksManager::getPageRank(const QString &url) { - if (!d->m_loadedHistory) - loadHistory(); - - //Check for a valid entry + //Check for a valid entry if (url.isNull()) return 0; int rank = 0; - QList rootChildren (d->m_historyRootNode->children()); + QList historyNodes = d->m_bookmarkSession->fetchHistory(); - for (int i=0; i < rootChildren.count(); i++) { + for (int i=0; i < historyNodes.count(); i++) { //Update rank if there is a history for this URL. - if (!rootChildren[i]->getUrl().compare(url)) + if (!historyNodes[i]->getUrl().compare(url)) rank++; } + + while (!historyNodes.isEmpty()) + delete historyNodes.takeFirst(); + return rank; } diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/BookmarksManager.h --- a/browsercore/appfw/Api/Managers/BookmarksManager.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/BookmarksManager.h Tue Jul 06 14:03:49 2010 +0300 @@ -59,13 +59,14 @@ //Gets ref count of the page from history int getPageRank(const QString &url); static BookmarksManager* getSingleton(); - + signals: void bookmarkEntryAdded(QString,QString); void launchBookmarkEditDailog(QString,QString); void bookmarkEntryModified(QString, QString); void historyCleared(); void confirmHistoryClear(); + void bookmarksCleared(); public slots: @@ -88,19 +89,14 @@ private: //For loading the history from data base - void loadHistory(); - void loadHistoryProxy(); - //Finds the folder to which the date belongs - QString findFolderForDate( QDate& date) const; - //add the node to history proxy - void addToHistoryProxy(QString &strFoldername, BookmarkNode*node); - //add the history item to root node specified - bool dateInThisMonth(QDate &date)const; + QString normalizeUrl(const QString &url); private: BookmarksManagerPrivate * const d; bool m_isBookmarkDbreadRequired; QString m_bookmakrData; + QVector m_folderVector; + QMap m_historyMap; }; } diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/BookmarksManager_p.h --- a/browsercore/appfw/Api/Managers/BookmarksManager_p.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/BookmarksManager_p.h Tue Jul 06 14:03:49 2010 +0300 @@ -44,16 +44,6 @@ //! flag to indicate was able to connect to book marks bool m_connectedToBookmarks; //! flag to indicate bookmarks are loaded from data base - bool m_loadedBookmarks; - //! flag to indicate history is loaded from data base - bool m_loadedHistory; - //! Root node for bookmark - BookmarkNode *m_bookmarkRootNode; // owned - //! Root node for history - BookmarkNode *m_historyRootNode; // owned - - //! Root node for history proxy model - BookmarkNode *m_historyRootNodeProxy; // owned int m_maxUrls; BrowserContent* m_bookmarkSession; //flag to indicate importing bookmarks diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/ContentAgent.cpp --- a/browsercore/appfw/Api/Managers/ContentAgent.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/ContentAgent.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -85,7 +85,7 @@ QString ContentAgent::getBookmarks() { QList nodes; - nodes = d->m_bookmarkSession->FetchAllBookmarks(); + nodes = d->m_bookmarkSession->fetchAllBookmarks(); QString bookmarkData = "["; for(int i=0;i namespace WRT { @@ -70,6 +72,12 @@ m_gotoMode = GotoModeReloadable; + // FIXME it is a temp fix for the url change issued with cached pages + if (ok) { + WebPageController * pageController = WebPageController::getSingleton(); + if (pageController->currentPage()->loadController() == this) + m_textBoxValue = pageController->currentDocUrl(); + } // TODO: Change to editing mode if load failed /* // if page succeed, set the text and goto reloading mode, else load mode diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/Managers.pri --- a/browsercore/appfw/Api/Managers/Managers.pri Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/Managers.pri Tue Jul 06 14:03:49 2010 +0300 @@ -29,6 +29,8 @@ $$PWD/webpagecontroller_p.h \ $$PWD/downloadcontroller_p.h \ $$PWD/downloadcontroller.h \ + $$PWD/downloadproxy_p.h \ + $$PWD/downloadproxy.h \ $$PWD/contentagent_p.h \ $$PWD/contentagent.h \ $$PWD/lowmemoryhandler.h \ @@ -41,6 +43,8 @@ $$PWD/viewcontroller.cpp \ $$PWD/webpagecontroller.cpp \ $$PWD/downloadcontroller.cpp \ + $$PWD/downloadproxy.cpp \ + $$PWD/downloadproxydata.cpp \ $$PWD/contentagent.cpp \ $$PWD/lowmemoryhandler.cpp diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadcontroller.cpp --- a/browsercore/appfw/Api/Managers/downloadcontroller.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/downloadcontroller.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,6 +22,8 @@ #include "downloadcontroller.h" #include "downloadcontroller_p.h" +#include "downloadproxy_p.h" + #include #include #include @@ -84,7 +86,7 @@ case QNetworkReply::ProtocolFailure: return "QNetworkReply::ProtocolFailure"; default: - return 0; + return "???"; } } @@ -130,293 +132,6 @@ } } -static const char * downloadPriorityToString(DownloadPriority priority) -{ - switch (priority) { - case High: - return "High"; - case Low: - return "Low"; - default: - return 0; - } -} - -static const char * downloadScopeToString(DownloadScope scope) -{ - switch (scope) { - case Normal: - return "Normal"; - case Background: - return "Background"; - default: - return 0; - } -} - -static const char * downloadStateToString(DownloadState state) -{ - switch (state) { - case DlNone: - return "DlNone"; - case DlCreated: - return "DlCreated"; - case DlStarted: - return "DlStarted"; - case DlInprogress: - return "DlInprogress"; - case DlPaused: - return "DlPaused"; - case DlCompleted: - return "DlCompleted"; - case DlFailed: - return "DlFailed"; - case DlCancelled: - return "DlCancelled"; - case DlDescriptorUpdated: - return "DlDescriptorUpdated"; - default: - return 0; - } -} - -static const char * downloadTypeToString(DownloadType type) -{ - switch (type) { - case Parallel: - return "Parallel"; - case Sequential: - return "Sequential"; - default: - return 0; - } -} - -static void debugDownloadStr( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - QString value = download->getAttribute(attribute).toString(); - if (value.length() == 0) { - return; - } - - qDebug() << "DL" << download->id() << name << value; -} - -static void debugDownloadInt( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int value = download->getAttribute(attribute).toInt(); - if (value == 0) { - return; - } - - qDebug() << "DL" << download->id() << name << value; -} - -static void debugDownloadUInt( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - uint value = download->getAttribute(attribute).toUInt(); - if (value == 0) { - return; - } - - qDebug() << "DL" << download->id() << name << value; -} - -static void debugDownloadError( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int num = download->getAttribute(attribute).toInt(); - - const char * str = downloadErrorToString(static_cast(num)); - if (str == 0) { - str = "???"; - } - - qDebug() << "DL" << download->id() << name << num << str; -} - -static void debugDownloadPriority( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int num = download->getAttribute(attribute).toInt(); - - const char * str = downloadPriorityToString(static_cast(num)); - if (str == 0) { - str = "???"; - } - - qDebug() << "DL" << download->id() << name << num << str; -} - -static void debugDownloadScope( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int num = download->getAttribute(attribute).toInt(); - - const char * str = downloadScopeToString(static_cast(num)); - if (str == 0) { - str = "???"; - } - - qDebug() << "DL" << download->id() << name << num << str; -} - -static void debugDownloadState( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int num = download->getAttribute(attribute).toInt(); - - const char * str = downloadStateToString(static_cast(num)); - if (str == 0) { - str = "???"; - } - - qDebug() << "DL" << download->id() << name << num << str; -} - -static void debugDownloadType( - Download * download, - DownloadAttribute attribute, - const char * name) -{ - int num = download->getAttribute(attribute).toInt(); - - const char * str = downloadTypeToString(static_cast(num)); - if (str == 0) { - str = "???"; - } - - qDebug() << "DL" << download->id() << name << num << str; -} - -void DownloadController::debugDownload(Download * download) -{ - debugDownloadState(download, - DlDownloadState, - "DlDownloadState"); - - debugDownloadError(download, - DlLastError, - "DlLastError"); - - debugDownloadStr(download, - DlLastErrorString, - "DlLastErrorString"); - - debugDownloadStr(download, - DlSourceUrl, - "DlSourceUrl"); - - debugDownloadStr(download, - DlContentType, - "DlContentType"); - - debugDownloadStr(download, - DlDestPath, - "DlDestPath"); - - debugDownloadStr(download, - DlFileName, - "DlFileName"); - - debugDownloadInt(download, - DlDownloadedSize, - "DlDownloadedSize"); - - debugDownloadInt(download, - DlTotalSize, - "DlTotalSize"); - - debugDownloadInt(download, - DlLastPausedSize, - "DlLastPausedSize"); - - debugDownloadInt(download, - DlPercentage, - "DlPercentage"); - - debugDownloadStr(download, - DlStartTime, - "DlStartTime"); - - debugDownloadStr(download, - DlEndTime, - "DlEndTime"); - - debugDownloadUInt(download, - DlElapsedTime, - "DlElapsedTime"); - - debugDownloadStr(download, - DlRemainingTime, - "DlRemainingTime"); - - debugDownloadStr(download, - DlSpeed, - "DlSpeed"); - - debugDownloadScope(download, - DlDownloadScope, - "DlDownloadScope"); - - debugDownloadType(download, - DlDownloadType, - "DlDownloadType"); - - debugDownloadPriority(download, - DlPriority, - "DlPriority"); - - debugDownloadInt(download, - DlProgressInterval, - "DlProgressInterval"); - - debugDownloadStr(download, - OMADownloadDescriptorName, - "OMADownloadDescriptorName"); - - debugDownloadStr(download, - OMADownloadDescriptorVersion, - "OMADownloadDescriptorVersion"); - - debugDownloadStr(download, - OMADownloadDescriptorType, - "OMADownloadDescriptorType"); - - debugDownloadStr(download, - OMADownloadDescriptorSize, - "OMADownloadDescriptorSize"); - - debugDownloadStr(download, - OMADownloadDescriptorVendor, - "OMADownloadDescriptorVendor"); - - debugDownloadStr(download, - OMADownloadDescriptorDescription, - "OMADownloadDescriptorDescription"); - - debugDownloadStr(download, - OMADownloadDescriptorNextURL, - "OMADownloadDescriptorNextURL"); -} - static void debugDownloadEvent(DEventType type) { const char * name = downloadEventToString(type); @@ -522,9 +237,12 @@ // Start download. - emit m_downloadController->downloadCreated(download); + DownloadProxy downloadProxy(new DownloadProxyData(download)); + + emit m_downloadController->downloadCreated(downloadProxy); download->registerEventReceiver(this); + download->start(); } @@ -540,6 +258,9 @@ return true; case DownloadsCleared: + // ;;; In new DL mgr will have DownloadManager 'Removed' event instead. + // ;;; Looks like this will only be generated when all downloads are removed. + // ;;; In that case we can emit the same signal. emit m_downloadController->downloadsCleared(); return true; @@ -578,34 +299,36 @@ if (errorStr != 0) error = errorStr; + DownloadProxy downloadProxy(new DownloadProxyData(download)); + switch (type) { case Started: - emit m_downloadController->downloadStarted(download); + emit m_downloadController->downloadStarted(downloadProxy); return true; case HeaderReceived: - emit m_downloadController->downloadHeaderReceived(download); + emit m_downloadController->downloadHeaderReceived(downloadProxy); return true; case Progress: - emit m_downloadController->downloadProgress(download); + emit m_downloadController->downloadProgress(downloadProxy); return true; case Completed: - emit m_downloadController->downloadFinished(download); + emit m_downloadController->downloadFinished(downloadProxy); return true; case Paused: - emit m_downloadController->downloadPaused(download, error); + emit m_downloadController->downloadPaused(downloadProxy, error); return true; case Cancelled: - emit m_downloadController->downloadCancelled(download, error); + emit m_downloadController->downloadCancelled(downloadProxy, error); return true; case Failed: - emit m_downloadController->downloadFailed(download, error); + emit m_downloadController->downloadFailed(downloadProxy, error); return true; case DescriptorUpdated: @@ -613,11 +336,11 @@ return true; case NetworkLoss: - emit m_downloadController->downloadNetworkLoss(download, error); + emit m_downloadController->downloadNetworkLoss(downloadProxy, error); return true; case Error: - emit m_downloadController->downloadError(download, error); + emit m_downloadController->downloadError(downloadProxy, error); return true; case OMADownloadDescriptorReady: diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadcontroller.h --- a/browsercore/appfw/Api/Managers/downloadcontroller.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/downloadcontroller.h Tue Jul 06 14:03:49 2010 +0300 @@ -25,6 +25,8 @@ #include #include "BWFGlobal.h" +#include "downloadproxy.h" + class QFileInfo; class QNetworkProxy; class QNetworkReply; @@ -33,8 +35,6 @@ class QUrl; class QWebPage; -class Download; - class DownloadControllerPrivate; class BWF_EXPORT DownloadController : public QObject @@ -45,8 +45,6 @@ DownloadController(const QString & client, const QNetworkProxy & proxy); ~DownloadController(); - static void debugDownload(Download * download); - public slots: bool handlePage(QWebPage * page); @@ -57,25 +55,25 @@ void startDownload(const QNetworkRequest & request); signals: - void downloadCreated(Download * download); + void downloadCreated(DownloadProxy downloadProxy); - void downloadStarted(Download * download); + void downloadStarted(DownloadProxy downloadProxy); - void downloadHeaderReceived(Download * download); + void downloadHeaderReceived(DownloadProxy downloadProxy); - void downloadProgress(Download * download); + void downloadProgress(DownloadProxy downloadProxy); - void downloadFinished(Download * download); + void downloadFinished(DownloadProxy downloadProxy); - void downloadPaused(Download * download, const QString & error); + void downloadPaused(DownloadProxy downloadProxy, const QString & error); - void downloadCancelled(Download * download, const QString & error); + void downloadCancelled(DownloadProxy downloadProxy, const QString & error); - void downloadFailed(Download * download, const QString & error); + void downloadFailed(DownloadProxy downloadProxy, const QString & error); - void downloadNetworkLoss(Download * download, const QString & error); + void downloadNetworkLoss(DownloadProxy downloadProxy, const QString & error); - void downloadError(Download * download, const QString & error); + void downloadError(DownloadProxy downloadProxy, const QString & error); void downloadsCleared(); diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadcontroller_p.h --- a/browsercore/appfw/Api/Managers/downloadcontroller_p.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/downloadcontroller_p.h Tue Jul 06 14:03:49 2010 +0300 @@ -29,6 +29,7 @@ class QString; class QUrl; +class Download; class DownloadEvent; class DownloadManager; diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browsercore/appfw/Api/Managers/downloadproxy.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "downloadproxy.h" +#include "downloadproxy_p.h" + +DownloadProxy::DownloadProxy(DownloadProxyData * data) +: m_data(data) +{ +} + +DownloadProxy::~DownloadProxy() +{ +} + +void DownloadProxy::debug() +{ + m_data->debug(); +} + +void DownloadProxy::remove() +{ + m_data->remove(); +} + +QString DownloadProxy::fileName() +{ + return m_data->fileName(); +} diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadproxy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browsercore/appfw/Api/Managers/downloadproxy.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef __DOWNLOAD_PROXY_H__ +#define __DOWNLOAD_PROXY_H__ + +#include +#include + +#include "BWFGlobal.h" + +// Each DownloadProxy object encapsulates an instance of the Download class +// used by the Download Manager. DownloadProxy is used to shield client +// code from direct knowledge of the Download class. +// +// Knowledge of the Download class is confined to the DownloadProxyData class. +// DownloadProxyData objects are created by the DownloadController as necessary +// to construct DownloadProxy objects that may be exposed to client code via +// signals or other mechanisms. + +class DownloadProxyData; + +class BWF_EXPORT DownloadProxy +{ +public: + DownloadProxy(DownloadProxyData * data); + + ~DownloadProxy(); + + void debug(); + + void remove(); + + QString fileName(); + +private: + QSharedPointer m_data; +}; + +#endif // __DOWNLOAD_PROXY_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadproxy_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browsercore/appfw/Api/Managers/downloadproxy_p.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef __DOWNLOAD_PROXY_P_H__ +#define __DOWNLOAD_PROXY_P_H__ + +#include + +class Download; + +class DownloadProxyData +{ +public: + DownloadProxyData(Download * download); + + ~DownloadProxyData(); + + void debug(); + + void remove(); + + QString fileName(); + +private: + Download * m_download; +}; + +#endif // __DOWNLOAD_PROXY_P_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/downloadproxydata.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browsercore/appfw/Api/Managers/downloadproxydata.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "downloadproxy_p.h" + +#include +#include + +#ifdef USE_DOWNLOAD_MANAGER +#include "download.h" +#include "downloadmanager.h" +#endif // USE_DOWNLOAD_MANAGER + +DownloadProxyData::DownloadProxyData(Download * download) +: m_download(download) +{} + +DownloadProxyData::~DownloadProxyData() +{ + // Nothing to do, Download * is owned by DownloadManager. +} + +#ifdef USE_DOWNLOAD_MANAGER + +// Helper functions for translating various download attribute enum values. + +static const char * downloadState(int state) +{ + switch (state) { + case DlNone: + return "None"; + case DlCreated: + return "Created"; + case DlStarted: + return "Started"; + case DlInprogress: + return "InProgress"; + case DlPaused: + return "Paused"; + case DlCompleted: + return "Completed"; + case DlFailed: + return "Failed"; + case DlCancelled: + return "Cancelled"; + case DlDescriptorUpdated: + return "DescriptorUpdated"; + default: + return "???"; + } +} + +static const char * downloadError(QNetworkReply::NetworkError error) +{ + switch (error) { + case QNetworkReply::NoError: + return "QNetworkReply::NoError"; + case QNetworkReply::ConnectionRefusedError: + return "QNetworkReply::ConnectionRefusedError"; + case QNetworkReply::RemoteHostClosedError: + return "QNetworkReply::RemoteHostClosedError"; + case QNetworkReply::HostNotFoundError: + return "QNetworkReply::HostNotFoundError"; + case QNetworkReply::TimeoutError: + return "QNetworkReply::TimeoutError"; + case QNetworkReply::OperationCanceledError: + return "QNetworkReply::OperationCanceledError"; + case QNetworkReply::SslHandshakeFailedError: + return "QNetworkReply::SslHandshakeFailedError"; + case QNetworkReply::ProxyConnectionRefusedError: + return "QNetworkReply::ProxyConnectionRefusedError"; + case QNetworkReply::ProxyConnectionClosedError: + return "QNetworkReply::ProxyConnectionClosedError"; + case QNetworkReply::ProxyNotFoundError: + return "QNetworkReply::ProxyNotFoundError"; + case QNetworkReply::ProxyTimeoutError: + return "QNetworkReply::ProxyTimeoutError"; + case QNetworkReply::ProxyAuthenticationRequiredError: + return "QNetworkReply::ProxyAuthenticationRequiredError"; + case QNetworkReply::ContentAccessDenied: + return "QNetworkReply::ContentAccessDenied"; + case QNetworkReply::ContentOperationNotPermittedError: + return "QNetworkReply::ContentOperationNotPermittedError"; + case QNetworkReply::ContentNotFoundError: + return "QNetworkReply::ContentNotFoundError"; + case QNetworkReply::AuthenticationRequiredError: + return "QNetworkReply::AuthenticationRequiredError"; + case QNetworkReply::ContentReSendError: + return "QNetworkReply::ContentReSendError"; + case QNetworkReply::ProtocolUnknownError: + return "QNetworkReply::ProtocolUnknownError"; + case QNetworkReply::ProtocolInvalidOperationError: + return "QNetworkReply::ProtocolInvalidOperationError"; + case QNetworkReply::UnknownNetworkError: + return "QNetworkReply::UnknownNetworkError"; + case QNetworkReply::UnknownProxyError: + return "QNetworkReply::UnknownProxyError"; + case QNetworkReply::UnknownContentError: + return "QNetworkReply::UnknownContentError"; + case QNetworkReply::ProtocolFailure: + return "QNetworkReply::ProtocolFailure"; + default: + return "???"; + } +} + +// Helper functions to get download attribute of a particular type. + +static int intAttribute(Download * download, DownloadAttribute which) +{ + return download->getAttribute(which).toInt(); +} + +static uint uintAttribute(Download * download, DownloadAttribute which) +{ + return download->getAttribute(which).toUInt(); +} + +static QString stringAttribute(Download * download, DownloadAttribute which) +{ + return download->getAttribute(which).toString(); +} + +// Helper functions for reporting download attributes. + +template +void debugDownloadAttribute( + Download * download, + char const * name, + const T & value) +{ + qDebug() << "DL" << download->id() << name << value; +} + +static void debugDownloadInt( + Download * download, + DownloadAttribute which, + const char * name) +{ + int value = intAttribute(download, which); + + debugDownloadAttribute(download, name, value); +} + +static void debugDownloadUInt( + Download * download, + DownloadAttribute which, + const char * name) +{ + uint value = uintAttribute(download, which); + + debugDownloadAttribute(download, name, value); +} + +static void debugDownloadStr( + Download * download, + DownloadAttribute which, + const char * name) +{ + QString value = stringAttribute(download, which); + + debugDownloadAttribute(download, name, value); +} + +static void debugDownloadState(Download * download) +{ + int num = intAttribute(download, DlDownloadState); + + const char * state = downloadState(num); + + debugDownloadAttribute(download, "DownloadState", state); + +} + +static void debugDownloadError(Download * download) +{ + int num = intAttribute(download, DlLastError); + + const char * error = downloadError(static_cast(num)); + + debugDownloadAttribute(download, "DownloadError", error); +} + +// Helper function for implementing DownloadProxyData::debug(). + +static void debugDownload(Download * download) +{ + debugDownloadState(download); + + debugDownloadError(download); + + debugDownloadStr(download, + DlLastErrorString, + "LastErrorString"); + + debugDownloadStr(download, + DlSourceUrl, + "SourceUrl"); + + debugDownloadStr(download, + DlContentType, + "ContentType"); + + debugDownloadStr(download, + DlDestPath, + "DestPath"); + + debugDownloadStr(download, + DlFileName, + "FileName"); + + debugDownloadInt(download, + DlDownloadedSize, + "DownloadedSize"); + + debugDownloadInt(download, + DlTotalSize, + "TotalSize"); + + debugDownloadInt(download, + DlLastPausedSize, + "LastPausedSize"); + + debugDownloadInt(download, + DlPercentage, + "Percentage"); + + debugDownloadStr(download, + DlStartTime, + "StartTime"); + + debugDownloadStr(download, + DlEndTime, + "EndTime"); + + debugDownloadUInt(download, + DlElapsedTime, + "ElapsedTime"); + + debugDownloadStr(download, + DlRemainingTime, + "RemainingTime"); + + debugDownloadStr(download, + DlSpeed, + "Speed"); + + debugDownloadInt(download, + DlProgressInterval, + "ProgressInterval"); +} + +#endif // USE_DOWNLOAD_MANAGER + +void DownloadProxyData::debug() +{ +#ifdef USE_DOWNLOAD_MANAGER + if (m_download == 0) { + return; + } + + int id = m_download->id(); + + DownloadManager * manager = m_download->downloadManager(); + + Download * download = manager->findDownload(id); + + if (download != 0) { + debugDownload(download); + } +#endif // USE_DOWNLOAD_MANAGER +} + +void DownloadProxyData::remove() +{ +#ifdef USE_DOWNLOAD_MANAGER + if (m_download == 0) { + return; + } + + DownloadManager * manager = m_download->downloadManager(); + + manager->removeOne(m_download); + + // Download is no longer valid. + + m_download = 0; +#endif // USE_DOWNLOAD_MANAGER +} + +QString DownloadProxyData::fileName() +{ +#ifdef USE_DOWNLOAD_MANAGER + if (m_download == 0) { + return QString(); + } + + return stringAttribute(m_download, DlFileName); +#else // USE_DOWNLOAD_MANAGER + return QString(); +#endif // USE_DOWNLOAD_MANAGER +} diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/secureuicontroller.cpp --- a/browsercore/appfw/Api/Managers/secureuicontroller.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/secureuicontroller.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,7 @@ #include "secureuicontroller_p.h" #include "secureuicontroller.h" +#include "webpagecontroller.h" namespace WRT { @@ -187,10 +188,13 @@ * * This function should be called when the final load ended. */ -void SecureUIController::endSecureCheck(bool) +void SecureUIController::endSecureCheck(bool loadFinished) { //qDebug()<<"endSecureCheck Internal state = "<m_internalState; + if (!loadFinished) + setTopLevelScheme(WebPageController::getSingleton()->currentDocUrl()); + /* Save the current secure state */ determineSecureState(); diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/secureuicontroller.h --- a/browsercore/appfw/Api/Managers/secureuicontroller.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/secureuicontroller.h Tue Jul 06 14:03:49 2010 +0300 @@ -76,7 +76,7 @@ void setTopLevelScheme(const QUrl & url); void secureCheck(QWebFrame* frame, QNetworkRequest* request); - void endSecureCheck(bool); + void endSecureCheck(bool loadFinished); void onSslErrors(QNetworkReply*,const QList &); signals: diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/webpagecontroller.cpp --- a/browsercore/appfw/Api/Managers/webpagecontroller.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/webpagecontroller.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -41,6 +41,10 @@ #include #include #include +#include +#include +#include +#include using namespace WRT; #if defined(Q_OS_SYMBIAN) // for shareToMail @@ -143,9 +147,12 @@ m_networkError (false), m_networkErrorMsg("No network error"), m_networkErrorUrl("No Url"), + m_promptMsg("No message"), + m_promptReserved(""), m_memoryHandler(new LowMemoryHandler(this)), d(new WebPageControllerPrivate(this)), - m_settingsLoaded(0) + m_settingsLoaded(0), + m_bErrorUrlMatches(false) { // Register a new MetaType WebPageData. It is needed to serialize history (starage) qRegisterMetaTypeStreamOperators ("WebPageData"); @@ -158,7 +165,9 @@ connect( d->m_actionBack, SIGNAL( triggered() ), this, SLOT( currentBack() ) ); connect( d->m_actionForward, SIGNAL( triggered() ), this, SLOT( currentForward() ) ); + connect( m_memoryHandler, SIGNAL( lowMemory() ), this, SIGNAL( lowMemory() ) ); connect( m_memoryHandler, SIGNAL( lowMemory() ), this, SLOT( handleLowMemory() ) ); + connect( m_memoryHandler, SIGNAL( outOfMemory() ), this, SIGNAL( outOfMemory() ) ); connect( m_memoryHandler, SIGNAL( outOfMemory() ), this, SLOT( handleOutOfMemory() ) ); m_memoryHandler->start(); @@ -197,7 +206,7 @@ Q_ASSERT( page ); page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, (bool) BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsInt("DeveloperExtras")); - + connect( page, SIGNAL( loadFinished(bool) ), SLOT( onLoadFinishedForBackgroundWindow(bool) ) ); // emit signal indicating that new page is being created emit creatingPage( page ); @@ -274,57 +283,59 @@ */ void WebPageController::closePage ( WRT::WrtBrowserContainer *page ) { - WRT::WrtBrowserContainer * theCurrentPage = currentPage(); - bool updateCurrentPageIndex = false; + if(pageCount() > 1) { + WRT::WrtBrowserContainer * theCurrentPage = currentPage(); + bool updateCurrentPageIndex = false; - // get index of page we want to remove - int closeIndex = d->m_allPages.indexOf(page); - if(closeIndex < 0) - return; + // get index of page we want to remove + int closeIndex = d->m_allPages.indexOf(page); + if(closeIndex < 0) + return; - // was this page the "current page?" - // if so, we need to select the page to become the new one - // select the previous page unless at the beginning, then select next - if(page == theCurrentPage) { - int newCurrIndex = closeIndex - 1; - if(closeIndex == 0 ) { - newCurrIndex = closeIndex + 1; - } + // was this page the "current page?" + // if so, we need to select the page to become the new one + // select the previous page unless at the beginning, then select next + if(page == theCurrentPage) { + int newCurrIndex = closeIndex - 1; + if(closeIndex == 0 ) { + newCurrIndex = closeIndex + 1; + } - // change the current page - if(newCurrIndex >= 0) { - theCurrentPage = d->m_allPages.at(newCurrIndex); - setCurrentPage(theCurrentPage); - updateCurrentPageIndex = true; + // change the current page + if(newCurrIndex >= 0) { + theCurrentPage = d->m_allPages.at(newCurrIndex); + setCurrentPage(theCurrentPage); + updateCurrentPageIndex = true; + } + else { + d->m_currentPage = -1; + emit pageChanged(page, NULL); + } } else { - d->m_currentPage = -1; - emit pageChanged(page, NULL); + /* Adjust m_currentPage if the index of the page deleted is less than + * current page + */ + if (closeIndex < d->m_currentPage ) + updateCurrentPageIndex = true; } - } - else { - /* Adjust m_currentPage if the index of the page deleted is less than - * current page - */ - if (closeIndex < d->m_currentPage ) - updateCurrentPageIndex = true; - } + + // actually delete the page from the list + d->m_allPages.removeAt(closeIndex); - // actually delete the page from the list - d->m_allPages.removeAt(closeIndex); + // update the current page index if necessary + // (this will just update the index now that we've removed the page from the list) + if(updateCurrentPageIndex) { + int index = d->m_allPages.indexOf(theCurrentPage); + if(index >= 0) + d->m_currentPage = index; + } - // update the current page index if necessary - // (this will just update the index now that we've removed the page from the list) - if(updateCurrentPageIndex) { - int index = d->m_allPages.indexOf(theCurrentPage); - if(index >= 0) - d->m_currentPage = index; + // and emit sig that it was done + emit pageDeleted(page); + + delete page; } - - // and emit sig that it was done - emit pageDeleted(page); - - delete page; } /*! @@ -358,7 +369,7 @@ disconnect(oldPage->networkAccessManager(), 0, this, 0); disconnect(oldPage->loadController(), 0, this, 0); connect(oldPage, SIGNAL(createNewWindow(WrtBrowserContainer*)), this, SLOT(createWindow(WrtBrowserContainer*))); - + connect(oldPage, SIGNAL(loadFinished(bool)), SLOT(onLoadFinishedForBackgroundWindow(bool))); } // aggregate "current page" signalling from this page to PageMgr clients connect(page, SIGNAL(secureStateChange(int)), this, SLOT(secureStateChange(int))); @@ -367,6 +378,9 @@ connect( page->mainFrame(), SIGNAL(initialLayoutCompleted() ), SIGNAL( initialLayoutCompleted() ) ); connect( page, SIGNAL( loadProgress(int) ), SIGNAL( loadProgress(int) ) ); connect( page, SIGNAL( loadFinished(bool) ), SLOT( onLoadFinished(bool) ) ); + + connect( page, SIGNAL( databaseQuotaExceeded (QWebFrame *,QString) ), SLOT( onDatabaseQuotaExceeded (QWebFrame *,QString)) ); + connect( page->mainFrame(), SIGNAL( iconChanged() ), SIGNAL( pageIconChanged() ) ); connect( page->loadController(), SIGNAL( pageLoadStarted() ), SIGNAL( pageLoadStarted() ) ); connect( page->loadController(), SIGNAL( pageLoadFailed() ), SIGNAL( pageLoadFailed() ) ); @@ -416,6 +430,37 @@ } } + +void WebPageController::onDatabaseQuotaExceeded (QWebFrame *frame, QString database) +{ + QString dbdir = QWebSettings::offlineStoragePath (); + QDir dir(dbdir); + + if(!dir.exists()||(dir.count() <= 1)) // empty DB + return; + + + if(frame) + { + QWebSecurityOrigin qwso = frame->securityOrigin(); + qint64 quota = qwso.databaseQuota() ; + qint64 usage = qwso.databaseUsage() ; + } + m_promptMsg = "Database Quota Error"; + emit databaseQuotaExceeded (frame, database); + + return; +} + +void WebPageController::onLoadFinishedForBackgroundWindow(bool ok) +{ + if (!ok) + return; + WRT::WrtBrowserContainer* page = qobject_cast (sender()); + if (page) + page->setUpdateThumbnail(true); +} + void WebPageController::updateHistory() { BookmarksManager::getSingleton()->addHistory(currentDocUrl(), currentDocTitle()); @@ -441,11 +486,14 @@ void WebPageController::processNetworkErrorUrl(const QUrl & url ) { QString errorUrl = url.toString(); - QString currentUrl = currentDocUrl(); + QString requestedUrl = currentRequestedUrl(); m_networkErrorUrl = url.toString(); -// TODO: may not necessary -// Here we should be able to do various handling of the error url, such -// as comparing with QWebPage URL, ... etc + + // Check if requestedUrl matches the URL from the network error + // This is to resolve the problems when error popups occur when they shouldn't + // especially during download. + int matches = m_networkErrorUrl.compare(requestedUrl); + if (matches == 0) m_bErrorUrlMatches = true; } //void QWEBKIT_EXPORT qt_drt_garbageCollector_collect(); @@ -778,6 +826,9 @@ { updateActions(true); + // Reset to false for new page + m_bErrorUrlMatches = false; + // This is needed for loading a restored window (otherwise url bar is empty) currentPage()->loadController()->setUrlText(currentPage()->history()->currentItem().url().toString()); } @@ -797,7 +848,7 @@ { d->m_actionReload->setEnabled(!pageIsLoading); d->m_actionStop->setEnabled(pageIsLoading); - + WRT::WrtBrowserContainer* activePage = currentPage(); if(activePage) { @@ -891,9 +942,10 @@ void WebPageController::loadLocalFile() { - QString chromeBaseDir = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory"); + QString chromeBaseDir = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("LocalPagesBaseDirectory"); QString startPage = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("StartPage"); QString startPagePath = chromeBaseDir + startPage; + currentLoad(startPagePath); } @@ -1271,6 +1323,37 @@ } } + +bool WebPageController::removeDirectory(QDir &aDir) +{ + bool has_err = false; + if (aDir.exists()) + { + QFileInfoList entries = aDir.entryInfoList(QDir::NoDotAndDotDot | + QDir::Dirs | QDir::Files); + int count = entries.size(); + for (int idx = 0; ((idx < count) && (0 == has_err)); idx++) + { + QFileInfo entryInfo = entries[idx]; + QString path = entryInfo.absoluteFilePath(); + if (entryInfo.isDir()) + { + QDir dir(path); + has_err = removeDirectory(dir); + } + else + { + QFile file(path); + if (!file.remove()) + has_err = true; + } + } + if (!aDir.rmdir(aDir.absolutePath())) + has_err = true; + } + return(has_err); +} + void WebPageController::clearHistoryInMemory() { WRT::WrtBrowserContainer * activePage = currentPage(); @@ -1324,6 +1407,30 @@ void WebPageController::deleteCache() { + + QWebDatabase::removeAllDatabases(); + + QString str1 = QWebSettings::offlineStoragePath (); + QString str2 = QWebSettings::offlineWebApplicationCachePath (); + QWebSettings * globalSettings = QWebSettings::globalSettings(); + QString LocalStoragePath = globalSettings->localStoragePath(); + + /*QString deleteFlag = d->m_historyDir + QLatin1String("/deleteOfflineStorage"); + QFile deleteFileFlag(deleteFlag); + if(deleteFileFlag.open(QIODevice::WriteOnly)) { // create indicator that marks offline storage for deletion while next browser startup + deleteFileFlag.close(); + }*/ + + QDir LocalStorage(LocalStoragePath); + removeDirectory(LocalStorage); + + QString applicationCacheFile = d->m_historyDir + QLatin1String("/ApplicationCache.db"); + QFile file(applicationCacheFile); + if(file.open(QIODevice::ReadOnly)) { + file.remove(); // may fail if file in usage; will be deleted in next browser startup + file.close(); + } + if ( !BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value("DiskCacheEnabled").toBool() ) return; @@ -1377,7 +1484,6 @@ } - void WebPageController::urlChanged(const QUrl& url) { //private slot @@ -1385,7 +1491,6 @@ emit partialUrlChanged(urlString); } - QString WebPageController::partialUrl(const QUrl& url) { @@ -1420,31 +1525,31 @@ bool needRestore = false; for (int i = 0; i < allPages()->count(); i++) { - WRT::WrtBrowserContainer* page = allPages()->at(i); - QWebHistoryItem item = page->history()->currentItem(); - - WebPageData data = item.userData().value(); + WRT::WrtBrowserContainer* page = allPages()->at(i); + QWebHistoryItem item = page->history()->currentItem(); + WebPageData data = item.userData().value(); // If not still a blank window, check whether we need to update the img if (!page->emptyWindow() ){ QImage img = data.m_thumbnail; - - bool isSameMode = ( (img.size().width() > img.size().height()) == (currSize.width() > currSize.height()) ); - if (img.isNull() || !isSameMode) { - - qDebug() << "need new thumbnail!!!" << img.size() << ":" << currSize; - needRestore = true; - view->setPage(page); - page->setWebWidget(view); - QCoreApplication::sendEvent(view, new WebPageControllerUpdateViewPortEvent()); - page->savePageDataToHistoryItem(page->mainFrame(), &item); - } + bool isSameMode = ( (img.size().width() > img.size().height()) == (currSize.width() > currSize.height()) ); + if (img.isNull() || !isSameMode) { + needRestore = true; + view->setPage(page); + page->setWebWidget(view); + QCoreApplication::sendEvent(view, new WebPageControllerUpdateViewPortEvent()); + page->savePageDataToHistoryItem(page->mainFrame(), &item); + page->setUpdateThumbnail(false); + } + if (page->needUpdateThumbnail()) { + page->savePageDataToHistoryItem(page->mainFrame(), &item); + page->setUpdateThumbnail(false); + } } } // restore - if (needRestore) - { + if (needRestore) { view->setPage(savedPage); savedPage->setWebWidget(view); } @@ -1452,14 +1557,11 @@ void WebPageController::updatePageThumbnails() { - // update current page's thumbnail forcely + // update current page's thumbnail forcely since the scrolling position may change WRT::WrtBrowserContainer *page = currentPage(); QWebHistoryItem item = page->history()->currentItem(); - page->savePageDataToHistoryItem(page->mainFrame(), &item); - - WebPageData data = item.userData().value(); - + page->setUpdateThumbnail(false); checkAndUpdatePageThumbnails(); } @@ -1521,6 +1623,18 @@ return m_networkErrorUrl; } +bool WebPageController::errorUrlMatches() { + return m_bErrorUrlMatches; +} + +QString WebPageController::promptMsg() { + return m_promptMsg; +} + +QString WebPageController::promptReserved() { + return m_promptReserved; +} + /*! \fn void WebPageController::pageCreated(WrtPage* newPage); emitted when a page is created diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Managers/webpagecontroller.h --- a/browsercore/appfw/Api/Managers/webpagecontroller.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Managers/webpagecontroller.h Tue Jul 06 14:03:49 2010 +0300 @@ -32,6 +32,7 @@ #include "browserpagefactory.h" #include "BWFGlobal.h" #include "messageboxproxy.h" +#include class QGraphicsWebView; class LowMemoryHandler; @@ -113,6 +114,9 @@ bool loadCanceled(); Q_PROPERTY(bool loadCanceled READ loadCanceled) + bool errorUrlMatches(); + Q_PROPERTY(bool errorUrlMatches READ errorUrlMatches) + bool networkError(); Q_PROPERTY(bool networkError READ networkError) @@ -121,6 +125,12 @@ QString networkErrorUrl(); Q_PROPERTY(QString networkErrorUrl READ networkErrorUrl) + + QString promptMsg(); + Q_PROPERTY(QString promptMsg READ promptMsg) + + QString promptReserved(); + Q_PROPERTY(QString promptReserved READ promptReserved) WRT::WrtBrowserContainer* openPage(); WRT::WrtBrowserContainer* openPageFromHistory(int index); @@ -151,6 +161,8 @@ void updatePageThumbnails(); void resizeAndUpdatePageThumbnails(QSize& s); QString partialUrl(const QUrl &url); + bool removeDirectory(QDir &aDir); + private: void checkAndUpdatePageThumbnails(); @@ -221,6 +233,8 @@ void handleOutOfMemory(); void onLoadFinished(bool); + void onDatabaseQuotaExceeded (QWebFrame *,QString); + void onLoadFinishedForBackgroundWindow(bool); signals: void creatingPage( WRT::WrtBrowserContainer* newPage); void pageCreated( WRT::WrtBrowserContainer* newPage); @@ -232,6 +246,7 @@ void initialLayoutCompleted(); void loadProgress( const int progress ); void loadFinished( const bool ok ); + void databaseQuotaExceeded (QWebFrame *,QString); void currentPageIconChanged(); void currentPageUrlChanged( const QUrl & url); @@ -261,12 +276,19 @@ // Signal for network status void networkErrorHappened(const QString & msg ); + + // Signals for low and out of memory + void lowMemory(); + void outOfMemory(); private: bool m_networkError; QString m_networkErrorMsg; QString m_networkErrorUrl; + bool m_bErrorUrlMatches; + QString m_promptMsg; + QString m_promptReserved; LowMemoryHandler *m_memoryHandler; WebPageControllerPrivate * const d; int m_settingsLoaded; diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Api/Views/WindowView.cpp --- a/browsercore/appfw/Api/Views/WindowView.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Api/Views/WindowView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -5,14 +5,14 @@ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 2.1 of the License. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, +* along with this program. If not, * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". * * Description: @@ -238,7 +238,7 @@ { QString pagetitle(d->m_pageList->at(centerIndex)->mainFrame()->title()); if(pagetitle.isEmpty()) - title += qtTrId("txt_browser_windows_blank"); + title += qtTrId("txt_browser_windows_new_window"); else title += pagetitle; } @@ -375,7 +375,7 @@ connect(d->m_actionDelWindow, SIGNAL(triggered()), this, SLOT(delPage())); } -void WindowView::setMode(Mode m) +void WindowView::setMode(Mode m) { d->m_mode = m; } @@ -437,7 +437,7 @@ QWebHistoryItem item = window->history()->currentItem(); WebPageData data = item.userData().value(); QImage img = data.m_thumbnail; - + QSize size = window->webWidget()->size().toSize(); QSize imgSize = img.size(); float ratio = (float)size.width() / (float)size.height(); @@ -446,7 +446,7 @@ size.scale(imgSize, Qt::KeepAspectRatio); img = img.copy(0, 0, size.width(), size.height()); } - + d->m_flowInterface->addSlide(img, title); } setCenterIndex(d->m_pageManager->currentPage()); @@ -583,7 +583,7 @@ { Q_ASSERT(d->m_flowInterface); - //qDebug() << "WindowView::addPage: COUNT "<< d->m_newPages.count(); + //qDebug() << "WindowView::addPage: COUNT "<< d->m_newPages.count(); if (d->m_flowInterface->slideAnimationOngoing() || (d->m_mode == WindowViewModeNormal && d->m_state == WindowViewAddPage)) return; @@ -598,9 +598,9 @@ title = pg->mainFrame()->title(); else if (!pg->mainFrame()->url().isEmpty() ) title = d->m_pageManager->partialUrl(pg->mainFrame()->url()); - else + else title = d->m_pageManager->partialUrl(pg->mainFrame()->requestedUrl()); - + //qDebug() << "WindowView::addPage - Title " << pg->mainFrame()->title() << "Url : "<< pg->mainFrame()->url().toString()<< "Requested Url : " << pg->mainFrame()->requestedUrl().toString() ; } @@ -615,12 +615,12 @@ /* Adding a new page is completed when the index reaches the newly added index*/ Q_ASSERT(d->m_state == WindowViewAddPage); - - //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); + + //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); /* If new pages were added, show them before transitioning back to content view */ if (d->m_newPages.count() ) { - //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); + //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); QTimer::singleShot(WINDOWVIEW_TIME_TO_ADD_NEXTPAGE, this, SLOT(addNextPage())); } @@ -637,7 +637,7 @@ void WindowView::addNextPage() { - //qDebug() << " WindowView::addNextPage " << d->m_newPages.count() << "Added Page " << d->m_newPages.at(0); + //qDebug() << " WindowView::addNextPage " << d->m_newPages.count() << "Added Page " << d->m_newPages.at(0); addPage(d->m_newPages.takeFirst()); } @@ -663,7 +663,7 @@ disconnect(d->m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(addPageCplt())); d->m_state = WindowViewActive; updateActions(); - + if (d->m_mode == WindowViewModeTransition ) { emit newWindowTransitionComplete(); } diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/appfw/Common/FilmstripFlow.cpp --- a/browsercore/appfw/Common/FilmstripFlow.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/appfw/Common/FilmstripFlow.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -1651,7 +1651,9 @@ return; if(event->pos().x() > ( (size().width() - d->m_centerWindowSize.width())/ 2) && - event->pos().x() < ( (size().width() + d->m_centerWindowSize.width())/ 2) ) + event->pos().x() < ( (size().width() + d->m_centerWindowSize.width())/ 2) && + event->pos().y() > d->m_centerTopSpace && + event->pos().y() < d->m_centerTopSpace + d->m_centerWindowSize.height()) { emit ok(d->m_centerIndex); } diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/ZoomMetaData.h --- a/browsercore/core/ZoomMetaData.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/ZoomMetaData.h Tue Jul 06 14:03:49 2010 +0300 @@ -22,6 +22,11 @@ #ifndef __ZOOMMETADATA_H__ #define __ZOOMMETADATA_H__ +#ifdef BEDROCK_TILED_BACKING_STORE +#include +#include +#endif + // To store the view port proeperties that affect zoom set through meta data. // This is available in the main frame of the page but to avoid parsing the meta // data again, store it @@ -39,6 +44,14 @@ qreal minScale; qreal maxScale; bool userScalable; - +#ifdef BEDROCK_TILED_BACKING_STORE + qreal initialScale; + QRectF rect; + QRectF webViewSize; + qreal scale; + QSizeF viewportSize; + QString m_specifiedWidth; + QString m_specifiedHeight; +#endif }; #endif //__ZOOMMETADATA_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/core.pro --- a/browsercore/core/core.pro Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/core.pro Tue Jul 06 14:03:49 2010 +0300 @@ -127,6 +127,11 @@ unix : contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions } +contains(br_tiled_backing_store, yes) { + DEFINES += BEDROCK_TILED_BACKING_STORE +} + + CONFIG -= warn_on *-g++* : QMAKE_CXXFLAGS += -Wreturn-type -fno-strict-aliasing diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/network/WebNetworkConnectionManager.cpp --- a/browsercore/core/network/WebNetworkConnectionManager.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/network/WebNetworkConnectionManager.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -27,7 +27,7 @@ Constructs a WebNetworkConfigurationManager with the given \a parent. */ WebNetworkConnectionManager::WebNetworkConnectionManager(QObject *parent) - : QObject(parent), m_WebNetworkSession(0) + : QObject(parent), m_WebNetworkSession(0), m_offlined(false) { // set up handlers for Network Configuration Manager signals connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), @@ -117,8 +117,6 @@ // set up handlers for the WebNetworkSession signals connect(m_WebNetworkSession, SIGNAL(sessionConfigurationChanged(const QNetworkConfiguration &)), this, SLOT(handleSessionConfigurationChanged(const QNetworkConfiguration &))); - connect(m_WebNetworkSession, SIGNAL(sessionStateChanged(const QNetworkConfiguration &, QNetworkSession::State)), - this, SLOT(handleSessionStateChanged(const QNetworkConfiguration &, QNetworkSession::State))); } /*! @@ -128,6 +126,7 @@ void WebNetworkConnectionManager::deleteSession(void) { delete m_WebNetworkSession; + m_WebNetworkSession = 0; } /*! @@ -164,17 +163,21 @@ } /*! - Handle the conlineStateChanged signal from Network Configuration Manager. + Handle the onlineStateChanged signal from Network Configuration Manager. */ void WebNetworkConnectionManager::handleOnlineStateChanged(bool isOnline) { + emit networkOnlineStateChanged(isOnline); + if (!isOnline) { qDebug() << "offline"; + m_offlined = true; } else { qDebug() << "online"; + m_offlined = false; } // flash icon to indicate the online state change with "online" and "offline". } @@ -184,8 +187,48 @@ */ void WebNetworkConnectionManager::handleConfigurationChanged(const QNetworkConfiguration &config) { - qDebug() << "Configuration" << config.name() << "Changed"; -} + qDebug() << "Configuration" << config.name() << "Changed"; + qDebug() << "bearername:" << config.bearerName() << "type:" << config.type() << "state:" << config.state() << "purpose:" << config.purpose(); + + /* The QNetworkSession is closed becuase of previous offline condition. Re-open the session if + the configuration matches the configurations hold by the QNetworkSession */ +#ifdef NO_OFFLINED_BUG + if (isOfflined()) + { +#endif // NO_OFFLINED_BUG + if (m_WebNetworkSession && !m_WebNetworkSession->isOpen()) + { + QNetworkConfiguration sessionConfig = m_WebNetworkSession->configuration(); + QList children = sessionConfig.children(); + switch(sessionConfig.type()) + { + case QNetworkConfiguration::ServiceNetwork: + /* Traverse all configuration to find the matching configuration */ + foreach(QNetworkConfiguration tmpConfig, children) + { + if (config == tmpConfig) + { + if ((config.state() == QNetworkConfiguration::Discovered) || + (config.state() == QNetworkConfiguration::Active)) + m_WebNetworkSession->open(); + break; + } + } + break; + case QNetworkConfiguration::InternetAccessPoint: + qDebug() << "InternetAccessPoint"; + break; + case QNetworkConfiguration::UserChoice: + qDebug() << "UserChoice"; + break; + default: + break; + } + } +#ifdef NO_OFFLINED_BUG + } +#endif // NO_OFFLINED_BUG +} /*! Handle the networkNameChanged signal from Network Configuration Manager and translate @@ -195,75 +238,13 @@ */ void WebNetworkConnectionManager::handleSessionConfigurationChanged(const QNetworkConfiguration &config) { - qDebug() << "handleSessionConfigurationChanged" << "bearname:" << config.bearerName(); + qDebug() << "handleSessionConfigurationChanged" << "bearername:" << config.bearerName(); #ifdef QT_MOBILITY_SYSINFO QSystemNetworkInfo::NetworkMode mode; mode = m_mapStringNetworkMode[config.bearerName()]; - switch(mode) - { - case QSystemNetworkInfo::EthernetMode: - case QSystemNetworkInfo::WlanMode: - case QSystemNetworkInfo::BluetoothMode: - case QSystemNetworkInfo::WimaxMode: - emit networkNameChanged(mode, config.name()); - break; - case QSystemNetworkInfo::GsmMode: - case QSystemNetworkInfo::CdmaMode: - case QSystemNetworkInfo::WcdmaMode: - break; - case QSystemNetworkInfo::UnknownMode: - default: - emit networkNameChanged(mode, config.name()); - break; - } -#endif // QT_MOBILITY_SYSINFO -} -/*! - Handle the networkSignalStrengthChanged from Network Configuration Manager and - translate sessionStateChanged to networkSignalStrengthChanged. - - It a\ emits networkSignalStrengthChanged for non cellular network connection. -*/ -void WebNetworkConnectionManager::handleSessionStateChanged(const QNetworkConfiguration &config, - QNetworkSession::State state) -{ - int strength = 0; - - qDebug() << "handleSessionStateChanged" << "bearname:" << config.bearerName(); - - switch(state) - { - case QNetworkSession::Connecting: - case QNetworkSession::Connected: - case QNetworkSession::Roaming: - strength = 100; - break; - default: - break; - } - -#ifdef QT_MOBILITY_SYSINFO - QSystemNetworkInfo::NetworkMode mode; - mode = m_mapStringNetworkMode[config.bearerName()]; - switch(mode) - { - case QSystemNetworkInfo::EthernetMode: - case QSystemNetworkInfo::WlanMode: - case QSystemNetworkInfo::BluetoothMode: - case QSystemNetworkInfo::WimaxMode: - emit networkSignalStrengthChanged(mode, strength); - break; - case QSystemNetworkInfo::GsmMode: - case QSystemNetworkInfo::CdmaMode: - case QSystemNetworkInfo::WcdmaMode: - break; - case QSystemNetworkInfo::UnknownMode: - default: - emit networkSignalStrengthChanged(mode, strength); - break; - } + emit networkSessionNameChanged(mode, config.name()); #endif // QT_MOBILITY_SYSINFO } @@ -283,3 +264,4 @@ #endif // QT_MOBILITY_SYSINFO } // WRT + diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/network/WebNetworkConnectionManager.h --- a/browsercore/core/network/WebNetworkConnectionManager.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/network/WebNetworkConnectionManager.h Tue Jul 06 14:03:49 2010 +0300 @@ -30,10 +30,10 @@ QTM_USE_NAMESPACE +namespace WRT { + class WebNetworkSession; -namespace WRT { - class WRT_BROWSER_EXPORT WebNetworkConnectionManager : public QObject { Q_OBJECT @@ -46,23 +46,21 @@ QNetworkConfiguration defaultConfiguration() const; void createSession(QNetworkConfiguration config); void deleteSession(); + bool isOfflined() const { return m_offlined; } #ifdef QT_MOBILITY_SYSINFO Q_SIGNALS: - void networkModeChanged(QSystemNetworkInfo::NetworkMode mode); - void networkNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString &netName); - void networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode mode, int strength); + void networkOnlineStateChanged(bool isOnline); + void networkSessionNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString &netName); #endif // QT_MOBILITY_SYSINFO -private Q_SLOTS: - void handleConfigurationUpdateCompleted(); - void handleConfigurationAdded(const QNetworkConfiguration& config); - void handleConfigurationRemoved(const QNetworkConfiguration& config); - void handleOnlineStateChanged(bool isOnline); - void handleConfigurationChanged(const QNetworkConfiguration& config); - void handleSessionConfigurationChanged(const QNetworkConfiguration &config); - void handleSessionStateChanged(const QNetworkConfiguration &config, - QNetworkSession::State state); +protected Q_SLOTS: + virtual void handleConfigurationUpdateCompleted(); + virtual void handleConfigurationAdded(const QNetworkConfiguration& config); + virtual void handleConfigurationRemoved(const QNetworkConfiguration& config); + virtual void handleOnlineStateChanged(bool isOnline); + virtual void handleConfigurationChanged(const QNetworkConfiguration& config); + virtual void handleSessionConfigurationChanged(const QNetworkConfiguration &config); private: #ifdef QT_MOBILITY_SYSINFO @@ -73,7 +71,8 @@ QNetworkConfigurationManager m_NetworkConfigurationManager; WebNetworkSession *m_WebNetworkSession; + bool m_offlined; }; -} +} // namesspace WRT #endif /* WEBNETWORKCONNECTIONMANAGER_H_ */ diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/network/WebNetworkSession.cpp --- a/browsercore/core/network/WebNetworkSession.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/network/WebNetworkSession.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -21,6 +21,8 @@ #include "WebNetworkSession.h" +namespace WRT { + /*! Constructs a Web Network Session based on \a QNetworkConfiguration with the given \a parent. @@ -110,11 +112,16 @@ // flash the old connection network qDebug() << "Reject new Network Connection"; } - emit sessionConfigurationChanged(m_NetworkSession->configuration()); + + emit sessionConfigurationChanged(activeConfiguration()); } /*! - Handle the stateChanged signal from Network Session. + Handle the stateChanged signal from Network Session. If the session is based on a single + access point configuration, the state of the session is the same state of the associated + network interface. A QNetworkConfiguration::ServiceNetwork based session summarizes the + state of all its children and therefore returns the Connected state if at least one of its + sub configurations is connected. It emits networkSignalStrengthChanged signal with current QNetworkConfiguraiton and QNetworkSession::State. @@ -157,7 +164,7 @@ void WebNetworkSession::handleOpened() { qDebug() << "Session Opened"; - + emit sessionConfigurationChanged(activeConfiguration()); } @@ -233,4 +240,6 @@ } return activeConfig; -} \ No newline at end of file +} + +} // namespace WRT \ No newline at end of file diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/network/WebNetworkSession.h --- a/browsercore/core/network/WebNetworkSession.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/network/WebNetworkSession.h Tue Jul 06 14:03:49 2010 +0300 @@ -21,30 +21,36 @@ #ifndef WEBNETWORKSESSION_H_ #define WEBNETWORKSESSION_H_ +#include "brtglobal.h" #include QTM_USE_NAMESPACE -class WebNetworkSession : public QObject +namespace WRT { + +class WRT_BROWSER_EXPORT WebNetworkSession : public QObject { Q_OBJECT public: WebNetworkSession(const QNetworkConfiguration &config, QObject *parent = 0); virtual ~WebNetworkSession(); - + QNetworkConfiguration configuration() const { return m_NetworkSession->configuration(); } + bool isOpen() const { return m_NetworkSession->isOpen(); } + void open() { m_NetworkSession->open(); } + Q_SIGNALS: void sessionConfigurationChanged(const QNetworkConfiguration &config); void sessionStateChanged(const QNetworkConfiguration &config, QNetworkSession::State state); -private Q_SLOTS: - void handlePreferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless); - void handleNewConfigurationActivated(); - void handleStateChanged(QNetworkSession::State state); - void handleOpened(); - void handleClosed(); - void handleError(QNetworkSession::SessionError error); +protected Q_SLOTS: + virtual void handlePreferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless); + virtual void handleNewConfigurationActivated(); + virtual void handleStateChanged(QNetworkSession::State state); + virtual void handleOpened(); + virtual void handleClosed(); + virtual void handleError(QNetworkSession::SessionError error); private: QNetworkConfiguration activeConfiguration(); @@ -52,4 +58,6 @@ QNetworkSession *m_NetworkSession; }; +} // namespace WRT + #endif /* WEBNETWORKSESSION_H_ */ diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/network/webnetworkaccessmanager.cpp --- a/browsercore/core/network/webnetworkaccessmanager.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/network/webnetworkaccessmanager.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -23,7 +23,6 @@ #include #include #include - #if QT_VERSION >= 0x040500 #include // #include "networkdiskcache.h" @@ -68,8 +67,8 @@ void WebNetworkAccessManager::onfinished(QNetworkReply* reply) { QNetworkReply::NetworkError networkError = reply->error(); - QString replyUrl = reply->url().toString(); - + QString requestUrl = reply->request().url().toString(); + if ( networkError != QNetworkReply::OperationCanceledError && networkError != QNetworkReply::NoError ) { @@ -85,7 +84,7 @@ } } emit networkErrorHappened(errorMsg); - emit networkErrorUrl(replyUrl); + emit networkErrorUrl(requestUrl); } } @@ -93,7 +92,6 @@ { delete m_cookieJar; setCache(NULL); - delete m_reply; } QNetworkReply* WebNetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) @@ -115,9 +113,9 @@ if(m_browserContainer->mainFrame()) { - if(m_browserContainer->mainFrame()->url().scheme().contains("https")) { + if(m_browserContainer->mainFrame()->url().scheme() == "https") { - if (op == QNetworkAccessManager::PostOperation && req.url().scheme().contains("http")) { + if (op == QNetworkAccessManager::PostOperation && req.url().scheme() == "http") { m_text = tr("Secure Page Warning:"); m_informativeText = tr("Do you want to continue?"); @@ -133,6 +131,12 @@ } } } + if(request.url().scheme() == "qrc") + { + reply = new NetworkErrorReply(QNetworkReply::ProtocolUnknownError, "Unknown scheme", request.url()); + QMetaObject::invokeMethod(reply, "finished", Qt::QueuedConnection); + } + if (reply == NULL) { reply = createRequestHelper(op, req, outgoingData); } @@ -188,6 +192,7 @@ QNetworkProxy proxy; QString proxyString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("NetworkProxy"); + QString portString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("NetworkPort"); if (proxyString.isEmpty()) { @@ -199,7 +204,7 @@ { proxy.setType(QNetworkProxy::HttpProxy); proxy.setHostName(proxyString); - proxy.setPort(8080); + proxy.setPort(portString.toInt()); } setProxy(proxy); diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/wrtbrowsercontainer.cpp --- a/browsercore/core/wrtbrowsercontainer.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/wrtbrowsercontainer.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -59,6 +59,7 @@ , m_pageFactory(0) , m_widget(0) , m_fileChooser(0) +, m_needUpdateThumbnail(false) { m_page = page; @@ -111,6 +112,23 @@ settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value("PopupBlocking").toInt()); // Download related enable "forwardUnsupportedContent" to redirect unsupported content to download manager setForwardUnsupportedContent(true); +#ifdef BEDROCK_TILED_BACKING_STORE + settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + settings()->setAttribute(QWebSettings::ZoomTextOnly, false); + settings()->setAttribute(QWebSettings::FrameFlatteningEnabled, true); + + //Configure tiling properties + //This would set tile size to (256, 256) and add 25ms delay between constructing + //individual tiles. The settings would try to cache an area 1.5x width and 1.5x height + //of the current viewport (centered to the viewport) with tiles and would drop tiles + //after they are outside an area 2x the width and 2.5x the height of the viewport. + //Refer https://bugs.webkit.org/show_bug.cgi?id=39874 + + setProperty("_q_TiledBackingStoreTileSize", QSize(256, 256)); + setProperty("_q_TiledBackingStoreTileCreationDelay", 25); + setProperty("_q_TiledBackingStoreCoverAreaMultiplier", QSizeF(1.5, 1.5)); + setProperty("_q_TiledBackingStoreKeepAreaMultiplier", QSizeF(2., 2.5)); +#endif #ifndef NO_NETWORK_ACCESS_MANAGER setNetworkAccessManager(new WebNetworkAccessManager(this,this)); @@ -370,6 +388,19 @@ return QWebPage::chooseFile(parentFrame, suggestedFile); } +QString WrtBrowserContainer::userAgentForUrl(const QUrl& url) const +{ + QString uaString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("UserAgentString"); + + if (uaString.isEmpty()) + { + QUrl url; + return QWebPage::userAgentForUrl(url); + } + else + return uaString; +} + WRT::WrtBrowserContainer* WrtBrowserContainer::createWindow( QWebPage::WebWindowType webWindowType) { diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/wrtbrowsercontainer.h --- a/browsercore/core/wrtbrowsercontainer.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/wrtbrowsercontainer.h Tue Jul 06 14:03:49 2010 +0300 @@ -88,9 +88,14 @@ bool restoreSession(); void setFileChooser(WrtBrowserFileChooser * chooser); + + void setUpdateThumbnail(bool update) { d->m_needUpdateThumbnail = update; } + bool needUpdateThumbnail() { return d->m_needUpdateThumbnail; } protected: virtual QString chooseFile(QWebFrame * parentFrame, const QString & suggestedFile); + virtual QString userAgentForUrl(const QUrl& url) const; + Q_SIGNALS: diff -r 0f2326c2a325 -r 1c3b8676e58c browsercore/core/wrtbrowsercontainer_p.h --- a/browsercore/core/wrtbrowsercontainer_p.h Wed Jun 23 17:59:43 2010 +0300 +++ b/browsercore/core/wrtbrowsercontainer_p.h Tue Jul 06 14:03:49 2010 +0300 @@ -49,6 +49,7 @@ WRT::LoadController * m_loadController; //Owned ZoomMetaData m_zoomData; WrtBrowserFileChooser * m_fileChooser; // Owned + bool m_needUpdateThumbnail; }; } #endif diff -r 0f2326c2a325 -r 1c3b8676e58c browserui.pri --- a/browserui.pri Wed Jun 23 17:59:43 2010 +0300 +++ b/browserui.pri Tue Jul 06 14:03:49 2010 +0300 @@ -76,19 +76,20 @@ br_download_mgr=no br_default_iap=no br_orbit_ui=no - br_increased_heap=no + br_openurl=no + br_tiled_backing_store=no # For now Symbian only, Windows, Maemo will use the defaults symbian { contains (browser_addon, fivezero) { br_fast_allocator=yes br_download_mgr=yes - br_increased_heap=yes br_mobility_sysinfo=yes br_mobility_bearer=yes } contains (browser_addon, ninetwo) { br_fast_allocator=yes + br_download_mgr=yes br_mobility_sysinfo=yes br_mobility_bearer=yes } @@ -97,6 +98,7 @@ br_mobility_sysinfo=yes br_mobility_bearer=yes br_orbit_ui=yes + br_openurl=yes } } } diff -r 0f2326c2a325 -r 1c3b8676e58c browserui.pro --- a/browserui.pro Wed Jun 23 17:59:43 2010 +0300 +++ b/browserui.pro Tue Jul 06 14:03:49 2010 +0300 @@ -2,14 +2,16 @@ CONFIG += ordered include (browserui.pri) -SUBDIRS += bedrockProvisioning -SUBDIRS += browsercore -SUBDIRS += ginebra2 + SUBDIRS += bedrockProvisioning + SUBDIRS += browsercore + SUBDIRS += ginebra2 # rom MUST come last because it depends on *_template.pkg files generated by qmake from all the other apps -SUBDIRS += rom + SUBDIRS += rom + contains( what, tests ) { - SUBDIRS += internal/tests/perfTracing - SUBDIRS += internal/tests/mw + exists($$PWD/internal/tests/perfTracing/perfTracing.pro): SUBDIRS += internal/tests/perfTracing/perfTracing.pro + exists($$PWD/internal/tests/mw/mw.pro): SUBDIRS += internal/tests/mw/mw.pro + exists($$PWD/internal/tests/Bookmarks_Test/Bookmarks_Test.pro): SUBDIRS += internal/tests/mw/Bookmarks_Test/Bookmarks_Test.pro } symbian: { diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ActionButton.cpp --- a/ginebra2/ActionButton.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ActionButton.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -27,8 +27,10 @@ ActionButton::ActionButton(ChromeSnippet * snippet, QGraphicsItem* parent) : NativeChromeItem(snippet, parent), m_internalAction(NULL), - m_triggerOn(QEvent::GraphicsSceneMouseRelease), - m_active(false) + m_triggerOnUp(true), + m_triggerOnDown(false), + m_active(false), + m_activeOnPress(true) { @@ -44,15 +46,12 @@ QIcon::Mode mode = QIcon::Normal; if (action) { - if (m_active || action->isChecked() ) { - mode = QIcon::Selected; + if (m_active) { + mode = QIcon::Active; } else if (!action->isEnabled()) { mode = QIcon::Disabled; } - else { - mode = QIcon::Active; - } } m_icon.paint(painter, boundingRect().toRect(), Qt::AlignCenter, mode, QIcon::On); painter->restore(); @@ -61,14 +60,18 @@ void ActionButton::mousePressEvent( QGraphicsSceneMouseEvent * ev ) { + QAction * action = defaultAction(); - if (action ) { - if (m_triggerOn == ev->type()){ + if (action && (action->isEnabled()) ) { + //qDebug() << "mousePressEvent" << m_triggerOnDown << ev->type(); + // If m_activeOnPress is true, set active flag to set icon state to Selected + if (m_activeOnPress ) + setActive(true); + if (m_triggerOnDown == true) { if (ev->button() == Qt::LeftButton) { - if (action->isEnabled()){ + action->trigger(); emit activated(); - } } } @@ -78,30 +81,32 @@ void ActionButton::mouseReleaseEvent( QGraphicsSceneMouseEvent * ev ) { + + bool trigger = sceneBoundingRect().contains(ev->scenePos()); + QAction * action = defaultAction(); //qDebug() << "ActionButton::mouseReleaseEvent " << m_snippet->elementId(); - if (m_triggerOn == ev->type()){ + + if ( trigger && m_triggerOnUp == true) { if (ev->button() == Qt::LeftButton) { if (action && action->isEnabled()){ action->trigger(); emit activated(); + } } } + // If m_activeOnPress is true, reset active flag to set icon state to Normal + if (m_activeOnPress || !trigger) + setActive(false); emit mouseEvent(ev->type() ); } - void ActionButton::contextMenuEvent( QGraphicsSceneContextMenuEvent * ev ) - { - Q_UNUSED(ev) - emit contextMenuEvent(); - } - //Action buttons only have one action at a time, so whenever we add an action, we remove any previously set action //NB: The action is typically one of the available actions on a view (via ControllableView.getContext()). //ActionButtonSnippet provides the scriptable method connectAction() to create native connections to view actions - void ActionButton::setAction ( QAction * action, QEvent::Type triggerOn ) + void ActionButton::setAction ( QAction * action, bool triggerOnDown, bool triggerOnUp ) { QAction * currentAction = defaultAction(); if (currentAction == action) @@ -112,39 +117,33 @@ } addAction(action); connect(action, SIGNAL(changed()),this, SLOT(onActionChanged())); - m_triggerOn = triggerOn; + m_triggerOnUp = triggerOnUp; + m_triggerOnDown = triggerOnDown; // Save the action as the internal action and set its properties m_internalAction = action; - m_internalAction->setCheckable(true); + m_internalAction->setCheckable(false); update(); } - void ActionButton::disconnectAction () { - setAction(NULL); - } - void ActionButton::setEnabled(bool enabled) { m_internalAction->setEnabled(enabled); } - void ActionButton::setChecked(bool checked) + void ActionButton::setActiveOnPress(bool active) { - m_internalAction->setChecked(checked); + m_activeOnPress = active; } void ActionButton::setActive(bool active) { - m_active = active; - update(); - } - - void ActionButton::setInputEvent(QEvent::Type event) - { - m_triggerOn = event; + if (m_active != active ) { + m_active = active; + update(); + } } //NB: handle icon on/off states too? @@ -181,7 +180,7 @@ QAction * action = defaultAction(); if (action && action->isEnabled() && !action->isChecked()){ action->setChecked(true); - update(); + setActive(true); } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ActionButton.h --- a/ginebra2/ActionButton.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ActionButton.h Tue Jul 06 14:03:49 2010 +0300 @@ -39,33 +39,32 @@ void paint( QPainter * painter, const QStyleOptionGraphicsItem * opt, QWidget * widget ); void addIcon( const QString & icon, QIcon::Mode mode = QIcon::Normal ); QIcon icon() {return m_icon;} - void setAction ( QAction * action, QEvent::Type triggerOn = QEvent::GraphicsSceneMouseRelease ); - void disconnectAction(); + void setAction ( QAction * action, bool triggerOnDown = false, bool triggerOnUp = true); void setEnabled(bool); - void setChecked(bool); void setActive(bool); - void setInputEvent(QEvent::Type event); + void setActiveOnPress(bool); QAction * defaultAction(); bool isChecked() {return m_internalAction->isChecked();} - public slots: + public Q_SLOTS: void onActionChanged(); void onHidden(); void onShown(); - signals: + Q_SIGNALS: void activated(); - void contextMenuEvent(); + protected: void mousePressEvent( QGraphicsSceneMouseEvent * ev ); void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev ); - void contextMenuEvent( QGraphicsSceneContextMenuEvent * ev ); private: QAction * m_internalAction; QIcon m_icon; - QEvent::Type m_triggerOn; + bool m_triggerOnUp; + bool m_triggerOnDown; QIcon::Mode m_state; bool m_active; + bool m_activeOnPress; }; } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ActionButtonSnippet.cpp --- a/ginebra2/ActionButtonSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ActionButtonSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -30,14 +30,22 @@ } + ActionButtonSnippet * ActionButtonSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + ActionButtonSnippet* that = new ActionButtonSnippet(elementId, chrome, 0, element); + that->setChromeWidget( new ActionButton( that ) ); + return that; + } + QAction * ActionButtonSnippet::getDefaultAction() { return (static_cast(m_widget)->defaultAction()); } - void ActionButtonSnippet::setDefaultAction( QAction * action, QEvent::Type triggerOn ) + //void ActionButtonSnippet::setDefaultAction( QAction * action, QEvent::Type triggerOn ) + void ActionButtonSnippet::setDefaultAction( QAction * action, bool triggerOnDown, bool triggerOnUp) { - static_cast(m_widget)->setAction(action,triggerOn); + static_cast(m_widget)->setAction(action,triggerOnDown, triggerOnUp); } QIcon ActionButtonSnippet::icon( ) @@ -56,11 +64,6 @@ } - void ActionButtonSnippet::setSelectedIcon( const QString & icon ) - { - static_cast(m_widget)->addIcon(icon, QIcon::Selected); - } - void ActionButtonSnippet::setActiveIcon( const QString & icon ) { static_cast(m_widget)->addIcon(icon, QIcon::Active); @@ -68,15 +71,14 @@ // Scriptable method to directly connect an action button to a view action - void ActionButtonSnippet::connectAction( const QString & action, const QString & view, const QString & inputEvent ) + void ActionButtonSnippet::connectAction( const QString & action, const QString & view, bool onDown, bool onUp) { ControllableViewBase *viewBase = m_chrome->getView( view ); if (viewBase){ QAction * viewAction = viewBase->getAction(action); if (viewAction) - static_cast(m_widget)->setAction(viewAction, - (inputEvent == "Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease); + static_cast(m_widget)->setAction(viewAction, onDown, onUp); return; } } @@ -91,19 +93,14 @@ static_cast(m_widget)->setEnabled(enabled); } - void ActionButtonSnippet::setLatched( bool latched ) - { - static_cast(m_widget)->setChecked(latched); - } - void ActionButtonSnippet::setActive( bool enabled ) { static_cast(m_widget)->setActive(enabled); } - void ActionButtonSnippet::setInputEvent( const QString & inputEvent ) + void ActionButtonSnippet::setActiveOnPress( bool active ) { - static_cast(m_widget)->setInputEvent((inputEvent=="Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease); + static_cast(m_widget)->setActiveOnPress(active); } void ActionButtonSnippet::updateButtonState(bool state) { diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ActionButtonSnippet.h --- a/ginebra2/ActionButtonSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ActionButtonSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -29,33 +29,30 @@ namespace GVA { + class ActionButtonSnippet : public ChromeSnippet { Q_OBJECT public: ActionButtonSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); virtual ~ActionButtonSnippet() {;} + static ActionButtonSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); QAction * getDefaultAction(); - void setDefaultAction( QAction * action, QEvent::Type triggerOn = QEvent::GraphicsSceneMouseRelease ); + void setDefaultAction( QAction * action, bool triggerOnDown =false, bool triggerOnUp=true); QIcon icon(); bool isChecked(); void setActive( bool active ); + void setActiveOnPress( bool ); public slots: void setIcon( const QString & icon ); void setDisabledIcon( const QString & icon ); - void setSelectedIcon( const QString & icon ); void setActiveIcon( const QString & icon ); - void connectAction ( const QString & action, const QString & view, const QString & inputEvent = "Up" ); + void connectAction( const QString & action, const QString & view, bool onDown = false, bool onUp = true); + void setEnabled( bool enabled ); - void setLatched( bool latched ); - void setInputEvent( const QString & inputEvent ); void updateButtonState(bool state); - - signals: - void activated(); - void contextMenuEvent(); }; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/BookmarksToolbarSnippet.cpp --- a/ginebra2/BookmarksToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/BookmarksToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,6 +22,7 @@ */ #include "BookmarksToolbarSnippet.h" +#include "ToolbarChromeItem.h" #include "ViewStack.h" #include "GWebContentView.h" #include "BookmarksManager.h" @@ -30,8 +31,8 @@ namespace GVA { BookmarksToolbarSnippet::BookmarksToolbarSnippet(const QString& elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : DualButtonToolbarSnippet(elementId, chrome, ownerArea, element, widget), + const QWebElement & element) + : DualButtonToolbarSnippet(elementId, chrome, element), m_action1(0), m_action2(0) { } @@ -43,7 +44,14 @@ if(m_action2) delete m_action2; } - + + BookmarksToolbarSnippet * BookmarksToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + BookmarksToolbarSnippet * that = new BookmarksToolbarSnippet( elementId, chrome, element ); + that->setChromeWidget( new ToolbarChromeItem( that ) ); + return that; + } + void BookmarksToolbarSnippet::addChild(ChromeSnippet * child) { WebChromeContainerSnippet * s = dynamic_cast(child); if (!s) { @@ -51,16 +59,16 @@ if (child->elementId() == "BookmarksBackButton" ) { t->actionId = BOOKMARKS_VIEW_ACTION_BACK; t->actionName = BOOKMARKS_TOOLBAR_BACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; } else if (child->elementId() == "BookmarksAddButton" ) { t->actionId = BOOKMARKS_VIEW_ACTION_ADD; t->actionName = BOOKMARKS_TOOLBAR_ADD; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add_pressed.png"; } t->id = child->elementId(); m_actionInfo.append(t); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/BookmarksToolbarSnippet.h --- a/ginebra2/BookmarksToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/BookmarksToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -38,8 +38,9 @@ { Q_OBJECT public: - BookmarksToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + BookmarksToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~BookmarksToolbarSnippet(); + static BookmarksToolbarSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); Q_SIGNALS: void addBookmarkSelected(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeDOM.cpp --- a/ginebra2/ChromeDOM.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeDOM.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -16,6 +16,7 @@ * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". * * Description: +* * */ @@ -120,121 +121,102 @@ } return handlers; } + +//TODO: Get rid of rectangle argument to snippets. This is redundant with the element argument!! +//TODO: Rewrite using function table + + ChromeSnippet * ChromeDOM::nativeSnippetForClassName(const QString & className, const QString elementId, QWebElement element) + { + QRectF rect = element.geometry(); + + if (className == "ContentToolbar") { + return ContentToolbarSnippet::instance(elementId, m_chrome, element); + } + else if (className == "WindowToolbar") { + return WindowToolbarSnippet::instance(elementId, m_chrome, element); + } + else if (className == "RecentUrlToolbar") { + return RecentUrlToolbarSnippet::instance(elementId, m_chrome, element); + } + else if (className == "BookmarksToolbar") { + return BookmarksToolbarSnippet::instance(elementId, m_chrome, element); + } + else if (className == "SettingsToolbar") { + return SettingsToolbarSnippet::instance(elementId, m_chrome, element); + } + else if (className == "MostVisitedPagesWidget") { + return MostVisitedSnippet::instance(elementId, m_chrome, element); + } + else if (className == "ActionButton") { + return ActionButtonSnippet::instance(elementId, m_chrome, element); + } + else if (className == "PageSnippet") { + return PageSnippet::instance(elementId, m_chrome, element); + } + else if (className == "UrlSearchSnippet") { + return GUrlSearchSnippet::instance(elementId, m_chrome, element); + } + else if (className == "TextEditSnippet") { + return EditorSnippet::instance(elementId, m_chrome, element); + } + else { + ChromeSnippet* result = new ChromeSnippet(elementId, m_chrome, 0, element); + result->setChromeWidget(new QGraphicsWidget()); + return result; + } + } + ChromeSnippet *ChromeDOM::getSnippet(const QString &docElementId, QGraphicsItem* parent) { Q_UNUSED(parent) - ChromeSnippet * result = 0; + ChromeSnippet * snippet = 0; QWebElement doc = m_page->mainFrame()->documentElement(); QWebElement element = doc.findFirst("#" + docElementId); - QRect rect = element.geometry();//getElementRect(docElementId); + QRect rect = element.geometry(); + //TODO: This may not be accurate since final heights may not have been computed at this point!! m_height += rect.height(); - //m_bytes += rect.width() * rect.height() * 3; //Calculate total rendered area at 24 bit depth - //qDebug() << "Chrome total rects at 24 bits: " << m_bytes; + // qDebug() << "Snippet: ID: " << docElementId << " Owner Area: " << rect << " Element Rect: " << element.geometry(); + if (!rect.isNull()) { QString className = element.attribute("data-GinebraNativeClass", "__NO_CLASS__"); if (className == "__NO_CLASS__") { if (element.attribute("data-GinebraContainer", "false") == "true") { - ChromeItem * widget = new ChromeItem(NULL); - result = new WebChromeContainerSnippet(docElementId, m_chrome, rect, element, - widget); - widget->setSnippet(result); + snippet = new WebChromeContainerSnippet(docElementId, m_chrome, element); + snippet->setChromeWidget(new ChromeItem(snippet)); } else { - result = new WebChromeSnippet(docElementId, m_chrome, rect, element); - m_renderer->addRenderItem((static_cast (result))->item()); + snippet = new WebChromeSnippet(docElementId, m_chrome, element); + m_renderer->addRenderItem((static_cast (snippet))->item()); } } else { - - if (className == "ContentToolbar" ) { - ContentToolbarChromeItem * widget = new ContentToolbarChromeItem(); - result = new ContentToolbarSnippet(docElementId, m_chrome, rect, element, widget); - widget->setSnippet(result); - } - else if (className == "WindowToolbar" ) { - ToolbarChromeItem * widget = new ToolbarChromeItem(); - result = new WindowToolbarSnippet(docElementId, m_chrome, rect, element, widget); - widget->setSnippet(result); - } - else if (className == "RecentUrlToolbar" ) { - ToolbarChromeItem * widget = new ToolbarChromeItem(); - result = new RecentUrlToolbarSnippet(docElementId, m_chrome, rect, element, widget); - widget->setSnippet(result); - } - else if (className == "BookmarksToolbar" ) { - ToolbarChromeItem * widget = new ToolbarChromeItem(); - result = new BookmarksToolbarSnippet(docElementId, m_chrome, rect, element, widget); - widget->setSnippet(result); - } - else if (className == "SettingsToolbar" ) { - ToolbarChromeItem * widget = new ToolbarChromeItem(); - result = new SettingsToolbarSnippet(docElementId, m_chrome, rect, element, widget); - widget->setSnippet(result); - } - else if (className == "ToolBar" ) { - ToolbarChromeItem * widget = new ToolbarChromeItem(); - result = new WebChromeContainerSnippet(docElementId, m_chrome, rect, element, - widget); - widget->setSnippet(result); - } - else { - QGraphicsWidget * w = 0; - if (className == "MostVisitedPagesWidget") { - result = new MostVisitedSnippet(docElementId, m_chrome, 0, element); - MostVisitedPagesWidget* mostVisited; - mostVisited = new MostVisitedPagesWidget(result, m_chrome); - mostVisited->hide(); - w = mostVisited; - } - else if (className == "ActionButton") { - result = new ActionButtonSnippet(docElementId, m_chrome, 0, element); - w = new ActionButton(result); - } - else if (className == "PageSnippet") { - result = new PageSnippet(docElementId, m_chrome, 0, element); - w = new PageItem(result, m_chrome); - } - else if (className == "ProgressBar") { - result = new ProgressBarSnippet(docElementId, m_chrome, 0, element); - w = new ProgressBarItem(result); - } - else if (className == "UrlSearchSnippet") { - result = new GUrlSearchSnippet(docElementId, m_chrome, 0, element); - w = new GUrlSearchItem(result, m_chrome); - } - else if (className == "TextEditSnippet") { - result = new EditorSnippet(docElementId, m_chrome, 0, element); - w = new TextEditItem(result, m_chrome); - } - else { - //Chrome snippet takes ownership of w - result = new ChromeSnippet(docElementId, m_chrome, 0, element); - w = new QGraphicsWidget(); - } - result->setWidget(w); - //Have snippet deterimine its own size when in anchor layout - w->resize(rect.width(), rect.height()); - w->setPreferredSize(rect.width(), rect.height()); - w->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); - //Have snippet determine its own location when NOT in anchor layout - w->setPos(rect.x(), rect.y()); - } + snippet = nativeSnippetForClassName(className, docElementId, element); + //TODO: Is the following still needed? + QGraphicsWidget * widget = snippet->widget(); + //Have snippet determine its own size when in anchor layout. Again, these will not + //necessarily be accurate at this point. + widget->resize(rect.width(), rect.height()); + widget->setPreferredSize(rect.width(), rect.height()); + widget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); + //Have snippet determine its own location when NOT in anchor layout + widget->setPos(rect.x(), rect.y()); + } QWebElement parentElem; if (!(parentElem = findChromeParent(element)).isNull()) { - result->setParentId(parentElem.attribute("id")); + snippet->setParentId(parentElem.attribute("id")); } //Set auto-layout attributes - result->setAnchor(element.attribute("data-GinebraAnchor", "AnchorNone"), false); - result->setAnchorOffset(element.attribute("data-GinebraAnchorOffset", "0").toInt()); - result->setInitiallyVisible(element.attribute("data-GinebraVisible", "false") == "true"); - result->setHidesContent(element.attribute("data-GinebraHidesContent", "false") == "true"); + snippet->setAnchor(element.attribute("data-GinebraAnchor", "AnchorNone"), false); + snippet->setAnchorOffset(element.attribute("data-GinebraAnchorOffset", "0").toInt()); + snippet->setInitiallyVisible(element.attribute("data-GinebraVisible", "false") == "true"); + snippet->setHidesContent(element.attribute("data-GinebraHidesContent", "false") == "true"); } - return result; + return snippet; } QWebElement ChromeDOM::findChromeParent(QWebElement element) diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeDOM.h --- a/ginebra2/ChromeDOM.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeDOM.h Tue Jul 06 14:03:49 2010 +0300 @@ -57,6 +57,7 @@ int height() { return m_height; } private: QWebElement findChromeParent(QWebElement element); + ChromeSnippet *nativeSnippetForClassName(const QString & className, const QString elementId, QWebElement element); QWebPage * m_page; ChromeRenderer * m_renderer; ChromeWidget * m_chrome; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeEffect.h --- a/ginebra2/ChromeEffect.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeEffect.h Tue Jul 06 14:03:49 2010 +0300 @@ -28,12 +28,16 @@ namespace GVA { -/* +/*! * The ChromeEffect namespace is intended to provide settings and drawing methods that can be * used by various classes for common display requirements, so far, just disabled mode drawing is * supported but more can be added... */ namespace ChromeEffect { + /*! + * Paint a rectangle that will give the underlying item a "disabled" look -- ie. whitewashed + * or darkened or whatever the UI spec is. + */ void paintDisabledRect(QPainter *painter, const QRectF &rect); static qreal disabledOpacity = 0.65; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeLayout.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ChromeLayout.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include +#include +#include + +#include "ChromeSnippet.h" +#include "WebChromeContainerSnippet.h" +#include "ChromeLayout.h" +#include "SlidingWidget.h" +#include "ViewController.h" +#include "ObjectCharm.h" +#include "bedrockprovisioning.h" + +namespace GVA { + +// ----------------------------- + + ChromeLayout::ChromeLayout(QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent, wFlags), + m_topBar(0), + m_bottomBar(0), + m_leftBar(0), + m_rightBar(0), + m_aspect(portrait), + m_bottomBarHeight(0) + { + m_layout = new QGraphicsAnchorLayout(); + m_layout->setContentsMargins(0,0,0,0); + m_layout->setSpacing(0); + setLayout(m_layout); + addAnchors(); + m_viewPort = new SlidingWidget(this); + m_layout->addAnchor(m_viewPort, Qt::AnchorTop, m_topBar, Qt::AnchorBottom); + m_layout->addAnchor(m_viewPort, Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop); + m_layout->addAnchor(m_viewPort, Qt::AnchorLeft, m_leftBar, Qt::AnchorRight); + m_layout->addAnchor(m_viewPort, Qt::AnchorRight, m_rightBar, Qt::AnchorLeft); + } + + ChromeLayout::~ChromeLayout() + { + delete m_bottomBar; + delete m_topBar; + delete m_leftBar; + delete m_rightBar; + delete m_viewPort; + } + + void ChromeLayout::addAnchors(){ + if (!m_bottomBar){ + m_bottomBar = new QGraphicsWidget(this); + m_bottomBar->setPreferredHeight(0); + m_bottomBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); + m_layout->addAnchor(m_bottomBar, Qt::AnchorBottom, m_layout, Qt::AnchorBottom); + m_layout->addAnchors(m_bottomBar, m_layout, Qt::Horizontal); + } + if (!m_topBar){ + m_topBar = new QGraphicsWidget(this); + m_topBar->setPreferredHeight(0); + m_topBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); + m_layout->addAnchor(m_topBar, Qt::AnchorTop, m_layout, Qt::AnchorTop); + m_layout->addAnchors(m_topBar, m_layout, Qt::Horizontal); + } + if (!m_leftBar){ + m_leftBar = new QGraphicsWidget(this); + m_leftBar->setPreferredWidth(0); + m_leftBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); + m_layout->addAnchor(m_leftBar, Qt::AnchorLeft, m_layout, Qt::AnchorLeft); + m_layout->addAnchors(m_leftBar, m_layout, Qt::Vertical); + } + if (!m_rightBar){ + m_rightBar = new QGraphicsWidget(this); + m_rightBar->setPreferredWidth(0); + m_rightBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); + m_layout->addAnchor(m_rightBar, Qt::AnchorRight, m_layout, Qt::AnchorRight); + m_layout->addAnchors(m_rightBar, m_layout, Qt::Vertical); + } + } + + void ChromeLayout::resizeEvent(QGraphicsSceneResizeEvent *ev) + { + emit resizing(ev->newSize()); + int aspect = m_aspect; + m_aspect = (ev->newSize().width() > ev->newSize().height())?landscape:portrait; + if (m_aspect != aspect) { + QString mode = (m_aspect == landscape ? "Landscape" : "Portrait"); + emit aspectChanged(m_aspect); + } + QGraphicsWidget::resizeEvent(ev); + } + + void ChromeLayout::addView(ControllableViewBase * controllableView){ + if (controllableView->widget()) { + m_viewPort->setWindow(controllableView->widget()); + controllableView->widget()->setFocusPolicy(Qt::ClickFocus); //NB: Is this needed? Does it break anything? + controllableView->widget()->setZValue(-1.0); //Make sure we are behind any center anchored snippets + } + } + + void ChromeLayout::anchorToView(ChromeSnippet* snippet, const QString& where) + { + Q_UNUSED(where) + m_viewPort->attachItem(snippet->widget()); + } + + void ChromeLayout::detachFromView(ChromeSnippet* snippet, const QString& where) + { + Q_UNUSED(where) + m_viewPort->detachItem(snippet->widget()); + } + + void ChromeLayout::anchorTogether(ChromeSnippet * first, ChromeSnippet * second, qreal x, qreal y) + { + first->widget()->setParentItem(second->widget()); + first->widget()->setPos(x,y); + } + + void ChromeLayout::unAnchor(ChromeSnippet* snippet) + { + snippet->widget()->setParentItem(0); + snippet->widget()->setParentItem(this); + } + + qreal ChromeLayout::shrinkView(qreal delta) + { + m_viewPort->setShrinkMax(bottomBarHeight()); + return m_viewPort->shrink(delta); + } + + qreal ChromeLayout::slideView(qreal delta) + { + return m_viewPort->slide(delta); + } + + //Check to see if snippet has an anchor and lay it out accordingly. + //Otherwise snippets determine their own positions from html + + void ChromeLayout::anchorSnippet(ChromeSnippet * snippet) + { + if (snippet->anchor() == anchorBottom){ + if (snippet->hidesContent()){ + m_layout->addAnchor(snippet->widget(), Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop); + m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_bottomBar, Qt::AnchorHorizontalCenter); + } else { + snippet->widget()->setParentItem(m_bottomBar); + snippet->widget()->setY(-snippet->anchorOffset()); + } + } + else if (snippet->anchor() == anchorTop){ + if (snippet->hidesContent()){ + m_layout->addAnchor(snippet->widget(),Qt::AnchorTop, m_topBar, Qt::AnchorBottom); + m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_topBar, Qt::AnchorHorizontalCenter); + } + else { + snippet->widget()->setParentItem(m_topBar); + snippet->widget()->setY(snippet->anchorOffset()); + } + } + else if (snippet->anchor() == anchorLeft){ + if (snippet->hidesContent()) + m_layout->addAnchor(snippet->widget(),Qt::AnchorLeft, m_leftBar, Qt::AnchorRight); + else { + snippet->widget()->setParentItem(m_leftBar); + snippet->widget()->setX(snippet->anchorOffset()); + } + } + else if (snippet->anchor() == anchorRight){ + if (snippet->hidesContent()) + m_layout->addAnchor(snippet->widget(),Qt::AnchorRight, m_rightBar, Qt::AnchorLeft); + else { + snippet->widget()->setParentItem(m_rightBar); + snippet->widget()->setX(-snippet->anchorOffset()); + } + } + else if (snippet->anchor() == anchorCenter) { + snippet->widget()->setParentItem(m_viewPort); + snippet->widget()->setZValue(0.0); + QGraphicsAnchorLayout * vl = static_cast(m_viewPort->layout()); + vl->addAnchor(snippet->widget(), Qt::AnchorVerticalCenter, vl, Qt::AnchorVerticalCenter); + vl->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, vl, Qt::AnchorHorizontalCenter); + } + else if (snippet->anchor() == anchorTopLeft){ + m_layout->addCornerAnchors(snippet->widget(), Qt::TopLeftCorner, m_layout, Qt::TopLeftCorner); + } + else if (snippet->anchor() == anchorTopRight) + m_layout->addCornerAnchors(snippet->widget(), Qt::TopRightCorner, m_layout, Qt::TopRightCorner); + else if (snippet->anchor() == anchorBottomLeft) + m_layout->addCornerAnchors(snippet->widget(), Qt::BottomLeftCorner, m_layout, Qt::BottomLeftCorner); + else if (snippet->anchor() == anchorBottomRight) + m_layout->addCornerAnchors(snippet->widget(), Qt::BottomRightCorner, m_layout, Qt::BottomRightCorner); + } + + void ChromeLayout:: addSnippet(ChromeSnippet * snippet, ChromeSnippet * container ) + { + snippet->widget()->setParentItem(this); + if (container){ + container->addChild(snippet); + } + anchorSnippet(snippet); + } + + // Call after a snippet changes to visible state + + void ChromeLayout::snippetShown(ChromeSnippet * snippet) + { + if (snippet->hidesContent()) { + if (snippet->anchor() == anchorBottom) { + /* snippet->widget()->size().height() is zero for WebChromeContainerSnippet + when default visible container snippet is shown, get ownerArea height instead */ + WebChromeContainerSnippet * s = dynamic_cast(snippet); + if (!s) { + m_bottomBarHeight = snippet->widget()->size().height(); + } + else { + m_bottomBarHeight = s->ownerArea().height(); + } + } + return; + } + if (snippet->anchor() == anchorBottom) + m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + snippet->widget()->preferredHeight()); + else if (snippet->anchor() == anchorTop) + m_topBar->setPreferredHeight(m_topBar->preferredHeight() + snippet->widget()->preferredHeight()); + else if (snippet->anchor() == anchorLeft){ + m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + snippet->widget()->preferredWidth()); + } + else if (snippet->anchor() == anchorRight){ + m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + snippet->widget()->preferredWidth()); + } + } + + // Call before a snippet changes to invisible state + + void ChromeLayout::snippetHiding(ChromeSnippet * snippet) + { + if (snippet->hidesContent()) + return; + if (snippet->anchor() == anchorBottom) + m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() - snippet->widget()->preferredHeight()); + else if (snippet->anchor() == anchorTop) + m_topBar->setPreferredHeight(m_topBar->preferredHeight() - snippet->widget()->preferredHeight()); + else if (snippet->anchor() == anchorLeft){ + m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() - snippet->widget()->preferredWidth()); + } + else if (snippet->anchor() == anchorRight){ + m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() - snippet->widget()->preferredWidth()); + } + } + + QString ChromeLayout::getDisplayMode() const { + return (m_aspect==portrait)?"portrait":"landscape"; + } + + void ChromeLayout::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) + { + event->accept(); + } + + //NB: Deprecate. This really shouldn't be necessary: anchor bars should be implemented as an expanding + //widget class. + + void ChromeLayout::adjustAnchorOffset(ChromeSnippet * snippet, qreal delta) + { + if (snippet->anchor() == anchorBottom) + m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + delta); + else if (snippet->anchor() == anchorTop) + m_topBar->setPreferredHeight(m_topBar->preferredHeight() + delta); + else if (snippet->anchor() == anchorLeft){ + m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + delta); + } + else if (snippet->anchor() == anchorRight){ + m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + delta); + } + } + + void ChromeLayout::setScene(QGraphicsScene *scene) + { + m_scene = scene; + //This is the root of the scene hierarchy + m_scene->addItem(this); + + // For testing, turn on red dot that appears in response to various mouse events. + if(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsInt("EnableTouchCircle", false)) { + new TouchCircleCharm(m_scene, this); + } + + } + +} // endof namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeLayout.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ChromeLayout.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef __GINEBRA_CHROMELAYOUT_H__ +#define __GINEBRA_CHROMELAYOUT_H__ + +#include + +class ControllableViewBase; +class QGraphicsSceneContextMenuEvent; + +namespace GVA { + + class ChromeSnippet; + class SlidingWidget; + + enum ChromeAnchor + { + anchorNone, + anchorCenter, + anchorTop, + anchorBottom, + anchorLeft, + anchorRight, + anchorTopLeft, + anchorTopRight, + anchorBottomLeft, + anchorBottomRight + }; + + enum Aspect + { + portrait, + landscape + }; + + + /*! + * \brief This class is responsible for laying out the snippets and views that constitute the UI + */ + + class ChromeLayout : public QGraphicsWidget + { + + Q_OBJECT + + public: + ChromeLayout(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); + virtual ~ChromeLayout(); + void addView(ControllableViewBase * controllableView); + void addSnippet(ChromeSnippet * snippet, ChromeSnippet * container); + void anchorSnippet(ChromeSnippet * snippet); //TODO: should be private, but is needed from ChromeWidget::anchorSnippet which is caled from ChromeSnippet + //NB: Should be deprecated (see comment in .cpp) + void adjustAnchorOffset(ChromeSnippet * snippet, qreal delta); + void anchorToView(ChromeSnippet* snippet, const QString & where = "top"); + void detachFromView(ChromeSnippet* snippet, const QString & where = "top"); + void anchorTogether(ChromeSnippet* first, ChromeSnippet * second, qreal x = 0, qreal y = 0); + void unAnchor(ChromeSnippet* first); + QGraphicsScene * scene() { return m_scene; } + void setScene(QGraphicsScene *scene); + int bottomBarHeight() { return m_bottomBarHeight;} + /// \brief Returns either "portrait" or "landscape". + QString getDisplayMode() const; + Q_PROPERTY(QString displayMode READ getDisplayMode) + + public slots: + void snippetShown(ChromeSnippet * snippet); + void snippetHiding(ChromeSnippet * snippet); + qreal slideView(qreal delta); + qreal shrinkView(qreal delta); + int width(){ return (int)size().width(); } + + signals: + void resizing(QSizeF newSize); + void aspectChanged(int aspect); + + protected: + virtual void resizeEvent(QGraphicsSceneResizeEvent *ev); + virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event); + + private: + void addAnchors(); + QGraphicsScene * m_scene; + QGraphicsAnchorLayout *m_layout; + QGraphicsAnchorLayout *m_viewLayout; + SlidingWidget *m_viewPort; + QGraphicsWidget *m_topBar; + QGraphicsWidget *m_bottomBar; + QGraphicsWidget *m_leftBar; + QGraphicsWidget *m_rightBar; + Aspect m_aspect; + int m_bottomBarHeight; + }; + +} // end of namespace GVA + +#endif // __GINEBRA_CHROMEWIDGET_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeRenderer.cpp --- a/ginebra2/ChromeRenderer.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeRenderer.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -56,8 +56,7 @@ WebChromeItem * item; if(!m_renderList.isEmpty()){ foreach(item, m_renderList){ - item->setOwnerArea(QRectF(item->element().geometry())); - if (item->ownerArea().intersects(dirtyRect) && !item->isPainting()){ + if (item->elementRect().intersects(dirtyRect) && !item->isPainting()){ item->update(); } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeSnippet.cpp --- a/ginebra2/ChromeSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -76,10 +76,14 @@ void ChromeSnippet::onContextMenuEvent(QGraphicsSceneContextMenuEvent * ev) { - qDebug() << "ChromeSnippet::contextMenuEvent: " << ev->pos(); emit contextMenuEvent(ev->pos().x(), ev->pos().y()); } + void ChromeSnippet::setChromeWidget(QGraphicsWidget * widget) + { + m_widget = widget; + m_widget->hide(); + } //NB: Would be architecturally cleaner to do this translation in ChromeDOM //so snippets don't have to know anything about dom attribute string values @@ -108,7 +112,7 @@ else setAnchor(anchorNone); if (update) - m_chrome->anchorSnippet(this); + m_chrome->layout()->anchorSnippet(this); } void ChromeSnippet::setAnchorOffset(int offset, bool update) @@ -118,8 +122,8 @@ if (update){ if (m_widget->isVisible()) - m_chrome->adjustAnchorOffset(this, delta); - m_chrome->anchorSnippet(this); + m_chrome->adjustAnchorOffset(this, delta); + m_chrome->layout()->anchorSnippet(this); } } @@ -166,12 +170,12 @@ m_widget->show(); if (m_vAnimator && animate) m_vAnimator->setVisible(m_visible, animate); - m_chrome->snippetShown(this); //NB: handle this via shown signal + m_chrome->layout()->snippetShown(this); //NB: handle this via shown signal m_hiding = false; emit shown(); } else{ - m_chrome->snippetHiding(this); //NB: handle this via hiding signal + m_chrome->layout()->snippetHiding(this); //NB: handle this via hiding signal m_hiding = true; if (m_vAnimator) m_vAnimator->setVisible(m_visible, animate); @@ -210,8 +214,7 @@ } void ChromeSnippet::setEnabled(bool value) { - qDebug() << "ChromeSnippet::setEnabled: " << objectName() << value; - if(m_enabled == value) + if(m_enabled == value) return; m_enabled = value; @@ -315,7 +318,6 @@ QRect parentGeo = m_element.geometry(); //Get child geometry relative to parent QRectF childGeom(childGeo.x()-parentGeo.x(), childGeo.y()-parentGeo.y(), childGeo.width(), childGeo.height()); - qDebug() << "Parent geometry: " << parentGeo << " child geometry: " << childGeo; childSnippet->widget()->setGeometry(childGeom); } @@ -323,7 +325,6 @@ void ChromeSnippet::addChild(ChromeSnippet * child) { - qDebug() << "ChromeSnippet::addChild: " << child->elementId(); QWebElement c = m_element.findFirst("#" + child->elementId()); if (c.isNull()) return; @@ -357,13 +358,13 @@ void ChromeSnippet::anchorToView(const QString& view, const QString& where) { Q_UNUSED(where) - m_chrome->anchorToView(this, view); + m_chrome->layout()->anchorToView(this, view); } void ChromeSnippet::detachFromView(const QString& view, const QString& where) { Q_UNUSED(where) - m_chrome->detachFromView(this, view); + m_chrome->layout()->detachFromView(this, view); } void ChromeSnippet::anchorTo(const QString & id, int x, int y) @@ -374,7 +375,7 @@ void ChromeSnippet::unAnchor() { setAnchor("AnchorNone"); - m_chrome->unAnchor(this); + m_chrome->layout()->unAnchor(this); } QObject *ChromeSnippet::animate(int duration) { @@ -392,8 +393,7 @@ void ChromeSnippet::grabFocus() { - qDebug() << "ChromeSnippet::grabFocus()"; - m_widget->setFocus(); + m_widget->setFocus(); } int ChromeSnippet::zValue() diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeSnippet.h --- a/ginebra2/ChromeSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -27,6 +27,7 @@ #include #include #include "ChromeWidget.h" +#include "ChromeLayout.h" class QGraphicsWidget; @@ -57,7 +58,7 @@ public: ChromeSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); virtual ~ChromeSnippet(); - ChromeWidget* chrome() { return m_chrome; } + ChromeWidget * chrome() { return m_chrome; } void setInitiallyVisible(bool initiallyVisible) { m_initiallyVisible = initiallyVisible; } //NB: needed? void setHidesContent(bool hidesContent) { m_hidesContent = hidesContent; } void setAnchor(ChromeAnchor anchor) {m_anchor = anchor;} @@ -68,7 +69,7 @@ QString elementId() { return m_elementId; } QGraphicsWidget* widget() { return m_widget; } QGraphicsWidget const * constWidget() const { return m_widget; } - virtual void setWidget(QGraphicsWidget * widget) { m_widget = widget; } + virtual void setChromeWidget(QGraphicsWidget * widget); QString parentId() { return m_parentId; } void setParentId(const QString& parent) { m_parentId = parent; } void setTransform(QTransform transform); @@ -111,12 +112,12 @@ //NB: deprecate repaint: if this is needed, then there are bugs that are preventing updates void repaint() { m_widget->update(); } void onContextMenuEvent(QGraphicsSceneContextMenuEvent * ev); - void disableDontShowFlag() {m_dontshowFlag = false ;} + signals: void hidden(); void shown(); void externalMouseEvent( - int type, + QEvent * ev, const QString & name, const QString & description); void contextMenuEvent(int x, int y); @@ -137,12 +138,10 @@ Q_PROPERTY(int anchorOffset READ anchorOffset WRITE setAnchorOffset) Q_PROPERTY(int zValue READ zValue WRITE setZValue) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) - Q_PROPERTY(bool dontShow READ getDontShowFlag WRITE setDontShowFlag) Q_PROPERTY(QObject* position READ getPosition) Q_PROPERTY(QObject* geometry READ getGeometry) Q_PROPERTY(bool enabled WRITE setEnabled READ enabled) - bool getDontShowFlag() {return m_dontshowFlag;} - void setDontShowFlag(bool flag){ m_dontshowFlag = flag;} + bool enabled() const; void setEnabled(bool value); protected: diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeView.cpp --- a/ginebra2/ChromeView.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -23,7 +23,8 @@ #include #include "ChromeView.h" -#include "ChromeWidget.h" +#include "ChromeWidget.h" //TODO: get rid of this, refer directly to layout +#include "ChromeLayout.h" #ifndef NO_QSTM_GESTURE #include "qstmgestureevent.h" #endif @@ -40,20 +41,21 @@ namespace GVA { -ChromeView::ChromeView(ChromeWidget * chrome, QWidget * parent) +ChromeView::ChromeView(QGraphicsScene *graphicsScene, ChromeWidget * chrome, QWidget * parent) #ifdef ORBIT_UI : HbMainWindow(parent), #else - : QGraphicsView(new QGraphicsScene(), parent), + : QGraphicsView(graphicsScene, parent), #endif // ORBIT_UI - m_topWidget(chrome) + m_chrome(chrome), + m_topWidget(chrome->layout()) { #ifdef ORBIT_UI - addView(chrome); + addView(chrome->layout()); #endif // ORRBIT_UI // Initialize the ChromeWidget with the scene created in the ChromeView - chrome->setScene(scene()); + chrome->layout()->setScene(scene()); //setGeometry(chrome->geometry().toRect()); setObjectName("ChromeView"); @@ -62,6 +64,13 @@ setStyleSheet("QGraphicsView#ChromeView {margin:0; border: 0; padding:0; background:#fff}"); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + +#ifdef BEDROCK_TILED_BACKING_STORE + setFrameShape(QFrame::NoFrame); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + scene()->setItemIndexMethod(QGraphicsScene::NoIndex); +#endif + //NB: maybe not needed? setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); //installEventFilter(this); @@ -84,7 +93,6 @@ ChromeView::~ChromeView() { - } void ChromeView::resizeEvent(QResizeEvent * ev) @@ -92,15 +100,23 @@ //Resize the chrome to match the view and scene rectangle size if (m_topWidget) { - // On calling setGeometry on QGraphicsWidget, the layout resize if - // first called before resize on children happens. In order to avoid painting - // the children in the worn positions, first let children change size - ChromeWidget * w = static_cast(m_topWidget); - w->sizeChange(ev->size()); - - m_topWidget->setGeometry(0,0, ev->size().width(), ev->size().height()); + // On calling setGeometry on QGraphicsWidget, the layout resizes if + // first called before resize on children happens. In order to avoid painting + // the children in their old positions, first let children change size + // ChromeWidget * w = static_cast(m_topWidget); + // w->sizeChange(ev->size()); + //TODO: move sizeChange to ChromeLayout, remove m_chrome member !!!!! + m_chrome->sizeChange(ev->size()); + m_topWidget->setGeometry(0,0, ev->size().width(), ev->size().height()); } QGraphicsView::resizeEvent(ev); + +#ifdef BEDROCK_TILED_BACKING_STORE + if (scene()) { + QRectF rect(QPointF(0, 0), size()); + scene()->setSceneRect(rect); + } +#endif } //Never scroll the chrome diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeView.h --- a/ginebra2/ChromeView.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeView.h Tue Jul 06 14:03:49 2010 +0300 @@ -38,7 +38,7 @@ { Q_OBJECT public: - ChromeView(ChromeWidget * chrome, QWidget * parent = 0 ); + ChromeView(QGraphicsScene *graphicsScene, ChromeWidget * chrome, QWidget * parent = 0 ); ~ChromeView(); void resizeEvent(QResizeEvent * ev); bool event(QEvent* event); @@ -55,6 +55,7 @@ private: QGraphicsWidget * m_topWidget; + ChromeWidget * m_chrome; //TODO: get rid of this }; } #endif //__GINEBRA_CHROMEVIEW_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeWidget.cpp --- a/ginebra2/ChromeWidget.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeWidget.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -26,10 +26,10 @@ #include #include #include -#include #include "bedrockprovisioning.h" #include "ChromeWidgetJSObject.h" +#include "ChromeLayout.h" #include "ChromeRenderer.h" #include "ChromeDOM.h" #include "Snippets.h" @@ -71,20 +71,18 @@ // ----------------------------- ChromeWidget::ChromeWidget(QGraphicsItem * parent, Qt::WindowFlags wFlags) - : QGraphicsWidget(parent, wFlags), + : QObject(0), m_renderer(0), m_dom(0), m_viewController(new ViewController()), - m_topBar(0), - m_bottomBar(0), - m_leftBar(0), - m_rightBar(0), - m_aspect(portrait), m_jsObject(new ChromeWidgetJSObject(0, this)), m_localeDelegate(new LocaleDelegate(this)), - m_downloads(new Downloads()), - m_bottomBarHeight(0) + m_downloads(new Downloads()) { + m_layout = new ChromeLayout(parent, wFlags); + QObject::connect(m_layout, SIGNAL(resizing(QSizeF)), this, SLOT(onResize(QSizeF))); + QObject::connect(m_layout, SIGNAL(aspectChanged(int)), this, SLOT(onAspectChanged(int))); + DeviceImpl *deviceImpl = new DEVICEIMPL(); NetworkImpl *networkImpl = new NETWORKIMPL(); m_deviceDelegate = new DeviceDelegate(deviceImpl); @@ -94,22 +92,9 @@ ChromeEffect::disabledColor.setNamedColor(provisioning->valueAsString("DisabledColor", "#FFFFFF")); ChromeEffect::disabledOpacity = static_cast(provisioning->valueAsString("DisabledOpacity", "0.65").toFloat()); - //Keep key events not otherwise consumed from going to the scene - //installEventFilter(this); - m_layout = new QGraphicsAnchorLayout(); - m_layout->setContentsMargins(0,0,0,0); - m_layout->setSpacing(0); - setLayout(m_layout); - addAnchors(); - m_viewPort = new SlidingWidget(this); - //m_viewBar = new CollapsingWidget(m_viewPort); #ifndef __gva_no_chrome__ m_snippets = new Snippets(this, this); #endif - m_layout->addAnchor(m_viewPort, Qt::AnchorTop, m_topBar, Qt::AnchorBottom); - m_layout->addAnchor(m_viewPort, Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop); - m_layout->addAnchor(m_viewPort, Qt::AnchorLeft, m_leftBar, Qt::AnchorRight); - m_layout->addAnchor(m_viewPort, Qt::AnchorRight, m_rightBar, Qt::AnchorLeft); #ifndef __gva_no_chrome__ m_page = static_cast(new GVA::WebPageWrapper(this, "Chrome Javascript error")); m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); @@ -121,6 +106,7 @@ #ifndef __gva_no_chrome__ m_jsObject->setObjectName("chrome"); + // Pass some signals from this object to the Javascript object. QObject::connect(this, SIGNAL(chromeComplete()), m_jsObject, SIGNAL(chromeComplete())); QObject::connect(this, SIGNAL(aspectChanged(int)), m_jsObject, SIGNAL(aspectChanged(int))); @@ -130,7 +116,9 @@ QObject::connect(this, SIGNAL(popupHidden(const QString &)), m_jsObject, SIGNAL(popupHidden(const QString &))); //addJSObjectToEngine(this); + m_app = new GinebraApplication(); + //addJSObjectToEngine(m_app); QObject::connect( @@ -150,8 +138,70 @@ // TO DO: need a better home for this. qMetaTypeId(); qRegisterMetaType("QObjectList"); + + //for QA Automation test tool purpose +#if !defined(QT_NO_LIBRARY) + QLibrary testLib("qttestability"); + if(testLib.load()){ + typedef void (*TasInitialize)(void); + TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); +#ifdef Q_OS_SYMBIAN + //not found so use ordinal + if(!initFunction){ + initFunction = (TasInitialize)testLib.resolve("1"); + } +#endif + if(initFunction){ + initFunction(); + } + } +#endif } + ChromeWidget::~ChromeWidget() + { + delete m_viewController; + delete m_jsObject; + delete m_layout; + delete m_renderer; + delete m_dom; + delete m_page; + delete m_snippets; + delete m_localeDelegate; + delete m_deviceDelegate; + delete m_networkDelegate; + delete m_app; + delete m_downloads; + } + + //Handle resizing signal from layout + + void ChromeWidget::onResize(QSizeF size) + { +#ifndef __gva_no_chrome__ + if (m_dom && m_renderer) { + emit prepareForGeometryChange(); + m_renderer->resize(size); + } +#endif + } + + //Handle aspectChanged signal from layout + + void ChromeWidget::onAspectChanged(int aspect) + { + QString mode = (aspect == landscape ? "Landscape" : "Portrait"); + ControllableViewBase* cview = m_viewController->currentView(); + if (cview) + cview->displayModeChanged(mode); + emit aspectChanged(aspect); + } + + void ChromeWidget::updateChromeLayout() { + m_renderer->updateChromeLayout(); + } + + void ChromeWidget::loadUrlToCurrentPage(const QUrl & url) { WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage(); @@ -171,84 +221,16 @@ m_downloads->handlePage(page); } - ChromeWidget::~ChromeWidget() - { - // clearChrome(); // Crashes on exit - delete m_viewController; - delete m_jsObject; - delete m_bottomBar; - delete m_topBar; - delete m_leftBar; - delete m_rightBar; - delete m_viewPort; - // delete m_viewLayout; // Crashes on exit - delete m_renderer; - delete m_dom; - delete m_page; - // delete m_scene; // Crashes on exit - delete m_snippets; - // delete m_layout; // Crashes on exit - delete m_localeDelegate; - delete m_deviceDelegate; - delete m_networkDelegate; - delete m_app; - delete m_downloads; - } - - - //Eat key events not otherwise consumed. - /*bool ChromeWidget::eventFilter(QObject * obj, QEvent * ev) - { - if (ev->type() == QEvent::KeyPress){ - return true; - } - return QObject::eventFilter(obj,ev); - - }*/ - - void ChromeWidget::resizeEvent(QGraphicsSceneResizeEvent *ev) - { -#ifndef __gva_no_chrome__ - if (m_dom && m_renderer) { - emit prepareForGeometryChange(); - // m_renderer->setGeometry(QRectF(-1200,-1200, ev->newSize().width(), m_dom->height())); - m_renderer->resize(QSizeF(ev->newSize().width(), m_dom->height())); - } - int aspect = m_aspect; - m_aspect = (ev->newSize().width() > ev->newSize().height())?landscape:portrait; - if (m_aspect != aspect) { - QString mode = (m_aspect == landscape ? "Landscape" : "Portrait"); - ControllableViewBase* cview = m_viewController->currentView(); - if (cview) - cview->displayModeChanged(mode); - emit aspectChanged(m_aspect); - } -#endif - QGraphicsWidget::resizeEvent(ev); - } - - void ChromeWidget::updateChromeLayout() { - qDebug() << "ChromeWidget::updateChromeLayout"; - m_renderer->updateChromeLayout(); - } - - /* - //For layout debugging - void ChromeWidget::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget* widget){ - painter->fillRect(geometry(), Qt::red); - } - */ - void ChromeWidget::setChromeBaseDirectory(const QString dir) { m_baseDirectory = dir; + if(m_baseDirectory.left(2) == ":/") // resource path have to be converted to resource url + m_baseDirectory = "qrc:///" + m_baseDirectory.mid(2); } void ChromeWidget::setChromeFile(const QString filePath) { #ifndef __gva_no_chrome__ - qDebug() << "ChromeWidget::setChromeFile: " << m_baseDirectory << filePath; m_page->mainFrame()->load(QUrl(m_baseDirectory + filePath)); - qDebug() << "ChromeWidget::setChromeFile: done"; #else Q_UNUSED(filePath) #endif @@ -260,92 +242,38 @@ m_page->triggerAction(QWebPage::Reload); } + // TODO: needed? void ChromeWidget::addViewToLayout(ControllableViewBase * controllableView){ - //qDebug() << "ChromeWidget::addViewToLayout: " << controllableView->widget(); - if (controllableView->widget()) { - m_viewPort->setWindow(controllableView->widget()); - controllableView->widget()->setFocusPolicy(Qt::ClickFocus); //NB: Is this needed? Does it break anything? - controllableView->widget()->setZValue(-1.0); //Make sure we are behind any center anchored snippets - } + m_layout->addView(controllableView); } void ChromeWidget::addView(ControllableViewBase * controllableView) { //qDebug() << "ChromeWidget::addView: " << controllableView->widget(); m_viewController->addView(controllableView); - - /* - if (controllableView->widget()) { - addViewToLayout(controllableView); - } - else { - qWarning() << "ChromeWidget::addView: view has no widget. " << controllableView; - connect(controllableView, SIGNAL(instantiated(ControllableViewBase *)), this, SLOT(onViewInstantiated(ControllableViewBase *))); - } -// m_jsObjects.append(controllableView); // Add to list of exported objects -#ifndef __gva_no_chrome__ - addJSObjectToWindow(controllableView); // Export to DOM -#endif - //addJSObjectToEngine(viewDelegate); // Export to script engine - */ } - - void ChromeWidget::anchorToView(ChromeSnippet* snippet, const QString& where) - { - Q_UNUSED(where) - //m_viewBar->addItem(snippet); - m_viewPort->attachItem(snippet->widget()); - } - - void ChromeWidget::detachFromView(ChromeSnippet* snippet, const QString& where) - { - Q_UNUSED(where) - // m_viewBar->removeItem(snippet); - m_viewPort->detachItem(snippet->widget()); - } - + void ChromeWidget::anchorTogether(ChromeSnippet* first, const QString& secondId, qreal x, qreal y) { ChromeSnippet* second = getSnippet(secondId); if (second){ - //qDebug() << "Anchoring: " << first->objectName() << " to: " << second->objectName(); - first->widget()->setParentItem(second->widget()); - first->widget()->setPos(x,y); + m_layout->anchorTogether(first, second, x, y); } else { - qDebug() << "ChromeWidget::anchorTogether: error, not found: " << secondId; + qDebug() << "Chrome::anchorTogether: error, not found: " << secondId; } } - void ChromeWidget::unAnchor(ChromeSnippet* snippet) - { - snippet->widget()->setParentItem(0); - snippet->widget()->setParentItem(this); - } - - qreal ChromeWidget::shrinkView(qreal delta) - { - m_viewPort->setShrinkMax(bottomBarHeight()); - return m_viewPort->shrink(delta); - } - - qreal ChromeWidget::slideView(qreal delta) - { - //return m_viewBar->collapse(delta); - return m_viewPort->slide(delta); - } - ControllableViewBase * ChromeWidget::getView(const QString& view) { return m_viewController->view(view); } void ChromeWidget::showView(const QString &name) { - qDebug() << "ChromeWidget::showView: " << name; m_viewController->showView(name); } void ChromeWidget::onCurrentViewChanged() { - addViewToLayout(m_viewController->currentView()); + m_layout->addView(m_viewController->currentView()); } // Clean up all existing snippets; @@ -362,41 +290,25 @@ void ChromeWidget::loadFinished(bool ok) // slot { - qDebug() << "ChromeWidget::loadFinished: " << ok; if (!ok) { - qDebug() << "ChromeWidget::loadFinished: error"; return; } - //NB: do we really need to instantiate a new renderer? - if (m_renderer) - delete m_renderer; - // qDebug() << "Instantiate renderer"; - m_renderer = new ChromeRenderer(m_page, this); - // qDebug() << "Resize the renderer 1"; - m_renderer->resize(size()); - // m_renderer->setPos(-1200, -1200); - // m_renderer->setZValue(-3); -#ifdef Q_OS_SYMBIAN - //connect(m_renderer, SIGNAL(symbianCarriageReturn()), this, SIGNAL(symbianCarriageReturn())); -#endif + if (!m_renderer) + m_renderer = new ChromeRenderer(m_page, this); + m_renderer->resize(m_layout->size()); if (m_dom) delete m_dom; // NB: This may need some further investigation m_dom = new ChromeDOM(m_page, this); getInitialSnippets(); - //Set the final renderer size to match the chrome - //m_renderer->resize(size().width(), m_dom->height()); - m_renderer->resize(QSizeF(size().width(), m_dom->height())); + m_renderer->resize(QSizeF(m_layout->size().width(), m_dom->height())); //qDebug() << m_dom->getCacheableScript(); - // Let internal objects know that the chrome is complete. emit internalChromeComplete(); // Now let the javascript world know that it is complete. emit chromeComplete(); - // connect ViewStack to creatingPage signal connect( WebPageController::getSingleton(), SIGNAL(creatingPage(WRT::WrtBrowserContainer*)), ViewStack::getSingleton(), SLOT(creatingPage(WRT::WrtBrowserContainer*))); - qDebug() << "ChromeWidget::loadFinished: done"; } void ChromeWidget::chromeInitialized() @@ -438,108 +350,16 @@ } } - void ChromeWidget::addAnchors(){ - if (!m_bottomBar){ - m_bottomBar = new QGraphicsWidget(this); - m_bottomBar->setPreferredHeight(0); - m_bottomBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - m_layout->addAnchor(m_bottomBar, Qt::AnchorBottom, m_layout, Qt::AnchorBottom); - m_layout->addAnchors(m_bottomBar, m_layout, Qt::Horizontal); - } - if (!m_topBar){ - m_topBar = new QGraphicsWidget(this); - m_topBar->setPreferredHeight(0); - m_topBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - m_layout->addAnchor(m_topBar, Qt::AnchorTop, m_layout, Qt::AnchorTop); - m_layout->addAnchors(m_topBar, m_layout, Qt::Horizontal); - } - if (!m_leftBar){ - m_leftBar = new QGraphicsWidget(this); - m_leftBar->setPreferredWidth(0); - m_leftBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); - m_layout->addAnchor(m_leftBar, Qt::AnchorLeft, m_layout, Qt::AnchorLeft); - m_layout->addAnchors(m_leftBar, m_layout, Qt::Vertical); - } - if (!m_rightBar){ - m_rightBar = new QGraphicsWidget(this); - m_rightBar->setPreferredWidth(0); - m_rightBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); - m_layout->addAnchor(m_rightBar, Qt::AnchorRight, m_layout, Qt::AnchorRight); - m_layout->addAnchors(m_rightBar, m_layout, Qt::Vertical); - } - } - - //Check to see if snippet has an anchor and lay it out accordingly. - //Otherwise snippets determine their own positions from html - - void ChromeWidget::anchorSnippet(ChromeSnippet * snippet) - { - if (snippet->anchor() == anchorBottom){ - if (snippet->hidesContent()){ - m_layout->addAnchor(snippet->widget(), Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop); - m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_bottomBar, Qt::AnchorHorizontalCenter); - } else { - snippet->widget()->setParentItem(m_bottomBar); - snippet->widget()->setY(-snippet->anchorOffset()); - } - } - else if (snippet->anchor() == anchorTop){ - if (snippet->hidesContent()){ - m_layout->addAnchor(snippet->widget(),Qt::AnchorTop, m_topBar, Qt::AnchorBottom); - m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_topBar, Qt::AnchorHorizontalCenter); - } - else { - snippet->widget()->setParentItem(m_topBar); - snippet->widget()->setY(snippet->anchorOffset()); - } - } - else if (snippet->anchor() == anchorLeft){ - if (snippet->hidesContent()) - m_layout->addAnchor(snippet->widget(),Qt::AnchorLeft, m_leftBar, Qt::AnchorRight); - else { - snippet->widget()->setParentItem(m_leftBar); - snippet->widget()->setX(snippet->anchorOffset()); - } - } - else if (snippet->anchor() == anchorRight){ - if (snippet->hidesContent()) - m_layout->addAnchor(snippet->widget(),Qt::AnchorRight, m_rightBar, Qt::AnchorLeft); - else { - snippet->widget()->setParentItem(m_rightBar); - snippet->widget()->setX(-snippet->anchorOffset()); - } - } - else if (snippet->anchor() == anchorCenter) { - snippet->widget()->setParentItem(m_viewPort); - snippet->widget()->setZValue(0.0); - QGraphicsAnchorLayout * vl = static_cast(m_viewPort->layout()); - vl->addAnchor(snippet->widget(), Qt::AnchorVerticalCenter, vl, Qt::AnchorVerticalCenter); - vl->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, vl, Qt::AnchorHorizontalCenter); - } - else if (snippet->anchor() == anchorTopLeft){ - qDebug() << "Setting top left anchor"; - m_layout->addCornerAnchors(snippet->widget(), Qt::TopLeftCorner, m_layout, Qt::TopLeftCorner); - } - else if (snippet->anchor() == anchorTopRight) - m_layout->addCornerAnchors(snippet->widget(), Qt::TopRightCorner, m_layout, Qt::TopRightCorner); - else if (snippet->anchor() == anchorBottomLeft) - m_layout->addCornerAnchors(snippet->widget(), Qt::BottomLeftCorner, m_layout, Qt::BottomLeftCorner); - else if (snippet->anchor() == anchorBottomRight) - m_layout->addCornerAnchors(snippet->widget(), Qt::BottomRightCorner, m_layout, Qt::BottomRightCorner); - } - + //TODO: check new logic + void ChromeWidget:: addSnippet(ChromeSnippet * snippet, const QString & docElementId ) { m_snippets->addSnippet(snippet, docElementId); - snippet->widget()->setParentItem(this); - + ChromeSnippet * container = 0; if (!snippet->parentId().isNull()){ - ChromeSnippet * container = getSnippet(snippet->parentId()); - if (container) - container->addChild(snippet); + container = getSnippet(snippet->parentId()); } - - anchorSnippet(snippet); + m_layout->addSnippet(snippet, container); } //NB: This really shouldn't be necessary: anchor bars should be implemented as an expanding @@ -547,72 +367,7 @@ void ChromeWidget::adjustAnchorOffset(ChromeSnippet * snippet, qreal delta) { - if (snippet->anchor() == anchorBottom) - m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + delta); - else if (snippet->anchor() == anchorTop) - m_topBar->setPreferredHeight(m_topBar->preferredHeight() + delta); - else if (snippet->anchor() == anchorLeft){ - m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + delta); - } - else if (snippet->anchor() == anchorRight){ - m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + delta); - } - } - - // Call after a snippet changes to visible state - // (NB: does not check to see whether snippet has been - // correctly added to chrome (by calling addSnippet). - // At a minimum should assert that the anchor "bars" - // are not null.) - - void ChromeWidget::snippetShown(ChromeSnippet * snippet) - { - if (snippet->hidesContent()) { - if (snippet->anchor() == anchorBottom) { - /* snippet->widget()->size().height() is zero for WebChromeContainerSnippet - when default visible container snippet is shown, get ownerArea height instead */ - WebChromeContainerSnippet * s = dynamic_cast(snippet); - if (!s) { - m_bottomBarHeight = snippet->widget()->size().height(); - } - else { - m_bottomBarHeight = s->ownerArea().height(); - } - } - return; - } - if (snippet->anchor() == anchorBottom) - m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + snippet->widget()->preferredHeight()); - else if (snippet->anchor() == anchorTop) - m_topBar->setPreferredHeight(m_topBar->preferredHeight() + snippet->widget()->preferredHeight()); - else if (snippet->anchor() == anchorLeft){ - m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + snippet->widget()->preferredWidth()); - } - else if (snippet->anchor() == anchorRight){ - m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + snippet->widget()->preferredWidth()); - } - } - - // Call before a snippet changes to invisible state - // (NB: does not check to see whether snippet has been - // correctly added to chrome (by calling addSnippet). - // At a minimum should assert that the anchor "bars" - // are not null.) - - void ChromeWidget::snippetHiding(ChromeSnippet * snippet) - { - if (snippet->hidesContent()) - return; - if (snippet->anchor() == anchorBottom) - m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() - snippet->widget()->preferredHeight()); - else if (snippet->anchor() == anchorTop) - m_topBar->setPreferredHeight(m_topBar->preferredHeight() - snippet->widget()->preferredHeight()); - else if (snippet->anchor() == anchorLeft){ - m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() - snippet->widget()->preferredWidth()); - } - else if (snippet->anchor() == anchorRight){ - m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() - snippet->widget()->preferredWidth()); - } + m_layout->adjustAnchorOffset(snippet, delta); } ChromeSnippet *ChromeWidget::getSnippet(const QString & docElementId, QGraphicsItem * parent) { @@ -658,28 +413,18 @@ qDebug() << msg; } - QString ChromeWidget::getDisplayMode() const { - return (m_aspect==portrait)?"portrait":"landscape"; - } - void ChromeWidget::onViewInstantiated(ControllableViewBase *view) { // slot - qDebug() << "ChromeWidget::onViewInstantiated: "; // << view; addViewToLayout(view); } QObject* ChromeWidget::getDisplaySize() const { - ScriptSize * sz = new ScriptSize(size().toSize()); + ScriptSize * sz = new ScriptSize(m_layout->size().toSize()); m_page->mainFrame()->addToJavaScriptWindowObject("size", sz, QScriptEngine::ScriptOwnership); return sz; } -void ChromeWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) -{ - event->accept(); -} - /* void ChromeWidget::addJSObjectToEngine(QObject *object) { @@ -693,27 +438,17 @@ } */ - void ChromeWidget::setScene(QGraphicsScene *scene) + void ChromeWidget::emitPopupShown(const QString &popupId) { - m_scene = scene; - //This is the root of the scene hierarchy - m_scene->addItem(this); - - // For testing, turn on red dot that appears in response to various mouse events. - if(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsInt("EnableTouchCircle", false)) { - new TouchCircleCharm(m_scene, this); - } - } - - void ChromeWidget::emitPopupShown(const QString &popupId) { - qDebug() << "ChromeWidget::emitPopupShown: " << popupId; emit popupShown(popupId); } - void ChromeWidget::emitPopupHidden(const QString &popupId) { + void ChromeWidget::emitPopupHidden(const QString &popupId) + { emit popupHidden(popupId); } + void ChromeWidget::dump() { qDebug() << "---------------------"; qDebug() << "ChromeWidget::dump"; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeWidget.h --- a/ginebra2/ChromeWidget.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeWidget.h Tue Jul 06 14:03:49 2010 +0300 @@ -34,12 +34,13 @@ class MostVisitedPageStore; class ControllableViewBase; -class QGraphicsSceneContextMenuEvent; + using namespace WRT; namespace GVA { class ChromeSnippet; + class ChromeLayout; class ChromeDOM; class ChromeRenderer; class GinebraApplication; @@ -53,32 +54,11 @@ class NetworkDelegate; class Downloads; - enum ChromeAnchor - { - anchorNone, - anchorCenter, - anchorTop, - anchorBottom, - anchorLeft, - anchorRight, - anchorTopLeft, - anchorTopRight, - anchorBottomLeft, - anchorBottomRight - }; - - enum Aspect - { - portrait, - landscape - }; - /*! * \brief This class is responsible for maintaining the browser chrome and * most of the other major components of the application. - * */ - class ChromeWidget : public QGraphicsWidget + class ChromeWidget : public QObject { Q_OBJECT @@ -89,8 +69,10 @@ void setChromeBaseDirectory(const QString dir); void setChromeFile(const QString file); void addView(ControllableViewBase * controllableView); - QGraphicsScene * getScene() { return m_scene; } //NB: change name to scene() !! - void setScene(QGraphicsScene *scene); + + void addViewToLayout(ControllableViewBase * controllableView); + ChromeLayout * layout() { return m_layout; } + void setLayout(ChromeLayout * layout) { m_layout = layout; } ChromeRenderer * renderer() { return m_renderer; } ChromeDOM * dom() { return m_dom; } QRect getSnippetRect(const QString &docElementId); @@ -99,42 +81,33 @@ ControllableViewBase * getView(const QString& name); void showView(const QString &name); QWebPage * page() { return m_page; } - void anchorSnippet(ChromeSnippet * snippet); //NB: get rid of this (see comment in .cpp)!!! void adjustAnchorOffset(ChromeSnippet * snippet, qreal delta); - void anchorToView(ChromeSnippet* snippet, const QString & where = "top"); - void detachFromView(ChromeSnippet* snippet, const QString & where = "top"); void anchorTogether(ChromeSnippet* first, const QString & secondId, qreal x = 0, qreal y = 0); - void unAnchor(ChromeSnippet* first); - //void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget* widget = 0); QGraphicsView *graphicsView() { return m_view; } void dump(); QString getBaseDirectory() const { return m_baseDirectory; } ViewController * viewController() { return m_viewController; } // needed for UrlSearchSnippet QString currentView() {return m_viewController->currentView()->type() ;} - int bottomBarHeight() { return m_bottomBarHeight;} void updateChromeLayout(); void sizeChange(QSize sz){ emit prepareForSizeChange(sz) ;} void emitPopupShown(const QString &popupId); void emitPopupHidden(const QString &popupId); public slots: - int width(){return (int)size().width();} - void snippetShown(ChromeSnippet * snippet); - void snippetHiding(ChromeSnippet * snippet); void loadStarted(); void loadFinished(bool ok); void exportJSObjects(); void exportJSObjectsToPage(QWebPage *page); void alert(const QString & msg); - qreal slideView(qreal delta); - qreal shrinkView(qreal delta); void onViewInstantiated(ControllableViewBase *view); void onCurrentViewChanged(); void chromeInitialized(); void reloadChrome(); void loadUrlToCurrentPage(const QUrl & url); void pageCreated(WRT::WrtBrowserContainer * page); + void onResize(QSizeF size); + void onAspectChanged(int aspect); signals: void internalChromeComplete(); @@ -150,31 +123,20 @@ public: Q_PROPERTY(QObjectList snippets READ getSnippets) QObjectList getSnippets(); - /// \brief Returns either "portrait" or "landscape". - QString getDisplayMode() const; - Q_PROPERTY(QString displayMode READ getDisplayMode) QObject* getDisplaySize() const; Q_PROPERTY(QObject* displaySize READ getDisplaySize) - protected: - virtual void resizeEvent(QGraphicsSceneResizeEvent *ev); - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event); - //bool eventFilter(QObject *obj, QEvent *ev); private: void addSnippet( ChromeSnippet * snippet, const QString & docElementId); void getInitialSnippets(); void clearChrome(); - void addAnchors(); void addJSObjectToWindow(QObject *object); void addJSObjectToPage(QObject *object, QWebPage *page); void updateMVGeometry(); - void addViewToLayout(ControllableViewBase * controllableView); - //void addJSObjectToEngine(QObject *object); - QGraphicsScene * m_scene; - QGraphicsView *m_view; - QGraphicsAnchorLayout *m_layout; + ChromeLayout * m_layout; + QGraphicsView *m_view; //TBD: not used? QString m_baseDirectory; QWebPage * m_page; ChromeRenderer * m_renderer; @@ -183,21 +145,12 @@ ViewController *m_viewController; //QList m_jsObjects; //QScriptEngine m_engine; - QGraphicsAnchorLayout *m_viewLayout; - SlidingWidget *m_viewPort; - QGraphicsWidget *m_topBar; - QGraphicsWidget *m_bottomBar; - QGraphicsWidget *m_leftBar; - QGraphicsWidget *m_rightBar; - //CollapsingWidget *m_viewBar; GinebraApplication *m_app; - Aspect m_aspect; ChromeWidgetJSObject *m_jsObject; LocaleDelegate *m_localeDelegate; // Owned DeviceDelegate *m_deviceDelegate; NetworkDelegate *m_networkDelegate; Downloads * m_downloads; // Owned - int m_bottomBarHeight; }; } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ChromeWidgetJSObject.h --- a/ginebra2/ChromeWidgetJSObject.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ChromeWidgetJSObject.h Tue Jul 06 14:03:49 2010 +0300 @@ -25,6 +25,7 @@ #include #include +#include "ChromeLayout.h" #include "ChromeWidget.h" #include "ChromeEffect.h" @@ -33,8 +34,6 @@ namespace GVA { -class ChromeWidget; - /*! * \defgroup JavascriptAPI Javascript API objects. * All classes in this group provide Javascript API access to the underlying @@ -61,9 +60,9 @@ ChromeWidgetJSObject(QObject *parent, ChromeWidget *chromeWidget); public slots: - int width() { return m_chromeWidget->width(); } + int width() { return m_chromeWidget->layout()->size().width(); } void alert(const QString & msg) { m_chromeWidget->alert(msg); } - qreal slideView(qreal delta) { return m_chromeWidget->slideView(delta); } + qreal slideView(qreal delta) { return m_chromeWidget->layout()->slideView(delta); } void chromeInitialized() { m_chromeWidget->chromeInitialized(); } void reloadChrome() { m_chromeWidget->reloadChrome(); } void loadUrlToCurrentPage(const QString & url) { m_chromeWidget->loadUrlToCurrentPage(url); } @@ -89,7 +88,7 @@ Q_PROPERTY(QObjectList snippets READ getSnippets) /// \brief Returns either "portrait" or "landscape". - QString getDisplayMode() const { return m_chromeWidget->getDisplayMode(); } + QString getDisplayMode() const { return m_chromeWidget->layout()->getDisplayMode(); } Q_PROPERTY(QString displayMode READ getDisplayMode) QObject* getDisplaySize() const { return m_chromeWidget->getDisplaySize(); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentToolbarChromeItem.cpp --- a/ginebra2/ContentToolbarChromeItem.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentToolbarChromeItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -29,6 +29,7 @@ #include "mostvisitedsnippet.h" #include "webpagecontroller.h" #include "ViewController.h" +#include "ChromeEffect.h" #include @@ -83,11 +84,12 @@ emit updateVisibility(step); } - ContentToolbarChromeItem::ContentToolbarChromeItem(QGraphicsItem* parent) - : ToolbarChromeItem(parent), + ContentToolbarChromeItem::ContentToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent) + : ToolbarChromeItem(snippet, parent), m_background(NULL), m_state(CONTENT_TOOLBAR_STATE_FULL), - m_autoHideToolbar(true) + m_autoHideToolbar(true), + m_timerState(CONTENT_TOOLBAR_TIMER_STATE_ALLOW) { m_inactivityTimer = new QTimer(this); @@ -96,7 +98,12 @@ m_animator = new ToolbarFadeAnimator(); connect(m_animator, SIGNAL(updateVisibility(qreal)), this, SLOT(onUpdateVisibility(qreal))); connect(m_animator, SIGNAL(finished()), this, SLOT(onAnimFinished())); - + + m_maxOpacity = m_bgopacity = opacity(); + if (m_autoHideToolbar ) { + connect(m_snippet->chrome(), SIGNAL(chromeComplete()), this, SLOT(onChromeComplete())); + } + setFlags(QGraphicsItem::ItemDoesntPropagateOpacityToChildren); } @@ -119,6 +126,29 @@ } + void ContentToolbarChromeItem::mousePressEvent(QGraphicsSceneMouseEvent * ev) + { + // If we are not in full state, ignore the event. Once igonre, none of the + // other mouse events are received until the next mouse press + if (m_state == CONTENT_TOOLBAR_STATE_PARTIAL ) { + ev->ignore(); + } + else { + ChromeSnippet * mv = m_snippet->chrome()->getSnippet("MostVisitedViewId"); + // Let mostvisited snippet handle the key press if it is visible + if (mv && mv->isVisible() ){ + ev->ignore(); + } + } + } + + void ContentToolbarChromeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * ev) + { + Q_UNUSED(ev); + // Do nothing - prevent the event from trickling down + + } + void ContentToolbarChromeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget) { Q_UNUSED(opt) @@ -143,6 +173,10 @@ // fill path with color painter->fillPath(*m_background,QBrush(grad())); painter->drawPath(*m_background); + if(m_state == CONTENT_TOOLBAR_STATE_FULL && !isEnabled()) { + // Disabled, apply whitewash. + ChromeEffect::paintDisabledRect(painter, opt->exposedRect); + } break; default: qDebug() << "ContentToolbarChromeItem::paint invalid state" ; @@ -170,24 +204,33 @@ //qDebug() << __PRETTY_FUNCTION__ << webView; if (webView ) { connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); - connect(webView, SIGNAL(loadStarted()), this, SLOT(stopInactivityTimer())); - connect(webView->widget(), SIGNAL(contextEvent(::WebViewEventContext *)), this, SLOT(stopInactivityTimer())); + connect(webView, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); +#ifdef BEDROCK_TILED_BACKING_STORE + connect(webView, SIGNAL(contextEvent(::WebViewEventContext *)), this, SLOT(resetTimer())); +#else + connect(webView->widget(), SIGNAL(contextEvent(::WebViewEventContext *)), this, SLOT(resetTimer())); +#endif } } + void ContentToolbarChromeItem::onLoadStarted() { + + m_timerState = CONTENT_TOOLBAR_TIMER_STATE_ALLOW; + stopInactivityTimer(); + } + void ContentToolbarChromeItem::onLoadFinished(bool ok) { Q_UNUSED(ok); - //qDebug() << __PRETTY_FUNCTION__ << m_state; + //qDebug() << __PRETTY_FUNCTION__ << m_state << "Timer Allowed" << m_timerState; - if (m_autoHideToolbar ) { + if (m_autoHideToolbar && m_timerState == CONTENT_TOOLBAR_TIMER_STATE_ALLOW) { ControllableViewBase* curView = m_snippet->chrome()->viewController()->currentView(); if (curView && curView->type() == "webView") { GWebContentView * gView = qobject_cast (curView); bool isSuperPage = gView ? gView->currentPageIsSuperPage() : false; - qDebug() << "Super Page " << isSuperPage; // Start inactivity timer if full toolbar is visible if (!isSuperPage && m_state == CONTENT_TOOLBAR_STATE_FULL ) @@ -196,6 +239,11 @@ } } + void ContentToolbarChromeItem::resetTimer() { + + m_timerState = CONTENT_TOOLBAR_TIMER_STATE_NONE; + stopInactivityTimer(); + } void ContentToolbarChromeItem::stopInactivityTimer() { @@ -221,9 +269,7 @@ //qDebug() << __PRETTY_FUNCTION__ << type ; if (type == QEvent::MouseButtonPress || type == QEvent::GraphicsSceneMousePress) { - // stop inactivity timer - if (m_inactivityTimer->isActive() ) - m_inactivityTimer->stop(); + resetTimer(); } } @@ -289,18 +335,25 @@ void ContentToolbarChromeItem::onAnimFinished() { + ContentToolbarState state = CONTENT_TOOLBAR_STATE_INVALID; + bool animate = false; //qDebug() << __PRETTY_FUNCTION__ << m_state; switch (m_state) { case CONTENT_TOOLBAR_STATE_ANIM_TO_PARTIAL: - changeState(CONTENT_TOOLBAR_STATE_PARTIAL); + state = CONTENT_TOOLBAR_STATE_PARTIAL; break; case CONTENT_TOOLBAR_STATE_ANIM_TO_FULL: - changeState(CONTENT_TOOLBAR_STATE_FULL, true); + state = CONTENT_TOOLBAR_STATE_FULL; + animate = true; break; default: break; } + + ContentToolbarSnippet * s = static_cast(m_snippet); + s->handleToolbarStateChange(state); + changeState(state, animate); //qDebug() << __PRETTY_FUNCTION__ << m_state; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentToolbarChromeItem.h --- a/ginebra2/ContentToolbarChromeItem.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentToolbarChromeItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,7 @@ #define __GINEBRA_CONTENTTOOLBARCHROMEITEM_H #include +#include "Toolbar.h" #include "ToolbarChromeItem.h" class QTimeLine; @@ -59,17 +60,8 @@ { Q_OBJECT - enum ContentToolbarState { - - CONTENT_TOOLBAR_STATE_FULL, - CONTENT_TOOLBAR_STATE_PARTIAL, - CONTENT_TOOLBAR_STATE_ANIM_TO_PARTIAL, - CONTENT_TOOLBAR_STATE_ANIM_TO_FULL, - CONTENT_TOOLBAR_STATE_INVALID - }; - public: - ContentToolbarChromeItem(QGraphicsItem* parent = 0); + ContentToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent = 0); virtual ~ContentToolbarChromeItem(); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); virtual void setSnippet(ChromeSnippet * s); @@ -80,12 +72,18 @@ protected: virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); + /// Reimplemented to consume the events + virtual void mousePressEvent( QGraphicsSceneMouseEvent * ev ); + virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev ); + private slots: void onChromeComplete(); void stopInactivityTimer(); void onLoadFinished(bool); + void onLoadStarted(); + void resetTimer(); void onInactivityTimer(); void onSnippetMouseEvent( QEvent::Type type); @@ -114,6 +112,7 @@ qreal m_maxOpacity; ContentToolbarState m_state; bool m_autoHideToolbar; + ContentToolbarTimerState m_timerState; }; } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentToolbarSnippet.cpp --- a/ginebra2/ContentToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -1,3 +1,4 @@ + /* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. @@ -17,27 +18,28 @@ * * Description: * This class extends WebChromeContainerSnippet class to hold the -* content view toolbar buttons -* Note: Showing/Hiding of the sub-chrome snippets in response to -* the button selection is not entirely done here as we have a -* a hybrid html-native design. +* content view toolbar buttons. Showing/Hiding of the sub-chrome snippets in response to +* the button selection is not entirely done here as we have a hybrid html-native design. * MostVisited: Show/Hide is handled in handleMVButton. * Menu: Show is handled in Javascript. Hide is handled here. -* Zoom: Show/Hide is handled here +* Zoom: Show/Hide is handled here. Zoom action buttons * Note: Most Visited is native while Menu and Zoom are html based. All three of them need to * be dismissed if the user taps anywhere else on the screen. Since mv is native, it handles * all mouse events and dismisses itself. Zoom/Menu are created as PopupChromeItem which receives * the mouse events in its event filter and emits a signal if the user taps anywhere on the screen * other than itself. This signal is handled here. +* Sub-chromes are hidden after a specified timeout if there is no user interaction with the +* particular chrome. This class listens to the mouse events of the sub-chromes and +* their children to manage this. * */ #include "ContentToolbarSnippet.h" #include "ContentToolbarChromeItem.h" #include "mostvisitedsnippet.h" -#include "Toolbar.h" #include "ViewStack.h" #include "webpagecontroller.h" +#include "ExternalEventCharm.h" #include @@ -45,8 +47,8 @@ namespace GVA { - ContentToolbarSnippet::ContentToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : ToolbarSnippet(elementId, chrome, ownerArea, element, widget), + ContentToolbarSnippet::ContentToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + : ToolbarSnippet(elementId, chrome, element), m_middleSnippet(NULL), m_subChromeSnippet(NULL) { @@ -62,19 +64,26 @@ delete m_subChromeInactiveTimer; } + ContentToolbarSnippet * ContentToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + ContentToolbarSnippet * that = new ContentToolbarSnippet( elementId, chrome, element ); + that->setChromeWidget( new ContentToolbarChromeItem( that ) ); + return that; + } + void ContentToolbarSnippet::updateSize(QSize size) { - //qDebug() << "ContentToolbarSnippet::updateSize" << size.width() ; - setWidth(size.width()); - ToolbarSnippet::updateSize(size); + //qDebug() << "ContentToolbarSnippet::updateSize" << size.width() ; + setWidth(size.width()); + ToolbarSnippet::updateSize(size); } void ContentToolbarSnippet::updateOwnerArea() { - //qDebug() << "ContentToolbarSnippet::updateOwnerArea" << m_chrome->width() ; - setWidth(m_chrome->width()); - ToolbarSnippet::updateOwnerArea(); + //qDebug() << "ContentToolbarSnippet::updateOwnerArea" << m_chrome->width() ; + setWidth(m_chrome->layout()->size().width()); + ToolbarSnippet::updateOwnerArea(); //qDebug() << "------------Relayout "<< elementId() << hidesContent(); // If hidesContent is true, it means that the snippet is tied to the chrome's layout. Hence, we @@ -83,8 +92,8 @@ // that would cause the this snippet to be painted in incorrect position before the layoutRequest // is handled if (hidesContent() ) { - chrome()->layout()->invalidate(); - chrome()->layout()->activate(); + chrome()->layout()->layout()->invalidate(); + chrome()->layout()->layout()->activate(); } } @@ -113,37 +122,37 @@ if (id == "BackButtonSnippet" ) { t->actionId = CONTENT_VIEW_ACTION_BACK; t->actionName = CONTENT_TOTOLBAR_BACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_disabled.png"; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; } else if (id == "ZoomButtonSnippet" ) { t->actionId = CONTENT_VIEW_ACTION_ZOOM; t->actionName = CONTENT_TOTOLBAR_ZOOM; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom.png"; t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom_disabled.png"; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom_pressed.png"; } else if (id == "MenuButtonSnippet" ) { t->actionId = CONTENT_VIEW_ACTION_MENU; t->actionName = CONTENT_TOTOLBAR_MENU; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu_pressed.png"; } else if (id == "MostVisitedButtonSnippet" ) { t->actionId = CONTENT_VIEW_ACTION_MOSTVISITED; t->actionName = CONTENT_TOTOLBAR_MOSTVISITED; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited_pressed.png"; } else if (id == "ToggleTBButtonSnippet" ) { t->actionId = CONTENT_VIEW_ACTION_TOGGLETB; t->actionName = CONTENT_TOTOLBAR_TOGGLETB; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB.png"; + t->normalImg = TOOLBAR_FULL_TB_TOGGLE_ICON; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB_pressed.png"; + t->activeImg = TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON; } t->id = id; m_actionInfo.append(t); @@ -156,7 +165,7 @@ connect(child, SIGNAL(childAdded(ChromeSnippet*)), this, SLOT(childAdded(ChromeSnippet*))); m_middleSnippet = s; // Set the snippet width - setWidth(m_chrome->width()); + setWidth(m_chrome->layout()->size().width()); } else { addActionInfo(child->elementId()); @@ -174,6 +183,7 @@ // Connect back to initialLayoutCompleted signal ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_BACK); connect(WebPageController::getSingleton(), SIGNAL(initialLayoutCompleted()), button->widget(), SLOT(onHidden())); + connect(WebPageController::getSingleton(), SIGNAL(loadFinished(bool)), button->widget(), SLOT(onHidden())); connect(m_chrome, SIGNAL(aspectChanged(int)) , this, SLOT(onAspectChanged())); @@ -191,7 +201,6 @@ * widget's mosueEvent signal */ QList items = it->childItems(); - ContentToolbarChromeItem * w = static_cast(widget()); //qDebug() << " ------------------- Num of children " << items.count(); for (int i = 0; i < items.count() ; i++) { @@ -205,40 +214,67 @@ manageChildren(item); } else { // Individual item - //qDebug() << "Item: " << item->snippet()->elementId(); - if (w->autoHideToolbar()) { - connect(item, SIGNAL(mouseEvent(QEvent::Type)), w, SLOT(onSnippetMouseEvent(QEvent::Type))); - } - // Connect to the mouse event to show selected image on key press - //connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type))); - setAction(item->snippet()); - - - ChromeSnippet * link = item->snippet()->linkedSnippet(); + //qDebug() << "Item: " << item->snippet()->elementId(); + ContentToolbarChromeItem * w = static_cast(widget()); + if (w->autoHideToolbar()) { + // Connect to the snippet's mouse event to cancel auto-timeout + connect(item, SIGNAL(mouseEvent(QEvent::Type)), w, SLOT(onSnippetMouseEvent(QEvent::Type))); + } - if (link) { - ChromeItem* it = dynamic_cast (link->widget()); - if (it ) { - connect(it, SIGNAL(mouseEvent(QEvent::Type)), this, SLOT(onSnippetMouseEvent(QEvent::Type))); - // Save the linked children to be used later for hiding - w->addLinkedChild(link); - - // In case it has more children, recurse - manageChildren(it); - } - } + setAction(item->snippet()); + manageLink(item); } } } } + void ContentToolbarSnippet::manageLink(ChromeItem * item) { + + // If it has a linked snippet, connect to it's mouse event and also + // to it's children's mouse events + ChromeSnippet * link = item->snippet()->linkedSnippet(); + if (link) { + ChromeItem* it = dynamic_cast (link->widget()); + if (it ) { + // Connect to linked snippet's mouse events to control the sub-chrome + connect(it, SIGNAL(mouseEvent(QEvent::Type)), this, SLOT(onSnippetMouseEvent(QEvent::Type))); + + // Save the linked children to be used later for hiding + ContentToolbarChromeItem * w = static_cast(widget()); + w->addLinkedChild(link); + + // In case it has children, connect to their mouse events as well + QList childItems = it->childItems(); + int count = childItems.count(); + + // If the linked snippet has children that are widgets themselves, listen to their + // mouse events as well. + for (int i = 0; i < count ; i++) { + ChromeItem * child = dynamic_cast(childItems.at(i)); + + // To control sub-chrome timer + connect(child, SIGNAL(mouseEvent(QEvent::Type)), this, SLOT(onSnippetMouseEvent(QEvent::Type))); + } + } + } + } + void ContentToolbarSnippet::setAction(ChromeSnippet * s) { //qDebug() << "setAction: " << s->elementId(); ToolbarSnippet::setAction(s); ActionButtonSnippet * button = static_cast (s); + + // Set selected on press to false here so that we can control when to + // change action button icon state + button->setActiveOnPress(false); + button->getDefaultAction()->setCheckable(true); + + ChromeItem * item = static_cast(s->widget()); + connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type))); + int index = getIndex(s); if (index != -1) { @@ -275,7 +311,8 @@ // Connect to hide and show signals of the linked snippet connectHideShowSignals(button); - connect( button->linkedSnippet(), SIGNAL(externalMouseEvent(int, const QString , const QString )), this, SLOT(onExternalMouse(int, const QString , const QString))); + connect( button->linkedSnippet(), SIGNAL(externalMouseEvent(QEvent *, const QString , const QString )), this, SLOT(onExternalMouse(QEvent *, const QString , const QString))); + } @@ -288,7 +325,7 @@ // Connect to hide and show signals of the linked snippet connectHideShowSignals(button); - connect( button->linkedSnippet(), SIGNAL(externalMouseEvent(int, const QString , const QString )), this, SLOT(onExternalMouse(int, const QString , const QString))); + connect( button->linkedSnippet(), SIGNAL(externalMouseEvent(QEvent *, const QString , const QString )), this, SLOT(onExternalMouse(QEvent *, const QString , const QString))); } @@ -317,20 +354,24 @@ ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_ZOOM); ChromeSnippet * zoomSnippet = button->linkedSnippet(); - //qDebug() << "ContentToolbarSnippet::handleZoomButton() : Show flag: " << zoomSnippet->getDontShowFlag() << "Checked " << button->isChecked(); - // Zoom bar is dismissed if the user taps anywhere on the screen. We get externalMouseEvent - // if the user presses the button also. In addition to that the action is triggered and the - // handler is called. In this case, we don't need to do anything, so we use the DontShowFlag - // to determine if there is any action needed. - if (zoomSnippet->getDontShowFlag() ){ - // Set selected state to false as it gets enabled in ActionButton mousePressEvent handling - button->setLatched(false); - zoomSnippet->setDontShowFlag(false); + if (zoomSnippet->isVisible() ) { + zoomSnippet->hide(); } else { hideOtherPopups(button->elementId()); - zoomSnippet->show(); + zoomSnippet->show(); + + // Show the action buttons. We can get the snippets by their id or do this to show them. + ChromeItem* it = dynamic_cast (zoomSnippet->widget()); + QList childItems = it->childItems(); + int count = childItems.count(); + + for (int i = 0; i < count ; i++) { + ChromeItem * child = dynamic_cast(childItems.at(i)); + child->snippet()->show(); + + } } } @@ -340,20 +381,14 @@ ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_MENU); ChromeSnippet * menuSnippet = button->linkedSnippet(); - //qDebug() << "ContentToolbarSnippet::handleMenuButton() : Show flag: " << button->linkedSnippet()->getDontShowFlag() << "Checked: " << button->isChecked(); - if (menuSnippet ) { - //qDebug() << "ContentToolbarSnippet::handleMenuButton() : Dont show flag " << menuSnippet->getDontShowFlag(); - if (menuSnippet->getDontShowFlag() ){ - // Set selected state to false as it gets enabled in ActionButton mousePressEvent handling - button->setLatched(false); - menuSnippet->setDontShowFlag(false); - } - else { - // Hide other pop-ups if any. Showing the menu is handled in - // javascript - emit menuButtonSelected(); - hideOtherPopups(button->elementId()); - } + if (!menuSnippet->isVisible() ) { + + emit menuButtonSelected(); + hideOtherPopups(button->elementId()); + + } + else { + menuSnippet->hide(); } } @@ -367,11 +402,8 @@ } void ContentToolbarSnippet::handleToggleTBButton() { - ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_TOGGLETB); ContentToolbarChromeItem * w = static_cast(widget()); - w->toggleMiddleSnippet(); - button->updateButtonState(false); } @@ -445,16 +477,17 @@ ActionButton* button = static_cast ( sender()); ActionButtonSnippet * buttonSnippet = static_cast( button->snippet()); ChromeSnippet * linkedSnippet = buttonSnippet->linkedSnippet(); - //qDebug() << "ContentToolbarSnippet::onMouseEvent : Button : " << buttonSnippet->elementId() << " type: " << type << "Is Enabled " << button->defaultAction()->isEnabled(); + //qDebug() << "ContentToolbarSnippet::onMouseEvent : Button : " << buttonSnippet->elementId() << " type: " << type ; // Set the action button state to active so that we can show a selected image before the // action is acted upon - if (button->defaultAction()->isEnabled() && type == QEvent::GraphicsSceneMousePress ) { + if ( (button->defaultAction()->isEnabled() && type == QEvent::GraphicsSceneMousePress ) || + (button->defaultAction()->isEnabled() && type == QEvent::GraphicsSceneMouseDoubleClick )) { // Set active flag if there is no linked snippet (the button acts as toggle if it // has a linked snippet. If there is linked snippet, set active flag if the linked snippet - // is not visible and dont show flag is false - if (!linkedSnippet || (linkedSnippet && (!linkedSnippet->isVisible() && !linkedSnippet->getDontShowFlag()))){ + // is not visible + if (!linkedSnippet || (linkedSnippet && (!linkedSnippet->isVisible() ))) { buttonSnippet->setActive(true); } } @@ -526,25 +559,74 @@ } } - void ContentToolbarSnippet::onExternalMouse( int type, + void ContentToolbarSnippet::onExternalMouse( QEvent * ev , const QString & name, const QString & description) { - Q_UNUSED(type); Q_UNUSED(description); ChromeSnippet * snippet = static_cast (sender()); - //qDebug() << "ContentToolbarSnippet::onExternalMouse" << snippet->elementId() << name; + QGraphicsSceneMouseEvent * me = static_cast(ev); + ChromeSnippet * linkedButton = getLinkedButton(snippet); + + // For sub-chromes like zoom and menu, we get mouse events anywhere on the + // screen including the ones on the corresponding button on the toolbar. Hide + // the sub-chrome only if the mouse press is anywhere other than the + // corresponding button + if (linkedButton ) { + ChromeItem * item = static_cast(linkedButton->widget()); + if (item && item->sceneBoundingRect().contains(me->scenePos() )) { + return; + } + } - if (name == "QGraphicsSceneMousePressEvent" || name == "QGraphicsSceneResizeEvent" ) { + if (name == ExternalEventCharm::s_mouseClick) { snippet->hide(); - snippet->setDontShowFlag(true); - QTimer::singleShot(500, snippet, SLOT(disableDontShowFlag())); } } +void ContentToolbarSnippet::handleToolbarStateChange(ContentToolbarState state){ + + + ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_TOGGLETB); + + // set the appopriate icons based on the state + + if (state != CONTENT_TOOLBAR_STATE_INVALID ) { + if (state == CONTENT_TOOLBAR_STATE_PARTIAL ) { + button->setIcon(TOOLBAR_PARTIAL_TB_TOGGLE_ICON); + button->setActiveIcon(TOOLBAR_PARTIAL_TB_SELECTED_TOGGLE_ICON); + } + else if (state == CONTENT_TOOLBAR_STATE_FULL ) { + button->setIcon(TOOLBAR_FULL_TB_TOGGLE_ICON); + button->setActiveIcon(TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON); + + } + // Also reset the button state if the change in state was triggered by toggle-button selection + button->updateButtonState(false); + + } +} + +ChromeSnippet* ContentToolbarSnippet::getLinkedButton(ChromeSnippet * snippet ) { + + ChromeSnippet * linkedButton = NULL; + for (int i = 0; i < m_actionInfo.size() ; i++ ) { + ToolbarActions_t * t = m_actionInfo.at(i); + ChromeSnippet * s = getActionButtonSnippet (t->actionId) ; + if (s->linkedSnippet() && s->linkedSnippet()->elementId() == snippet->elementId() ) { + linkedButton = s; + break; + } + + } + return linkedButton; + + +} + } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentToolbarSnippet.h --- a/ginebra2/ContentToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,7 @@ #include #include "ActionButtonSnippet.h" +#include "Toolbar.h" #include "ToolbarSnippet.h" #include "WebChromeContainerSnippet.h" @@ -35,10 +36,13 @@ { Q_OBJECT public: - ContentToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + ContentToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~ContentToolbarSnippet(); + static ContentToolbarSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); WebChromeContainerSnippet * middleSnippet() { return m_middleSnippet;} + void handleToolbarStateChange(ContentToolbarState); + Q_SIGNALS: void menuButtonSelected(); void menuButtonCanceled(); @@ -52,12 +56,18 @@ void childAdded(ChromeSnippet* child); void updateOwnerArea(); void updateSize(QSize ); + + /// Slot that sets the state of the action button to active. Handles mouseEvent signal of toolbar + /// action buttons and any sub-chrome children action buttons void onMouseEvent( QEvent::Type type); + + /// Slot that resets the timer that controls the sub-chrome. Handles mouseEvent signal of the sub-chrome + /// as well as those of the sub-chrome chidlren's void onSnippetMouseEvent( QEvent::Type type); void onHidden(); void onShown(); void onInactivityTimer(); - void onExternalMouse(int type, const QString & name, const QString & description); + void onExternalMouse(QEvent * ev, const QString & name, const QString & description); void onAspectChanged( ); @@ -76,7 +86,8 @@ void setWidth(int); void resetTimer(bool start=true); void hideOtherPopups(QString); - + void manageLink(ChromeItem * item) ; + ChromeSnippet* getLinkedButton(ChromeSnippet * snippet ); WebChromeContainerSnippet* m_middleSnippet; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GContentViewTouchNavigation.cpp --- a/ginebra2/ContentViews/GContentViewTouchNavigation.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GContentViewTouchNavigation.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -30,5 +30,4 @@ install(); connect(m_view, SIGNAL(BlockFocusChanged(QPoint)), this, SLOT(BlockFocusChanged(QPoint))); } - } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GContentViewTouchNavigation.h --- a/ginebra2/ContentViews/GContentViewTouchNavigation.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GContentViewTouchNavigation.h Tue Jul 06 14:03:49 2010 +0300 @@ -25,6 +25,7 @@ #include #include "GWebTouchNavigation.h" #include "GWebContentViewWidget.h" +#include "ChromeLayout.h" #include "ChromeWidget.h" namespace GVA @@ -40,17 +41,22 @@ GContentViewTouchNavigation(QWebPage* webPage, GWebContentViewWidget* view); void setChromeWidget(ChromeWidget* chrome) { m_chrome = chrome;} + Q_PROPERTY(qreal doubleClickEnabled READ getDoubleClickEnabled WRITE setDoubleClickEnabled) + qreal getDoubleClickEnabled() const { return m_doubleClickEnabled; } + void setDoubleClickEnabled(qreal value) { m_doubleClickEnabled = value; } + protected: GWebContentViewWidget *contentViewWidget() { return static_cast(m_view); } - virtual qreal slideView(qreal delta) { return m_chrome->slideView(delta); } - virtual qreal shrinkView(qreal delta) { return m_chrome->shrinkView(delta); } + virtual qreal slideView(qreal delta) { return m_chrome->layout()->slideView(delta); } + virtual qreal shrinkView(qreal delta) { return m_chrome->layout()->shrinkView(delta); } virtual qreal viewInitialScale() { return contentViewWidget()->initialScale(); } virtual void setViewBlockElement(const QWebElement &el) { contentViewWidget()->setBlockElement(el); } virtual void setViewZoomFactor(qreal zoom) { return contentViewWidget()->setZoomFactor(zoom); } protected: ChromeWidget* m_chrome; + }; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GWebContentView.cpp --- a/ginebra2/ContentViews/GWebContentView.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GWebContentView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,11 +22,19 @@ #include "GWebContentView.h" #include "GWebContentViewWidget.h" #include "GWebContentViewJSObject.h" +#include "SuperPageView.h" #include "ChromeWidget.h" #include "WebViewEventContext.h" #include "browserpagefactory.h" #include "wrtbrowsercontainer.h" + +#ifdef BEDROCK_TILED_BACKING_STORE +#include "WebContentViewWidget.h" +#endif + #include "webpagecontroller.h" +#include "Utilities.h" +#include "GSuperWebPage.h" #ifndef NO_QSTM_GESTURE #include "qstmgestureevent.h" #endif @@ -39,10 +47,6 @@ #include #include - -#define safe_connect(src, srcSig, target, targetSlot) \ - { int res = connect(src, srcSig, target, targetSlot); assert(res); } - namespace GVA { @@ -66,11 +70,20 @@ m_enabled(true) { setObjectName(objectName); - qDebug() << "GWebContentView::GWebContentView: this=" << this; WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage(); setActions(); + +#ifdef BEDROCK_TILED_BACKING_STORE + m_widget = new WebContentViewWidget(parent, page); + connect(m_widget + , SIGNAL(updateZoomActions(bool,bool)) + , this + , SLOT(setZoomActions(bool, bool))); +#else m_widget = new GWebContentViewWidget(parent, this, page); +#endif + #ifndef __gva_no_chrome__ setJSObject(objectName); #endif @@ -79,10 +92,16 @@ webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); +#ifndef BEDROCK_TILED_BACKING_STORE #ifdef NO_QSTM_GESTURE m_touchNavigation = new GContentViewTouchNavigation(page, m_widget); m_touchNavigation->setChromeWidget(m_chrome); - connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type))); + m_touchNavigation->setParent(m_jsObject); + m_touchNavigation->setObjectName("touchNav"); + safe_connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type))); + safe_connect(m_touchNavigation, SIGNAL(longPressEvent(QPoint)), + webWidget(), SLOT(onLongPressEvent(QPoint))); +#endif #endif WRT::WrtBrowserContainer * wrtPage = static_cast(page); if (wrtPage) { @@ -96,17 +115,36 @@ GWebContentView::~GWebContentView() { disconnect(m_jsObject); disconnect(webWidget()); +#ifndef BEDROCK_TILED_BACKING_STORE delete m_touchNavigation; +#endif foreach(QAction * action, m_actions) { delete action; } delete m_widget; - foreach(GWebPage *page, m_superPages) { + foreach(GSuperWebPage *page, m_superPages) { delete page; } } +#ifdef BEDROCK_TILED_BACKING_STORE +void GWebContentView::zoomIn(qreal deltaPercent) +{ + //FIX ME : Do we need deltaPercent? + Q_UNUSED(deltaPercent); + m_widget->setPageZoom(true); +} + +void GWebContentView::zoomOut(qreal deltaPercent) +{ + //FIX ME : Do we need deltaPercent? + Q_UNUSED(deltaPercent); + m_widget->setPageZoom(false); +} +#endif + +#ifndef BEDROCK_TILED_BACKING_STORE void GWebContentView::bitmapZoomStop() { if (m_timer) { @@ -206,12 +244,30 @@ } } +#endif void GWebContentView::connectAll() { //qDebug() << "GWebContentView::connectAll: " << widget(); #ifndef __gva_no_chrome__ +#ifndef BEDROCK_TILED_BACKING_STORE safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)), m_jsObject, SLOT(onContextEvent(::WebViewEventContext *))); +#else + safe_connect(this + , SIGNAL(contextEvent(::WebViewEventContext*)) + , m_jsObject + , SLOT(onContextEvent(::WebViewEventContext*))); + + safe_connect(m_widget + , SIGNAL(contextEventObject(QWebHitTestResult*)) + , this + , SLOT(handleContextEventObject(QWebHitTestResult*))); + + safe_connect(m_widget + , SIGNAL(viewScrolled(QPoint&, QPoint&)) + , this + , SLOT(handleViewScrolled(QPoint&, QPoint&))); +#endif QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &))); QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted())); QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int))); @@ -226,8 +282,12 @@ QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool))); QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool))); QObject::connect(this, SIGNAL(secureConnection(bool)), m_jsObject, SIGNAL(secureConnection(bool))); +#ifndef BEDROCK_TILED_BACKING_STORE connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int))); #endif + QObject::connect(this, SIGNAL(superPageShown(const QString&)), m_jsObject, SIGNAL(superPageShown(const QString&))); + +#endif connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)), this, SLOT(pageCreated(WRT::WrtBrowserContainer*))); connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)), @@ -250,9 +310,15 @@ return static_cast(m_widget); } +#ifdef BEDROCK_TILED_BACKING_STORE + QGraphicsWebView* GWebContentView::webWidget() const { + return m_widget->webView(); + } +#else GWebContentViewWidget *GWebContentView::webWidget() const { return m_widget; } +#endif QString GWebContentView::title() const { return webWidget()->title(); @@ -263,7 +329,11 @@ } QWebPage* GWebContentView::wrtPage() { +#ifdef BEDROCK_TILED_BACKING_STORE + return m_widget->page(); +#else return m_widget->wrtPage(); +#endif } void GWebContentView::setActions(){ @@ -303,7 +373,6 @@ void GWebContentView::triggerAction(const QString & action) { - qDebug() << "GWebContentView::triggerAction: " << action; QWebPage::WebAction webAction; if (action=="Stop") webAction = QWebPage::Stop; @@ -325,6 +394,7 @@ } void GWebContentView::changeZoomAction(qreal zoom){ + #ifndef BEDROCK_TILED_BACKING_STORE if (!webWidget()) return; if (!(webWidget()->isUserScalable() ) ){ deactivateZoomActions(); @@ -346,24 +416,53 @@ zoomInAction->setEnabled(true); } } +#endif } void GWebContentView::setZoomFactor(qreal factor){ if (webWidget()) +#ifdef BEDROCK_TILED_BACKING_STORE + webWidget()->setScale(factor); +#else webWidget()->setZoomFactor(factor); +#endif } +#ifdef BEDROCK_TILED_BACKING_STORE +QGraphicsWidget* GWebContentView::webWidgetConst() { + return m_widget; +} + +void GWebContentView::setZoomActions(bool enableZoomIn, bool enableZoomOut) +{ + m_actions.value("zoomIn")->setEnabled(enableZoomIn); + m_actions.value("zoomOut")->setEnabled(enableZoomOut); +} + qreal GWebContentView::getZoomFactor(){ + return webWidgetConst() ? webWidgetConst()->scale() : 0.0; + } + +#else qreal GWebContentView::getZoomFactor() const { return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0; } - - void GWebContentView::activate() { - qDebug() << "GWebContentView::activate"; - ControllableViewBase::activate(); +#endif + +void GWebContentView::activate() { +#ifdef BEDROCK_TILED_BACKING_STORE + WRT::WrtBrowserContainer* newPage = WebPageController::getSingleton()->currentPage(); + changeContentViewZoomInfo(newPage); +#endif + ControllableViewBase::activate(); } void GWebContentView::deactivate() { - qDebug() << "GWebContentView::deactivate"; +#ifdef BEDROCK_TILED_BACKING_STORE + if (!currentPageIsSuperPage()) { + WRT::WrtBrowserContainer* currentPage = WebPageController::getSingleton()->currentPage(); + currentPage->setPageZoomMetaData(m_widget->currentPageInfo()); + } +#endif ControllableViewBase::deactivate(); } @@ -479,7 +578,6 @@ void GWebContentView::back() { - qDebug() << "GWebContentView::back"; webWidget()->back(); } @@ -526,10 +624,12 @@ void GWebContentView::updateZoom(qreal delta){ Q_UNUSED(delta) +#ifndef BEDROCK_TILED_BACKING_STORE if (m_zoomIn) zoomBy(0.1); else zoomBy(-0.1); +#endif } void GWebContentView::onUrlChanged(const QUrl& url) @@ -542,9 +642,8 @@ emit secureConnection(false); } - GWebPage *GWebContentView::createSuperPage(const QString &name, bool persist) { - qDebug() << "GWebContentView::createSuperPage: " << name; - GWebPage *page = 0; + GSuperWebPage *GWebContentView::createSuperPage(const QString &name, bool persist) { + GSuperWebPage *page = 0; PageMap::iterator it = m_superPages.find(name); // If page doesn't exist create a new one. if (it == m_superPages.end()) { @@ -565,8 +664,7 @@ //No history for super pages page->page()->history()->setMaximumItemCount(0); //Limit page cache usage by super pages - //TODO: This needs to be further tested to weigh the costs and benefits. - page->page()->settings()->setMaximumPagesInCache(2); + //NB: needed? QPalette viewPalette = widget()->palette(); viewPalette.setBrush(QPalette::Base, Qt::white); @@ -588,14 +686,15 @@ else { qDebug() << "GWebContentView::createPage: page already exists: " << name; } + //Create a controllable view onto the super page so that it can be controlled by the view controller. + m_chrome->addView(new SuperPageView(this, page, name)); return page; } void GWebContentView::destroySuperPage(const QString &name) { - qDebug() << "GWebContentView::destroySuperPage: " << name; if (!m_superPages.contains(name)) return; - GWebPage *page = m_superPages.take(name); + GSuperWebPage *page = m_superPages.take(name); //This will destroy any QWebPage owned by the super page. The shared page is not //owned by the super page and will be deleted when the GWebContentView is deleted. if (page){ @@ -603,66 +702,93 @@ } } - void GWebContentView::setCurrentSuperPage(const QString &name) { + bool GWebContentView::setCurrentSuperPage(const QString &name) { PageMap::iterator it = m_superPages.find(name); if (it != m_superPages.end()) { m_currentSuperPage = it; + return true; } else { qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name; + return false; } } bool GWebContentView::isSuperPage(const QString &name){ PageMap::iterator it = m_superPages.find(name); - if (it != m_superPages.end()) { - return true; - } - qDebug() << "GWebContentView::superPage: not found: " << name; - return false; + if (it != m_superPages.end()) { + return true; + } + qDebug() << "GWebContentView::superPage: not found: " << name; + return false; } - GWebPage * GWebContentView::superPage(const QString &name) { - PageMap::iterator it = m_superPages.find(name); - if (it != m_superPages.end()) { - return it.value(); - } - qDebug() << "GWebContentView::superPage: not found: " << name; - return 0; + GSuperWebPage * GWebContentView::superPage(const QString &name) { + PageMap::iterator it = m_superPages.find(name); + if (it != m_superPages.end()) { + return it.value(); + } + qDebug() << "GWebContentView::superPage: not found: " << name; + return 0; } void GWebContentView::showSuperPage(const QString &name) { - setCurrentSuperPage(name); - qDebug() << "GWebContentView::showSuperPage: " << currentSuperPage(); - m_currentPageIsSuperPage = true; - webWidget()->setPage(currentSuperPage()->page()); - m_touchNavigation->setPage(webWidget()->page()); - m_touchNavigation->setWantSlideViewCalls(false); - webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize()); + if(isSuperPage(name)) { + if(currentPageIsSuperPage()) { + currentSuperPage()->onHidden(); + } + + setCurrentSuperPage(name); + m_currentPageIsSuperPage = true; +#ifndef BEDROCK_TILED_BACKING_STORE + webWidget()->setPage(currentSuperPage()->page()); + m_touchNavigation->setPage(webWidget()->page()); + m_touchNavigation->setWantSlideViewCalls(false); + webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize()); +#else + WRT::WrtBrowserContainer *pg = WebPageController::getSingleton()->currentPage(); + pg->setPageZoomMetaData(m_widget->currentPageInfo()); + m_widget->setPage(currentSuperPage()->page()); + m_widget->showPage(true); +#endif + emit superPageShown(name); + currentSuperPage()->onShown(); + } + else { + qDebug() << "GWebContentView::showSuperPage: error, not found: " << name; + } } void GWebContentView::showNormalPage() { if (webWidget()) { +#ifndef BEDROCK_TILED_BACKING_STORE webWidget()->showNormalPage(); webWidget()->setViewportSize(); m_touchNavigation->setPage(currentPage()); m_touchNavigation->setWantSlideViewCalls(true); +#else + m_widget->showPage(false); +#endif //TODO: Further testing is needed to show if the following is a net benefit. - if (m_currentPageIsSuperPage && (currentSuperPage()->page() == m_sharedPage)){ - //Clear contents of shared page to free resources. This should save - //memory for big pages, but at the performance cost of loading an empty page. - //An alternative is to delete the shared page every time and reallocate it when - //a super page is loaded. - currentSuperPage()->page()->mainFrame()->setHtml(QString()); + if (currentPageIsSuperPage()) { + if(currentSuperPage()->page() == m_sharedPage){ + //Clear contents of shared page to free resources. This should save + //memory for big pages, but at the performance cost of loading an empty page. + //An alternative is to delete the shared page every time and reallocate it when + //a super page is loaded. + currentSuperPage()->page()->mainFrame()->setHtml(QString()); + } + + currentSuperPage()->onHidden(); + m_currentPageIsSuperPage =false; } - m_currentPageIsSuperPage =false; } } QObjectList GWebContentView::getSuperPages() { QObjectList *result = new QObjectList; - foreach(GVA::GWebPage *page, m_superPages) { + foreach(GVA::GSuperWebPage *page, m_superPages) { result->append(page); } // TO DO: Need to add result to JS engine so it can be cleaned up. @@ -719,7 +845,7 @@ qDebug() << "\tcurrent page=: " << currentPage() << " title=" << currentPage()->mainFrame()->title(); qDebug() << "\tcurrent superpage=: " << currentSuperPage(); qDebug() << "\tsuperpage count=: " << m_superPages.count(); - foreach(GVA::GWebPage *page, m_superPages) { + foreach(GVA::GSuperWebPage *page, m_superPages) { page->dump(); } qDebug() << "GWebContentView::dump: finished"; @@ -735,7 +861,6 @@ void GWebContentView::pageCreated(WRT::WrtBrowserContainer* newPage) { - qDebug() << "GWebContentView::pageCreated"; /* save the page snapshot before changing the current page to the new page*/ WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage(); if (currPage) { @@ -747,44 +872,82 @@ // zoom actions. Set the user-scalable to false and also init the other zoom params // so that even if we change to windows view again without loading a page we are safe. // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked +#ifndef BEDROCK_TILED_BACKING_STORE newPage->setPageZoomMetaData(webWidget()->defaultZoomData()); - +#else + newPage->setPageZoomMetaData(m_widget->defaultZoomData()); +#endif /* Set the new page as the current page */ WebPageController::getSingleton()->setCurrentPage(newPage); /* Set the web widget- this one is responsible for webnavigation etc */ newPage->setWebWidget(webWidget()); +#ifndef BEDROCK_TILED_BACKING_STORE //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize())); +#endif } void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg) { +#ifdef BEDROCK_TILED_BACKING_STORE + QGraphicsWebView* w = webWidget(); +#else GWebContentViewWidget* w = webWidget(); +#endif + +#ifndef BEDROCK_TILED_BACKING_STORE w->setPage(pg); +#else + m_widget->setPage(pg); +#endif if (pg) { pg->setWebWidget(w); +#ifndef BEDROCK_TILED_BACKING_STORE // Change navigation also to the current page m_touchNavigation->setPage(pg); m_touchNavigation->setWantSlideViewCalls(true); +#endif } } void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) { - qDebug() << "GWebContentView::pageChanged"; Q_UNUSED(oldPage) updateWebPage(newPage); +#ifndef BEDROCK_TILED_BACKING_STORE // Set new page zoom info changeContentViewZoomInfo(newPage); +#endif } +#ifdef BEDROCK_TILED_BACKING_STORE + void GWebContentView::handleContextEventObject(QWebHitTestResult* eventTarget) + { + WebViewEventContext context(type(), *eventTarget); + if (currentPageIsSuperPage()) { + // Let the superpage handle the event. + currentSuperPage()->onContextEvent(&context); + } + else { + // Send the event directly. + emit contextEvent(&context); + } + } +void GWebContentView::handleViewScrolled(QPoint& scrollPos, QPoint& delta) +{ + if (delta.manhattanLength() && scrollPos.y() <= 5 && !currentPageIsSuperPage()) + m_chrome->layout()->slideView(-delta.y()); +} + +#endif void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){ // Copy the new page zoom info into cv +#ifndef BEDROCK_TILED_BACKING_STORE webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData()); if (webWidget()->isUserScalable()) { @@ -797,6 +960,9 @@ // that we might have been on another page earlier webWidget()->setPageZoomFactor(newPage->mainFrame()->zoomFactor()); } +#else + m_widget->setCurrentPageInfo(newPage->pageZoomMetaData()); +#endif } void GWebContentView::setJSObject(const QString &objectName) { @@ -809,7 +975,6 @@ } void GWebContentView::setEnabled(bool value) { - qDebug() << "GWebContentView::setEnabled: " << value; if(m_enabled == value) return; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GWebContentView.h --- a/ginebra2/ContentViews/GWebContentView.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GWebContentView.h Tue Jul 06 14:03:49 2010 +0300 @@ -30,7 +30,7 @@ #include "controllableviewimpl.h" #include "messageboxproxy.h" #include "ZoomMetaData.h" -#include "GWebPage.h" +#include "GSuperWebPage.h" #include "ContentViewDelegate.h" #include "GContentViewTouchNavigation.h" @@ -40,6 +40,7 @@ class QWebFrame; class QTimeLine; class GWebContentViewWidget; + namespace WRT { class WrtBrowserContainer; } @@ -50,6 +51,9 @@ class WebPageWrapper; class ChromeWidget; class ContentViewDelegate; +#ifdef BEDROCK_TILED_BACKING_STORE + class WebContentViewWidget; +#endif class GWebContentView : public ControllableViewBase { @@ -63,8 +67,11 @@ // do we need both of these? QGraphicsWidget* widget() const; +#ifdef BEDROCK_TILED_BACKING_STORE + QGraphicsWebView* webWidget() const; +#else GWebContentViewWidget *webWidget() const; - +#endif // Returns the DOM 'window' object of the page. QVariant getContentWindowObject(); @@ -79,8 +86,11 @@ QUrl url(); QWebPage *currentPage(); +#ifdef BEDROCK_TILED_BACKING_STORE + qreal getZoomFactor(); +#else qreal getZoomFactor() const; - +#endif static ControllableView* createNew(QWidget *parent); /*! @@ -98,35 +108,60 @@ void deactivateZoomActions(); // Super page methods. - GWebPage * createSuperPage(const QString &name, bool persist = false); + GSuperWebPage * createSuperPage(const QString &name, bool persist = false); void destroySuperPage(const QString &name); QObjectList getSuperPages(); - void setCurrentSuperPage(const QString &name); - GWebPage * currentSuperPage() {return m_currentSuperPage.value();} + bool setCurrentSuperPage(const QString &name); + GSuperWebPage * currentSuperPage() {return m_currentSuperPage.value();} void showSuperPage(const QString &name); - GWebPage * superPage(const QString &name); + GSuperWebPage * superPage(const QString &name); bool isSuperPage(const QString &name); bool currentPageIsSuperPage() const; + void bitmapZoomStop(); virtual void show() { - qDebug() << "GWebContentView::show: " << widget(); widget()->show(); } virtual void hide() { - qDebug() << "GWebContentView::hide: " << widget(); - widget()->hide(); + widget()->hide(); } - bool gesturesEnabled() const { return m_touchNavigation->enabled(); } - void setGesturesEnabled(bool value) { m_touchNavigation->setEnabled(value); } + bool gesturesEnabled() const { +#ifndef BEDROCK_TILED_BACKING_STORE + return m_touchNavigation->enabled(); +#endif + return false; + } + + void setGesturesEnabled(bool value) { +#ifndef BEDROCK_TILED_BACKING_STORE + m_touchNavigation->setEnabled(value); +#endif + } bool enabled() const; void setEnabled(bool value); - bool frozen() const { return webWidget()->frozen(); } - void freeze() { return webWidget()->freeze(); } - void unfreeze() { return webWidget()->unfreeze(); } + + bool frozen() const { +#ifndef BEDROCK_TILED_BACKING_STORE + return webWidget()->frozen(); +#else + return false; +#endif + } + + void freeze() { +#ifndef BEDROCK_TILED_BACKING_STORE + return webWidget()->freeze(); +#endif + } + void unfreeze() { +#ifndef BEDROCK_TILED_BACKING_STORE + return webWidget()->unfreeze(); +#endif + } signals: void ContextChanged(); @@ -142,20 +177,28 @@ void forwardEnabled(bool enabled); void startingPanGesture(int); void contentViewMouseEvent(QEvent::Type type); + void superPageShown(const QString &name); +#ifdef BEDROCK_TILED_BACKING_STORE + void contextEvent(::WebViewEventContext* context); +#endif public slots: void loadUrlToCurrentPage(const QString & url); void zoomIn(qreal factor = 0.1); void zoomOut(qreal factor = 0.1); +#ifndef BEDROCK_TILED_BACKING_STORE + void zoomP(); + void zoomN(); + void zoomBy(qreal delta) { zoomIn(delta); } +#else + void setZoomActions(bool enableZoomIn, bool enableZoomOut); +#endif void setZoomFactor(qreal factor); void showMessageBox(WRT::MessageBoxProxy* data); - void zoomP(); - void zoomN(); void stop(); void back(); void forward(); void reload(); - void zoomBy(qreal delta) { zoomIn(delta); } void zoom(bool in); void toggleZoom(); void stopZoom(); @@ -182,14 +225,26 @@ // Called by the page controller when changes a page. void pageChanged(WRT::WrtBrowserContainer * , WRT::WrtBrowserContainer *); +#ifdef BEDROCK_TILED_BACKING_STORE + void handleContextEventObject(QWebHitTestResult* eventTarget); + void handleViewScrolled(QPoint& scrollPos, QPoint& delta); +#endif protected: +#ifdef BEDROCK_TILED_BACKING_STORE + QGraphicsWidget* webWidgetConst(); +#else GWebContentViewWidget *webWidgetConst() const { return m_widget; } +#endif ChromeWidget *chrome() { return m_chrome; } void updateWebPage(WRT::WrtBrowserContainer * pg); void changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage); protected: +#ifdef BEDROCK_TILED_BACKING_STORE + WebContentViewWidget* m_widget; +#else GWebContentViewWidget *m_widget; +#endif QNetworkAccessManager *m_networkMgr; //Owned ChromeWidget *m_chrome; // not owned @@ -200,13 +255,15 @@ QTimeLine * m_timeLine; bool m_zoomIn; +#ifndef BEDROCK_TILED_BACKING_STORE GContentViewTouchNavigation* m_touchNavigation; +#endif bool m_backEnabled; bool m_forwardEnabled; ChromeWidget *m_chromeWidget; // not owned WebPageWrapper* m_sharedPage; - typedef QMap PageMap; + typedef QMap PageMap; PageMap m_superPages; PageMap::iterator m_currentSuperPage; bool m_currentPageIsSuperPage; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GWebContentViewJSObject.h --- a/ginebra2/ContentViews/GWebContentViewJSObject.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GWebContentViewJSObject.h Tue Jul 06 14:03:49 2010 +0300 @@ -24,6 +24,7 @@ #include #include "controllableviewimpl.h" #include "GWebContentView.h" +#include "GSuperWebPage.h" class WebViewEventContext; @@ -51,8 +52,20 @@ /*! This property holds whether touch navigation is enabled. */ Q_PROPERTY(bool gesturesEnabled READ getGesturesEnabled WRITE setGesturesEnabled) - bool getGesturesEnabled() const { return webContentViewConst()->gesturesEnabled(); } - void setGesturesEnabled(bool value) { webContentView()->setGesturesEnabled(value); } + bool getGesturesEnabled() const + { +#ifdef BEDROCK_TILED_BACKING_STORE + return false; +#else + return webContentViewConst()->gesturesEnabled(); +#endif + } + void setGesturesEnabled(bool value) + { +#ifndef BEDROCK_TILED_BACKING_STORE + webContentView()->setGesturesEnabled(value); +#endif + } Q_PROPERTY(bool enabled WRITE setEnabled READ enabled) bool enabled() const { return webContentViewConst()->enabled(); } @@ -65,9 +78,11 @@ void back() { webContentView()->back(); } void forward() { webContentView()->forward(); } void reload() { webContentView()->reload(); } +#ifndef BEDROCK_TILED_BACKING_STORE void zoomIn(qreal deltaPercent = 0.1) { webContentView()->zoomIn(deltaPercent); } void zoomOut(qreal deltaPercent = 0.1) { webContentView()->zoomOut(deltaPercent); } void zoomBy(qreal delta) { zoomIn(delta); } +#endif void zoom(bool in) { webContentView()->zoom(in); } void toggleZoom() { webContentView()->toggleZoom(); } void stopZoom() { webContentView()->stopZoom(); } @@ -81,7 +96,7 @@ bool currentPageIsSuperPage() { return webContentView()->currentPageIsSuperPage(); } void dump() { return webContentView()->dump(); } bool frozen() const { return webContentViewConst()->frozen(); } - void freeze() { qDebug() << "FREEZE"; return webContentView()->freeze(); } + void freeze() { return webContentView()->freeze(); } void unfreeze() { return webContentView()->unfreeze(); } // Super page slots. @@ -94,6 +109,15 @@ QObject * superPage(const QString &name) { return webContentView()->superPage(name); } bool isSuperPage(const QString &name) { return webContentView()->isSuperPage(name); } + bool bedrockTiledBackingStoreEnabled() + { +#ifdef BEDROCK_TILED_BACKING_STORE + return true; +#else + return false; +#endif + } + signals: void ContextChanged(); void iconChanged(); @@ -113,6 +137,8 @@ void onDisplayModeChanged(const QString &orientation); void contextEvent(QObject *context); + void superPageShown(const QString &name); + private slots: void statusBarMessage( const QString & text ); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GWebContentViewWidget.cpp --- a/ginebra2/ContentViews/GWebContentViewWidget.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GWebContentViewWidget.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -77,8 +77,7 @@ , m_bitmapImage(NULL) , m_checkeredBoxPixmap(NULL) { - qDebug() << "GWebContentViewWidget::GWebContentViewWidget: page=" << pg; - setParent(parent); + setParent(parent); if ( pg ) { setPage(pg); } @@ -87,7 +86,7 @@ #endif //ENABLE_PERF_TRACE m_currentinitialScale = zoomFactor(); - //connect(this->page()->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(onInitLayout())); + #ifndef NO_QSTM_GESTURE m_touchNavigation = new WebTouchNavigation(this); #endif @@ -121,8 +120,6 @@ { delete m_checkeredBoxPixmap; m_checkeredBoxPixmap = NULL; - int checkerPixmapSizeX = size().toSize().width(); - int checkerPixmapSizeY = size().toSize().height() + 50; m_checkeredBoxPixmap = new QPixmap(checkerSize, checkerSize); QPainter painter(m_checkeredBoxPixmap); painter.fillRect(0, 0, checkerSize, checkerSize, QColor(checkerColor1)); @@ -152,22 +149,24 @@ } void GWebContentViewWidget::updateFrozenImage() { - // Take a snapshot for to be displayed while in frozen state. - QStyleOptionGraphicsItem opt; - opt.levelOfDetail = 1.0; - opt.exposedRect = QRectF(QPointF(0,0), size()); + // Take a snapshot to be displayed while in frozen state. + + QStyleOptionGraphicsItem option; + option.levelOfDetail = 1.0; + option.exposedRect = QRectF(QPointF(0,0), size()); - m_frozenPixmap = new QPixmap(opt.exposedRect.size().toSize()); - QPainter painter(m_frozenPixmap); - paint(&painter, &opt); + // Discard existing pixmap. + delete m_frozenPixmap; + m_frozenPixmap = 0; - if(!isEnabled()) { - // Disabled, apply whitewash. + // Paint the window into a new pixmap (m_frozenPixmap must be 0 here for this to work). + QPixmap *frozenPixmap = new QPixmap(option.exposedRect.size().toSize()); + QPainter painter(frozenPixmap); + paint(&painter, &option); + painter.end(); - painter.setOpacity(ChromeEffect::disabledOpacity); - painter.fillRect(opt.exposedRect, ChromeEffect::disabledColor); - } - painter.end(); + // Now point m_frozenPixmap at the new pixmap. + m_frozenPixmap = frozenPixmap; } QImage GWebContentViewWidget::getPageSnapshot() @@ -201,6 +200,11 @@ //if there is change in mode (like landscape, potraite relayout the content) if (e->newSize().width() == e->oldSize().width()) return; + + //if page is empty do not update + if (page()->currentFrame()->url().isEmpty()) + return; + m_isResize = true; setViewportSize(); m_isResize = false; @@ -226,7 +230,6 @@ void GWebContentViewWidget::resizeEvent(QGraphicsSceneResizeEvent* e) { - // set the fixed text layout size for text wrapping #if defined CWRTINTERNALWEBKIT if (page()) { @@ -257,19 +260,23 @@ updateViewportSize(e); - if(frozen()) + if(frozen()) { updateFrozenImage(); +// if(m_frozenPixmap && (m_frozenPixmap->size() != this->size())) { +// QTimer::singleShot(50, this, SLOT(updateFrozenImage())); +// } + } } -void GWebContentViewWidget::contextMenuEvent(::QGraphicsSceneContextMenuEvent *event) { - QWebHitTestResult hitTest = page()->currentFrame()->hitTestContent(event->pos().toPoint()); - qDebug() << "GWebContentViewWidget::contextMenuEvent:" - << "\n\t pos=" << hitTest.pos() - << "\n\t linkUrl=" << hitTest.linkUrl() - << "\n\t imageUrl=" << hitTest.imageUrl(); +void GWebContentViewWidget::onLongPressEvent(QPoint pos) { + QWebHitTestResult hitTest = page()->currentFrame()->hitTestContent(pos); + //qDebug() << "GWebContentViewWidget::contextMenuEvent:" + // << "\n\t pos=" << hitTest.pos() + // << "\n\t linkUrl=" << hitTest.linkUrl() + // << "\n\t imageUrl=" << hitTest.imageUrl(); - WebViewEventContext *context = - new WebViewEventContext(view()->type(), hitTest); + ::WebViewEventContext *context = + new ::WebViewEventContext(view()->type(), hitTest); if (m_webContentView && m_webContentView->currentPageIsSuperPage()) { // Let the superpage handle the event. @@ -279,6 +286,10 @@ // Send the event directly. emit contextEvent(context); } +} + +void GWebContentViewWidget::contextMenuEvent(::QGraphicsSceneContextMenuEvent *event) { + // Ignore. The touch navigation code handles long presses. event->accept(); } @@ -292,7 +303,7 @@ } void GWebContentViewWidget::setPageZoomFactor(qreal zoom) -{ +{ //not zooming if it's bookmark or historyview or not a page if (!page() || (m_webContentView->type() == "webView" && @@ -500,6 +511,10 @@ } + if(!isEnabled()) { + // Disabled, apply whitewash. + ChromeEffect::paintDisabledRect(painter, option->exposedRect); + } #ifdef ENABLE_PERF_TRACE PERF_DEBUG() << "GWebContentViewWidget::paint__end: " << WrtPerfTracer::tracer()->elapsedTime(st) << "\n"; @@ -531,7 +546,6 @@ { if (m_wrtPage == pg) return; - qDebug() << "GWebContentViewWidget::setPage: " << pg; if (m_wrtPage) { disconnect(page()->mainFrame(), 0, this, 0); m_wrtPage->setView(0); @@ -586,7 +600,6 @@ //find the content size before applying zoom QSize docSizeBeforeZoom = page()->mainFrame()->contentsSize(); - qDebug()<<"setPageCenterZoomFactor() : "<mainFrame()->contentsSize(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/GWebContentViewWidget.h --- a/ginebra2/ContentViews/GWebContentViewWidget.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ContentViews/GWebContentViewWidget.h Tue Jul 06 14:03:49 2010 +0300 @@ -109,10 +109,38 @@ void setPageZoomMetaData(ZoomMetaData params); ZoomMetaData defaultZoomData(); void setCheckeredPixmap(); + + void onLoadStarted(); + void onLoadFinished(); + + /*! + * \brief Freeze the on-screen state of the window. + * Takes a snapshot of the window in its current state. The paint() method will then use + * this snapshot for all further paints, until unfreeze() is called. Freeze() increments + * a counter and unfreeze() decrements the counter so that nested calls to them are handled + * correctly. + * \sa unfreeze + */ + void freeze(); + + /*! + * \brief Unfreeze the on-screen state of the window. + * \sa freeze + */ + void unfreeze(); + + /*! + * \brief Returns true if the window is currently frozen. + * \sa freeze + * \sa unfreeze + */ + bool frozen() const { return m_frozenCount > 0; } + public slots: void setViewportSize(); void onInitLayout(); + void onLongPressEvent(QPoint pos); signals: void contextEvent(::WebViewEventContext *context); @@ -120,19 +148,17 @@ void pageZoomMetaDataChange(QWebFrame* frame, ZoomMetaData data);protected: void paintEvent(QPaintEvent *event); + void longPressEvent(::WebViewEventContext *context); -public: - void onLoadStarted(); - void onLoadFinished(); - - bool frozen() const { return m_frozenCount > 0; } - void freeze(); - void unfreeze(); +private slots: + /*! + * \brief Update the "frozen" image of this window. + */ + void updateFrozenImage(); private: void updateViewportSize(QGraphicsSceneResizeEvent *e); virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - void updateFrozenImage(); GVA::GWebContentView* m_webContentView; qreal m_dirtyZoomFactor; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ScrollableWebContentView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ScrollableWebContentView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,518 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "ScrollableWebContentView.h" + +#include "Gestures/GestureRecognizer.h" +#include "Kinetics/KineticScroller.h" +#include "ScrollableViewBase.h" +#include "ViewportMetaDataParser.h" +#include "WebContentAnimationItem.h" + +#include +#include +#include +#include +#include +#include + +//Kinetic scroll constants +static const int ScrollsPerSecond = 30; +static const int MinimumScrollVelocity = 10; +static const qreal AxisLockThreshold = .8; + + +//Zooming constants +static const int ZoomAnimationDuration = 300; //ms. Zooming transition duration +static const qreal ZoomStep = .5; //Incremental zoom step +const int TileUpdateEnableDelay = 500; //Wait duration before tiling updates are enabled. + +namespace GVA { + +ScrollableWebContentView::ScrollableWebContentView(WebContentAnimationItem* webAnimationItem, QGraphicsItem* parent) + : ScrollableViewBase(parent) + , m_gestureRecognizer(this) +{ + m_viewportMetaData = new ViewportMetaData(); + + //Kinetic scroller settings + //Sets the number of scrolls (frames) per second to sps. + m_kineticScroller->setScrollsPerSecond(ScrollsPerSecond); + //For elastic scroll in page edges + m_kineticScroller->setOvershootPolicy(KineticScroller::OvershootWhenScrollable); + + //Gesture settings + //For detecting scroll direction + m_gestureRecognizer.setAxisLockThreshold(AxisLockThreshold); + //To enable touch and drag scrolling + m_gestureRecognizer.setMinimumVelocity(MinimumScrollVelocity); + + setWidget(webAnimationItem); + //FIX ME : Revisit this code. Duplicate info sharing! + webAnimationItem->setViewportMetaData(m_viewportMetaData); + + + m_tileUpdateEnableTimer.setSingleShot(true); + connect(&m_tileUpdateEnableTimer, SIGNAL(timeout()), webAnimationItem, SLOT(enableContentUpdates())); + + //Setup zooming animator + m_zoomAnimator = new QPropertyAnimation(webAnimationItem, "geometry"); + m_zoomAnimator->setDuration(ZoomAnimationDuration); + connect(m_zoomAnimator, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), this, SLOT(zoomAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); +} + +ScrollableWebContentView::~ScrollableWebContentView() +{ + delete m_viewportMetaData; + delete m_kineticScroller; + + if(m_zoomAnimator) { + m_zoomAnimator->stop(); + delete m_zoomAnimator; + } +} + +WebContentAnimationItem* ScrollableWebContentView::viewportWidget() const +{ + return qobject_cast(scrollWidget()); +} + +void ScrollableWebContentView::zoomToScreenCenter(bool zoomIn) +{ + //If viewport metadata has user scalable false. + //Do not zoom. + if (!m_viewportMetaData->m_userScalable) + return; + + qreal scale = 1; + scale += ZoomStep; + + if (!zoomIn) + scale = 1/scale; + + qreal curScale = viewportWidget()->zoomScale(); + + if (zoomIn && (curScale * scale > m_viewportMetaData->m_maximumScale)) + scale = m_viewportMetaData->m_maximumScale / curScale; + else if (!zoomIn && (curScale * scale < m_viewportMetaData->m_minimumScale)) + scale = m_viewportMetaData->m_minimumScale / curScale; + + if(scale == 1.) + return; + + //Screen center + QPointF scrCenter(size().width()/2, size().height()/2); + //Map screen center to document + QPointF docPoint(viewportWidget()->mapFromScene(scrCenter)); + //Maintain that spot in the same point on the viewport + QPointF docPointInScr(viewportWidget()->mapToParent(docPoint)); + startZoomAnimToItemHotspot(docPoint, docPointInScr, scale); +} + +ZoomMetaData ScrollableWebContentView::currentPageInfo() +{ + ZoomMetaData data; + + data.initialScale = m_viewportMetaData->m_initialScale; + data.minScale = m_viewportMetaData->m_minimumScale; + data.maxScale = m_viewportMetaData->m_maximumScale; + data.userScalable = m_viewportMetaData->m_userScalable; + data.m_specifiedWidth = m_viewportMetaData->m_specifiedData.m_width; + data.m_specifiedHeight= m_viewportMetaData->m_specifiedData.m_height; + + data.rect = viewportWidget()->geometry(); + data.scale = viewportWidget()->zoomScale(); + data.webViewSize = viewportWidget()->webView()->geometry(); + data.viewportSize = size(); + + return data; +} + +void ScrollableWebContentView::setCurrentPageInfo(ZoomMetaData data) +{ + m_viewportMetaData->m_initialScale = data.initialScale; + m_viewportMetaData->m_minimumScale = data.minScale; + m_viewportMetaData->m_maximumScale = data.maxScale; + m_viewportMetaData->m_userScalable = data.userScalable; + m_viewportMetaData->m_specifiedData.m_width = data.m_specifiedWidth; + m_viewportMetaData->m_specifiedData.m_height = data.m_specifiedHeight; + m_viewportMetaData->m_isValid = true; + + m_viewportMetaData->m_width = data.webViewSize.width(); + m_viewportMetaData->m_height = data.webViewSize.height(); + + viewportWidget()->webView()->setGeometry(data.webViewSize); + viewportWidget()->setZoomScale(data.scale, true); + viewportWidget()->setGeometry(data.rect); + + if (data.viewportSize.width() != size().width()) + adjustViewportSize(data.viewportSize, size()); +} + +ZoomMetaData ScrollableWebContentView::defaultZoomData() +{ + ZoomMetaData data; + + data.initialScale = m_viewportMetaData->m_initialScale; + data.minScale = m_viewportMetaData->m_minimumScale; + data.maxScale = m_viewportMetaData->m_maximumScale; + data.userScalable = m_viewportMetaData->m_userScalable; + + data.scale = 1.0; + data.rect = QRectF(); + data.webViewSize = QRectF(); + data.viewportSize = QSizeF(); + + return data; +} + +void ScrollableWebContentView::updatePreferredContentSize() +{ + viewportWidget()->updatePreferredContentSize(QSize(m_viewportMetaData->m_width + , m_viewportMetaData->m_height)); +} + +void ScrollableWebContentView::setSuperPage() +{ + m_viewportMetaData->m_initialScale = 1.; + m_viewportMetaData->m_minimumScale = 1.; + m_viewportMetaData->m_maximumScale = 1.; + m_viewportMetaData->m_specifiedData.m_width = "device-width"; + m_viewportMetaData->m_specifiedData.m_height = "device-height"; + m_viewportMetaData->m_userScalable = false; + + QSize contentSize = viewportWidget()->contentsSize(); + QRect webViewRect(0, 0, size().width(), contentSize.height()); + viewportWidget()->webView()->setGeometry(webViewRect); + viewportWidget()->setZoomScale(1., true); + viewportWidget()->setGeometry(webViewRect); + + m_viewportMetaData->m_width = size().width(); + m_viewportMetaData->m_height = size().height(); + m_viewportMetaData->m_isValid = true; + + updatePreferredContentSize(); +} + +void ScrollableWebContentView::reset() +{ + // TODO: INVESTIGATE: In the case of multiple windows loading pages simultaneously, it is possible + // to be calling this slot on a signal from a frame that is not + // the frame of the page saved here. It might be better to use 'sender' instead of + // page->mainFrame() to get the metaData so that we use the meta data of the corresponding + // frame + + QWebPage* page = viewportWidget()->webView()->page(); + if (!page) + return; + + //Initialize viewport metadata + m_viewportMetaData->reset(); + + QWebFrame* frame = page->mainFrame(); + QMap metaData = frame->metaData(); + QString viewportTag = metaData.value("viewport"); + + QRect clientRect = geometry().toAlignedRect(); + ViewportMetaDataParser parser(clientRect); + *m_viewportMetaData = parser.parse(viewportTag); + + updatePreferredContentSize(); + setViewportWidgetGeometry(QRectF(QPointF(), + QSize(m_viewportMetaData->m_width, m_viewportMetaData->m_height) + * m_viewportMetaData->m_initialScale)); +} + +void ScrollableWebContentView::contentsSizeChanged(const QSize& newContentSize) +{ + QRect clientRect = geometry().toAlignedRect(); + m_viewportMetaData->updateViewportData(newContentSize, clientRect); + viewportWidget()->resize(QSize(m_viewportMetaData->m_width, m_viewportMetaData->m_height) + * m_viewportMetaData->m_initialScale); +} + +void ScrollableWebContentView::pageLoadFinished(bool ok) +{ + Q_UNUSED(ok); + QSize contentSize = viewportWidget()->contentsSize(); + QRect clientRect = geometry().toAlignedRect(); + m_viewportMetaData->updateViewportData(contentSize, clientRect); + + viewportWidget()->resize(QSize(m_viewportMetaData->m_width, m_viewportMetaData->m_height) + * m_viewportMetaData->m_initialScale); + viewportWidget()->setZoomScale(m_viewportMetaData->m_initialScale, true); +} + +bool ScrollableWebContentView::sceneEventFilter(QGraphicsItem* item, QEvent* event) +{ + Q_UNUSED(item); + + bool handled = false; + if (!isVisible()) + return handled; + + //Pass all events to recognizer + handled = m_gestureRecognizer.mouseEventFilter(static_cast(event)); + return handled; +} + +void ScrollableWebContentView::handleGesture(GestureEvent* gestureEvent) +{ + switch (gestureEvent->type()) { + case GestureEvent::Touch: + handlePress(gestureEvent); + break; + case GestureEvent::Release: + handleRelease(gestureEvent); + break; + case GestureEvent::Pan: + handlePan(gestureEvent); + break; + case GestureEvent::Flick: + handleFlick(gestureEvent); + break; + case GestureEvent::DoubleTap: + handleDoubleTap(gestureEvent); + break; + case GestureEvent::LongTap: + handleLongTap(gestureEvent); + break; + default: + break; + } + +} + +void ScrollableWebContentView::handlePress(GestureEvent* gestureEvent) +{ + m_kineticScroller->stop(); + QPointF pos = gestureEvent->position(); + sendEventToWebKit(QEvent::GraphicsSceneMousePress, pos); +} + +void ScrollableWebContentView::handleRelease(GestureEvent* gestureEvent) +{ + //Cache release event to send on release + QPointF pos = gestureEvent->position(); + sendEventToWebKit(QEvent::GraphicsSceneMouseRelease, pos); +} + +void ScrollableWebContentView::handleDoubleTap(GestureEvent* gestureEvent) +{ + if (!m_viewportMetaData->m_userScalable) + return; + + QRectF target; + WebContentAnimationItem* webViewProxy = viewportWidget(); + + // Contentview center is the focus hotspot + QPointF viewTargetHotspot(size().width() / 2, size().height() / 2); + + //Get the focussable element rect from current touch position + QPointF touchPoint = webViewProxy->mapFromScene(gestureEvent->position()); + QRectF zoomRect = webViewProxy->findZoomableRectForPoint(touchPoint); + + if (!zoomRect.isValid()) { + //FIX ME: Add an event ignore animation + return; + } + + // target is the center of the identified rect x-wise + // y-wise it's the place user touched + QPointF hotspot(zoomRect.center().x(), touchPoint.y()); + qreal scale = size().width() / zoomRect.size().width(); + startZoomAnimToItemHotspot(hotspot, viewTargetHotspot, scale, zoomRect); +} + +void ScrollableWebContentView::handlePan(GestureEvent* gestureEvent) +{ + QPoint scrollPos = ScrollableViewBase::scrollPosition(); + m_kineticScroller->doPan(gestureEvent->delta()); + QPoint delta; + delta.setX(-gestureEvent->delta().x()); + delta.setY(-gestureEvent->delta().y()); + emit viewScrolled(scrollPos, delta); +} + +void ScrollableWebContentView::handleFlick(GestureEvent* gestureEvent) +{ + QPoint scrollPos = ScrollableViewBase::scrollPosition(); + m_kineticScroller->doFlick(gestureEvent->velocity()); +} + +void ScrollableWebContentView::handleLongTap(GestureEvent* gestureEvent) +{ + QWebPage* page = viewportWidget()->webView()->page(); + QPointF contextPt = viewportWidget()->webView()->mapFromScene(gestureEvent->position()); + QWebHitTestResult result = page->currentFrame()->hitTestContent(contextPt.toPoint()); + + //Notify context menu observers + emit contextEventObject(&result); +} + +void ScrollableWebContentView::setViewportWidgetGeometry(const QRectF& r) +{ + ScrollableViewBase::setScrollWidgetGeometry(r); +} + +void ScrollableWebContentView::startZoomAnimToItemHotspot(const QPointF& hotspot, const QPointF& viewTargetHotspot, qreal scale, QRectF target) +{ + WebContentAnimationItem* animWidget = viewportWidget(); + + QPointF newHotspot = hotspot * scale; + QPointF newViewportOrigon = newHotspot - viewTargetHotspot; + QRectF zoomedRect(-newViewportOrigon, animWidget->size() * scale); + + QRectF temp = adjustScrollWidgetRect(zoomedRect); + qreal diff = qAbs(scrollWidget()->geometry().y() - temp.y()); + + //FIX ME : Seperate the logic for centerzoom and block-focus zoom + if (qFuzzyCompare(scrollWidget()->geometry().topLeft().x(), temp.topLeft().x()) + && qFuzzyCompare(scrollWidget()->geometry().width(), temp.width()) + && qFuzzyCompare(scrollWidget()->geometry().height(), temp.height()) + && !target.isEmpty() && (diff <= target.height())) { + + scale = size().width() / animWidget->size().width(); + newHotspot = QPointF(0, -animWidget->pos().y()) * scale; + newViewportOrigon = newHotspot - viewTargetHotspot; + zoomedRect = QRectF(-newViewportOrigon, animWidget->size() * scale); + } + + startZoomAnimation(zoomedRect); +} + +bool ScrollableWebContentView::isZoomedIn() const +{ + return size().width() < viewportWidget()->size().width(); +} + +void ScrollableWebContentView::stateChanged(KineticScrollable::State oldState + , KineticScrollable::State newState) +{ + ScrollableViewBase::stateChanged(oldState, newState); + + if (newState == KineticScrollable::Pushing) { + m_tileUpdateEnableTimer.stop(); + viewportWidget()->disableContentUpdates(); + } + else if (newState == KineticScrollable::AutoScrolling) { + m_tileUpdateEnableTimer.stop(); + viewportWidget()->disableContentUpdates(); + } + else if (newState == KineticScrollable::Inactive) { + m_tileUpdateEnableTimer.start(TileUpdateEnableDelay); + } +} + +void ScrollableWebContentView::startZoomAnimation(const QRectF& destRect) +{ + QAbstractAnimation::State animState = m_zoomAnimator->state(); + if (animState == QAbstractAnimation::Running) + return; + + m_zoomAnimator->setStartValue(scrollWidget()->geometry()); + m_animationEndRect = adjustScrollWidgetRect(destRect); + m_zoomAnimator->setEndValue(m_animationEndRect); + m_zoomAnimator->start(); +} + +void ScrollableWebContentView::stopZoomAnimation() +{ + m_animationEndRect = QRectF(); + m_zoomAnimator->stop(); +} + +void ScrollableWebContentView::updateZoomEndRect() +{ + if (m_animationEndRect.isValid()) + scrollWidget()->setGeometry(m_animationEndRect); +} + +void ScrollableWebContentView::zoomAnimationStateChanged(QAbstractAnimation::State newState,QAbstractAnimation::State) +{ + switch (newState) { + case QAbstractAnimation::Stopped: + updateZoomEndRect(); + break; + default: + break; + } +} + +void ScrollableWebContentView::resizeEvent(QGraphicsSceneResizeEvent* event) +{ + QGraphicsWidget::resizeEvent(event); + + //Ignore resize when chrome is being still setup + if (!event->oldSize().width()) + return; + + adjustViewportSize(event->oldSize(), event->newSize()); +} + +void ScrollableWebContentView::adjustViewportSize(QSizeF oldSize, QSizeF newSize) +{ + //FIX ME : Check this + if (m_viewportMetaData->m_isValid) { + + QRect clientRect = geometry().toAlignedRect(); + if (m_viewportMetaData->isLayoutNeeded()) { + m_viewportMetaData->orientationChanged(clientRect); + updatePreferredContentSize(); + return; + } else + m_viewportMetaData->updateViewportData(viewportWidget()->contentsSize(), clientRect); + } + + qreal scale = newSize.width() / oldSize.width(); + QPointF middleLeft(0, oldSize.height()/2); + QPointF docPoint(viewportWidget()->mapFromScene(middleLeft)); + + QPointF resizedMiddleLeft(0, newSize.height()/2); + QPointF resizedDocPoint(viewportWidget()->mapFromScene(resizedMiddleLeft)); + QPointF docPointInScr(viewportWidget()->mapToParent(resizedDocPoint)); + + //FIX ME : Should be handled with only following function call + //Since its not working, work-around is added. Plz fix it + //startZoomAnimToItemHotspot(docPoint, docPointInScr, scale); + + QPointF newHotspot = docPoint * scale; + QPointF newViewportOrigon = newHotspot - docPointInScr; + QRectF zoomedRect(-newViewportOrigon, viewportWidget()->size() * scale); + QRectF adjustRect = adjustScrollWidgetRect(zoomedRect); + + setScrollWidgetGeometry(zoomedRect); +} + +void ScrollableWebContentView::sendEventToWebKit(QEvent::Type type, QPointF& scenPos) +{ + //Setup event and send it to webkit + QGraphicsSceneMouseEvent event(type); + event.setScenePos(scenPos); + event.setPos(viewportWidget()->webView()->mapFromScene(event.scenePos())); + event.setButton(Qt::LeftButton); + event.setButtons(Qt::LeftButton); + event.setModifiers(Qt::NoModifier); + + viewportWidget()->webView()->page()->event(&event); +} + +} //namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ScrollableWebContentView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ScrollableWebContentView.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef ScrollableWebContentView_h +#define ScrollableWebContentView_h + +#include "Gestures/GestureEvent.h" +#include "Gestures/GestureListener.h" +#include "Gestures/GestureRecognizer.h" +#include "ScrollableViewBase.h" +#include "ZoomMetaData.h" + +#include +#include + +class QWebHitTestResult; + +namespace GVA { + +class ViewportMetaData; +class WebContentAnimationItem; + +class ScrollableWebContentView : public ScrollableViewBase, protected GestureListener { + Q_OBJECT +public: + ScrollableWebContentView(WebContentAnimationItem* viewportProxyWidget, QGraphicsItem* parent = 0); + ~ScrollableWebContentView(); + + WebContentAnimationItem* viewportWidget() const; + void zoomToScreenCenter(bool zoomIn); + + ZoomMetaData currentPageInfo(); + void setCurrentPageInfo(ZoomMetaData data); + ZoomMetaData defaultZoomData(); + void updatePreferredContentSize(); + void setSuperPage(); + +Q_SIGNALS: + void contextEventObject(QWebHitTestResult* eventTarget); + void viewScrolled(QPoint& scrollPos, QPoint& delta); + +public Q_SLOTS: + void reset(); + void contentsSizeChanged(const QSize&); + void pageLoadFinished(bool); + +protected: + bool sceneEventFilter(QGraphicsItem*, QEvent*); + + //From GestureListener + void handleGesture(GestureEvent*); + + //Helpers + void handlePress(GestureEvent*); + void handleRelease(GestureEvent*); + void handleFlick(GestureEvent*); + void handleDoubleTap(GestureEvent*); + void handlePan(GestureEvent*); + void handleLongTap(GestureEvent*); + + void setViewportWidgetGeometry(const QRectF& r); + void startZoomAnimToItemHotspot(const QPointF& hotspot, const QPointF& viewTargetHotspot, qreal scale, QRectF target = QRectF()); + bool isZoomedIn() const; + + //To handle kinetic scroller state changes + void stateChanged(KineticScrollable::State oldState, KineticScrollable::State newState); + + void startZoomAnimation(const QRectF& zoomedRect); + void stopZoomAnimation(); + void updateZoomEndRect(); + void resizeEvent(QGraphicsSceneResizeEvent* event); + void adjustViewportSize(QSizeF oldSize, QSizeF newSize); + void sendEventToWebKit(QEvent::Type type, QPointF& scenPos); + +protected Q_SLOTS: + void zoomAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State); + +private: + GestureRecognizer m_gestureRecognizer; + QRectF m_animationEndRect; + QPropertyAnimation* m_zoomAnimator; //Animates zooming transitions + ViewportMetaData* m_viewportMetaData; + QTimer m_tileUpdateEnableTimer; +}; //ScrollableWebContentView + +} //namespace GVA + +#endif //ScrollableWebContentView_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/SuperPageView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/SuperPageView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,60 @@ +/* + * SuperPageView.cpp + * + * Created on: Jun 11, 2010 + * Author: lewontin + */ + +#include "SuperPageView.h" +#include "GWebContentView.h" + +namespace GVA { + +SuperPageView::SuperPageView(GWebContentView * contentView, QObject * parent, const QString &objectName) +: ControllableViewBase(parent), + m_contentView(contentView) +{ + setObjectName(objectName); +} + +SuperPageView::~SuperPageView(){ + +} + +QGraphicsWidget* SuperPageView::widget() const +{ + //SuperPageView's widget is the content view widget + return m_contentView->widget(); +} + +void SuperPageView::show(){ + //Ask the content view to show the super page + m_contentView->showSuperPage(objectName()); + ControllableViewBase::activate(); +} + +QList SuperPageView::getContext() { + return m_actions.values(); +} + +//Creates an action, visible to JavaScript as name. If the script parameter is supplied, the +//the action will invoke the supplied script in the context of the super page main frame +//(not in the context of the caller). + +void SuperPageView::addAction(const QString & name, const QString & script){ + QAction* action; + action = m_actions[name] = new QAction(name, this); + action->setObjectName(name); + if(!script.isNull()){ + action->setData(script); + connect(action, SIGNAL(triggered()), this, SLOT(invokeScriptAction())); + } +} + +void SuperPageView::invokeScriptAction() { + QAction * action = static_cast(sender()); + QString script = action->data().toString(); + m_contentView->webWidget()->page()->mainFrame()->evaluateJavaScript(script); +} + +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/SuperPageView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/SuperPageView.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,40 @@ +/* + * SuperPageView.h + * + * Created on: Jun 11, 2010 + * Author: lewontin + */ + +#include "controllableviewimpl.h" + +#ifndef SUPERPAGEVIEW_H_ +#define SUPERPAGEVIEW_H_ + +namespace GVA { + +class GWebContentView; + +class SuperPageView : public ControllableViewBase +{ + Q_OBJECT + + public: + SuperPageView(GWebContentView * contentView, QObject * parent = 0, const QString &objectName = QString::null); + virtual ~SuperPageView(); + //Reimplement ControllableViewBase methods + static QString Type() { return "superPage"; } + virtual QString type() const { return Type(); } + QGraphicsWidget* widget() const; + virtual QList getContext(); + virtual void show(); + virtual void hide() {;} + public slots: + void addAction(const QString& action, const QString & script = QString()); + private slots: + void invokeScriptAction(); + private: + GWebContentView * m_contentView; + QMap m_actions; +}; +} +#endif /* SUPERPAGEVIEW_H_ */ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ViewportMetaData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ViewportMetaData.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,223 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "ViewportMetaData.h" + +static const int DefaultViewportWidth = 640; +static const int DefaultViewportHeight = 640; +static const int MinViewportWidth = 200; +static const int MaxViewportWidth = 10000; +static const int MinViewportHeight = 200; +static const int MaxViewportHeight = 10000; +static const qreal DefaultMinScale = 0.2; +static const qreal DefaultMaxScale = 5.; + +namespace GVA { + +ViewportMetaData::ViewportMetaData() +{ + initialize(); +} + +ViewportMetaData::ViewportMetaData(const ViewportMetaData& other) +{ + m_initialScale = other.m_initialScale; + m_minimumScale = other.m_minimumScale; + m_maximumScale = other.m_maximumScale; + m_width = other.m_width; + m_height = other.m_height; + m_userScalable = other.m_userScalable; + m_isValid = other.m_isValid; + m_scaleLimits = other.m_scaleLimits; + m_specifiedData.m_width = other.m_specifiedData.m_width; + m_specifiedData.m_height = other.m_specifiedData.m_height; + m_specifiedData.m_minScale = other.m_specifiedData.m_minScale; +} + +ViewportMetaData& ViewportMetaData::operator=(const ViewportMetaData& other) +{ + m_initialScale = other.m_initialScale; + m_minimumScale = other.m_minimumScale; + m_maximumScale = other.m_maximumScale; + m_width = other.m_width; + m_height = other.m_height; + m_userScalable = other.m_userScalable; + m_isValid = other.m_isValid; + m_scaleLimits = other.m_scaleLimits; + m_specifiedData.m_width = other.m_specifiedData.m_width; + m_specifiedData.m_height = other.m_specifiedData.m_height; + m_specifiedData.m_minScale = other.m_specifiedData.m_minScale; + + return *this; +} + +ViewportMetaData::~ViewportMetaData() +{} + +void ViewportMetaData::adjustViewportData(const QRect& clientRect) +{ + //Data updated from viewport tag + m_isValid = true; + + //Adjust viewport dimensions + m_width = qBound(MinViewportWidth, m_width, MaxViewportWidth); + m_height = qBound(MinViewportHeight, m_height, MaxViewportHeight); + + //Aspect ratio + qreal aspectRation = (qreal)clientRect.width() / clientRect.height(); + + if (m_width != DefaultViewportWidth && m_height == DefaultViewportHeight) { + //Width has been specified. Adjust height, min scale and max scale + m_height = m_width * (1 / aspectRation); + } else if (m_width == DefaultViewportWidth && m_height != DefaultViewportHeight) { + //Height has been specified. Adjust width, min scale and max scale + m_width = m_height * aspectRation; + } else { + //Putting below code under seperate 'else' to make it readable! + m_height = m_width * (1 / aspectRation); + } + + //Adjust zoom limits + adjustZoomValues(clientRect); +} + +void ViewportMetaData::updateViewportData(const QSize& newContentSize, const QRect& clientRect) +{ + //If still viewport tag has not been parsed + //Do not update values. + if(!m_isValid) + return; + + //Update with viewport dimensions + m_width = qBound(MinViewportWidth, newContentSize.width(), MaxViewportWidth); + m_height = qBound(MinViewportHeight, newContentSize.height(), MaxViewportHeight); + + //Adjust zoom limits + adjustZoomValues(clientRect); +} + +void ViewportMetaData::orientationChanged(const QRect& newClientRect) +{ + //If still viewport tag has not been parsed + //Do not update values. + if(!m_isValid) + return; + + //Aspect ratio + qreal aspectRation = (qreal)newClientRect.width() / newClientRect.height(); + + //Update with viewport dimensions + if (m_specifiedData.m_width.length()) { + if (QString::compare(m_specifiedData.m_width, "device-width", Qt::CaseInsensitive) == 0) + m_width = newClientRect.width(); + else if(QString::compare(m_specifiedData.m_width, "device-height", Qt::CaseInsensitive) == 0) + m_width = newClientRect.height(); + + m_height = m_width * (1 / aspectRation); + } + + //Check if width has not bee specified. + if (!m_specifiedData.m_width.length()) { + if (QString::compare(m_specifiedData.m_height, "device-width", Qt::CaseInsensitive) == 0) + m_height = newClientRect.width(); + else if(QString::compare(m_specifiedData.m_height, "device-height", Qt::CaseInsensitive) == 0) + m_height = newClientRect.height(); + + m_width = m_height * aspectRation; + } + + //Update with bounds + m_width = qBound(MinViewportWidth, m_width, MaxViewportWidth); + m_height = qBound(MinViewportHeight, m_height, MaxViewportHeight); +} + +bool ViewportMetaData::isLayoutNeeded() +{ + if (!isUserSpecifiedWidth() || !isUserSpecifiedHeight()) + return true; + return false; +} +void ViewportMetaData::initialize() +{ + m_initialScale = ValueUndefined; + m_minimumScale = DefaultMinScale; + m_maximumScale = DefaultMaxScale; + m_width = DefaultViewportWidth; + m_height = DefaultViewportHeight; + m_userScalable = true; + m_isValid = false; + + //Clear user defined scales + setFlag(UserDefinedMinumumScale, false); + setFlag(UserDefinedMaximumScale, false); + setFlag(UserDefinedInitialScale, false); +} + +void ViewportMetaData::adjustZoomValues(const QRect& clientRect) +{ + qreal fitToWidthZoom = (qreal)clientRect.width() / m_width; + fitToWidthZoom = qBound(DefaultMinScale, fitToWidthZoom, DefaultMaxScale); + + m_maximumScale = qBound(fitToWidthZoom, m_maximumScale, DefaultMaxScale); + + //Adjust minimum-sclae + if (getFlag(UserDefinedMinumumScale)) { + m_minimumScale = m_specifiedData.m_minScale; + m_minimumScale = qBound(fitToWidthZoom, m_minimumScale, m_maximumScale); + } + else + m_minimumScale = fitToWidthZoom; + + //Adjust initial-scale + if (getFlag(UserDefinedInitialScale)) + m_initialScale = qBound(m_minimumScale, m_initialScale, m_maximumScale); + else + m_initialScale = m_minimumScale; + + //Turn off zooming if min and max zoom are same + if (m_minimumScale == m_maximumScale) + m_userScalable = false; +} + + +//FIX ME : Merge below functions to single. Now in Hurry!! +bool ViewportMetaData::isUserSpecifiedWidth() +{ + if (m_specifiedData.m_width.length()) { + if (!QString::compare(m_specifiedData.m_width, "device-width", Qt::CaseInsensitive) + || !QString::compare(m_specifiedData.m_width, "device-height", Qt::CaseInsensitive)) + return false; + } + return true; +} + +bool ViewportMetaData::isUserSpecifiedHeight() +{ + if (m_specifiedData.m_height.length()) { + if (!QString::compare(m_specifiedData.m_height, "device-width", Qt::CaseInsensitive) + || !QString::compare(m_specifiedData.m_height, "device-height", Qt::CaseInsensitive)) + return false; + } + return true; +} + +}//namespace GVA + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ViewportMetaData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ViewportMetaData.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef ViewportMetaData_h +#define ViewportMetaData_h + +#include +#include +#include + +namespace GVA { + +struct ParsedViewportData{ + QString m_width; + QString m_height; + qreal m_minScale; +}; + +class ViewportMetaData { +public: + enum { + ValueUndefined = -1 + }; + + enum ScaleLimit { + UserDefinedMinumumScale = 0x1, + UserDefinedMaximumScale = 0x2, + UserDefinedInitialScale = 0x4, + }; + Q_DECLARE_FLAGS(ScaleLimits, ScaleLimit) + + ViewportMetaData(); + ViewportMetaData(const ViewportMetaData&); + ViewportMetaData& operator=(const ViewportMetaData&); + ~ViewportMetaData(); + + void adjustViewportData(const QRect& clientRect); + void updateViewportData(const QSize& size, const QRect& clientRect); + void orientationChanged(const QRect& newClientRect); + bool isLayoutNeeded(); + void reset() {initialize();} + + void setFlag(ScaleLimit scaleLimit, bool enable) + { + if (enable) + m_scaleLimits |= scaleLimit; + else + m_scaleLimits &= !scaleLimit; + } + + bool getFlag(ScaleLimit scaleLimit) + { + return m_scaleLimits.testFlag(scaleLimit); + } + +protected: + void initialize(); + void adjustZoomValues(const QRect& clientRect); + bool isUserSpecifiedWidth(); + bool isUserSpecifiedHeight(); + +public: + qreal m_initialScale; + qreal m_minimumScale; + qreal m_maximumScale; + int m_width; + int m_height; + bool m_userScalable; + ScaleLimits m_scaleLimits; + bool m_isValid; + ParsedViewportData m_specifiedData; +};//ViewportMetaData + +Q_DECLARE_OPERATORS_FOR_FLAGS(ViewportMetaData::ScaleLimits) + +} //namespace GVA + +#endif //ViewportMetaData_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ViewportMetaDataParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ViewportMetaDataParser.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "ViewportMetaDataParser.h" + +namespace GVA { + +ViewportMetaDataParser::ViewportMetaDataParser(const QRect& clientRect) + : m_clientRect(clientRect) +{} + +ViewportMetaDataParser::~ViewportMetaDataParser() +{} + +ViewportMetaData ViewportMetaDataParser::parse(const QString& viewportParams) +{ + ViewportMetaData viewportMetaData = processArguments(viewportParams); + viewportMetaData.adjustViewportData(m_clientRect); + return viewportMetaData; +} + + +//W A R N I N G +//FOLLOWING CODE HAS BEEN TAKEN FROM WebCore/dom/Document.cpp +//NEED TO REMOVE WHEN QtWebkit provides viewport param API + +// Though isspace() considers \t and \v to be whitespace, Win IE doesn't. +bool ViewportMetaDataParser::isSeparator(QChar c) +{ + return c == ' ' + || c == '\t' + || c == '\n' + || c == '\r' + || c == '=' + || c == ',' + || c == '\0' + || c == ';'; +} + +ViewportMetaData ViewportMetaDataParser::processArguments(const QString& features) +{ + int keyBegin, keyEnd; + int valueBegin, valueEnd; + ViewportMetaData viewportMetaData; + + int i = 0; + int length = features.length(); + QString buffer = features.toLower(); + + while (i < length) { + // skip to first non-separator, but don't skip past the end of the string + while (isSeparator(buffer[i])) { + if (i >= length) + break; + i++; + } + keyBegin = i; + + // skip to first separator + while (!isSeparator(buffer[i])) + i++; + keyEnd = i; + + // skip to first '=', but don't skip past a ',' or the end of the string + while (buffer[i] != '=') { + if (buffer[i] == ',' || i >= length) + break; + i++; + } + // skip to first non-separator, but don't skip past a ',' or the end of the string + while (isSeparator(buffer[i])) { + if (buffer[i] == ',' || i >= length) + break; + i++; + } + valueBegin = i; + + // skip to first separator + while (!isSeparator(buffer[i])) + i++; + valueEnd = i; + + Q_ASSERT(i <= length); + + QString keyString = buffer.mid(keyBegin, keyEnd - keyBegin); + QString valueString = buffer.mid(valueBegin, valueEnd - valueBegin); + setViewportFeature(keyString, valueString, viewportMetaData); + } + return viewportMetaData; +} + +void ViewportMetaDataParser::setViewportFeature(const QString& keyString, const QString& valueString, ViewportMetaData& viewportMetaData) +{ + float value = ViewportMetaData::ValueUndefined; + + if (QString::compare(valueString, "device-width", Qt::CaseInsensitive) == 0) + value = m_clientRect.width(); + else if (QString::compare(valueString, "device-height", Qt::CaseInsensitive) == 0) + value = m_clientRect.height(); + else if (QString::compare(valueString, "default", Qt::CaseInsensitive) == 0) { + // This allows us to distinguish the omission of a key from asking for the default value. + value = -2; + } + else if (valueString.length()) { + // listing a key with no value is shorthand for key=default + value = valueString.toDouble(); + } + + if (keyString == "initial-scale") { + viewportMetaData.m_initialScale = value; + viewportMetaData.setFlag(ViewportMetaData::UserDefinedInitialScale,true); + } + else if (keyString == "minimum-scale") { + viewportMetaData.m_minimumScale = value; + viewportMetaData.m_specifiedData.m_minScale = value; + viewportMetaData.setFlag(ViewportMetaData::UserDefinedMinumumScale,true); + } + else if (keyString == "maximum-scale") { + viewportMetaData.m_maximumScale = value; + viewportMetaData.setFlag(ViewportMetaData::UserDefinedMaximumScale,true); + } + else if (keyString == "user-scalable") { + if (QString::compare(valueString, "yes", Qt::CaseInsensitive) == 0) + viewportMetaData.m_userScalable = true; + else + viewportMetaData.m_userScalable = false; + } + else if (keyString == "width") { + viewportMetaData.m_width = value; + viewportMetaData.m_specifiedData.m_width = valueString; + } + else if (keyString == "height") { + viewportMetaData.m_height = value; + viewportMetaData.m_specifiedData.m_height = valueString; + } +} + +} //namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/ViewportMetaDataParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/ViewportMetaDataParser.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef ViewportMetaDataParser_h +#define ViewportMetaDataParser_h + +#include "ViewportMetaData.h" + +namespace GVA { + +class ViewportMetaDataParser : public QObject { +public: + ViewportMetaDataParser(const QRect& clientRect); + ~ViewportMetaDataParser(); + + ViewportMetaData parse(const QString&); + +private: + void adjustViewportData(ViewportMetaData& viewportMetaData); + bool isSeparator(QChar c); + ViewportMetaData processArguments(const QString& features); + void setViewportFeature(const QString& keyString, const QString& valueString, ViewportMetaData& viewportMetaData); + + QRect m_clientRect; +}; + +} //namespace GVA + +#endif //ViewportMetaDataParser_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebContentAnimationItem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebContentAnimationItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,177 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "WebContentAnimationItem.h" + +#include +#include +#include +#include + +static const int MinDoubleClickZoomTargetWidth = 100; //Target block width for applying double tap zoom +static const int ZoomCommitDuration = 50; //Timeout before commiting zoom +static const qreal ZoomableContentMinWidth = 300.; + +namespace GVA { + +WebContentAnimationItem::WebContentAnimationItem(QGraphicsWidget* parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent, wFlags) + , m_zoomCommitTimer(this) + , m_viewportMetaData(0) +{ + setFlag(QGraphicsItem::ItemHasNoContents, true); + setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); + setFlag(QGraphicsItem::ItemClipsToShape, true); + + setFiltersChildEvents(true); + + connect(&m_zoomCommitTimer, SIGNAL(timeout()), this, SLOT(commitZoom())); + m_zoomCommitTimer.setSingleShot(true); +} + +WebContentAnimationItem::~WebContentAnimationItem() +{} + +void WebContentAnimationItem::setWebView(QGraphicsWebView* webView) +{ + Q_ASSERT(m_webView); + m_webView = webView; + + //Enabling resize to contents avoids scrollbars in mainframe + m_webView->setResizesToContents(true); + m_webView->setParentItem(this); + m_webView->setAttribute(Qt::WA_OpaquePaintEvent, true); +} + +void WebContentAnimationItem::updatePreferredContentSize(const QSize& size) +{ + // FIXME: we have bug in QtWebKit API when tileCacheEnabled is true. + // this causes viewport not to reset between the page loads. + // Thus, we need to update viewport manually until we have fix for this. + + m_webView->page()->setPreferredContentsSize(size); + resize(contentsSize()); +} + +QSize WebContentAnimationItem::contentsSize() const +{ + return m_webView->page()->mainFrame()->contentsSize(); +} + +void WebContentAnimationItem::setZoomScale(qreal value, bool immediateCommit) +{ + value = qBound(m_viewportMetaData->m_minimumScale, value, m_viewportMetaData->m_maximumScale); + qreal curZoomScale = zoomScale(); + + if (qFuzzyCompare(value, curZoomScale)) { + notifyZoomActions(curZoomScale); + return; + } + + if (!immediateCommit) + disableContentUpdates(); + + m_webView->setScale(value); + + if (immediateCommit) + commitZoom(); + else + m_zoomCommitTimer.start(ZoomCommitDuration); +} + +qreal WebContentAnimationItem::zoomScale() const +{ + if (!m_webView) + return 1.; + + return m_webView->scale(); +} + +QRectF WebContentAnimationItem::findZoomableRectForPoint(const QPointF& point) +{ + QPointF zoomPoint = m_webView->mapFromParent(point); + + QWebHitTestResult hitResult = m_webView->page()->mainFrame()->hitTestContent(zoomPoint.toPoint()); + QWebElement targetElement = hitResult.enclosingBlockElement(); + + while (!targetElement.isNull() && targetElement.geometry().width() < MinDoubleClickZoomTargetWidth) + targetElement = targetElement.parent(); + + if (!targetElement.isNull()) { + QRectF elementRect = targetElement.geometry(); + qreal overMinWidth = elementRect.width() - ZoomableContentMinWidth; + if (overMinWidth < 0) + elementRect.adjust(overMinWidth / 2, 0, -overMinWidth / 2, 0); + zoomPoint.setX(elementRect.x()); + QRectF resultRect(zoomPoint, elementRect.size()); + return QRectF(m_webView->mapToParent(resultRect.topLeft()), + m_webView->mapToParent(resultRect.bottomRight())); + } + return QRectF(); +} + +void WebContentAnimationItem::disableContentUpdates() +{ + //Disable tiling updates + m_webView->setTiledBackingStoreFrozen(true); +} + +void WebContentAnimationItem::enableContentUpdates() +{ + //Enable tiling updates + m_webView->setTiledBackingStoreFrozen(false); +} + +void WebContentAnimationItem::commitZoom() +{ + m_zoomCommitTimer.stop(); + notifyZoomActions(zoomScale()); + enableContentUpdates(); +} + +void WebContentAnimationItem::resizeEvent(QGraphicsSceneResizeEvent* event) +{ + QGraphicsWidget::resizeEvent(event); + setZoomScale(size().width() / contentsSize().width()); +} + +void WebContentAnimationItem::notifyZoomActions(qreal newScale) +{ + bool enableZoomIn = false; + bool enableZoomOut = false; + + if (m_viewportMetaData->m_userScalable) { + + if (newScale > m_viewportMetaData->m_minimumScale) + enableZoomOut = true; + else + enableZoomOut = false; + + if (newScale < m_viewportMetaData->m_maximumScale) + enableZoomIn = true; + else + enableZoomIn = false; + } + + emit updateZoomActions(enableZoomIn, enableZoomOut); +} + +} //namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebContentAnimationItem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebContentAnimationItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef WebContentAnimationItem_h +#define WebContentAnimationItem_h + +#include "ViewportMetaDataParser.h" + +#include +#include + +class QGraphicsWebView; + +namespace GVA { + +class WebContentAnimationItem : public QGraphicsWidget { + Q_OBJECT + Q_PROPERTY(qreal zoomScale READ zoomScale WRITE setZoomScale) + +public: + WebContentAnimationItem(QGraphicsWidget* parent = 0, Qt::WindowFlags wFlags = 0); + ~WebContentAnimationItem(); + + void setWebView(QGraphicsWebView* webView); + QGraphicsWebView* webView() const { return m_webView; } + + void updatePreferredContentSize(const QSize& size); + QSize contentsSize() const; + + void setZoomScale(qreal, bool immediateCommit = false); + qreal zoomScale() const; + + QRectF findZoomableRectForPoint(const QPointF& point); + + void setViewportMetaData(ViewportMetaData* viewportMetaData) { m_viewportMetaData = viewportMetaData; } + +public Q_SLOTS: + void enableContentUpdates(); + void disableContentUpdates(); + void commitZoom(); + +protected: + void resizeEvent(QGraphicsSceneResizeEvent* event); + void notifyZoomActions(qreal newScale); + +Q_SIGNALS: + void updateZoomActions(bool enableZoomIn, bool enableZoomOut); + +private: + QGraphicsWebView* m_webView; + QTimer m_zoomCommitTimer; + ViewportMetaData* m_viewportMetaData; //Not owned! +}; //WebContentAnimationItem + +} //namespace GVA + +#endif //WebContentAnimationItem_h + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebContentViewWidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebContentViewWidget.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "WebContentViewWidget.h" + +#include "ScrollableWebContentView.h" +#include "WebContentAnimationItem.h" +#include "webpagecontroller.h" +#include "WebView.h" +#include "wrtbrowsercontainer.h" +#include "ZoomMetaData.h" + +#include +#include +#include + +namespace GVA { + +WebContentViewWidget::WebContentViewWidget(QObject* parent, QWebPage* page) + : m_webViewportProxy(new WebContentAnimationItem()) +{ + setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); + setParent(parent); + + m_webViewport = new ScrollableWebContentView(m_webViewportProxy, this); + + m_webView = new WebView(); + + if (page) + setPage(page); + + m_webViewportProxy->setWebView(m_webView); + updatePreferredContentSize(); + m_webViewportProxy->setPos(QPointF(0,0)); + + //FIX ME : Should we have to delete layout?? + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); + layout->setContentsMargins(0,0,0,0); + layout->setSpacing(0.); + layout->addItem(m_webViewport); + + connect(m_webViewportProxy + , SIGNAL(updateZoomActions(bool,bool)) + , this + , SIGNAL(updateZoomActions(bool,bool))); + connect(m_webViewport + , SIGNAL(contextEventObject(QWebHitTestResult*)) + , this + , SIGNAL(contextEventObject(QWebHitTestResult*))); + + connect(m_webViewport + , SIGNAL(viewScrolled(QPoint&, QPoint&)) + , this + , SIGNAL(viewScrolled(QPoint&, QPoint&))); +} + +WebContentViewWidget::~WebContentViewWidget() +{ + delete m_webView; + delete m_webViewportProxy; + delete m_webViewport; +} + +void WebContentViewWidget::resizeEvent(QGraphicsSceneResizeEvent* event) +{ + QGraphicsWidget::resizeEvent(event); + + setGeometry(QRectF(pos(), size())); + setPreferredSize(size()); +} + +QWebPage* WebContentViewWidget::page() +{ + return m_webView->page(); +} + +void WebContentViewWidget::setPage(QWebPage* page) +{ + m_webView->setPage(page); + + connect(this->page()->mainFrame(), SIGNAL(initialLayoutCompleted()), m_webViewport, SLOT(reset())); + connect(this->page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), m_webViewport, SLOT(contentsSizeChanged(const QSize&))); + connect(this->page()->mainFrame(), SIGNAL(loadFinished(bool)), m_webViewport, SLOT(pageLoadFinished(bool))); +} + +QGraphicsWebView* WebContentViewWidget::webView() +{ + return m_webView; +} + +ZoomMetaData WebContentViewWidget::currentPageInfo() +{ + return m_webViewport->currentPageInfo(); +} + +void WebContentViewWidget::setCurrentPageInfo(ZoomMetaData data) +{ + m_webViewport->setCurrentPageInfo(data); +} + +ZoomMetaData WebContentViewWidget::defaultZoomData() +{ + return m_webViewport->defaultZoomData(); +} + +void WebContentViewWidget::setPageZoom(bool zoomIn) +{ + Q_ASSERT(m_webViewport); + m_webViewport->zoomToScreenCenter(zoomIn); +} + +void WebContentViewWidget::showPage(bool isSuperPage) +{ + if (!isSuperPage) { + WRT::WrtBrowserContainer* wbc = WebPageController::getSingleton()->currentPage(); + setPage((QWebPage*)wbc); // static_cast here gives compiler error + } else { + //Its a super page + m_webViewport->setSuperPage(); + } +} + +void WebContentViewWidget::updatePreferredContentSize() +{ + m_webViewport->updatePreferredContentSize(); +} + +} // namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebContentViewWidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebContentViewWidget.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef WebContentViewWidget_h +#define WebContentViewWidget_h + +#include + +class QGraphicsWebView; +class QWebPage; +class QWebHitTestResult; +struct ZoomMetaData; + +namespace GVA { + +class ScrollableWebContentView; +class WebContentAnimationItem; +class WebView; + +class WebContentViewWidget : public QGraphicsWidget { + Q_OBJECT + Q_PROPERTY(QWebPage* page READ page WRITE setPage) + +public: + WebContentViewWidget(QObject* parent, QWebPage* page = 0); + ~WebContentViewWidget(); + + void resizeEvent(QGraphicsSceneResizeEvent* event); + + QWebPage* page(); + void setPage(QWebPage* page); + + QGraphicsWebView* webView(); + void setPageZoom(bool zoomIn); + + ZoomMetaData currentPageInfo(); + void setCurrentPageInfo(ZoomMetaData); + ZoomMetaData defaultZoomData(); + void showPage(bool isSuperPage); + void updatePreferredContentSize(); + +Q_SIGNALS: + void updateZoomActions(bool enableZoomIn, bool enableZoomOut); + void contextEventObject(QWebHitTestResult* eventTarget); + void viewScrolled(QPoint& scrollPos, QPoint& delta); + +private: + WebView* m_webView; + ScrollableWebContentView* m_webViewport; + WebContentAnimationItem* m_webViewportProxy; +}; + +}// namespace GVA + +#endif //WebContentViewWidget_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebView.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ +#include "WebView.h" + +#include "browserpagefactory.h" +#include "wrtbrowsercontainer.h" + +#include +#include + +namespace GVA { + +WebView::WebView() + : QGraphicsWebView() + , m_webPage(0) +{} + +WebView::~WebView() +{} + +QWebPage* WebView::page() const +{ + return m_webPage; +} + +void WebView::setPage(QWebPage* page) +{ + if (m_webPage == page) + return; + + if (m_webPage) { + disconnect(m_webPage->mainFrame(), 0, this, 0); + m_webPage->setView(0); + } + + m_webPage = page; + + if (!m_webPage) + m_webPage = createWebPage(); + + QGraphicsWebView::setPage(m_webPage); + + emit titleChanged(title()); + emit urlChanged(url()); +} + +QWebPage* WebView::createWebPage() +{ + return reinterpret_cast(BrowserPageFactory::openBrowserPage()); +} + +}//namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ContentViews/WebView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ContentViews/WebView.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef WebView_h +#define WebView_h + +#include + +class QWebPage; + +namespace GVA { + +class WebView :public QGraphicsWebView { + Q_OBJECT + Q_PROPERTY(QWebPage* page READ page WRITE setPage) +public: + WebView(); + ~WebView(); + + QWebPage* page()const; + void setPage(QWebPage* page); + +protected: + QWebPage* createWebPage(); + +private: + QWebPage* m_webPage; + +};//WebView +}//namespace GVA + +#endif //WebView_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/Downloads.cpp --- a/ginebra2/Downloads.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/Downloads.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -33,11 +33,7 @@ #include "bedrockprovisioning.h" #include "downloadcontroller.h" - -#ifdef USE_DOWNLOAD_MANAGER -#include "download.h" -#include "downloadmanager.h" -#endif +#include "downloadproxy.h" namespace GVA { @@ -62,33 +58,31 @@ m_downloadController = new DownloadController(client, proxy); -#ifdef USE_DOWNLOAD_MANAGER - safe_connect(m_downloadController, SIGNAL(downloadCreated(Download *)), - this, SLOT(reportDownloadCreated(Download *))); + safe_connect(m_downloadController, SIGNAL(downloadCreated(DownloadProxy)), + this, SLOT(reportDownloadCreated(DownloadProxy))); - safe_connect(m_downloadController, SIGNAL(downloadStarted(Download *)), - this, SLOT(reportDownloadStarted(Download *))); + safe_connect(m_downloadController, SIGNAL(downloadStarted(DownloadProxy)), + this, SLOT(reportDownloadStarted(DownloadProxy))); - safe_connect(m_downloadController, SIGNAL(downloadFinished(Download *)), - this, SLOT(reportDownloadSuccess(Download *))); + safe_connect(m_downloadController, SIGNAL(downloadFinished(DownloadProxy)), + this, SLOT(reportDownloadSuccess(DownloadProxy))); - safe_connect(m_downloadController, SIGNAL(downloadFailed(Download *, const QString &)), - this, SLOT(reportDownloadFailure(Download *, const QString &))); + safe_connect(m_downloadController, SIGNAL(downloadFailed(DownloadProxy, const QString &)), + this, SLOT(reportDownloadFailure(DownloadProxy, const QString &))); - safe_connect(m_downloadController, SIGNAL(downloadPaused(Download *, const QString &)), - this, SLOT(reportDownloadFailure(Download *, const QString &))); + safe_connect(m_downloadController, SIGNAL(downloadPaused(DownloadProxy, const QString &)), + this, SLOT(reportDownloadFailure(DownloadProxy, const QString &))); - safe_connect(m_downloadController, SIGNAL(downloadCancelled(Download *, const QString &)), - this, SLOT(reportDownloadFailure(Download *, const QString &))); + safe_connect(m_downloadController, SIGNAL(downloadCancelled(DownloadProxy, const QString &)), + this, SLOT(reportDownloadFailure(DownloadProxy, const QString &))); - safe_connect(m_downloadController, SIGNAL(downloadNetworkLoss(Download *, const QString &)), - this, SLOT(reportDownloadFailure(Download *, const QString &))); + safe_connect(m_downloadController, SIGNAL(downloadNetworkLoss(DownloadProxy, const QString &)), + this, SLOT(reportDownloadFailure(DownloadProxy, const QString &))); - // There is no Download* argument to extract data from so we may as well + // There is no argument to extract data from so we may as well // just connect signal to signal without going through another slot. safe_connect(m_downloadController, SIGNAL(downloadsCleared()), this, SIGNAL(downloadsCleared())); -#endif safe_connect(m_downloadController, SIGNAL(unsupportedDownload(const QUrl &)), this, SLOT(reportUnsupportedDownload(const QUrl &))); @@ -128,7 +122,6 @@ return false; } - qDebug() << "Download to:" << saveFile; saveInfo.setFile(saveFile); return true; } @@ -146,50 +139,46 @@ m_downloadController->startDownload(url, saveInfo); } -#ifdef USE_DOWNLOAD_MANAGER - -void Downloads::reportDownloadCreated(Download * download) +void Downloads::reportDownloadCreated(DownloadProxy downloadProxy) { // Localize dialog message. QString fmt = qtTrId("txt_browser_downloading_file"); - QString msg = fmt.arg(download->getAttribute(DlFileName).toString()); + QString msg = fmt.arg(downloadProxy.fileName()); emit downloadCreated(msg); } -void Downloads::reportDownloadStarted(Download * download) +void Downloads::reportDownloadStarted(DownloadProxy downloadProxy) { // Localize dialog message. QString fmt = qtTrId("txt_browser_downloading_file"); - QString msg = fmt.arg(download->getAttribute(DlFileName).toString()); + QString msg = fmt.arg(downloadProxy.fileName()); emit downloadCreated(msg); } -void Downloads::reportDownloadSuccess(Download * download) +void Downloads::reportDownloadSuccess(DownloadProxy downloadProxy) { // Localize dialog message. QString fmt = qtTrId("txt_browser_file_has_finished_downloading"); - QString msg = fmt.arg(download->getAttribute(DlFileName).toString()); + QString msg = fmt.arg(downloadProxy.fileName()); emit downloadSuccess(msg); // Don't forget to remove the download; otherwise the download // controller won't know to emit the DownloadsCleared signal. - DownloadManager * manager = download->downloadManager(); - - manager->removeOne(download); + downloadProxy.remove(); } -void Downloads::reportDownloadFailure(Download * download, const QString & error) +void Downloads::reportDownloadFailure(DownloadProxy downloadProxy, const QString & error) { // What went wrong? - DownloadController::debugDownload(download); + downloadProxy.debug(); // Localize dialog message. @@ -197,24 +186,18 @@ QString msg = fmt.arg( "", "", - download->getAttribute(DlFileName).toString()); + downloadProxy.fileName()); emit downloadFailure(msg); // Don't forget to remove the download; otherwise the download // controller won't know to emit the DownloadsCleared signal. - DownloadManager * manager = download->downloadManager(); - - manager->removeOne(download); + downloadProxy.remove(); } -#endif // USE_DOWNLOAD_MANAGER - void Downloads::reportUnsupportedDownload(const QUrl & url) { - qDebug() << "Unsupported download:" << url; - emit unsupportedDownload("Unsupported content"); // ;;; localize? or not b/c this is temporary? } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/Downloads.h --- a/ginebra2/Downloads.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/Downloads.h Tue Jul 06 14:03:49 2010 +0300 @@ -24,11 +24,12 @@ #include +#include "downloadproxy.h" + class QUrl; class QWebPage; class DownloadController; -class Download; namespace GVA { @@ -46,12 +47,10 @@ void downloadImage(const QString & imageUrl); private slots: -#ifdef USE_DOWNLOAD_MANAGER - void reportDownloadCreated(Download * download); - void reportDownloadStarted(Download * download); - void reportDownloadSuccess(Download * download); - void reportDownloadFailure(Download * download, const QString & error); -#endif + void reportDownloadCreated(DownloadProxy downloadProxy); + void reportDownloadStarted(DownloadProxy downloadProxy); + void reportDownloadSuccess(DownloadProxy downloadProxy); + void reportDownloadFailure(DownloadProxy downloadProxy, const QString & error); void reportUnsupportedDownload(const QUrl & url); signals: diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/DualButtonToolbarSnippet.cpp --- a/ginebra2/DualButtonToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/DualButtonToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -28,8 +28,8 @@ namespace GVA { DualButtonToolbarSnippet::DualButtonToolbarSnippet(const QString& elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : ToolbarSnippet(elementId, chrome, ownerArea, element, widget) + const QWebElement & element) + : ToolbarSnippet(elementId, chrome, element) { m_type = ""; } @@ -50,7 +50,7 @@ Update the item spacing based on the chrome width */ void DualButtonToolbarSnippet::updateOwnerArea() { - setChildSpacing(m_chrome->width()); + setChildSpacing(m_chrome->layout()->size().width()); ToolbarSnippet::updateOwnerArea(); } @@ -65,19 +65,6 @@ ToolbarSnippet::updateOwnerArea(); } - void DualButtonToolbarSnippet::onMouseEvent(QEvent::Type type) { - - //qDebug() << "DualButtonToolbarSnippet::onMouseEvent - Type:" << type; - ActionButton* button = static_cast ( sender()); - ActionButtonSnippet * buttonSnippet = static_cast( button->snippet()); - - if (type == QEvent::GraphicsSceneMousePress ) { - buttonSnippet->setActive(true); - } - else if (type == QEvent::GraphicsSceneMouseRelease ) { - buttonSnippet->updateButtonState(false); - } - } } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/DualButtonToolbarSnippet.h --- a/ginebra2/DualButtonToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/DualButtonToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -34,16 +34,13 @@ { Q_OBJECT public: - DualButtonToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + DualButtonToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~DualButtonToolbarSnippet(); /// Reimplemented void updateOwnerArea(); void updateSize(QSize ); - private Q_SLOTS: - void onMouseEvent(QEvent::Type type); - private: /// Must be Reimplemented virtual void setAction(ChromeSnippet * s) = 0; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/EditorSnippet.cpp --- a/ginebra2/EditorSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/EditorSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -29,11 +29,18 @@ connectAll(); } - void EditorSnippet::setWidget(QGraphicsWidget * widget){ - ChromeSnippet::setWidget(widget); + void EditorSnippet::setChromeWidget(QGraphicsWidget * widget){ + ChromeSnippet::setChromeWidget(widget); connectAll(); } + EditorSnippet * EditorSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + EditorSnippet* that = new EditorSnippet(elementId, chrome, 0, element); + that->setChromeWidget( new TextEditItem( that, chrome ) ); + return that; + } + void EditorSnippet::connectAll(){ if(m_widget){ GTextEditor * editor = static_cast(m_widget)->editor(); @@ -82,4 +89,16 @@ void EditorSnippet::unselect(){ return static_cast(m_widget)->unselect(); } + + int EditorSnippet::getTextOptions(){ + return (int) static_cast(m_widget)->getTextOptions(); + } + + void EditorSnippet::setTextOptions(int flag){ + return static_cast(m_widget)->setTextOptions(flag); + } + + void EditorSnippet::setMaxTextLength(int length){ + return static_cast(m_widget)->setMaxTextLength(length); + } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/EditorSnippet.h --- a/ginebra2/EditorSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/EditorSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -35,7 +35,8 @@ public: EditorSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); virtual ~EditorSnippet() {;} - virtual void setWidget(QGraphicsWidget * widget); + static EditorSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); + virtual void setChromeWidget(QGraphicsWidget * widget); Q_PROPERTY( QString text READ text WRITE setText) void setText( const QString & text ); QString text(); @@ -46,6 +47,10 @@ void unselect(); void onFocusChanged(bool in); void onTapped(QPointF& pos); + int getTextOptions(); + // Calling this function will overwrite the existing options + void setTextOptions(int flag); + void setMaxTextLength(int length); signals: void activated(); void lostFocus(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/EditorWidget.cpp --- a/ginebra2/EditorWidget.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/EditorWidget.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -42,8 +42,8 @@ GTextLineItem::GTextLineItem(QGraphicsItem * parent) : QGraphicsTextItem(parent) - , m_predictionDisabled(false) - , m_autoUppercase(false) + , m_maxTextLength(0) + , m_hints(Qt::ImhNoPredictiveText) // disable the predictive text { // Disable wrapping, force text to be stored and displayed // as a single line. @@ -60,15 +60,47 @@ GTextLineItem::~GTextLineItem() { + if (m_maxTextLength > 0) + disconnect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(contentsChange(int, int, int))); QApplication::setStartDragDistance(m_defaultStartDragDistance); } void GTextLineItem::setText(const QString & text) { - setPlainText(text); + QString newText = text; + if(m_maxTextLength > 0 && text.length() > m_maxTextLength ) { + newText = newText.left(m_maxTextLength); + } + setPlainText(newText); m_textLine = document()->begin().layout()->lineForTextPosition(0); } + void GTextLineItem::setMaxTextLength(int length) + { + if (m_maxTextLength <= 0 && length > 0) { + QString text = toPlainText(); + if( text.length() > length ) { + setPlainText(text.left(length)); + } + connect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(contentsChange(int, int, int))); + } else if (m_maxTextLength > 0 && length <= 0) { + disconnect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(contentsChange(int, int, int))); + } + m_maxTextLength = length; + } + + void GTextLineItem::contentsChange(int position, int charsRemoved, int charsAdded) + { + Q_UNUSED(position); + Q_UNUSED(charsRemoved); + Q_UNUSED(charsAdded); + if( m_maxTextLength > 0 && toPlainText().length() > m_maxTextLength ) { + QTextCursor cursor = textCursor(); + cursor.deletePreviousChar(); + setTextCursor(cursor); + } + } + // Get the pixel offset of the cursor. Needed to implement scrolling. qreal GTextLineItem::cursorX() @@ -179,21 +211,14 @@ // disable the drag & drop to fix the auto-delete-all issue QApplication::setStartDragDistance(1000); QGraphicsTextItem::focusInEvent(event); - // disable the text predictive - if (!m_predictionDisabled) { - QWidget* fw = QApplication::focusWidget(); - Qt::InputMethodHints hints = fw->inputMethodHints(); - hints |= Qt::ImhNoPredictiveText; - if (!m_autoUppercase) - hints |= Qt::ImhNoAutoUppercase; - fw->setInputMethodHints(hints); - m_predictionDisabled = true; - } - qDebug() << "GTextLineItem::focusInEvent"; - if (event->reason() != Qt::PopupFocusReason){ // to fix the special char issue on VKB - qDebug() << "GTextLineItem::focusInEvent: emit focus changed "; + + QWidget* fw = QApplication::focusWidget(); + Qt::InputMethodHints hints = fw->inputMethodHints(); + if (hints != m_hints) + fw->setInputMethodHints(m_hints); + + if (event->reason() != Qt::PopupFocusReason) // to fix the special char issue on VKB emit focusChanged(true); - } } void GTextLineItem::focusOutEvent(QFocusEvent * event) @@ -212,6 +237,11 @@ event->ignore(); } + void GTextLineItem::setInputMethodHints(Qt::InputMethodHints hints) + { + m_hints = hints; + m_hints |= Qt::ImhNoPredictiveText; // disable the predictive text + } // Methods for class GLineEditor // GLineEditor is a QGraphicsWidget that wraps a GTextLineItem to implement scrolling, @@ -291,7 +321,6 @@ painter->save(); painter->setRenderHint(QPainter::Antialiasing); // First, fill rectangle with background color. - qDebug() << "GLineEditor::paint" << boundingRect().width() << " " << size().width(); painter->fillRect(boundingRect(), m_backgroundColor); painter->restore(); if(!isEnabled()) { @@ -535,6 +564,7 @@ TextEditItem::TextEditItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent) : NativeChromeItem(snippet, parent) + , m_justFocusIn(false) { m_textEditor = new GTextEditor(snippet, chrome, this); @@ -560,8 +590,35 @@ //Padding sets the "border" width QString cssPadding = we.styleProperty("padding-top", QWebElement::ComputedStyle); m_textEditor->setPadding(cssPadding.remove("px").toInt()); - } + + safe_connect(m_textEditor, SIGNAL(focusChanged(bool)),this, SLOT(focusChanged(bool))); + safe_connect(m_textEditor, SIGNAL(tapped(QPointF&)),this, SLOT(tapped(QPointF&))); +} + void TextEditItem::tapped(QPointF& pos) +{ + bool hitText = m_textEditor->tappedOnText(pos.x()); + if (!m_justFocusIn && !hitText) + m_textEditor->unselect(); + + if (m_justFocusIn) { + m_justFocusIn = false; + if (hitText && !m_textEditor->hasSelection()) + m_textEditor->selectAll(); + } +} + +void TextEditItem::focusChanged(bool focusIn) +{ + if (focusIn) + m_justFocusIn = true; + else { + m_justFocusIn = false; + m_textEditor->unselect(); + m_textEditor->shiftToLeftEnd(); + } +} + TextEditItem::~TextEditItem() { delete m_textEditor; @@ -571,5 +628,10 @@ { m_textEditor->resize(ev->newSize()); } + + void TextEditItem::setTextOptions(int flag) + { + m_textEditor->setInputMethodHints((Qt::InputMethodHints)flag); + } } // namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/EditorWidget.h --- a/ginebra2/EditorWidget.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/EditorWidget.h Tue Jul 06 14:03:49 2010 +0300 @@ -46,12 +46,14 @@ qreal anchorX(); QRectF selectionRectF(); void setText(const QString & text); + void setMaxTextLength(int length); void selectAll(); void unselect(); qreal textWidth(); void setCursorPosition(int pos); - void setAutoUppercase(bool enable) { m_autoUppercase = enable; } bool hasSelection() { return (cursorX()!= anchorX()); } + Qt::InputMethodHints inputMethodHints() const { return m_hints; } + void setInputMethodHints(Qt::InputMethodHints hints); protected: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); @@ -64,6 +66,9 @@ virtual void focusOutEvent(QFocusEvent * event); virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); + private slots: + void contentsChange(int position, int charsRemoved, int charsAdded); + signals: void cursorXChanged(qreal newx); void textMayChanged(); @@ -73,8 +78,8 @@ private: QTextLine m_textLine; int m_defaultStartDragDistance; - bool m_predictionDisabled; - bool m_autoUppercase; + int m_maxTextLength; + Qt::InputMethodHints m_hints; }; class GLineEditor : public QGraphicsWidget @@ -101,6 +106,10 @@ void shiftToLeftEnd() { setCursorPosition(0); } int characterCount() { return m_editor->document()->characterCount(); } bool hasSelection() { return m_editor->hasSelection(); } + Qt::InputMethodHints inputMethodHints() { return m_editor->inputMethodHints(); } + // Calling this function will overwrite the existing hints + void setInputMethodHints(Qt::InputMethodHints hints) { m_editor->setInputMethodHints(hints); } + void setMaxTextLength(int length) { m_editor->setMaxTextLength(length); } protected: virtual bool eventFilter(QObject * object, QEvent * event); @@ -195,10 +204,20 @@ void setCursorPosition(int pos) { m_textEditor->setCursorPosition(pos); } void selectAll() { m_textEditor->selectAll(); } void unselect() { m_textEditor->unselect(); } + int getTextOptions() { return (int) m_textEditor->inputMethodHints(); } + // Calling this function will overwrite the existing options + void setTextOptions (int flag); + void setMaxTextLength(int length) { m_textEditor->setMaxTextLength(length); } + + private slots: + void tapped(QPointF&); + void focusChanged(bool focusIn); + protected: virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); private: GTextEditor * m_textEditor; + bool m_justFocusIn; }; } // namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/FlickCharm.cpp --- a/ginebra2/FlickCharm.cpp Wed Jun 23 17:59:43 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,409 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Graphics Dojo project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "FlickCharm.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct FlickData { - typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State; - State state; - QObject *widget; - QPoint pressPos; - QPoint offset; - QPoint dragPos; - QPoint speed; - QList ignored; -}; - -class FlickCharmPrivate -{ -public: - QHash flickData; - QBasicTimer ticker; -}; - -FlickCharm::FlickCharm(QObject *parent): QObject(parent) -{ - d = new FlickCharmPrivate; -} - -FlickCharm::~FlickCharm() -{ - delete d; -} - -void FlickCharm::activateOn(QWidget *widget) -{ - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - QWidget *viewport = scrollArea->viewport(); - - viewport->installEventFilter(this); - scrollArea->installEventFilter(this); - - d->flickData.remove(viewport); - d->flickData[viewport] = new FlickData; - d->flickData[viewport]->widget = widget; - d->flickData[viewport]->state = FlickData::Steady; - - return; - } -} - -void FlickCharm::activateOn(QWebView *webView) -{ - if (webView) { - QWebFrame *frame = webView->page()->mainFrame(); - frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - - webView->installEventFilter(this); - - d->flickData.remove(webView); - d->flickData[webView] = new FlickData; - d->flickData[webView]->widget = webView; - d->flickData[webView]->state = FlickData::Steady; - - return; - } -} - -void FlickCharm::activateOn(QGraphicsWebView *webView) -{ - qDebug() << "FlickCharm::activateOn"; - if (webView) { - QWebFrame *frame = webView->page()->mainFrame(); - frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - - webView->installEventFilter(this); - - d->flickData.remove(webView); - d->flickData[webView] = new FlickData; - d->flickData[webView]->widget = webView; - d->flickData[webView]->state = FlickData::Steady; - - return; - } -} - -void FlickCharm::deactivateFrom(QWidget *widget) -{ - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - QWidget *viewport = scrollArea->viewport(); - - viewport->removeEventFilter(this); - scrollArea->removeEventFilter(this); - - delete d->flickData[viewport]; - d->flickData.remove(viewport); - - return; - } - - QWebView *webView = dynamic_cast(widget); - if (webView) { - webView->removeEventFilter(this); - - delete d->flickData[webView]; - d->flickData.remove(webView); - - return; - } -} - -static QPoint scrollOffset(QObject *widget) -{ - int x = 0, y = 0; - - QGraphicsWebView *gWebView = dynamic_cast(widget); - if (gWebView) { - QWebFrame *frame = gWebView->page()->mainFrame(); - x = frame->evaluateJavaScript("window.scrollX").toInt(); - y = frame->evaluateJavaScript("window.scrollY").toInt(); - } - - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - x = scrollArea->horizontalScrollBar()->value(); - y = scrollArea->verticalScrollBar()->value(); - } - - QWebView *webView = dynamic_cast(widget); - if (webView) { - QWebFrame *frame = webView->page()->mainFrame(); - x = frame->evaluateJavaScript("window.scrollX").toInt(); - y = frame->evaluateJavaScript("window.scrollY").toInt(); - } - - return QPoint(x, y); -} - -static void setScrollOffset(QObject *widget, const QPoint &p) -{ - QGraphicsWebView *gWebView = dynamic_cast(widget); - if (gWebView) { - QWebFrame *frame = gWebView->page()->mainFrame(); - if (frame) - frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); - return; - } - - QAbstractScrollArea *scrollArea = dynamic_cast(widget); - if (scrollArea) { - scrollArea->horizontalScrollBar()->setValue(p.x()); - scrollArea->verticalScrollBar()->setValue(p.y()); - return; - } - - QWebView *webView = dynamic_cast(widget); - QWebFrame *frame = webView ? webView->page()->mainFrame() : 0; - if (frame) - frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y())); -} - -static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) -{ - int x = qBound(-max, speed.x(), max); - int y = qBound(-max, speed.y(), max); - x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); - y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); - return QPoint(x, y); -} - -bool FlickCharm::eventFilter(QObject *object, QEvent *event) -{ -// qDebug() << "FlickCharm::eventFilter: " << object << event; -// if (!object->isWidgetType()) -// return false; - - QEvent::Type type = event->type(); - switch (type) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseMove: - break; - default: - return false; - } - - QPoint eventPos; - QEvent::Type eventType; - Qt::MouseButtons eventButtons; - QMouseEvent *mouseEvent = dynamic_cast(event); - if (mouseEvent) { - if (mouseEvent->modifiers() != Qt::NoModifier) - return false; - eventPos = mouseEvent->pos(); - eventType = mouseEvent->type(); - eventButtons = mouseEvent->buttons(); - } - else { - QGraphicsSceneMouseEvent *mouseEvent = dynamic_cast(event); - if (mouseEvent && mouseEvent->modifiers() == Qt::NoModifier) { - eventPos = mouseEvent->pos().toPoint(); - eventType = mouseEvent->type(); - eventButtons = mouseEvent->buttons(); - } - else - return false; - } - -// QWidget *viewport = dynamic_cast(object); - FlickData *data = d->flickData.value(object); - if (!data || data->ignored.removeAll(event)) { - return false; - } - - bool consumed = false; - switch (data->state) { - - case FlickData::Steady: - if (eventType == QEvent::MouseButtonPress || - eventType == QEvent::GraphicsSceneMousePress) - if (eventButtons == Qt::LeftButton) { - consumed = true; - data->state = FlickData::Pressed; - data->pressPos = eventPos; - data->offset = scrollOffset(data->widget); - } - break; - - case FlickData::Pressed: - if (eventType == QEvent::MouseButtonRelease) { - consumed = true; - data->state = FlickData::Steady; - - QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, - data->pressPos, Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); - QMouseEvent *event2 = new QMouseEvent(*mouseEvent); - - data->ignored << event1; - data->ignored << event2; - QApplication::postEvent(object, event1); - QApplication::postEvent(object, event2); - } - else if (eventType == QEvent::GraphicsSceneMouseRelease) { - consumed = true; - data->state = FlickData::Steady; - - QGraphicsSceneMouseEvent *origMouseEvent = static_cast(event); - QGraphicsSceneMouseEvent *event1 = - new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress); - event1->setPos(origMouseEvent->pos()); - event1->setScenePos(origMouseEvent->scenePos()); - event1->setLastPos(origMouseEvent->lastPos()); - event1->setLastScenePos(origMouseEvent->lastScenePos()); - event1->setButtons(origMouseEvent->buttons()); - event1->setButton(origMouseEvent->button()); - event1->setModifiers(origMouseEvent->modifiers()); - - QGraphicsSceneMouseEvent *event2 = new QGraphicsSceneMouseEvent(origMouseEvent->type()); - event2->setPos(origMouseEvent->pos()); - event2->setScenePos(origMouseEvent->scenePos()); - event2->setLastPos(origMouseEvent->lastPos()); - event2->setLastScenePos(origMouseEvent->lastScenePos()); - event2->setButtons(origMouseEvent->buttons()); - event2->setButton(origMouseEvent->button()); - event2->setModifiers(origMouseEvent->modifiers()); - - data->ignored << event1; - data->ignored << event2; - QApplication::postEvent(object, event1); - QApplication::postEvent(object, event2); - } - if (eventType == QEvent::MouseMove || - eventType == QEvent::GraphicsSceneMouseMove) { - consumed = true; - data->state = FlickData::ManualScroll; - data->dragPos = QCursor::pos(); - if (!d->ticker.isActive()) - d->ticker.start(20, this); - } - break; - - case FlickData::ManualScroll: - if (eventType == QEvent::MouseMove || - eventType == QEvent::GraphicsSceneMouseMove) { - consumed = true; - QPoint delta = eventPos - data->pressPos; - setScrollOffset(data->widget, data->offset - delta); - } - if (eventType == QEvent::MouseButtonRelease || - eventType == QEvent::GraphicsSceneMouseRelease) { - consumed = true; - data->state = FlickData::AutoScroll; - } - break; - - case FlickData::AutoScroll: - if (eventType == QEvent::MouseButtonPress || - eventType == QEvent::GraphicsSceneMousePress) { - consumed = true; - data->state = FlickData::Stop; - data->speed = QPoint(0, 0); - data->pressPos = eventPos; - data->offset = scrollOffset(data->widget); - } - if (eventType == QEvent::MouseButtonRelease || - eventType == QEvent::GraphicsSceneMouseRelease) { - consumed = true; - data->state = FlickData::Steady; - data->speed = QPoint(0, 0); - } - break; - - case FlickData::Stop: - if (eventType == QEvent::MouseButtonRelease || - eventType == QEvent::GraphicsSceneMouseRelease) { - consumed = true; - data->state = FlickData::Steady; - } - if (eventType == QEvent::MouseMove || - eventType == QEvent::GraphicsSceneMouseMove) { - consumed = true; - data->state = FlickData::ManualScroll; - data->dragPos = QCursor::pos(); - if (!d->ticker.isActive()) - d->ticker.start(20, this); - } - break; - - default: - break; - } - - return consumed; -} - -void FlickCharm::timerEvent(QTimerEvent *event) -{ - int count = 0; - QHashIterator item(d->flickData); - while (item.hasNext()) { - item.next(); - FlickData *data = item.value(); - - if (data->state == FlickData::ManualScroll) { - count++; - data->speed = QCursor::pos() - data->dragPos; - data->dragPos = QCursor::pos(); - } - - if (data->state == FlickData::AutoScroll) { - count++; - data->speed = deaccelerate(data->speed); - QPoint p = scrollOffset(data->widget); - setScrollOffset(data->widget, p - data->speed); - if (data->speed == QPoint(0, 0)) - data->state = FlickData::Steady; - } - } - - if (!count) - d->ticker.stop(); - - QObject::timerEvent(event); -} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/FlickCharm.h --- a/ginebra2/FlickCharm.h Wed Jun 23 17:59:43 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the Graphics Dojo project on Qt Labs. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 or 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef FLICKCHARM_H -#define FLICKCHARM_H - -#include - -class FlickCharmPrivate; -class QWidget; -class QGraphicsWebView; -class QWebView; - -class FlickCharm: public QObject -{ - Q_OBJECT -public: - FlickCharm(QObject *parent = 0); - ~FlickCharm(); - void activateOn(QWidget *widget); - void activateOn(QWebView *webView); - void activateOn(QGraphicsWebView *webView); - void deactivateFrom(QWidget *widget); - bool eventFilter(QObject *object, QEvent *event); - -protected: - void timerEvent(QTimerEvent *event); - -private: - FlickCharmPrivate *d; -}; - -#endif // FLICKCHARM_H diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GSuperWebPage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/GSuperWebPage.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "GSuperWebPage.h" + +namespace GVA { + +GSuperWebPage::GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget) + : GWebPage(page), + m_chromeWidget(chromeWidget) +{ + if (!m_page) { + m_page = new WebPageWrapper(this, "Superpage javascript error"); + } + //qDebug() << "GSuperWebPage::GSuperWebPage: page=" << GWebPage::page(); + connect(GWebPage::page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); +} + +void GSuperWebPage::load(const QString &url) { + //qDebug() << "GSuperWebPage::load: " << url; + QString tmpUrl = url; + if(tmpUrl.left(2) == ":/") // resource path have to be converted to resource url + tmpUrl = "qrc:///" + tmpUrl.mid(2); + page()->mainFrame()->load(tmpUrl); +} + +void GSuperWebPage::onJavaScriptWindowObjectCleared() { + //qDebug() << "GSuperWebPage::onJavaScriptWindowObjectCleared: " << objectName(); + if (m_chromeWidget) + m_chromeWidget->exportJSObjectsToPage(m_page); +} + +} // GVA namespace + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GSuperWebPage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/GSuperWebPage.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef GSUPERWEBPAGE_H +#define GSUPERWEBPAGE_H + +#include "GWebPage.h" + +namespace GVA { + +// ------------------------------ +/*! \ingroup JavascriptAPI +* \brief A content view that has full access to the Javascript APIs. +* +* Example code to load an HTML file into a super page: +* \code +* window.views.WebView.createSuperPage("BookmarkView", true); +* window.views.WebView.BookmarkView.load("./chrome/BookmarkView.html"); +* \endcode +*/ +class GSuperWebPage : public GWebPage { + Q_OBJECT +public: + GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget); + void onShown() { emit shown(); } + void onHidden() { emit hidden(); } + +public slots: + void load(const QString &url); + +signals: + /*! + * Triggered by the javascript code within the superpage when it wants a context menu to be displayed by + * the chrome's javascript. + * + * The normal chain of events is: + * \li User executes a long-press (or RMB click). + * \li Qt sends QContextMenuEvent from QWebView. + * \li GWebContentViewWidget::contextMenuEvent is called, which passes the event to the superpage + * (if one is currently displayed). + * \li The superpage emits \c contextEvent(). + * \li The context event handler in the superpage's javascript determines what was clicked on + * and emits \c showContextMenu() from the superpage. + * \li Javascript \c showContextMenu signal handler in the chrome is called which then displays the context menu. + */ + void showContextMenu(QVariant obj); + + /*! + * Triggered when the page is shown. + */ + void shown(); + + /*! + * Triggered when the page is hidden. + */ + void hidden(); + +private slots: + void onJavaScriptWindowObjectCleared(); + +private: + ChromeWidget *m_chromeWidget; // not owned +}; + +} // GVA namespace + +#endif // GSUPERWEBPAGE_H diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GWebPage.cpp --- a/ginebra2/GWebPage.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/GWebPage.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -42,30 +42,4 @@ .arg(message).toAscii(); } -// ---------------------------------------- -// GSuperWebPage -// ---------------------------------------- - -GSuperWebPage::GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget) - : GWebPage(page), - m_chromeWidget(chromeWidget) -{ - if (!m_page) { - m_page = new WebPageWrapper(this, "Superpage javascript error"); - } - qDebug() << "GSuperWebPage::GSuperWebPage: page=" << GWebPage::page(); - connect(GWebPage::page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); -} - -void GSuperWebPage::load(const QString &url) { - qDebug() << "GSuperWebPage::load: " << url; - page()->mainFrame()->load(url); -} - -void GSuperWebPage::onJavaScriptWindowObjectCleared() { - qDebug() << "GSuperWebPage::onJavaScriptWindowObjectCleared: " << objectName(); - if (m_chromeWidget) - m_chromeWidget->exportJSObjectsToPage(m_page); -} - } // GVA namespace diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GWebPage.h --- a/ginebra2/GWebPage.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/GWebPage.h Tue Jul 06 14:03:49 2010 +0300 @@ -72,8 +72,11 @@ signals: /// Triggered by a QContextEvent such as a long-press or right mouse button click. void contextEvent(::WebViewEventContext *context); - +#ifdef BEDROCK_TILED_BACKING_STORE +public slots: +#else protected slots: +#endif void onContextEvent(::WebViewEventContext *context) { emit contextEvent(context); } protected: @@ -82,48 +85,6 @@ friend class GWebContentViewWidget; }; -// ------------------------------ -/*! \ingroup JavascriptAPI -* \brief A content view that has full access to the Javascript APIs. -* -* Example code to load an HTML file into a super page: -* \code -* window.views.WebView.createSuperPage("BookmarkView", true); -* window.views.WebView.BookmarkView.load("./chrome/BookmarkView.html"); -* \endcode -*/ -class GSuperWebPage : public GWebPage { - Q_OBJECT -public: - GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget); - -public slots: - void load(const QString &url); - -signals: - /*! - * Triggered by the javascript code within the superpage when it wants a context menu to be displayed by - * the chrome's javascript. - * - * The normal chain of events is: - * \li User executes a long-press (or RMB click). - * \li Qt sends QContextMenuEvent from QWebView. - * \li GWebContentViewWidget::contextMenuEvent is called, which passes the event to the superpage - * (if one is currently displayed). - * \li The superpage emits \c contextEvent(). - * \li The context event handler in the superpage's javascript determines what was clicked on - * and emits \c showContextMenu() from the superpage. - * \li Javascript \c showContextMenu signal handler in the chrome is called which then displays the context menu. - */ - void showContextMenu(QVariant obj); - -private slots: - void onJavaScriptWindowObjectCleared(); - -private: - ChromeWidget *m_chromeWidget; // not owned -}; - } #endif // __GINEBRA_GWEBPAGE_H__ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GWebTouchNavigation.cpp --- a/ginebra2/GWebTouchNavigation.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/GWebTouchNavigation.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -20,25 +20,20 @@ */ #include "GWebTouchNavigation.h" +#include "wrtBrowserUtils.h" + #include #include #include #include -#include "GWebContentViewWidget.h" -#include "GWebContentView.h" #include #include #include #include #include -#include - -#include "wrtBrowserUtils.h" -#include "ChromeWidget.h" -#include -#define LONG_PRESS_DURATION 500 +namespace GVA { const int KFlickSpeed = 400; const qreal PI = 3.1415926535897932; @@ -58,19 +53,14 @@ const int KPanThreshold = 2; const int KThreshHoldValForLink = 10; const qreal KDeccelaration = 1000.00; -//const int KDefaultViewportWidth = 980; -//const int KDefaultPortraitScaleWidth = 540; - -//const int KKineticTimeout = 60; static const int KStartPanDistance = 50; static const int KWaitForClickTimeoutMS = 200; +static const int KLongPressDuration = 1000; +static const int KLongPressThreshold = 30; //The amount of pixels to try to pan before pan mode unlocks static const int KPanModeChangeDelta = 100; - -namespace GVA { - /*! \class WebTouchNavigation \since cwrt 1.0 @@ -99,11 +89,13 @@ , m_contentHeight(0) , m_isContextEvent(false) , m_wantSlideViewCalls(true) +, m_doubleClickEnabled(true) { install(); connect(m_webPage, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); } + inline void GWebTouchNavigation::cancelPressEvent() { if (m_pressEvent) { delete m_pressEvent; @@ -122,16 +114,10 @@ */ GWebTouchNavigation::~GWebTouchNavigation() { - disconnect(m_doubleClickTimer, SIGNAL(timeout()), this, SLOT(doubleClickTimerExpired())); - if (m_doubleClickTimer) { - m_doubleClickTimer->stop(); - delete m_doubleClickTimer; - } - disconnect(m_scrollTimer, SIGNAL(timeout()),this,SLOT(pan())); + delete m_doubleClickTimer; delete m_scrollTimer; - - disconnect(m_kineticTimer, SIGNAL(timeout()),this,SLOT(kineticScroll())); delete m_kineticTimer; + delete m_longPressTimer; uninstall(); cancelPressEvent(); @@ -293,15 +279,15 @@ { if (qAbs(diff.x()) < KPanThreshold && qAbs(diff.y()) < KPanThreshold) return; - else if (m_dragPoints.size() == 1) { - setViewBlockElement(QWebElement()); - } + else if (m_dragPoints.size() == 1) { + setViewBlockElement(QWebElement()); + } - if (!m_isPanning) { + if (!m_isPanning) { qreal dy = qAbs(diff.y()); qreal dx = qAbs(diff.x()); if (dy > KStartPanDistance || dx > KStartPanDistance - || m_delayedPressMoment.elapsed() > KWaitForClickTimeoutMS) { + || m_delayedPressMoment.elapsed() > KWaitForClickTimeoutMS) { //get the scroll direction Direction scrollDir = findDirectionWithAngle(diff); if (scrollDir == UP || scrollDir == DOWN) @@ -314,15 +300,15 @@ } } - if (m_isPanning) { - m_scrolled= false; - m_frame = getNextScrollableFrame(diff); - QPoint scrollPosition = m_frame->scrollPosition(); - if (diff.manhattanLength()) - panBy(diff); + if (m_isPanning) { + m_scrolled= false; + m_frame = getNextScrollableFrame(diff); + QPoint scrollPosition = m_frame->scrollPosition(); + if (diff.manhattanLength()) + panBy(diff); - m_scrolled = (scrollPosition != m_frame->scrollPosition()); - } + m_scrolled = (scrollPosition != m_frame->scrollPosition()); + } } void GWebTouchNavigation::startPanGesture(PanDirection directionHint) { @@ -469,7 +455,7 @@ m_higlightedPos = m_touchPosition = pos; m_frame = m_webPage->frameAt(pos); if (!m_frame) - m_frame = m_webPage->currentFrame(); + m_frame = m_webPage->currentFrame(); m_dragPoints.clear(); @@ -507,17 +493,14 @@ m_doubleClickTimer->start(KDoubleClickTimeOut); m_pressEvent = new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, getEventModifier(pos)); + m_longPressPosition = pos; + startLongPressTimer(); } void GWebTouchNavigation::handleMousePressEvent(QMouseEvent* ev) { if (!ev) return; m_lastMoveEventTime.setHMS(0,0,0,0); //H, M, S, mS - if (!m_longPressTimer){ - delete m_longPressTimer; - m_longPressTimer = 0; - } - startTimer(); m_scrolled = false; m_ishighlighted = false; m_higlightedPos = m_touchPosition = ev->pos(); @@ -535,7 +518,7 @@ m_offset = 0; highlightableElement(ev); - getFocusedElement(); + emitFocusedElementChanged(); //send a mouse press QMouseEvent iev(ev->type(), m_touchPosition, ev->button(), ev->buttons(), getEventModifier(m_higlightedPos)); @@ -560,7 +543,7 @@ } bool GWebTouchNavigation::canDehighlight(QMouseEvent* ev) - { +{ bool checkDehighlight = false; QPoint pt = ev->pos() + m_frame->scrollPosition(); @@ -578,8 +561,8 @@ int newoffset = (pt.x()- centerpt.x())*(pt.x()- centerpt.x()) + (pt.y()- centerpt.y())*(pt.y()- centerpt.y()); if (newoffset <= m_offset ) { - m_offset = newoffset; - checkDehighlight = false; + m_offset = newoffset; + checkDehighlight = false; } else { m_offset =0; @@ -592,7 +575,7 @@ } return checkDehighlight; } - void GWebTouchNavigation::dehighlight(QMouseEvent* ev) +void GWebTouchNavigation::dehighlight(QMouseEvent* ev) { m_higlightedPos = QPoint(0,0); m_ishighlighted = false; @@ -613,11 +596,18 @@ */ void GWebTouchNavigation::mouseMoveEvent(const QPoint& pos, const QPoint& diff) { + if (m_longPressTimer && m_longPressTimer->isActive()){ + QPoint diff2 = m_longPressPosition - pos; + if (qAbs(diff2.x()) > KLongPressThreshold || qAbs(diff2.y()) > KLongPressThreshold) { + stopLongPressTimer(); + } + } if (m_pressEvent){ QPoint diff2 = m_pressEvent->pos() - pos; - if (qAbs(diff2.x()) < KTouchThresholdX && qAbs(diff2.y()) < KTouchThresholdY) - return; + if (qAbs(diff2.x()) < KTouchThresholdX && qAbs(diff2.y()) < KTouchThresholdY) { + return; + } } if (m_doubleClickTimer && m_doubleClickTimer->isActive()) { @@ -627,7 +617,6 @@ cancelPressEvent(); } - stopTimer(); QMouseEvent tmpEv(QEvent::MouseMove, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); handleHighlightChange(&tmpEv); @@ -649,17 +638,17 @@ if (!m_textSelected) scrollFrame(diff); - //m_touchPosition = pos; - DragPoint dragPoint; - dragPoint.iPoint = pos; - dragPoint.iTime = QTime::currentTime(); - m_dragPoints.append(dragPoint); + //m_touchPosition = pos; + DragPoint dragPoint; + dragPoint.iPoint = pos; + dragPoint.iTime = QTime::currentTime(); + m_dragPoints.append(dragPoint); - QTime now(QTime::currentTime()); - m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec()); + QTime now(QTime::currentTime()); + m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec()); - while (m_dragPoints.size() > 4) - m_dragPoints.removeFirst(); + while (m_dragPoints.size() > 4) + m_dragPoints.removeFirst(); } @@ -670,6 +659,8 @@ */ void GWebTouchNavigation::mouseReleaseEvent(const QPoint& pos) { + stopLongPressTimer(); + if (m_isPanning) m_isPanning = false; if (m_doubleClickTimer && m_doubleClickTimer->isActive()) { @@ -709,10 +700,10 @@ m_frame = m_webPage->frameAt(ev->pos()); if (!m_frame) m_frame = m_webPage->currentFrame(); - assert(m_frame); + Q_ASSERT(m_frame); - stopTimer(); - if (m_scrolled) { + stopLongPressTimer(); + if (m_scrolled) { int msecs = 0; if (!m_lastMoveEventTime.isNull()) { //Start deceleration only if the delta since last drag event is less than threshold @@ -735,10 +726,14 @@ startScrollTimer(); } } else { + // we don't want to automatically display the SIP (Software input panel) by qtwebkit + bool sipEnabled = qApp->autoSipEnabled(); + qApp->setAutoSipEnabled(false); QMouseEvent iev = m_ishighlighted ? QMouseEvent(ev->type(), m_higlightedPos, ev->button(), ev->buttons(), getEventModifier(m_higlightedPos)) : QMouseEvent(QEvent::MouseButtonRelease, m_touchPosition, ev->button(), ev->buttons(), getEventModifier(m_touchPosition)); m_webPage->event(&iev); + qApp->setAutoSipEnabled(sipEnabled); #if defined __SYMBIAN32__ // FIXME Remove this, it will be fixed Qt 4.6.3 ? if (ev->button() == Qt::LeftButton) { @@ -774,6 +769,9 @@ void GWebTouchNavigation::handleDoubleClickEvent(QMouseEvent* ev) { + if (!m_doubleClickEnabled) + return; + QPoint imageFocusPoint; QWebHitTestResult hitTest = getHitTestResult(ev); @@ -1048,6 +1046,7 @@ if (m_scrollDistance.y() > ((contentSize.height()-documentViewPoint.y())/2)) m_scrollDistance.setY((contentSize.height()-documentViewPoint.y())/2); break; + default: break; } } @@ -1144,7 +1143,7 @@ else if (isNear(angle, 300.0, 330.0)) { direction = TOPRIGHT; } - assert(direction != NONE); + Q_ASSERT(direction != NONE); return direction; } @@ -1279,26 +1278,35 @@ } scrollCurrentFrame(diffX, diffY); } -void GWebTouchNavigation::timerControl() + +void GWebTouchNavigation::onLongPressTimer() { - stopTimer();// stop timer as soon as timeout - emit longPressEvent(); + stopLongPressTimer();// stop timer as soon as timeout + emit longPressEvent(m_touchPosition); } -void GWebTouchNavigation::startTimer() + +void GWebTouchNavigation::startLongPressTimer() { - m_longPressTimer = new QTimer(this); - connect(m_longPressTimer,SIGNAL(timeout()),this,SLOT(timerControl())); - m_longPressTimer->start(LONG_PRESS_DURATION); + if(!m_longPressTimer) { + m_longPressTimer = new QTimer(this); + connect(m_longPressTimer, SIGNAL(timeout()), this, SLOT(onLongPressTimer())); + } + else { + m_longPressTimer->stop(); + } + m_longPressTimer->start(KLongPressDuration); } -void GWebTouchNavigation::stopTimer() + +void GWebTouchNavigation::stopLongPressTimer() { if (m_longPressTimer){ - m_longPressTimer->stop(); - delete m_longPressTimer; - m_longPressTimer = 0; - } + m_longPressTimer->stop(); + delete m_longPressTimer; + m_longPressTimer = 0; + } } -void GWebTouchNavigation::getFocusedElement() + +void GWebTouchNavigation::emitFocusedElementChanged() { QWebHitTestResult htRes = m_frame->hitTestContent(m_touchPosition); wrtBrowserDefs::BrowserElementType elType = wrtBrowserUtils::getTypeFromElement(htRes); @@ -1317,16 +1325,14 @@ /* shrink the viewport size at bottom if content is scrolled to bottom, so that use can click the link under the toolbar */ + /* if (m_frame == m_webPage->mainFrame()) { if (scrollPosition.y() + m_webPage->viewportSize().height() >= m_frame->contentsSize().height()) { qreal slide = shrinkView(-dy); dy+=slide; } - /* - else { - qDebug()<<"scrollPosition.y() = "<viewportSize().height() = "<viewportSize().height()<<" m_frame->contentsSize().height() = "<contentsSize().height(); - }*/ } + */ m_frame->scroll(dx, dy); } @@ -1346,6 +1352,7 @@ dy+=slide; finalPos.setY(scrollPosition.y() - dy); } + /* if (m_frame == m_webPage->mainFrame()) { if (scrollPosition.y() + m_webPage->viewportSize().height() == m_frame->contentsSize().height()) { qreal slide = shrinkView(-dy); @@ -1353,7 +1360,7 @@ } finalPos.setY(scrollPosition.y() - dy); } - + */ m_frame->setScrollPosition(finalPos); } @@ -1372,13 +1379,13 @@ if (m_webPage) { disconnect(m_webPage, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); disconnect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); - disconnect(m_webPage->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), this, SLOT(onContentsSizeChanged(const QSize &))); + //disconnect(m_webPage->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), this, SLOT(onContentsSizeChanged(const QSize &))); } m_webPage = page; if (m_webPage) { connect(m_webPage, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); - connect(m_webPage->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), this, SLOT(onContentsSizeChanged(const QSize &))); + //connect(m_webPage->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), this, SLOT(onContentsSizeChanged(const QSize &))); } } @@ -1391,4 +1398,9 @@ shrinkView(100); } } + +void GWebTouchNavigation::enableDClick(bool aValue) +{ + m_doubleClickEnabled = aValue; } +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/GWebTouchNavigation.h --- a/ginebra2/GWebTouchNavigation.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/GWebTouchNavigation.h Tue Jul 06 14:03:49 2010 +0300 @@ -40,6 +40,7 @@ class QWebPage; class QTimer; class QWebElement; +class WebViewEventContext; namespace GVA { @@ -86,8 +87,8 @@ void setWantSlideViewCalls(bool value) { m_wantSlideViewCalls = value; } signals: - void longPressEvent();// mouse long press signal - void focusElementChanged(wrtBrowserDefs::BrowserElementType &);// mouse long press signal + void longPressEvent(QPoint pos);// mouse long press signal + void focusElementChanged(wrtBrowserDefs::BrowserElementType &); void pageScrollPositionZero(); /// Sent when this object starts panning/scrolling the page. Can be useful for @@ -96,16 +97,19 @@ void startingPanGesture(int directionHint); void mouseEvent(QEvent::Type type); + protected slots: void scrollToEdge(); void doubleClickTimerExpired(); - void timerControl();// local slot for controlling timer + void onLongPressTimer(); void pan(); void kineticScroll(); void BlockFocusChanged(QPoint pt); void onLoadStarted(); void onLoadFinished(bool ok); void onContentsSizeChanged(const QSize &); + void enableDClick(bool aValue); + protected: bool eventFilter(QObject *object, QEvent *event); void mousePressEvent(const QPoint& pos); @@ -154,9 +158,9 @@ void handleHighlightChange(QMouseEvent* ev); bool canDehighlight(QMouseEvent* ev); void dehighlight(QMouseEvent* ev); - void getFocusedElement(); - void startTimer(); - void stopTimer(); + void emitFocusedElementChanged(); + void startLongPressTimer(); + void stopLongPressTimer(); void stopScrolling(); void startPanGesture(PanDirection); @@ -187,6 +191,7 @@ bool m_ishighlighted; int m_offset; QTimer* m_longPressTimer;// long press timer + QPoint m_longPressPosition; QPoint m_initialSpeed; qreal m_finalzoomfactor; QTimer* m_scrollTimer; @@ -213,6 +218,8 @@ bool m_isContextEvent; // Flag that governs whether calls to slideView should be made or not. bool m_wantSlideViewCalls; + + bool m_doubleClickEnabled; }; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/KineticHelper.cpp --- a/ginebra2/KineticHelper.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/KineticHelper.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -60,7 +60,6 @@ m_kineticTimer->start(m_kineticTimeout); m_actualTime = QTime::currentTime(); m_actualTime.start(); - qDebug() << "starting kinetic timer at " << m_initialPos << ", at " << m_actualTime; } @@ -77,12 +76,8 @@ int t = m_actualTime.elapsed(); m_kineticScrollTime += (((qreal)t) / 1000); - qDebug() << "kineticScroll(): elapsed: " << t << ", m_kineticSteps: " << m_kineticSteps << - ", m_kineticScrollTime: " << m_kineticScrollTime << - ", decelX: "<< decelX << ", decelY: " << decelY << ", m_initialSpeed: " << m_initialSpeed; if (m_initialSpeed.x()) { vx = m_initialSpeed.x() + decelX * m_kineticScrollTime; - qDebug() << "vx: " << vx; if (vx * m_initialSpeed.x() < 0) { dx = 0; vx = 0; @@ -95,7 +90,6 @@ if (m_initialSpeed.y()) { vy = m_initialSpeed.y() + decelY * m_kineticScrollTime; - qDebug() << "vy: " << vy; if (vy * m_initialSpeed.y() < 0) { dy = 0; vy = 0; @@ -110,12 +104,10 @@ QPoint distPos = m_initialPos + QPointF(dx, dy).toPoint(); if (vx != 0 || vy != 0) { - qDebug() << "kineticScroll(): scroll from " << scrollPos << " to " << distPos; m_scrollable->scrollTo(distPos); } if ((vx == 0 && vy == 0) || scrollPos == m_scrollable->getScrollPosition()) { - qDebug() << "kineticScroll(): stopping timer"; stopScrolling(); } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ObjectCharm.cpp --- a/ginebra2/ObjectCharm.cpp Wed Jun 23 17:59:43 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ - -#include -#include -#include -#include -#include - -#include "ObjectCharm.h" - -namespace GVA { - -// ---------------------------- -// ObjectCharm -// ---------------------------- - -ObjectCharm::ObjectCharm(QObject *object) - : m_object(object) -{ - m_object->installEventFilter(this); - connect(m_object, SIGNAL(destroyed()), this, SLOT(onObjectDestroyed())); -} - -void ObjectCharm::onObjectDestroyed() { - deleteLater(); -} - -// ---------------------------- -// ExternalEventCharm -// ---------------------------- - -inline QGraphicsScene *ExternalEventCharm::scene() { - QGraphicsObject *item = static_cast(m_object); - return item->scene(); -} - -ExternalEventCharm::ExternalEventCharm(QGraphicsObject *object) - : ObjectCharm(object) -{ -} - -bool ExternalEventCharm::eventFilter(QObject *object, QEvent *event) { - //qDebug() << "ExternalEventCharm::eventFilter: " << object << event; - // Check for external events grabbed by this item. - - checkForExternalEvent(this, event); - - switch (event->type()) { - case QEvent::Show: - { - scene()->installEventFilter(this); - break; - } - case QEvent::Hide: - { - scene()->removeEventFilter(this); - break; - } - default: break; - } - - // standard event processing - return object->eventFilter(object, event); -} - -void ExternalEventCharm::checkForExternalEvent(QObject * o, QEvent * e) -{ - Q_UNUSED(o); - - // Ignore all but a few mouse press events. - - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseDoubleClick: - break; - default: - return; - } - - QGraphicsSceneMouseEvent * me = static_cast(e); - - QPointF eventPosition = me->scenePos(); - - QGraphicsObject *item = static_cast(m_object); - - QRectF itemGeometry = item->sceneBoundingRect(); - - if (!itemGeometry.contains(eventPosition)) { - emitExternalEvent(e); - } -} - -void ExternalEventCharm::emitExternalEvent(QEvent * e) -{ - QString description; - - QDebug stream(&description); - stream << e; - - QString name = description; - name.truncate(name.indexOf('(')); - - emit externalMouseEvent(e->type(), name, description.trimmed()); -} - -// ---------------------------- -// TouchCircleCharm -// ---------------------------- - -TouchCircleCharm::TouchCircleCharm(QObject *object, QGraphicsItem *parent) - : ObjectCharm(object), - m_timer(new QTimer()) -{ - m_item = new QGraphicsEllipseItem(QRect(0,0,20,20), parent); - m_item->hide(); - m_item->setPen(QPen(QColor(Qt::black))); - m_item->setBrush(QBrush(QColor(200, 0, 0))); - m_item->setZValue(100); // make sure it isn't obscured - - m_timer->setSingleShot(true); - connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimer())); -} - -TouchCircleCharm::~TouchCircleCharm() { - delete m_item; - delete m_timer; -} - -bool TouchCircleCharm::eventFilter(QObject *object, QEvent *event) { - switch (event->type()) { - case QEvent::GraphicsSceneMousePress: { - // Show the item. - QGraphicsSceneMouseEvent * me = static_cast(event); - m_item->setPos(me->scenePos().x() - m_item->rect().width()/2, - me->scenePos().y() - m_item->rect().height()/2); - - // Change the color to indicate click. - m_item->setBrush(QBrush(QColor(0, 0, 200))); - - m_item->show(); - m_timer->stop(); - break; - } - case QEvent::GraphicsSceneMouseMove: { - if(m_item->isVisible()) { - // Move it to new position. - QGraphicsSceneMouseEvent * me = static_cast(event); - m_item->setPos(me->scenePos().x() - m_item->rect().width()/2, - me->scenePos().y() - m_item->rect().height()/2); - - // Change the color to indicate drag. - m_item->setBrush(QBrush(QColor(200, 0, 0))); - } - break; - } - case QEvent::GraphicsSceneMouseDoubleClick: { - if(m_item->isVisible()) { - // Change the color to indicate double click. - m_item->setBrush(QBrush(QColor(0, 200, 0))); - - m_timer->stop(); - } - break; - } - case QEvent::GraphicsSceneMouseRelease: { - if(m_item->isVisible()) { - // Start timer to hide it. - m_timer->start(2000); - } - break; - } - } - return object->eventFilter(object, event); -} - -void TouchCircleCharm::onTimer() { // slot - m_item->hide(); -} - -} // namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ObjectCharm.h --- a/ginebra2/ObjectCharm.h Wed Jun 23 17:59:43 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ - - -#ifndef OBJECTCHARM_H_ -#define OBJECTCHARM_H_ - -#include - -class QGraphicsObject; -class QGraphicsScene; -class QGraphicsItem; - -namespace GVA { - -// ------------------------------- - -/*! - * Base class for object "charms". Charms set an event filter on a particular - * object and perform some action in response to the events sent to the object. - * ObjectCharms automatically destroy themselves when the target object is - * destroyed. - */ -class ObjectCharm : public QObject { - Q_OBJECT - public: - ObjectCharm(QObject *object); - - private slots: - virtual void onObjectDestroyed(); - - protected: - QObject *m_object; -}; - -// ------------------------------- - -/*! - * This class emits a signal when the user clicks outside of the given graphics object. - */ -class ExternalEventCharm : public ObjectCharm { - Q_OBJECT - public: - ExternalEventCharm(QGraphicsObject *object); - - signals: - /*! This signal is emitted when the user clicks outside of the object. - * \param type The Qt event type. - * \param name The Qt event name. - * \param description The Qt event description. - */ - void externalMouseEvent( - int type, - const QString & name, - const QString & description); - private: - void checkForExternalEvent(QObject * o, QEvent * e); - void emitExternalEvent(QEvent * e); - bool eventFilter(QObject *object, QEvent *event); - QGraphicsScene *scene(); -}; - -// ------------------------------- - -/*! - * This class draws a circle in response to mouse click events on the given object. Intended - * for testing purposes only. - */ -class TouchCircleCharm : public ObjectCharm { - Q_OBJECT - public: - TouchCircleCharm(QObject *object, QGraphicsItem *parent = 0); - ~TouchCircleCharm(); - - private slots: - void onTimer(); - - private: - bool eventFilter(QObject *object, QEvent *event); - - class QGraphicsEllipseItem * m_item; - class QTimer * m_timer; -}; - -} - -#endif /* OBJECTCHARM_H_ */ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PageItem.cpp --- a/ginebra2/PageItem.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PageItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,7 +22,7 @@ #include "PageItem.h" #include "GWebTouchNavigation.h" #include "Utilities.h" -#include "GWebPage.h" +#include "GSuperWebPage.h" #include "ChromeWidget.h" #include @@ -45,7 +45,7 @@ // --------------------------------- PageItem::PageItem(ChromeSnippet * snippet, ChromeWidget* chrome) - : NativeChromeItem(snippet, chrome), + : NativeChromeItem(snippet, chrome->layout()), m_webView(0), m_touchNavigation(0), m_superPage(0), @@ -68,8 +68,6 @@ return; } - qDebug() << "PageItem::instantiate"; - // Create the web page. m_page = new WebPageWrapper(this, "Page snippet javascript error"); m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); @@ -88,7 +86,6 @@ // Create the web view. m_webView = new PageItemWebView(this); m_webView->setPage(m_page); - safe_connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); m_touchNavigation = new GWebTouchNavigation(m_page, m_webView); @@ -115,7 +112,6 @@ } void PageItem::cleanUp() { // slot - qDebug() << "PageItem::cleanUp"; delete m_cleanupTimer; m_cleanupTimer = 0; delete m_touchNavigation; @@ -128,7 +124,6 @@ } void PageItem::resizeEvent(::QGraphicsSceneResizeEvent *event) { - qDebug() << "PageItem::resizeEvent: " << event->newSize(); setWebViewSize(event->newSize()); } @@ -187,7 +182,6 @@ //} QVariant PageItem::evaluateJavaScript(const QString &expression) { - qDebug() << "PageItem::evaluateJavaScript: " << expression; if (m_webView) { QWebFrame *frame = m_webView->page()->mainFrame(); if (frame) @@ -196,8 +190,4 @@ return QVariant(); } -void PageItem::onLoadFinished(bool ok) { // slot - qDebug() << "PageItem::onLoadFinished: " << ok; -} - } // GVA namespace diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PageItem.h --- a/ginebra2/PageItem.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PageItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -27,7 +27,6 @@ #include class QGraphicsWebView; -class FlickCharm; namespace GVA { @@ -62,7 +61,6 @@ void cleanUpOnTimer(); public slots: - void onLoadFinished(bool ok); void cleanUp(); protected: diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PageSnippet.cpp --- a/ginebra2/PageSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PageSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,7 +22,7 @@ #include "PageSnippet.h" #include "PageItem.h" #include "Utilities.h" -#include "ObjectCharm.h" +#include "ExternalEventCharm.h" #include #include @@ -47,32 +47,38 @@ PageSnippet::PageSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element) - : ChromeSnippet(elementId, chrome, widget, element) + : ChromeSnippet(elementId, chrome, widget, element), + m_externalEventCharm(0) { } -void PageSnippet::setWidget(QGraphicsWidget * widget) { - ChromeSnippet::setWidget(widget); - ExternalEventCharm *charm = new ExternalEventCharm(widget); // auto deleted - safe_connect(charm, SIGNAL(externalMouseEvent(int, const QString &, const QString &)), - this, SIGNAL(externalMouseEvent(int, const QString &, const QString &))); +PageSnippet::~PageSnippet() { + delete m_externalEventCharm; +} + +PageSnippet * PageSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) +{ + PageSnippet* that = new PageSnippet(elementId, chrome, 0, element); + that->setChromeWidget( new PageItem( that, chrome ) ); + return that; +} + +void PageSnippet::setChromeWidget(QGraphicsWidget * widget) { + ChromeSnippet::setChromeWidget(widget); + m_externalEventCharm = new ExternalEventCharm(widget); + safe_connect(m_externalEventCharm, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &)), + this, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &))); } void PageSnippet::setVisible(bool visiblity, bool animate) { - qDebug() << "PageSnippet::setVisible: " << visiblity; ChromeSnippet::setVisible(visiblity, animate); } -void PageSnippet::onLoadFinished(bool ok) { // slot - qDebug() << "PageSnippet::onLoadFinished: " << ok; -} - QString PageSnippet::url() const { return constPageItem()->url(); } void PageSnippet::setUrl(const QString &url) { - qDebug() << "PageSnippet::setUrl: " << url; pageItem()->setUrl(url); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PageSnippet.h --- a/ginebra2/PageSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PageSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -49,10 +49,13 @@ public: PageSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); + ~PageSnippet(); + + static PageSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); // ChromeSnippet overrides: virtual void setVisible(bool visiblity, bool animate = true); - virtual void setWidget(QGraphicsWidget * widget); + virtual void setChromeWidget(QGraphicsWidget * widget); /// The URL of the web page. QString url() const; @@ -78,13 +81,11 @@ /// Destroys the web view, web page, etc. to free up memory. void cleanUp(); -private slots: - /// Called when the page has finished loading. - void onLoadFinished(bool ok); - private: PageItem *pageItem(); PageItem const *constPageItem() const; + + ExternalEventCharm *m_externalEventCharm; }; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PopupWebChromeItem.cpp --- a/ginebra2/PopupWebChromeItem.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PopupWebChromeItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,50 +22,48 @@ #include "PopupWebChromeItem.h" #include "ChromeWidget.h" #include "WebChromeSnippet.h" +#include "ExternalEventCharm.h" namespace GVA { PopupWebChromeItem::PopupWebChromeItem( - const QRectF & ownerArea, ChromeWidget * chrome, const QWebElement & element, QGraphicsItem * parent, bool modal) -: WebChromeItem(ownerArea, chrome, element, parent), - m_modal(modal) +: WebChromeItem(chrome, element, parent), + m_modal(modal), + m_externalEventCharm(0) { } PopupWebChromeItem::~PopupWebChromeItem() -{} +{ + delete m_externalEventCharm; +} void PopupWebChromeItem::init(WebChromeSnippet * snippet) { WebChromeItem::init(snippet); + m_externalEventCharm = new ExternalEventCharm(this); // Forward externalMouseEvent signals from context items. QObject::connect( - this, - SIGNAL(externalMouseEvent(int, const QString &, const QString &)), + m_externalEventCharm, + SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &)), snippet, - SIGNAL(externalMouseEvent(int, const QString &, const QString &))); + SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &))); } bool PopupWebChromeItem::event(QEvent * e) { - // Check for external events grabbed by this item. - - checkForExternalEvent(this, e); - switch (e->type()) { case QEvent::Show: - scene()->installEventFilter(this); if(snippet() && m_modal) { chrome()->emitPopupShown(snippet()->objectName()); } break; case QEvent::Hide: - scene()->removeEventFilter(this); if(snippet() && m_modal) { chrome()->emitPopupHidden(snippet()->objectName()); } @@ -78,78 +76,4 @@ return WebChromeItem::event(e); } -bool PopupWebChromeItem::eventFilter(QObject * o, QEvent * e) -{ - // Check for external events NOT grabbed by this item. - - checkForExternalEvent(o, e); - - // Don't filter any events. - - return false; -} - -void PopupWebChromeItem::checkForExternalEvent(QObject * o, QEvent * e) -{ - Q_UNUSED(o); - - // Ignore all events when this item is not showing. - - if (!isVisible()) { - return; - } - - // Ignore all but a few mouse press events. - - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseDoubleClick: -// Commented out because new context menu resizes itself, don't want externalMouseEvents -// in that case. -// case QEvent::GraphicsSceneResize: - break; - default: - return; - } - - // Check where the mouse press event occurred. - // If it was outside this item's bounding rectangle, - // then tell the world. - -// Commented out because new context menu resizes itself, don't want externalMouseEvents -// in that case. -// if (e->type() == QEvent::GraphicsSceneResize) -// { -// QGraphicsSceneResizeEvent *resizeEvent = static_cast(e); -// qDebug() << "PopupWebChromeItem::checkForExternalEvent: " << resizeEvent->newSize() << resizeEvent->oldSize(); -// if (resizeEvent->newSize() != resizeEvent->oldSize()) -// emitExternalEvent(e); -// return; -// } - - QGraphicsSceneMouseEvent * me = static_cast(e); - - QPointF eventPosition = me->scenePos(); - - QRectF itemGeometry = sceneBoundingRect(); - - if (!itemGeometry.contains(eventPosition)) { - emitExternalEvent(e); - } -} - -void PopupWebChromeItem::emitExternalEvent(QEvent * e) -{ - QString description; - - QDebug stream(&description); - stream << e; - - QString name = description; - name.truncate(name.indexOf('(')); - - emit externalMouseEvent(e->type(), name, description.trimmed()); -} - } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/PopupWebChromeItem.h --- a/ginebra2/PopupWebChromeItem.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/PopupWebChromeItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -59,7 +59,6 @@ public: PopupWebChromeItem( - const QRectF & ownerArea, ChromeWidget * chrome, const QWebElement & element, QGraphicsItem * parent = 0, @@ -71,19 +70,17 @@ signals: void externalMouseEvent( - int type, + QEvent * ev, const QString & name, const QString & description); -protected: - virtual bool event(QEvent * event); - virtual bool eventFilter(QObject * object, QEvent * event); - private: void checkForExternalEvent(QObject * object, QEvent * event); void emitExternalEvent(QEvent * event); + bool event(QEvent * e); bool m_modal; + class ExternalEventCharm *m_externalEventCharm; }; } // end of namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/RecentUrlToolbarSnippet.cpp --- a/ginebra2/RecentUrlToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/RecentUrlToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,6 +22,7 @@ */ #include "RecentUrlToolbarSnippet.h" +#include "ToolbarChromeItem.h" #include "ViewStack.h" #include "GWebContentView.h" #include "BookmarksManager.h" @@ -30,8 +31,8 @@ namespace GVA { RecentUrlToolbarSnippet::RecentUrlToolbarSnippet(const QString& elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : DualButtonToolbarSnippet(elementId, chrome, ownerArea, element, widget), + const QWebElement & element) + : DualButtonToolbarSnippet(elementId, chrome, element), m_action1(0) { } @@ -42,6 +43,13 @@ delete m_action1; } + RecentUrlToolbarSnippet * RecentUrlToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + RecentUrlToolbarSnippet * that = new RecentUrlToolbarSnippet( elementId, chrome, element ); + that->setChromeWidget( new ToolbarChromeItem( that ) ); + return that; + } + void RecentUrlToolbarSnippet::addChild(ChromeSnippet * child) { WebChromeContainerSnippet * s = dynamic_cast(child); if (!s) { @@ -49,16 +57,16 @@ if (child->elementId() == "RecentBackButton" ) { t->actionId = RECENTURL_VIEW_ACTION_BACK; t->actionName = RECENTURL_TOOLBAR_BACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; } else if (child->elementId() == "RecentClearallButton" ) { t->actionId = RECENTURL_VIEW_ACTION_CLEARALL; t->actionName = RECENTURL_TOOLBAR_CLEARALL; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall.png"; t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_disabled.png"; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_pressed.png"; } t->id = child->elementId(); m_actionInfo.append(t); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/RecentUrlToolbarSnippet.h --- a/ginebra2/RecentUrlToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/RecentUrlToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -38,8 +38,9 @@ { Q_OBJECT public: - RecentUrlToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + RecentUrlToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~RecentUrlToolbarSnippet(); + static RecentUrlToolbarSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); private Q_SLOTS: /// Back action trigger handler. Switches back to webview diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ScrollableViewBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ScrollableViewBase.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#include "ScrollableViewBase.h" + + +#include "Kinetics/KineticScroller.h" + +#include +#include +#include + +namespace GVA { + +ScrollableViewBase::ScrollableViewBase(QGraphicsItem* parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent, wFlags) + , m_scrollWidget(0) +{ + //To get only the mouse events within the ScrollableViewBase. + setFlag(QGraphicsItem::ItemClipsToShape, true); + + //To disable childrens painting outside the ViewportItem's rect. + setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); + + //To speed up painting. + setFlag(QGraphicsItem::ItemHasNoContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + + m_kineticScroller = new KineticScroller(this); + + //Event filter on all children of the viewport, so that all mouse + //events can be intercepted and used for kinetic scrolling. + setFiltersChildEvents(true); +} + +ScrollableViewBase::~ScrollableViewBase() +{} + +void ScrollableViewBase::setWidget(QGraphicsWidget* view) +{ + if (view == m_scrollWidget) + return; + + if (m_scrollWidget) { + m_scrollWidget->setParentItem(0); + delete m_scrollWidget; + } + + m_scrollWidget = view; + m_scrollWidget->setAttribute(Qt::WA_OpaquePaintEvent, true); + m_scrollWidget->setParentItem(this); +} + +QSize ScrollableViewBase::viewportSize() const +{ + return size().toSize(); +} + +QPoint ScrollableViewBase::maximumScrollPosition() const +{ + QSizeF contentsSize = m_scrollWidget->size(); + QSizeF viewportSize = size(); + QSize maxScrollSize = (contentsSize - viewportSize).toSize(); + + return QPoint(qMax(0, maxScrollSize.width()), qMax(0, maxScrollSize.height())); +} + +QPoint ScrollableViewBase::scrollPosition() const +{ + return (-scrollWidgetPos()).toPoint(); +} + +void ScrollableViewBase::setScrollPosition(const QPoint& pos, const QPoint& overShoot) +{ + m_overShoot = overShoot; + setScrollWidgetPos(-pos); +} + +void ScrollableViewBase::stateChanged(KineticScrollable::State oldState + , KineticScrollable::State newState) +{ + Q_UNUSED(oldState); + Q_UNUSED(newState); +} + +void ScrollableViewBase::setScrollWidgetGeometry(const QRectF& geom) +{ + scrollWidget()->setGeometry(adjustScrollWidgetRect(geom)); +} + +QRectF ScrollableViewBase::adjustScrollWidgetRect(const QRectF& rect) +{ + //FIX ME : Stop animation of scroll widget before adjusting it here?? + QRectF newRect(rect); + + QSizeF widgetSize = rect.size(); + QSizeF viewportSize = size(); + + qreal w = viewportSize.width() - widgetSize.width(); + qreal h = viewportSize.height() - widgetSize.height(); + + if ( w > 0 ) { + newRect.moveLeft(0); + m_extraPos.setX(w/2); + } + else { + m_extraPos.setX(0); + if (newRect.x() < w) + newRect.moveLeft(w); + if (newRect.x() > 0) + newRect.moveLeft(0); + } + + if ( h > 0 ) { + m_extraPos.setY(h/2); + newRect.moveTop(0); + } + else { + m_extraPos.setY(0); + if (newRect.y() < h) + newRect.moveTop(h); + if (newRect.y() > 0) + newRect.moveTop(0); + } + //newRect.translate(m_extraPos); + newRect.translate(m_overShoot); + return newRect; +} + +void ScrollableViewBase::setScrollWidgetPos(const QPointF& pos) +{ + setScrollWidgetGeometry(QRectF(pos, scrollWidget()->size())); +} + +QPointF ScrollableViewBase::scrollWidgetPos() const +{ + return scrollWidget()->pos() /*- m_extraPos*/ - m_overShoot; +} + +} //namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ScrollableViewBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/ScrollableViewBase.h Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". +* +* Description: +* +*/ + +#ifndef ScrollableViewBase_h +#define ScrollableViewBase_h + +#include "Kinetics/KineticScrollable.h" + +#include + +namespace GVA { + +class KineticScroller; + +class ScrollableViewBase : public QGraphicsWidget, public KineticScrollable { +public: + ScrollableViewBase(QGraphicsItem* parent = 0, Qt::WindowFlags wFlags = 0); + ~ScrollableViewBase(); + + void setWidget(QGraphicsWidget*); + +protected: + + //KineticScrollable pure virtuals + QSize viewportSize() const; + QPoint maximumScrollPosition() const ; + QPoint scrollPosition() const; + void setScrollPosition(const QPoint& pos, const QPoint& overshootDelta); + void stateChanged(KineticScrollable::State oldState, KineticScrollable::State newState); + + QGraphicsWidget* scrollWidget() const { return m_scrollWidget; } + virtual void setScrollWidgetGeometry(const QRectF& r); + QRectF adjustScrollWidgetRect(const QRectF&); + + //Helpers for adjusting scroll pos + void setScrollWidgetPos(const QPointF& pos); + QPointF scrollWidgetPos() const; + +protected: + KineticScroller* m_kineticScroller; + +private: + QGraphicsWidget* m_scrollWidget; + QPointF m_overShoot; + QPointF m_extraPos; +}; //ScrollableViewBase + +} //namespace GVA + +#endif //ScrollableViewBase_h diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SettingsToolbarSnippet.cpp --- a/ginebra2/SettingsToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SettingsToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,6 +22,7 @@ */ #include "SettingsToolbarSnippet.h" +#include "ToolbarChromeItem.h" #include "ViewStack.h" #include "GWebContentView.h" #include "webpagecontroller.h" @@ -30,8 +31,8 @@ namespace GVA { SettingsToolbarSnippet::SettingsToolbarSnippet(const QString& elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : DualButtonToolbarSnippet(elementId, chrome, ownerArea, element, widget), + const QWebElement & element) + : DualButtonToolbarSnippet(elementId, chrome, element), m_action1(0), m_action2(0) { } @@ -44,6 +45,13 @@ delete m_action2; } + SettingsToolbarSnippet * SettingsToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + SettingsToolbarSnippet * that = new SettingsToolbarSnippet( elementId, chrome, element ); + that->setChromeWidget( new ToolbarChromeItem( that ) ); + return that; + } + void SettingsToolbarSnippet::addChild(ChromeSnippet * child) { WebChromeContainerSnippet * s = dynamic_cast(child); if (!s) { @@ -51,16 +59,16 @@ if (child->elementId() == "SettingsBackButton" ) { t->actionId = SETTINGS_VIEW_ACTION_BACK; t->actionName = SETTINGS_TOOLBAR_BACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; } else if (child->elementId() == "SettingsFeedbackButton" ) { t->actionId = SETTINGS_VIEW_ACTION_FEEDBACK; t->actionName = SETTINGS_TOOLBAR_FEEDBACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_feedback.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_feedback.png"; t->disabledImg = ""; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_feedback_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_feedback_pressed.png"; } t->id = child->elementId(); m_actionInfo.append(t); @@ -100,6 +108,10 @@ void SettingsToolbarSnippet::handleBackButton() { GWebContentView* webView = static_cast (chrome()->getView("WebView")); if(webView) { + // Reloading here because otherwise the settings won't collapse when leaving and + // re-entering the view. This fixes BR-3525. If there's a better way to do this in + // the future this can be removed. + webView->reload(); webView->showNormalPage(); webView->setGesturesEnabled(true); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SettingsToolbarSnippet.h --- a/ginebra2/SettingsToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SettingsToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -36,8 +36,9 @@ { Q_OBJECT public: - SettingsToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + SettingsToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~SettingsToolbarSnippet(); + static SettingsToolbarSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); private Q_SLOTS: // Back action trigger handler. Switches back to webview diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SlidingWidget.cpp --- a/ginebra2/SlidingWidget.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SlidingWidget.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -55,8 +55,6 @@ void SlidingWidget::resizeEvent(QGraphicsSceneResizeEvent *ev) { - qDebug() << "SlidingWidget::resizeEvent: " << ev->newSize(); - qDebug()<<"m_shrinked="<resize(ev->newSize()); m_windowSize = ev->newSize(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/Snippets.cpp --- a/ginebra2/Snippets.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/Snippets.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -61,9 +61,9 @@ foreach(ChromeSnippet *snippet, m_snippetMap){ if (snippet){ //If anchored, shrink the anchor bar - m_chrome->snippetHiding(snippet); + m_chrome->layout()->snippetHiding(snippet); //Remove about-to-be-deleted snippet from scene - m_chrome->getScene()->removeItem(snippet->widget()); + m_chrome->layout()->scene()->removeItem(snippet->widget()); delete snippet; } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SystemDeviceImpl.cpp --- a/ginebra2/SystemDeviceImpl.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SystemDeviceImpl.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -38,8 +38,6 @@ // set current charging state then keep it up to date with signal handler m_batteryCharging = (m_deviceInfo->currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) ? true : false; - qDebug() << "DeviceDelegate: charging state = " << m_deviceInfo->currentPowerState(); - qDebug() << "DeviceDelegate: charging = " << m_batteryCharging; safe_connect(m_deviceInfo, SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), this, SLOT(handlePowerStateChanged(QSystemDeviceInfo::PowerState))); } @@ -65,7 +63,6 @@ bool batteryCharging = (state == QSystemDeviceInfo::WallPowerChargingBattery) ? true : false; - qDebug() << "DeviceDelegate: new charging state = " << state; if (batteryCharging != m_batteryCharging) { m_batteryCharging = batteryCharging; //qDebug() << "DeviceDelegate: new charging = " << m_batteryCharging; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SystemNetworkImpl.cpp --- a/ginebra2/SystemNetworkImpl.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SystemNetworkImpl.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -29,8 +29,11 @@ namespace GVA { +#define WCDMA2GSM_WORKAROUND // work around for QtMobility issue + SystemNetworkImpl::SystemNetworkImpl() - : m_currentMode(QSystemNetworkInfo::UnknownMode) + : m_currentMode(QSystemNetworkInfo::UnknownMode), + m_sessionNetworkName("") { // create Qt Mobility API objects for network information m_networkInfo = new QSystemNetworkInfo(this); @@ -49,17 +52,16 @@ QSystemNetworkInfo::NetworkMode, QSystemNetworkInfo::NetworkStatus)), this, SLOT(handleNetworkStatusChanged(QSystemNetworkInfo::NetworkMode, QSystemNetworkInfo::NetworkStatus))); -#ifdef QT_MOBILITY_BEARER_MANAGEMENT +#ifdef QT_MOBILITY_BEARER_MANAGEMENT // Get the singleton instance of WebNetworkConnectionManager WRT::WebNetworkConnectionManager &webNetworkConnectionManager = WRT::WebNetworkConnectionManagerSingleton::Instance(); - - safe_connect(&webNetworkConnectionManager, SIGNAL(networkNameChanged( + + safe_connect(&webNetworkConnectionManager, SIGNAL(networkOnlineStateChanged(bool)), + this, SLOT(handleNetworkOnlineStateChanged(bool))); + safe_connect(&webNetworkConnectionManager, SIGNAL(networkSessionNameChanged( QSystemNetworkInfo::NetworkMode, const QString&)), this, - SLOT(handleNetworkNameChanged(QSystemNetworkInfo::NetworkMode, const QString&))); - safe_connect(&webNetworkConnectionManager, SIGNAL(networkSignalStrengthChanged( - QSystemNetworkInfo::NetworkMode, int)), this, - SLOT(handleNetworkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode, int))); + SLOT(handleNetworkSessionNameChanged(QSystemNetworkInfo::NetworkMode, const QString&))); // Update all configurations webNetworkConnectionManager.updateConfigurations(); @@ -74,28 +76,43 @@ //! Gets the network name for the current network mode. QString SystemNetworkImpl::getNetworkName() const { - QString netName = m_networkInfo->networkName(m_currentMode); + QString netName; - // if WLAN SSID name is unknown show "WiFi" - if ((m_currentMode == QSystemNetworkInfo::WlanMode) && - (netName == "")) { - netName = "WiFi"; + switch(m_currentMode) { + case QSystemNetworkInfo::WlanMode: + case QSystemNetworkInfo::EthernetMode: + case QSystemNetworkInfo::BluetoothMode: + case QSystemNetworkInfo::WimaxMode: + // for wireless cases use name from session. +#ifdef QT_MOBILITY_BEARER_MANAGEMENT + netName = m_sessionNetworkName; +#else + netName = m_networkInfo->networkName(m_currentMode); + // if WLAN SSID name is unknown show "WiFi" + if (netName == "") + netName = "WiFi"; +#endif // QT_MOBILITY_BEARER_MANAGEMENT + break; + + default: + netName = m_networkInfo->networkName(m_currentMode); + break; } - //qDebug() << "DeviceDelegate: network name " << netName; + qDebug() << "SystemNetworkImpl::getNetworkName: network name " << netName; return (netName); } //! Gets the network signal strength for the current network mode. int SystemNetworkImpl::getNetworkSignalStrength() const { - int strength = m_networkInfo->networkSignalStrength(m_currentMode); - + int strength = m_networkInfo->networkSignalStrength(m_currentMode); + // Strength in WLAN mode is reported as -1 by QtMobility if ((strength == -1) && (m_currentMode == QSystemNetworkInfo::WlanMode)) { strength = 100; } - + return (strength); } @@ -106,8 +123,7 @@ void SystemNetworkImpl::handleNetworkModeChanged( QSystemNetworkInfo::NetworkMode mode) { - qDebug() << "handleNetworkModeChanged" << "Mode:" << mode; - m_currentMode = mode; + qDebug() << "SystemNetworkImpl::handleNetworkModeChanged" << "Mode:" << mode; } //! Handles the networkSignalStrengthChanged signal from system network info. @@ -118,15 +134,17 @@ void SystemNetworkImpl::handleNetworkSignalStrengthChanged( QSystemNetworkInfo::NetworkMode mode, int strength) { - qDebug() << "handleNetworkSignalStrengthChanged" << "Mode:" << mode << "strength:" << strength; + qDebug() << "SystemNetworkImpl::handleNetworkSignalStrengthChanged" << "Mode:" << mode << "strength:" << strength; + + // Only send signal strength changes for current mode. + if (mode == m_currentMode) { + // Unknown mode could mean network error so send negative strength to indicate offline. + if (m_currentMode == QSystemNetworkInfo::UnknownMode) + strength = -1; - // Bootstrap the mode change if no networkModeChanged signal is recived - if (m_currentMode == 0) - m_currentMode = mode; - - // Only send signal strength changes for current mode. - if (mode == m_currentMode) + qDebug() << "SystemNetworkImpl::handleNetworkSignalStrengthChanged" << "emit strength:" << strength; emit networkSignalStrengthChanged(strength); + } } //! Handles the networkNameChanged signal from system network info. @@ -137,15 +155,13 @@ void SystemNetworkImpl::handleNetworkNameChanged( QSystemNetworkInfo::NetworkMode mode, const QString& name) { - qDebug() << "handleNetworkStatusChanged" << "Mode:" << mode << "name:" << name; - - // Bootstrap the mode change if no networkModeChanged signal is recived - if (m_currentMode == 0) - m_currentMode = mode; - + qDebug() << "SystemNetworkImpl::handleNetworkNameChanged" << "Mode:" << mode << "name:" << name; + // Only send network name changes for current mode. - if (mode == m_currentMode) + if (mode == m_currentMode) { + // Now update name. emit networkNameChanged(name); + } } //! Handles the networkStatusChanged signal from system network info. @@ -156,8 +172,73 @@ void SystemNetworkImpl::handleNetworkStatusChanged( QSystemNetworkInfo::NetworkMode mode, QSystemNetworkInfo::NetworkStatus status) { - qDebug() << "handleNetworkSignalStrengthChanged" << "Mode:" << mode << "status:" << status; + qDebug() << "SystemNetworkImpl::handleNetworkStatusChanged" << "mode: " << mode << "status: " << status; +} + +#ifdef QT_MOBILITY_BEARER_MANAGEMENT +//! Handles online state changed signal from the web network connection manager. +/*! + \param mode network mode of connection that changed +*/ +void SystemNetworkImpl::handleNetworkOnlineStateChanged(bool isOnline) +{ + qDebug() << "SystemNetworkImpl::handleOnlineStateChanged" << "isOnline:" << isOnline; + + // Offline indicates no active network configurations. + if (!isOnline) { + qDebug() << "SystemNetworkImpl::handleOnlineStateChanged: change mode to unknown, emit -1 str"; + m_currentMode = QSystemNetworkInfo::UnknownMode; + // negative strength indicates offline to UI + emit networkSignalStrengthChanged(-1); + } + // Online indicates at least 1 active network config but not necessarily + // one being used by the browser. } +void SystemNetworkImpl::handleNetworkSessionNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString& name) +{ + // UI must get non-negative strength to indicate online status + int strength = m_networkInfo->networkSignalStrength(mode); + + qDebug() << "SystemNetworkImpl::handleNetworkSessionNameChanged" << "Mode:" << mode << "name:" << name << "strength:" << strength; + + switch (mode) { + case QSystemNetworkInfo::WlanMode: + case QSystemNetworkInfo::EthernetMode: + case QSystemNetworkInfo::BluetoothMode: + case QSystemNetworkInfo::WimaxMode: + // for wireless cases use name from session. + m_sessionNetworkName = name; + break; + + default: + // clear session name - not needed in this mode + m_sessionNetworkName = ""; + break; + } + +#ifdef WCDMA2GSM_WORKAROUND + // Work around for QtMobility issue. Bearer management reports WCDMA bearer but + // QSystemNetworkInfo sees connection as GSM mode. + if ((mode == QSystemNetworkInfo::WcdmaMode) && (strength < 0)) { + strength = m_networkInfo->networkSignalStrength(QSystemNetworkInfo::GsmMode); + if (strength >= 0) + mode = QSystemNetworkInfo::GsmMode; + } +#endif + + qDebug() << "SystemNetworkImpl::handleNetworkSessionNameChanged: set mode to " << mode; + m_currentMode = mode; + + // emit signal strength of new connection, + // use wrapper access method for correct WLAN strength + qDebug() << "SystemNetworkImpl::handleNetworkSessionNameChanged: emit str=" << getNetworkSignalStrength(); + emit networkSignalStrengthChanged(getNetworkSignalStrength()); + + // Update network name on mode change. + qDebug() << "SystemNetworkImpl::handleNetworkSessionNameChanged: emit network name= " << getNetworkName(); + emit networkNameChanged(getNetworkName()); +} +#endif // QT_MOBILITY_BEARER_MANAGEMENT + } // GVA - diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/SystemNetworkImpl.h --- a/ginebra2/SystemNetworkImpl.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/SystemNetworkImpl.h Tue Jul 06 14:03:49 2010 +0300 @@ -49,10 +49,15 @@ void handleNetworkNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString& name); void handleNetworkStatusChanged(QSystemNetworkInfo::NetworkMode mode, QSystemNetworkInfo::NetworkStatus status); +#ifdef QT_MOBILITY_BEARER_MANAGEMENT + void handleNetworkOnlineStateChanged(bool isOnline); + void handleNetworkSessionNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString& name); +#endif // QT_MOBILITY_BEARER_MANAGEMENT private: QSystemNetworkInfo *m_networkInfo; QSystemNetworkInfo::NetworkMode m_currentMode; + QString m_sessionNetworkName; }; } // GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/Toolbar.h --- a/ginebra2/Toolbar.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/Toolbar.h Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,20 @@ namespace GVA { + enum ContentToolbarTimerState { + CONTENT_TOOLBAR_TIMER_STATE_NONE, + CONTENT_TOOLBAR_TIMER_STATE_ALLOW + }; + + enum ContentToolbarState { + + CONTENT_TOOLBAR_STATE_FULL, + CONTENT_TOOLBAR_STATE_PARTIAL, + CONTENT_TOOLBAR_STATE_ANIM_TO_PARTIAL, + CONTENT_TOOLBAR_STATE_ANIM_TO_FULL, + CONTENT_TOOLBAR_STATE_INVALID + }; + enum ContentViewActions { CONTENT_VIEW_ACTION_BACK, @@ -62,14 +76,21 @@ int actionId; QString actionName; + QString normalImg; QString activeImg; QString disabledImg; - QString selectedImg; QString id; }; +#define TOOLBAR_BUTTON_PATH ":/chrome/bedrockchrome/toolbar.snippet/icons/" +#define TOOLBAR_FULL_TB_TOGGLE_ICON TOOLBAR_BUTTON_PATH "icon_toggle_fullTB.png" +#define TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON TOOLBAR_BUTTON_PATH "icon_toggle_fullTB_pressed.png" +#define TOOLBAR_PARTIAL_TB_TOGGLE_ICON TOOLBAR_BUTTON_PATH "icon_toggle_partialTB.png" +#define TOOLBAR_PARTIAL_TB_SELECTED_TOGGLE_ICON TOOLBAR_BUTTON_PATH "icon_toggle_partialTB_pressed.png" -#define TOOLBAR_POPUP_INACTIVITY_DURATION 5000 + + +#define TOOLBAR_POPUP_INACTIVITY_DURATION 8000 #define TOOLBAR_ZOOMBAR_INACTIVITY_DURATION 8000 #define DUAL_TOOLBAR_NUM_BUTTONS 2 diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ToolbarChromeItem.cpp --- a/ginebra2/ToolbarChromeItem.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ToolbarChromeItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,7 @@ #include "NativeChromeItem.h" #include "GWebContentView.h" #include "WebChromeContainerSnippet.h" +#include "ChromeEffect.h" #include @@ -33,12 +34,12 @@ namespace GVA { - ToolbarChromeItem::ToolbarChromeItem(QGraphicsItem* parent) + ToolbarChromeItem::ToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent) : ChromeItem(NULL, parent), m_partialbg(NULL), m_opacity(TOOLBAR_BG_OPACITY) { - + setSnippet(snippet); } ToolbarChromeItem::~ToolbarChromeItem() @@ -76,6 +77,10 @@ // restore painter painter->restore(); + if(!isEnabled()) { + // Disabled, apply whitewash. + ChromeEffect::paintDisabledRect(painter, opt->exposedRect); + } } void ToolbarChromeItem::setProperties() { @@ -91,6 +96,8 @@ void ToolbarChromeItem::addPartialbg() { WebChromeContainerSnippet * s = static_cast(m_snippet); + if(!s->layout()->itemAt(TOOLBAR_LEFTCORNER_ITEM)) + return; QRectF rc = s->layout()->itemAt(TOOLBAR_LEFTCORNER_ITEM)->geometry(); if (m_partialbg) { delete m_partialbg; @@ -112,17 +119,15 @@ void ToolbarChromeItem::setSnippet(ChromeSnippet* snippet) { ChromeItem::setSnippet(snippet); - - QString cssVal = m_snippet->element().styleProperty("border-top-color", QWebElement::ComputedStyle); + QString cssVal = m_snippet->element().styleProperty("border-top-color", + QWebElement::ComputedStyle); NativeChromeItem::CSSToQColor(cssVal, m_borderColor); cssVal = m_snippet->element().styleProperty("padding-top", QWebElement::ComputedStyle); - m_padding = cssVal.remove("px").toInt(); - + m_padding = cssVal.remove("px").toInt(); cssVal = m_snippet->element().styleProperty("border-top-width", QWebElement::ComputedStyle); m_borderWidth = cssVal.remove("px").toInt(); - setProperties(); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ToolbarChromeItem.h --- a/ginebra2/ToolbarChromeItem.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ToolbarChromeItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -24,7 +24,7 @@ #include #include "ChromeSnippet.h" -#include "ChromeItem.h" +#include "NativeChromeItem.h" namespace GVA { @@ -33,7 +33,7 @@ { Q_OBJECT public: - ToolbarChromeItem(QGraphicsItem* parent = 0); + ToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent = 0); virtual ~ToolbarChromeItem(); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); virtual void setSnippet(ChromeSnippet* snippet); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ToolbarSnippet.cpp --- a/ginebra2/ToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -29,8 +29,8 @@ namespace GVA { - ToolbarSnippet::ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : WebChromeContainerSnippet(elementId, chrome, ownerArea, element, widget) + ToolbarSnippet::ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + : WebChromeContainerSnippet(elementId, chrome, element) { connect(m_chrome, SIGNAL(chromeComplete()), this, SLOT(onChromeComplete())); @@ -53,8 +53,8 @@ void ToolbarSnippet::updateOwnerArea() { - setLayoutWidth(m_chrome->width()); - WebChromeContainerSnippet::updateOwnerArea(); + setLayoutWidth(m_chrome->layout()->size().width()); + WebChromeContainerSnippet::updateOwnerArea(); } @@ -69,10 +69,7 @@ void ToolbarSnippet::setAction(ChromeSnippet * s) { //qDebug() << "setAction: " << s->elementId() << m_actionInfo.size(); - ChromeItem * item = static_cast(s->widget()); - bool res = connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type))); - ActionButtonSnippet * button = static_cast (s); int index = getIndex(s); @@ -83,9 +80,9 @@ // Set the button icons if it has not been set for any state (we can do this through Javascript) //qDebug() << "setAction " << s->elementId() << button->icon().isNull(); if (button->icon().isNull() ) { - button->setIcon(t->activeImg); + button->setIcon(t->normalImg); button->setDisabledIcon(t->disabledImg); - button->setSelectedIcon(t->selectedImg); + button->setActiveIcon(t->activeImg); } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ToolbarSnippet.h --- a/ginebra2/ToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -42,11 +42,9 @@ { Q_OBJECT public: - ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~ToolbarSnippet(); - protected Q_SLOTS: - virtual void onMouseEvent( QEvent::Type type) = 0; private Q_SLOTS: virtual void onChromeComplete(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/UrlSearchSnippet.cpp --- a/ginebra2/UrlSearchSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/UrlSearchSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -23,6 +23,7 @@ #include "Utilities.h" #include "ChromeRenderer.h" +#include "ChromeLayout.h" #include "ChromeWidget.h" #include "PageSnippet.h" #include "ViewController.h" @@ -33,6 +34,8 @@ #include "GWebContentView.h" #include "WindowFlowView.h" +#include + namespace GVA { #define GO_BUTTON_ICON ":/chrome/bedrockchrome/urlsearch.snippet/icons/go_btn.png" @@ -95,6 +98,7 @@ m_urlSearchEditor->setProgressColor(progressColor); m_urlSearchEditor->setBorderColor(m_borderColor); m_urlSearchEditor->setPadding(0.1); // draw the Rounded Rect + m_urlSearchEditor->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); safe_connect(m_urlSearchEditor, SIGNAL(textMayChanged()), this, SLOT(updateLoadStateAndSuggest())); safe_connect(m_urlSearchEditor, SIGNAL(activated()),this, SLOT(urlSearchActivatedByEnterKey())); safe_connect(m_urlSearchEditor, SIGNAL(focusChanged(bool)),this, SLOT(focusChanged(bool))); @@ -104,6 +108,8 @@ m_urlSearchBtn = new ActionButton(snippet, m_viewPort); QAction* urlSearchBtnAction = new QAction(this); m_urlSearchBtn->setAction(urlSearchBtnAction); // FIXME: should use diff QActions + + m_urlSearchBtn->setActiveOnPress(false); safe_connect(urlSearchBtnAction, SIGNAL(triggered()), this, SLOT(urlSearchActivated())); // Get the icon size @@ -150,8 +156,8 @@ safe_connect(viewController, SIGNAL(currentViewChanged()), this, SLOT(viewChanged())); - safe_connect(ViewStack::getSingleton(), SIGNAL(currentViewChanged()), - this, SLOT(viewChanged())); + /* safe_connect(ViewStack::getSingleton(), SIGNAL(currentViewChanged()), + this, SLOT(viewChanged()));*/ } GUrlSearchItem::~GUrlSearchItem() @@ -251,7 +257,7 @@ GWebContentView * gView = qobject_cast (curView); bool isSuperPage = gView ? gView->currentPageIsSuperPage() : false; if(!isSuperPage) - m_chrome->slideView(100); + m_chrome->layout()->slideView(100); } // Strictly speaking we should set progress to 0. // But set it higher to give immediate visual feedback @@ -312,7 +318,7 @@ ViewController * viewController = m_chrome->viewController(); ControllableViewBase* curView = viewController->currentView(); if (curView && curView->type() == "webView" && pageController->contentsYPos() > 0) - m_chrome->slideView(-100); + m_chrome->layout()->slideView(-100); ++m_pendingClearCalls; @@ -322,7 +328,7 @@ void GUrlSearchItem::setPageCreated() { // remove slideview(100) since the new transition for the code-driven window - //m_chrome->slideView(100); + //m_chrome->layout()->slideView(100); } void GUrlSearchItem::setPageChanged() @@ -363,7 +369,6 @@ // view changes to web content view if (curView && curView->type() == "webView" && !isSuperPage) { - m_urlSearchEditor->setText(formattedUrl()); int progress = pageController->loadProgressValue(); if (progress >= 100) progress = 0; @@ -382,18 +387,17 @@ } } if (!isSuperPage && (pageController->contentsYPos() <= 0 || pageController->isPageLoading())){ - m_chrome->slideView(100); + m_chrome->layout()->slideView(100); } else { - m_chrome->slideView(-100); + m_chrome->layout()->slideView(-100); } m_backFromNewWinTrans = false; } else { pageController->urlTextChanged(m_urlSearchEditor->text()); - // Remove progress bar and url text field value so that + // Remove progress bar // incorrect values are not seen before we can update when we come back - m_urlSearchEditor->setText(""); m_urlSearchEditor->setProgress(0); - m_chrome->slideView(-100); + m_chrome->layout()->slideView(-100); } } @@ -505,6 +509,13 @@ m_justFocusIn = false; m_urlSearchEditor->unselect(); m_urlSearchEditor->shiftToLeftEnd(); + + // Suggestion snippet needs to know about this event. + PageSnippet * suggestSnippet = qobject_cast(m_chrome->getSnippet("SuggestsChromeId")); + if (suggestSnippet) { + QString cmd = "searchSuggests.urlSearchLostFocus();"; + suggestSnippet->evaluateJavaScript(cmd); + } } } @@ -525,7 +536,13 @@ QString GUrlSearchItem::formattedUrl() const { WebPageController * pageController = WebPageController::getSingleton(); - return pageController->currentDocUrl().replace(" ","+"); + QString url = pageController->loadText(); + // for first load of the windows restored from last session + if (url.isEmpty()&& pageController->currentDocUrl().isEmpty()) { + QWebHistoryItem item = pageController->currentPage()->history()->currentItem(); + url = item.url().toString(); + } + return url.replace(" ","+"); } GUrlSearchSnippet::GUrlSearchSnippet(const QString & elementId, ChromeWidget * chrome, @@ -534,6 +551,13 @@ { } +GUrlSearchSnippet * GUrlSearchSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) +{ + GUrlSearchSnippet* that = new GUrlSearchSnippet(elementId, chrome, 0, element); + that->setChromeWidget( new GUrlSearchItem( that, chrome ) ); + return that; +} + inline GUrlSearchItem* GUrlSearchSnippet::urlSearchItem() { return static_cast(widget()); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/UrlSearchSnippet.h --- a/ginebra2/UrlSearchSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/UrlSearchSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -93,6 +93,8 @@ public: GUrlSearchSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); + + static GUrlSearchSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); /// The URL of the web page. QString url() const; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ViewController.cpp --- a/ginebra2/ViewController.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ViewController.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -37,8 +37,6 @@ void ViewController::addView(ControllableViewBase *controllableView) { assert(controllableView); - qDebug() << "ViewController::addView: adding " << controllableView - << " jsObject=" << controllableView->jsObject(); QString key; // Set up parent/child link for javascript access to the view. if (controllableView->jsObject()) { @@ -69,7 +67,6 @@ } void ViewController::showCurrent() { - qDebug() << "ViewController::showCurrent: " << m_current.value(); ControllableViewBase *currentView = m_current.value(); if (!currentView) return; @@ -82,8 +79,11 @@ // Deactivate all others. foreach(ControllableViewBase *view, m_viewMap) { if (view && view->isActive() && view != currentView) { - view->hide(); - view->deactivate(); + //If this view has the same widget as the current view, + //then don't hide this view. + if(currentView->widget() != view->widget()) + view->hide(); + view->deactivate(); } } emit currentViewChanged(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ViewStack.cpp --- a/ginebra2/ViewStack.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ViewStack.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -72,14 +72,12 @@ void ViewStack::fromSettingsView(const QString &to) // goto WebView { + m_viewController->showContent(to); ChromeSnippet* tbSnippet = m_chrome->getSnippet("SettingsViewToolbarId"); if (tbSnippet) tbSnippet->hide(); WebPageController::getSingleton()->setSettingsLoaded(0); - - emit (currentViewChanged()); - m_viewController->showContent(to); } void ViewStack::fromWebView(const QString &to) @@ -92,10 +90,7 @@ void ViewStack::fromBookmarkTreeView(const QString &to) { - Q_UNUSED(to); - - m_viewController->viewChanged(); - + m_viewController->showContent(to); // Hide toolbar and dialog if visible ChromeSnippet* visibleSnippet = m_chrome->getSnippet("BookmarkViewToolbarId"); if (visibleSnippet) @@ -109,9 +104,7 @@ void ViewStack::fromBookmarkHistoryView(const QString &to) { - Q_UNUSED(to); - - m_viewController->viewChanged(); + m_viewController->showContent(to); ChromeSnippet* tbSnippet = m_chrome->getSnippet("RecentUrlViewToolbarId"); if (tbSnippet) tbSnippet->hide(); @@ -144,7 +137,6 @@ WebPageController::getSingleton()->setSettingsLoaded(0); - emit(currentViewChanged()); } void ViewStack::toWebView() @@ -159,8 +151,6 @@ ChromeSnippet* tbSnippet = m_chrome->getSnippet("RecentUrlViewToolbarId"); if (tbSnippet) tbSnippet->show(); - - m_viewController->viewChanged(); } void ViewStack::toBookmarkView() @@ -170,9 +160,6 @@ tbSnippet->show(); emit activateBookmark(); - - - m_viewController->viewChanged(); } void ViewStack::creatingPage(WRT::WrtBrowserContainer* page) { diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/ViewStack.h --- a/ginebra2/ViewStack.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/ViewStack.h Tue Jul 06 14:03:49 2010 +0300 @@ -80,7 +80,6 @@ void activateBookmark(); void activateWindowView(); void deActivateWindowView(); - void currentViewChanged(); void pageChanged(int); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeContainerSnippet.cpp --- a/ginebra2/WebChromeContainerSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeContainerSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -30,17 +30,16 @@ namespace GVA { - WebChromeContainerSnippet::WebChromeContainerSnippet(const QString & elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget* gwidget) - : ChromeSnippet(elementId, chrome, gwidget, element), - m_ownerArea(ownerArea), - m_layoutHeight(0) + WebChromeContainerSnippet::WebChromeContainerSnippet(const QString & elementId, ChromeWidget * chrome, const QWebElement & element) + : ChromeSnippet(elementId, chrome, 0, element) + ,m_layoutHeight(0) { - m_layoutWidth = chrome->width(); + m_layoutWidth = chrome->layout()->size().width(); - QGraphicsWidget * item = static_cast (widget()); + //QGraphicsWidget * item = static_cast (widget()); //NB: maybe size should be fixed only in one direction? - item->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + //item->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); //NB: add a method for setting owner area //item->setPreferredSize(m_ownerArea.width(), m_ownerArea.height()); //Also resize in case item is not part of anchor layout @@ -53,8 +52,8 @@ //Add a stretch element at the beginning. m_layout->addStretch(); - item->setLayout(m_layout); - //When chrome is resized owner areas for snippets may change + //item->setLayout(m_layout); + //When chrome is resized sizes for snippets may change QObject::connect(m_chrome->renderer(), SIGNAL(chromeResized()), this, SLOT(updateOwnerArea())); QObject::connect(m_chrome, SIGNAL(prepareForSizeChange(QSize)), this, SLOT(updateSize(QSize))); @@ -69,7 +68,13 @@ { ; //Do nothing since the layout positions children automatically. } - + + void WebChromeContainerSnippet::setChromeWidget(QGraphicsWidget * widget){ + widget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + widget->setLayout(m_layout); + ChromeSnippet::setChromeWidget(widget); + } + void WebChromeContainerSnippet::addChild(ChromeSnippet * child) { //Prevent layout from stretching the child widgets. NB: Revisit this to make configurable from chrome? @@ -83,7 +88,7 @@ if (childHeight > m_layoutHeight){ m_layoutHeight = childHeight; - setOwnerArea(); + updateSizes(); } emit childAdded(child); @@ -92,8 +97,7 @@ void WebChromeContainerSnippet:: updateOwnerArea() { - - setOwnerArea(); + updateSizes(); QObject::disconnect(m_chrome->renderer(), SIGNAL(chromeResized()), this, SLOT(updateOwnerArea())); } @@ -101,15 +105,15 @@ void WebChromeContainerSnippet::setLayoutHeight(int height){ if (m_layoutHeight != height){ m_layoutHeight = height; - setOwnerArea(); + updateSizes(); } } - void WebChromeContainerSnippet::setLayoutWidth(int width, bool update){ + void WebChromeContainerSnippet::setLayoutWidth(qreal width, bool update){ if (m_layoutWidth != width){ m_layoutWidth = width; if (update ) { - setOwnerArea(); + updateSizes(); } } } @@ -120,15 +124,12 @@ // m_layoutWidth should have been set by now through derived classes. We don't want to set it // here as that would overwrite any width set before. For example, width of the middle snippet // in toolbar is set by the main toolbar. - setOwnerArea(); - + updateSizes(); } - void WebChromeContainerSnippet::setOwnerArea() { - + void WebChromeContainerSnippet::updateSizes() { + QGraphicsWidget * item = static_cast (widget()); - m_ownerArea = m_chrome->getSnippetRect(m_elementId); - //Resize the item item->setPreferredSize(m_layoutWidth, m_layoutHeight); //Also resize in case item is not part of anchor layout diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeContainerSnippet.h --- a/ginebra2/WebChromeContainerSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeContainerSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -32,27 +32,26 @@ { Q_OBJECT public: - WebChromeContainerSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + WebChromeContainerSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~WebChromeContainerSnippet(); + virtual void setChromeWidget(QGraphicsWidget * widget); virtual void addChild(ChromeSnippet * child); QGraphicsLinearLayout* layout() { return m_layout;} - QRectF ownerArea() { return m_ownerArea;} Q_SIGNALS: void childAdded(ChromeSnippet * ); public slots: void setLayoutHeight(int height); - void setLayoutWidth(int width, bool update = false); + void setLayoutWidth(qreal width, bool update = false); virtual void updateSize(QSize ); + void updateSizes(); + QRectF ownerArea() { return QRectF(m_element.geometry());} virtual void updateOwnerArea(); protected slots: void positionChildren(); private: - void setOwnerArea(); - - QRectF m_ownerArea; qreal m_layoutHeight; qreal m_layoutWidth; QGraphicsLinearLayout * m_layout; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeItem.cpp --- a/ginebra2/WebChromeItem.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeItem.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -1,23 +1,23 @@ /* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, version 2.1 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program. If not, -* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". -* -* Description: -* -*/ + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 2.1 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, + * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". + * + * Description: + * + */ #include "WebChromeItem.h" #include "ChromeWidget.h" @@ -33,217 +33,195 @@ #include #include -namespace GVA { +namespace GVA +{ #ifndef NO_QSTM_GESTURE using namespace qstmGesture; #endif - WebChromeItem::WebChromeItem(const QRectF& ownerArea, ChromeWidget *chrome, const QWebElement & element, QGraphicsItem* parent) - : ChromeItem(NULL, parent), - m_ownerArea(ownerArea), - m_chrome(chrome), - m_element(element), - m_painting(false) - { - - - // G1: Prevent hover events from passing through to the underlying widget. - //setAcceptHoverEvents(true); ? - - //setFocusPolicy(Qt::ClickFocus); - //setOpacity(0.50); - //Set preferred size so item will resize as part of anchor layout +WebChromeItem::WebChromeItem(ChromeWidget *chrome, const QWebElement & element, QGraphicsItem* parent) : + ChromeItem(NULL, parent) + , m_chrome(chrome) + , m_element(element) + , m_painting(false) +{ setFlags(QGraphicsItem::ItemIsFocusable); - setPreferredSize(ownerArea.width(), ownerArea.height()); - //Also resize in case item is not part of anchor layout - resize(preferredSize()); + //Adjust the element size to match the element rectangle + updateSizes(); #ifndef NO_QSTM_GESTURE grabGesture(QStm_Gesture::assignedType()); #endif //Use QGraphicsScene cached rendering NB: This might degrade rendering quality for some animation transforms setCacheMode(QGraphicsItem::ItemCoordinateCache); - } +} - WebChromeItem::~WebChromeItem() - { +WebChromeItem::~WebChromeItem() +{ - } +} - void WebChromeItem::init(WebChromeSnippet * snippet) - { - setCachedHandlers(chrome()->dom()->getCachedHandlers(snippet->elementId(), ownerArea())); +void WebChromeItem::init(WebChromeSnippet * snippet) +{ + //TODO: revisit this, don't use owner area + //setCachedHandlers(chrome()->dom()->getCachedHandlers(snippet->elementId(), ownerArea())); m_snippet = snippet; //When chrome is resized owner areas for snippets may change //NB: Maybe this needs to be done on chromeRepainted too? - - QObject::connect( - renderer(), - SIGNAL(chromeResized()), - snippet, - SLOT(updateOwnerArea())); + + QObject::connect(renderer(), SIGNAL(chromeResized()), snippet, SLOT(updateOwnerArea())); - QObject::connect( - this, - SIGNAL(contextMenu(QGraphicsSceneContextMenuEvent *)), - snippet, - SLOT(onContextMenuEvent(QGraphicsSceneContextMenuEvent *))); - } + QObject::connect(this, SIGNAL(contextMenu(QGraphicsSceneContextMenuEvent *)), snippet, + SLOT(onContextMenuEvent(QGraphicsSceneContextMenuEvent *))); +} - QGraphicsScene * WebChromeItem::scene() - { - return m_chrome->getScene(); - } +QGraphicsScene * WebChromeItem::scene() +{ + return m_chrome->layout()->scene(); +} - ChromeRenderer * WebChromeItem::renderer() - { +ChromeRenderer * WebChromeItem::renderer() +{ return m_chrome->renderer(); - } +} - void WebChromeItem::setOwnerArea(const QRectF& ownerArea) - { - m_ownerArea = ownerArea; +//Adjust size to match the element rectangle +void WebChromeItem::updateSizes() +{ //Set preferred size so item will resize as part of anchor layout - setPreferredSize(ownerArea.width(), ownerArea.height()); + setPreferredSize(m_element.geometry().width(), m_element.geometry().height()); //Also resize in case item is not part of anchor layout resize(preferredSize()); - } +} - // NB: For now we only handle onclick (actually mouseUp). Fix this - // NB: Modify for multiple cached handlers: mouse click, long press - // and support handlers not executed in js engine. +// NB: For now we only handle onclick (actually mouseUp). Fix this +// NB: Modify for multiple cached handlers: mouse click, long press +// and support handlers not executed in js engine. - void WebChromeItem::cachedHandlerEvent(QGraphicsSceneMouseEvent * ev) - { - for (int i = 0; i < m_handlers.size(); i++){ - const CachedHandler & handler = m_handlers.at(i); - if (handler.rect().contains(ev->pos())){ - qDebug() << "Invoking cached handler: " << handler.script(); - //m_chrome->evalWithEngineContext(handler.script()); - handler.invoke(); - return; - } +void WebChromeItem::cachedHandlerEvent(QGraphicsSceneMouseEvent * ev) +{ + for (int i = 0; i < m_handlers.size(); i++) { + const CachedHandler & handler = m_handlers.at(i); + if (handler.rect().contains(ev->pos())) { + //m_chrome->evalWithEngineContext(handler.script()); + handler.invoke(); + return; + } } - } +} - void WebChromeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget) - { +void WebChromeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget) +{ Q_UNUSED(opt) Q_UNUSED(widget) - //For debugging - //painter->fillRect(QRectF(0,0, m_ownerArea.width(), m_ownerArea.height()), Qt::yellow); - //qDebug() << " WebChromeItem::paint: " << m_element.attribute("id"); m_painting = true; m_element.render(painter); m_painting = false; ChromeItem::paint(painter, opt, widget); - } - +} - void WebChromeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * ev) - { - - // qDebug() << "ChromeRenderer::contextMenuEvent"; +void WebChromeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * ev) +{ ev->setAccepted(true); //Signal context menu event emit contextMenu(ev); - } - - void WebChromeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * ev) - { +} +void WebChromeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * ev) +{ forwardMouseEvent(QEvent::MouseButtonDblClick, ev); - } +} - void WebChromeItem::grabFocus() - { +void WebChromeItem::grabFocus() +{ //setFocusProxy(m_chrome->renderer()); setFocus(); - } +} - void WebChromeItem::mousePressEvent(QGraphicsSceneMouseEvent * ev) - { +void WebChromeItem::mousePressEvent(QGraphicsSceneMouseEvent * ev) +{ //On mouse press, first invoke any cached handlers. cachedHandlerEvent(ev); //Then do normal mouse press handling setFocus(); - // setFocusProxy(m_chrome->renderer()); + // setFocusProxy(m_chrome->renderer()); forwardMouseEvent(QEvent::MouseButtonPress, ev); - } +} - void WebChromeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * ev) - { +void WebChromeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * ev) +{ forwardMouseEvent(QEvent::MouseButtonRelease, ev); #if defined __SYMBIAN32__ -// FIXME Remove this, it will be fixed Qt 4.6.3 ? - /* - if (ev->button() == Qt::LeftButton) { - QPoint p = QPoint(int(m_ownerArea.x()), int(m_ownerArea.y())) + ev->pos().toPoint(); - QWebFrame* frame = m_chrome->renderer()->page()->mainFrame(); - QWebHitTestResult htr = frame->hitTestContent(p); - if (htr.isContentEditable()) { - QEvent vkbEvent(QEvent::RequestSoftwareInputPanel); - QList views = m_chrome->renderer()->scene()->views(); - QWidget* view = qobject_cast(views.value(0)); - if (view) - QApplication::sendEvent(view, &vkbEvent); - } - } - */ + // FIXME Remove this, it will be fixed Qt 4.6.3 ? + /* + if (ev->button() == Qt::LeftButton) { + QRectF elementRectangle = m_element.geometry(); + QPoint p = QPoint(int(elementRectangle.x()), int(elementRectangle.y())) + ev->pos().toPoint(); + QWebFrame* frame = m_chrome->renderer()->page()->mainFrame(); + QWebHitTestResult htr = frame->hitTestContent(p); + if (htr.isContentEditable()) { + QEvent vkbEvent(QEvent::RequestSoftwareInputPanel); + QList views = m_chrome->renderer()->scene()->views(); + QWidget* view = qobject_cast(views.value(0)); + if (view) + QApplication::sendEvent(view, &vkbEvent); + } + } + */ #endif - } - +} - void WebChromeItem::mouseMoveEvent(QGraphicsSceneMouseEvent * ev) - { +void WebChromeItem::mouseMoveEvent(QGraphicsSceneMouseEvent * ev) +{ forwardMouseEvent(QEvent::MouseMove, ev); - } +} - - void WebChromeItem::forwardMouseEvent(QEvent::Type type, QGraphicsSceneMouseEvent *ev) { +void WebChromeItem::forwardMouseEvent(QEvent::Type type, QGraphicsSceneMouseEvent *ev) +{ emit mouseEvent(type); - // m_chrome->renderer()->setFocus(); - QMouseEvent shiftedEv( type, QPoint(int(m_ownerArea.x()), int(m_ownerArea.y()))+ev->pos().toPoint(), - ev->button(), ev->buttons(), ev->modifiers() ); - //qDebug() << "m_ownerArea: " << m_ownerArea << "ev->pos(): " << ev->pos() << + QRectF elementRectangle = m_element.geometry(); + QMouseEvent shiftedEv(type, QPoint(int(elementRectangle.x()), int(elementRectangle.y())) + + ev->pos().toPoint(), ev->button(), ev->buttons(), ev->modifiers()); + //qDebug() << "elementRectangle: " << elementRectangle << "ev->pos(): " << ev->pos() << // "shiftedEv.pos(): " << shiftedEv.pos(); - QApplication::sendEvent(m_chrome->renderer()->page(),&shiftedEv); - } + QApplication::sendEvent(m_chrome->renderer()->page(), &shiftedEv); +} - void WebChromeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event ) { +void WebChromeItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ // Translate to a mouse move event. - /* QMouseEvent shiftedEv( QEvent::MouseMove, QPoint(int(m_ownerArea.x()), int(m_ownerArea.y()))+event->pos().toPoint(), - Qt::NoButton, Qt::NoButton, Qt::NoModifier); - QApplication::sendEvent(m_chrome->renderer(), &shiftedEv); */ - } - /* - void WebChromeItem::keyPressEvent ( QKeyEvent * event ) { - qDebug() << "WebChromeItem: keyPressEvent " << event->type(); - QApplication::sendEvent(m_chrome->renderer(), event); - } + /* + QRectF elementRectangle = m_element.geometry(); + QMouseEvent shiftedEv( QEvent::MouseMove, QPoint(int(elementRectangle.x()), int(elementRectangle.y()))+event->pos().toPoint(), + Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QApplication::sendEvent(m_chrome->renderer(), &shiftedEv); */ +} +/* + void WebChromeItem::keyPressEvent ( QKeyEvent * event ) { + QApplication::sendEvent(m_chrome->renderer(), event); + } - void WebChromeItem::keyReleaseEvent ( QKeyEvent * event ) { - qDebug() << "WebChromeItem: keyReleaseEvent " << event->type(); - QApplication::sendEvent(m_chrome->renderer(), event); - } - */ + void WebChromeItem::keyReleaseEvent ( QKeyEvent * event ) { + QApplication::sendEvent(m_chrome->renderer(), event); + } + */ - bool WebChromeItem::event(QEvent* event) - { +bool WebChromeItem::event(QEvent* event) +{ #ifndef NO_QSTM_GESTURE - if (event->type() == QEvent::Gesture) { - QStm_Gesture* gesture = getQStmGesture(event); - if (gesture) { - QStm_GestureType gtype = gesture->getGestureStmType(); - if (gtype == QStmTouchGestureType || gtype == QStmReleaseGestureType) { - gesture->sendMouseEvents(); - return true; - } - } - } + if (event->type() == QEvent::Gesture) { + QStm_Gesture* gesture = getQStmGesture(event); + if (gesture) { + QStm_GestureType gtype = gesture->getGestureStmType(); + if (gtype == QStmTouchGestureType || gtype == QStmReleaseGestureType) { + gesture->sendMouseEvents(); + return true; + } + } + } #endif - return QGraphicsWidget::event(event); - } + return QGraphicsWidget::event(event); +} } // endof namespace GVA diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeItem.h --- a/ginebra2/WebChromeItem.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeItem.h Tue Jul 06 14:03:49 2010 +0300 @@ -19,6 +19,7 @@ * */ + #ifndef __GINEBRA_WEBCHROMEITEM_H__ #define __GINEBRA_WEBCHROMEITEM_H__ @@ -37,12 +38,12 @@ { Q_OBJECT public: - WebChromeItem(const QRectF& ownerArea, ChromeWidget* chrome, const QWebElement & element, QGraphicsItem* parent=0); + WebChromeItem(ChromeWidget* chrome, const QWebElement & element, QGraphicsItem* parent=0); virtual ~WebChromeItem(); virtual void init(WebChromeSnippet * snippet); void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); - QRectF ownerArea() {return m_ownerArea;}\ - void setOwnerArea(const QRectF& ownerArea); + QRectF elementRect() {return QRectF(m_element.geometry());} + void updateSizes(); void setCachedHandlers(QList handlers) {m_handlers = handlers;} QGraphicsScene * scene(); ChromeRenderer * renderer(); @@ -69,7 +70,8 @@ //virtual bool event(QEvent * ev); private: void cachedHandlerEvent(QGraphicsSceneMouseEvent * ev); - QRectF m_ownerArea; + //Owner area obsolete, use element rectangle + //QRectF m_ownerArea; QPixmap * m_pageBits; ChromeWidget* m_chrome; QWebElement m_element; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeSnippet.cpp --- a/ginebra2/WebChromeSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -32,25 +32,23 @@ static WebChromeItem * newChromeItem( ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element) { QString type = element.attribute("data-GinebraItemType", "normal"); if (type == "popup") { QString modal = element.attribute("data-GinebraPopupModal", "true"); - return new PopupWebChromeItem(ownerArea, chrome, element, 0, modal == "true"); + return new PopupWebChromeItem(chrome, element, 0, modal == "true"); } - return new WebChromeItem(ownerArea, chrome, element); + return new WebChromeItem(chrome, element); } WebChromeSnippet::WebChromeSnippet( const QString & elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element) - : ChromeSnippet(elementId, chrome, newChromeItem(chrome, ownerArea, element), element) + : ChromeSnippet(elementId, chrome, newChromeItem(chrome, element), element) { WebChromeItem * item = static_cast (widget()); @@ -77,11 +75,9 @@ { WebChromeItem * item = static_cast (widget()); - //Setting owner area also resets the item's size and preferred size - item->setOwnerArea(m_chrome->getSnippetRect(m_elementId)); - //qDebug() << WebChromeSnippet::updateOwnerArea: id: " << m_elementId << " element rect: " << item->ownerArea(); - //NB: Should move this to WebChromeItem::setOwnerArea()? - item->setCachedHandlers(m_chrome->dom()->getCachedHandlers(m_elementId, item->ownerArea())); + item->updateSizes(); + //TODO: Revisit this, don't use owner area + //item->setCachedHandlers(m_chrome->dom()->getCachedHandlers(m_elementId, item->ownerArea())); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WebChromeSnippet.h --- a/ginebra2/WebChromeSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WebChromeSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -36,7 +36,7 @@ { Q_OBJECT public: - WebChromeSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element); + WebChromeSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~WebChromeSnippet(); WebChromeItem* item(); public slots: diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WindowToolbarSnippet.cpp --- a/ginebra2/WindowToolbarSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WindowToolbarSnippet.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -22,14 +22,15 @@ */ #include "WindowToolbarSnippet.h" +#include "ToolbarChromeItem.h" #include "ViewStack.h" #include namespace GVA { WindowToolbarSnippet::WindowToolbarSnippet(const QString& elementId, ChromeWidget * chrome, - const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget) - : DualButtonToolbarSnippet(elementId, chrome, ownerArea, element, widget) + const QWebElement & element) + : DualButtonToolbarSnippet(elementId, chrome, element) { m_type = TOOLBAR_WINDOWS_VIEW; } @@ -38,6 +39,13 @@ { } + WindowToolbarSnippet * WindowToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) + { + WindowToolbarSnippet * that = new WindowToolbarSnippet(elementId, chrome, element); + that->setChromeWidget(new ToolbarChromeItem(that)); + return that; + } + void WindowToolbarSnippet::addChild(ChromeSnippet * child) { WebChromeContainerSnippet * s = dynamic_cast(child); @@ -46,17 +54,17 @@ if (child->elementId() == "WinBackButton" ) { t->actionId = WINDOW_VIEW_ACTION_BACK; t->actionName = WINDOW_TOOLBAR_BACK; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_disabled.png"; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; } else if (child->elementId() == "WinAddWindow" ) { t->actionId = WINDOW_VIEW_ACTION_ADD; t->actionName = WINDOW_TOOLBAR_ADD; - t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add.png"; + t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add.png"; t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add_disabled.png"; - t->selectedImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add_pressed.png"; + t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_add_pressed.png"; } t->id = child->elementId(); m_actionInfo.append(t); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/WindowToolbarSnippet.h --- a/ginebra2/WindowToolbarSnippet.h Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/WindowToolbarSnippet.h Tue Jul 06 14:03:49 2010 +0300 @@ -38,8 +38,9 @@ { Q_OBJECT public: - WindowToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget); + WindowToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); virtual ~WindowToolbarSnippet(); + static WindowToolbarSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element); private Q_SLOTS: /// Back action trigger handler. Switches back to webview diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/animators/FadeAnimator.cpp --- a/ginebra2/animators/FadeAnimator.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/animators/FadeAnimator.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -46,8 +46,6 @@ { qreal o = 1.0 - step; m_snippet->widget()->setOpacity((o > m_minOpacity)?o:m_minOpacity); - - qDebug() << step; } } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/animators/SlideAnimator.cpp --- a/ginebra2/animators/SlideAnimator.cpp Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/animators/SlideAnimator.cpp Tue Jul 06 14:03:49 2010 +0300 @@ -62,7 +62,6 @@ void SlideAnimator::updateVisibility(qreal step) { - qDebug() << step; QTransform transform = m_originalTransform; transform.translate(step*m_xRange, step*m_yRange); m_snippet->widget()->setTransform(transform); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/browserIcon.svg --- a/ginebra2/browserIcon.svg Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/browserIcon.svg Tue Jul 06 14:03:49 2010 +0300 @@ -1,94 +1,120 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - -BETA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/bookmarkview.superpage/BookmarkView.html --- a/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/BookmarkView.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/BookmarkView.html Tue Jul 06 14:03:49 2010 +0300 @@ -6,7 +6,6 @@ - @@ -14,26 +13,43 @@ Bookmark View @@ -42,6 +58,7 @@
    +
    diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkDialog.js --- a/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkDialog.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkDialog.js Tue Jul 06 14:03:49 2010 +0300 @@ -28,11 +28,16 @@ function bookmarkDialogIdHide(){ window.snippets.BookmarkDialogId.hide(); + snippets.BookmarkViewToolbarId.enabled = true; + snippets.WebViewToolbarId.enabled = true; } function launchBookmarkDialog(bmtitle, bmurl, dialogFlag) { try{ + snippets.BookmarkViewToolbarId.enabled = false; + snippets.WebViewToolbarId.enabled = false; + if (dialogFlag == 0) { var dlgTitle = document.getElementById("bookmarkDialogTitle"); dlgTitle.firstChild.nodeValue= window.localeDelegate.translateText("txt_browser_input_dial_add_bm"); @@ -48,8 +53,11 @@ window.snippets.BookmarkDialogUrlId.lostFocus.connect(urlFieldLostFocus); window.snippets.BookmarkDialogTitleId.gainedFocus.connect(titleFieldGainedFocus); window.snippets.BookmarkDialogUrlId.gainedFocus.connect(urlFieldGainedFocus); - - + // set max text length + // window.snippets.BookmarkDialogTitleId.setMaxTextLength(30); + var hints = window.snippets.BookmarkDialogUrlId.getTextOptions(); + hints |= 2; // Qt::ImhNoAutoUppercase 0x2 + window.snippets.BookmarkDialogUrlId.setTextOptions(hints); if (bmtitle == "") window.snippets.BookmarkDialogTitleId.text = "Title"; else @@ -61,7 +69,9 @@ window.snippets.BookmarkDialogUrlId.text = bmurl; window.snippets.BookmarkDialogId.show(false); - + + window.snippets.BookmarkDialogTitleId.selectAll(); + }catch(e){ alert(e); } } @@ -69,6 +79,8 @@ function bookmarkOperation() { + snippets.BookmarkViewToolbarId.enabled = true; + snippets.WebViewToolbarId.enabled = true; //get title and url from the dialog var bmtitle = window.snippets.BookmarkDialogTitleId.text; var bmurl = window.snippets.BookmarkDialogUrlId.text; @@ -78,22 +90,21 @@ var errCode; if (_dailogFlag == 0) - errCode = window.bookmarksManager.addBookmark(bmtitle,bmurl); + errCode = window.bookmarksManager.addBookmark(bmtitle,bmurl); else if (_dailogFlag == 1) - errCode = window.bookmarksManager.modifyBookmark(_OriginalTitle,bmtitle,bmurl); + errCode = window.bookmarksManager.modifyBookmark(_OriginalTitle,bmtitle,bmurl); - if (errCode == -2) { - alert("Bookmark Already Present"); - return; - } - else if (errCode == -3){ - alert("Bookmark Url Is Empty"); - return; + + if (errCode == -3){ + alert("Bookmark Url Is Empty"); + return; } else if (errCode != -0){ - alert("General Error"); - return; + alert("General Error"); + return; } + + } function titleFieldLostFocus() @@ -114,13 +125,11 @@ function titleFieldGainedFocus() { window.snippets.BookmarkDialogUrlId.unselect(); - window.snippets.BookmarkDialogTitleId.selectAll(); } function urlFieldGainedFocus() { window.snippets.BookmarkDialogTitleId.unselect(); - window.snippets.BookmarkDialogUrlId.selectAll(); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.css --- a/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.css Tue Jul 06 14:03:49 2010 +0300 @@ -2,6 +2,7 @@ padding : 0px; margin : 0px; height:100%; + background-color: #889cbf; } /* .bookmarkList li.ui-state-highlight { @@ -11,6 +12,11 @@ } */ +#BottomPad { + padding: 8px 10px 8px 10px; + height: 54px; +} + .bookmarkList li.highlight{ background-image: url(icons/list_itembg_pressed.png); font-weight: bold; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.js --- a/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/bookmarkview.superpage/bookmarkview.js Tue Jul 06 14:03:49 2010 +0300 @@ -148,7 +148,24 @@ function _addNewBookmark(bmtitle,bmurl) { - if (__previousSortEle != null) + if(__prevOpenedBookmarkControl) + _bookmarkHideControl(__prevOpenedBookmarkControl); + + var ul=document.getElementById('bookmarkListTree'); + for (x=0; x< ul.childNodes.length; x++) + { + var li_element= ul.childNodes[x]; + var bm_title= li_element.childNodes[1].childNodes[0].innerText; + + if(bmtitle.toLowerCase() == bm_title.toLowerCase()) + { + ul.removeChild(li_element); + break; + } + + } + + if(__previousSortEle != null) _disableSorting(__previousSortEle) __bookmarkCount += 1; @@ -168,6 +185,23 @@ function _editBookmark(bmtitle,bmurl) { + if(__prevOpenedBookmarkControl) + _bookmarkHideControl(__prevOpenedBookmarkControl); + + var ul=document.getElementById('bookmarkListTree'); + for (x=0; x< ul.childNodes.length; x++) + { + var li_element= ul.childNodes[x]; + var bm_title= li_element.childNodes[1].childNodes[0].innerText; + + if(bmtitle.toLowerCase() == bm_title.toLowerCase() && + __bookmarkEditElement.childNodes[1].childNodes[0].innerText.toLowerCase() != bmtitle.toLowerCase()) + { + ul.removeChild(li_element); + break; + } + + } __bookmarkEditElement.childNodes[1].childNodes[0].innerText = bmtitle; __bookmarkEditElement.childNodes[1].childNodes[2].innerText = bmurl; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/chrome.html --- a/ginebra2/chrome/bedrockchrome/chrome.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/chrome.html Tue Jul 06 14:03:49 2010 +0300 @@ -7,13 +7,15 @@ + + - + @@ -22,6 +24,7 @@ + @@ -36,7 +39,7 @@ -
    +
    + +
    + +
    @@ -204,5 +215,12 @@
    + +
    + +
    + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/chrome.js --- a/ginebra2/chrome/bedrockchrome/chrome.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/chrome.js Tue Jul 06 14:03:49 2010 +0300 @@ -1,4 +1,4 @@ - +var preLoadBookmarksDone=0; function calcToolbarPopAnchorOffset(anchoredSnippet, anchorToSnippet, xCenterOffset, @@ -26,44 +26,42 @@ // Display the super-page with the given name and path. function showSuperPage(pageName, path) { + if (window.views.WebView[pageName] == undefined) { window.views.WebView.createSuperPage(pageName, true); + window.views.WebView[pageName].load(chrome.baseDirectory + path); } - window.views.WebView[pageName].load(chrome.baseDirectory + path); - - // Show it. - window.views.WebView.zoomFactor = 1.0; - window.views.WebView.showSuperPage(pageName); + + if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) + window.views.WebView.zoomFactor = 1.0; + //window.views.WebView.showSuperPage(pageName); window.ViewStack.switchView(pageName, "WebView"); + if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) + window.views.WebView.touchNav.doubleClickEnabled = false; } function chrome_showBookmarksView() { - app.debug("chrome_showBookmarksView"); showSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); } function chrome_showHistoryView() { - app.debug("chrome_showHistoryView"); showSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); -// showHistoryView(); } function chrome_showWindowsView() { - app.debug("chrome_showWindowsView"); window.snippets.ZoomBarId.hide(); // hide Zoom Bar while showing windows view window.snippets.MostVisitedViewId.hide(); window.ViewStack.switchView("WindowView", "WebView"); } function chrome_showSettingsView() { - app.debug("chrome_showSettingsView"); showSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); } function chrome_showBasicMenu() { - if (!snippets.ContextMenuId.dontShow) { - cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); - } + + cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); + } function chrome_addBookmark() { @@ -95,29 +93,68 @@ function onActivateBookmarkView() { window.bookmarksManager.launchBookmarkEditDailog.connect(showBookmarkEditDialog); } +function preLoad() +{ + preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); + preloadSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); + preLoadBookmarksDone=1; +} +function _updateHistory() +{ + preloadSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); + +} + +function _updateBookmarks() +{ + preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); +} + +// chrome_popupShownCount keeps a count of how many popups are currently being shown so that +// we can re-enable the appropriate UI elements only when the last one is hidden. +var chrome_popupShownCount = 0; // Called when a PopupChromeItem is displayed. function onPopupShown(id) { - // Disable snippets etc. that should be greyed-out while the popup is shown. - snippets.UrlSearchChromeId.enabled = false; - views.WebView.enabled = false; - views.WebView.freeze(); + if(chrome_popupShownCount == 0) { + // Disable snippets etc. that should be greyed-out while the popup is shown. + snippets.UrlSearchChromeId.enabled = false; + views.WebView.enabled = false; + views.WebView.freeze(); + + // Note: this can be expanded as needed. We may want to disable all snippets except + // for the status bar and the one who's id was passed in. + } + chrome_popupShownCount++; - // Note: this can be expanded as needed. We may want to disable all snippets except - // for the urlSearchBar and the one who's id was passed in. + if(preLoadBookmarksDone==0) + { + preLoad(); + } } // Called when a PopupChromeItem is hidden. function onPopupHidden(id) { - // Re-enable snippets etc. that were greyed-out while the popup is shown. - snippets.UrlSearchChromeId.enabled = true; - views.WebView.enabled = true; - views.WebView.unfreeze(); + chrome_popupShownCount--; + if(chrome_popupShownCount == 0) { + // Re-enable snippets etc. that were greyed-out while popups were being shown. + snippets.UrlSearchChromeId.enabled = true; + views.WebView.enabled = true; + views.WebView.unfreeze(); + } + if(chrome_popupShownCount < 0) app.debug("onPopupHidden: error, chrome_popupShownCount invalid"); +} + +function preloadSuperPage(pageName, path) { + if (window.views.WebView[pageName] == undefined) { + window.views.WebView.createSuperPage(pageName, true); + } + window.views.WebView[pageName].load(chrome.baseDirectory + path); } function onChromeComplete(){ - if (app.ui() != "orbit_ui") { - snippets.StatusBarChromeId.show(); + if (app.ui() == "orbit_ui") { + snippets.StatusBarChromeId.hide(); } window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu); @@ -139,6 +176,9 @@ chrome.popupShown.connect(onPopupShown); chrome.popupHidden.connect(onPopupHidden); + window.pageController.loadFinished.connect(_updateHistory); + window.bookmarksManager.bookmarksCleared.connect(_updateBookmarks); + window.bookmarksManager.historyCleared.connect(_updateHistory); } // For debugging: prints all properties and functions attached to a given object. diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/contextmenu.snippet/ViewContextMenu.js --- a/ginebra2/chrome/bedrockchrome/contextmenu.snippet/ViewContextMenu.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/contextmenu.snippet/ViewContextMenu.js Tue Jul 06 14:03:49 2010 +0300 @@ -90,6 +90,10 @@ "text": window.localeDelegate.translateText("txt_browser_content_view_menu_nav_settings"), "onclick": chrome_showSettingsView, }, + { + "text": window.localeDelegate.translateText("txt_browser_content_view_menu_nav_exit"), + "onclick": window.app.quit, + }, ], }; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.css --- a/ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.css Tue Jul 06 14:03:49 2010 +0300 @@ -168,12 +168,6 @@ display: table-cell; } -/* Any Menu items when clicked. */ -.ContextMenu .MenuDiv ul li.RegularMenuLi:active, .ContextMenu .MenuDiv ul li ul li.MenuRowLi:active -{ - background: #ddd; -} - /* Last top-level menu item. */ .ContextMenu .MenuDiv ul li.MenuLi:last-child { @@ -182,6 +176,12 @@ border-bottom: 3px solid #374358; } +/* Menu item during mouse over. */ +.ContextMenu .MenuDiv ul li.MouseOverItem +{ + background: #d8dfed; +} + /* Item icons. */ .ContextMenu ul li img { diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.js --- a/ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/contextmenu.snippet/contextmenu.js Tue Jul 06 14:03:49 2010 +0300 @@ -1,5 +1,18 @@ var cm_TheContextMenu; - + +// Return true if the given element's className includes the given class. +function hasClass(ele,cls) { + return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); +} + +// Remove a class from an element's className. +function removeClass(ele,cls) { + if (hasClass(ele,cls)) { + var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); + ele.className=ele.className.replace(reg,' '); + } +} + function ContextMenu(snippetId, contentView) { this.snippetId = snippetId; this.mainDiv = undefined; @@ -9,6 +22,8 @@ // Width of a tab with no text, just the icon. Icons must all be the same width. // Update this if icon size or tab border width etc. changes -- or better yet, determine it dynamically. this.normalTabWidth = 64; + // Height of the menu is the max possible height to be used when positioning the snippet + this.menuHeight = 272; // ContextMenu is a singleton to avoid problems with scope-chaining in some of the // callbacks that it uses. See handleTabActivate. @@ -196,6 +211,14 @@ }.bind(this))(menuItem.onclick); } + itemLi.onmouseover = function() { + this.className += " MouseOverItem"; + }.bind(itemLi) + + itemLi.onmouseout = function() { + removeClass(this, "MouseOverItem"); + }.bind(itemLi) + // Create the item's icon. if (menuItem.icon != undefined) { var iconEl = document.createElement("img"); @@ -379,12 +402,6 @@ this.showTimeoutId = 0; this.cleanUp(); } - - this.show = function(menuData) { - this.cleanUp(); - this.create(menuData); - this.showTimeoutId = setTimeout('cm_TheContextMenu.showIt()', 10); - } this.cleanUp = function() { // Remove elements from DOM to save memory. @@ -404,7 +421,10 @@ this.cleanUp(); } - this.showIt = function() { + this.show = function(menuData) { + this.cleanUp(); + this.create(menuData); + cm_TheContextMenu.updateTabSizes(); // Use a timer to actually show the window to allow the page re-layout // to finish. We don't know when this really happens but 50ms seems to @@ -414,12 +434,12 @@ } this.showIt2 = function() { + var snippet = snippets[cm_TheContextMenu.snippetId]; - snippet.updateOwnerArea(); snippet.setZValue(2); - centerSnippet(snippet); + this.centerSnippet(); // if (showTail) { // cm_TheContextMenu.positionTail(); @@ -428,13 +448,27 @@ snippet.show(); } + + this.centerSnippet = function() { + + + var statusBarHeight = snippets.StatusBarChromeId.geometry.height; + + var snippet = snippets[cm_TheContextMenu.snippetId]; + var x = (chrome.displaySize.width - snippet.geometry.width) / 2; + + // Center the menu in the space between status bar and tool bar + var y = (chrome.displaySize.height - statusBarHeight - snippets.WebViewToolbarId.geometry.height - cm_TheContextMenu.menuHeight)/2; + snippet.setPosition(x, (y+statusBarHeight)); + + } chrome.chromeComplete.connect(createDelegate(this, function() { - var snippet = snippets[this.snippetId]; + var snippet = snippets[cm_TheContextMenu.snippetId]; chrome.aspectChanged.connect(createDelegate(this, function(a) { - centerSnippet(snippets[this.snippetId]); + this.centerSnippet(); })); snippet.hidden.connect(createDelegate(this, this.onHide)); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.css --- a/ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.css Tue Jul 06 14:03:49 2010 +0300 @@ -1,85 +1,59 @@ -//ClearHistory dialog - -#dummy -{ -} +/* ClearHistory dialog */ #ClearHistoryDialogId { - width: 302px; -} - -#ClearHistoryDialogId div.top{ - background-image: url(icons/dialog_top.png); - background-repeat: no-repeat; - height:11px; - width: 302px; -} - -#ClearHistoryDialogId div.body{ - background-image: url(icons/dialog_center.png); - height: 97px; - background-repeat: repeat-y; - width: 302px; -} - -#ClearHistoryDialogId div.bottom{ - background-image: url(icons/dialog_bottom.png); - background-repeat: no-repeat; - height:10px; - background-position:left bottom; - width: 302px; + width: 275px; + background: -webkit-gradient(linear, left top, left bottom, from(#556c90), to(#3c4d6a)); + border: 3px solid #002447; + padding: 20px; + -webkit-border-top-left-radius: 10px; + -webkit-border-top-right-radius: 10px; + -webkit-border-bottom-left-radius: 10px; + -webkit-border-bottom-right-radius: 10px; } #ClearHistoryDialogId div.textLabel{ - background-image: url(icons/icon_dialog_history_clear.png); - background-repeat: no-repeat; - font-size: 22px; - height: 21px; - width: 250px; - padding-left: 40px; - color: #fff; - margin-bottom: 20px; - margin-left: 15px; + text-align: center; + font-size: 22px; + color: #fff; + margin-bottom: 20px; } #ClearHistoryDialogId div.controls{ height: 50px; - /*width: 230px;*/ - width: 302px; + text-align: center; } -#ClearHistoryDialogId div.clearDoneButton{ +#ClearHistoryDialogId div.historyDialogButton { + width: 100px; + height: 54px; + display: inline-block; + background-repeat: no-repeat; + background-repeat: center center; + } - width: 100px; - height: 50px; - background-image: url(icons/button_dialog_history_clear_ok_wait.png); - background-repeat: no-repeat; - background-repeat: center center; - /*margin-right:10px;*/ - float: left; - margin-left:50px; - - +#ClearHistoryDialogId div.clearDoneButton { + background-image: url(icons/button_dialog_history_clear_ok_wait.png); } - #ClearHistoryDialogId div.clearDoneButton:active{ - background-image: url(icons/button_dialog_history_clear_ok_press.png); +#ClearHistoryDialogId div.clearDoneButton:active { + background-image: url(icons/button_dialog_history_clear_ok_press.png); } -#ClearHistoryDialogId div.clearCancelButton{ +#ClearHistoryDialogId div.clearCancelButton { + background-image: url(icons/button_dialog_history_clear_cancel_wait.png); +} - width: 150px; - height: 50px; - background-image: url(icons/button_dialog_history_clear_cancel_wait.png); - background-repeat: no-repeat; - background-repeat: center center; - border: none; - margin:none; - float: left; +#ClearHistoryDialogId div.clearCancelButton:active { + background-image: url(icons/button_dialog_history_clear_cancel_press.png); } - #ClearHistoryDialogId div.clearCancelButton:active { - background-image: url(icons/button_dialog_history_clear_cancel_press.png); +#hiddenDialogOK { + visibility: hidden; + background-image: url(icons/button_dialog_history_clear_ok_press.png); } +#hiddenDialogCancel { + visibility: hidden; + background-image: url(icons/button_dialog_history_clear_cancel_press.png); +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.js --- a/ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/historyview.superpage/clearhistorydialog.js Tue Jul 06 14:03:49 2010 +0300 @@ -12,26 +12,22 @@ function writeClearHistoryDialog() { - var message = window.localeDelegate.translateText("txt_browser_history_delete_are_you_sure"); - //Following string to be localized - BR-2979 - //var message = "Clear All History ?"; + var message = window.localeDelegate.translateText("txt_browser_history_delete_are_you_sure"); var html = - '
    '+ - '
    '+ - '
    '+message +'
    ' + - '
    ' + - '
    '+ - '
    '+ - '
    '+ - '
    ' + /*body*/ - '
    '; - + '
    '+message +'
    ' + + '
    ' + + '
    '+ + '
    '+ + '
    ' + + '
    ' + + '
    '; document.write(html); } function showClearHistoryDialog() { try{ - window.snippets.ClearHistoryDialogId.show(false); + window.snippets.ClearHistoryDialogId.show(false); + window.snippets.RecentUrlViewToolbarId.enabled = false; }catch(e){ alert(e); } } @@ -39,9 +35,10 @@ { window.bookmarksManager.clearHistory(); window.views.WebView.reload(); - window.snippets.ClearHistoryDialogId.hide(); + clearHistoryDialogIdHide(); } function clearHistoryDialogIdHide(){ window.snippets.ClearHistoryDialogId.hide(); + window.snippets.RecentUrlViewToolbarId.enabled = true; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/historyView.html --- a/ginebra2/chrome/bedrockchrome/historyview.superpage/historyView.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/historyview.superpage/historyView.html Tue Jul 06 14:03:49 2010 +0300 @@ -13,8 +13,28 @@ diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.css --- a/ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.css Tue Jul 06 14:03:49 2010 +0300 @@ -1,6 +1,7 @@ body{ padding: 0px; margin: 0px; + background-color: #889cbf; } .HistoryView{ @@ -8,6 +9,11 @@ height:100%; } +#BottomPad { + padding: 8px 10px 8px 10px; + height: 54px; +} + ul#folderMenu, ul#folderMenu ul { list-style-type:none; margin: 0; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.js --- a/ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/historyview.superpage/historyview.js Tue Jul 06 14:03:49 2010 +0300 @@ -1,5 +1,3 @@ -var _prevExpandedUL = null; -var _prevExpandedATag; function openHistoryElement(historyURL) { @@ -35,21 +33,12 @@ var aTag = document.createElement('a'); var subUL = document.createElement('ul'); - // Expand First Item & Hide all the other Items - if (i > 0) - { - aTag.className = 'closed'; - subUL.style.display = 'none'; - } - else - { - aTag.className = 'opened'; - subUL.style.display = 'block'; - _prevExpandedATag = aTag; - _prevExpandedUL = subUL; - } + + aTag.className = 'closed'; + subUL.style.display = 'none'; aTag.href = "#"; + aTag.id = "aTagId_"+i; aTag.innerHTML = '
    '+folderObjects[i]; aTag.onclick = eval('( function(){ toggleHistoryFolder(this, "#'+subUlId+'"); } )'); @@ -88,12 +77,28 @@ snippetId.innerHTML = ""; snippetId.appendChild(mainUL); + var bottomPad = document.createElement("div"); + bottomPad.id = 'BottomPad'; + snippetId.appendChild(bottomPad); + + var todayFolder = document.getElementById("aTagId_"+0); + var todaySubUl = document.getElementById("subUlId_"+0); + toggleHistoryFolder(todayFolder,todaySubUl); + + } catch(E) { alert(E); } } function toggleHistoryFolder(aTag, subUlId){ - try{ + + try{ + var filderList = document.getElementById('folderMenu'); + if (filderList.childNodes.length == 0 ) { + return; + } + + aTag.className = (aTag.className == 'opened') ? 'closed' : 'opened'; $(subUlId).toggle(); //$(subUlId).toggle("blind", {}, 175); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_cancel_press.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_cancel_press.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_cancel_wait.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_cancel_wait.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_ok_press.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_ok_press.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_ok_wait.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/button_dialog_history_clear_ok_wait.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_bottom.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_bottom.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_center.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_center.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_top.png Binary file ginebra2/chrome/bedrockchrome/historyview.superpage/icons/dialog_top.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/networkstatus.snippet/networkstatus.js --- a/ginebra2/chrome/bedrockchrome/networkstatus.snippet/networkstatus.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/networkstatus.snippet/networkstatus.js Tue Jul 06 14:03:49 2010 +0300 @@ -12,10 +12,12 @@ // Watch for page load errors. window.pageController.pageLoadFailed.connect( function() { - if (!window.pageController.loadCanceled ) { - update(); - showNetworkStatus(); + if (!window.pageController.loadCanceled ) { + if (window.pageController.errorUrlMatches) { + update(); + showNetworkStatus(); } + } } ); } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/button_dialog_out_of_memory_ok_press.png Binary file ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/button_dialog_out_of_memory_ok_press.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/button_dialog_out_of_memory_ok_wait.png Binary file ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/button_dialog_out_of_memory_ok_wait.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/icon_dialog_error.png Binary file ginebra2/chrome/bedrockchrome/outofmemory.snippet/icons/icon_dialog_error.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/outofmemory.snippet/outofmemorydialog.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/chrome/bedrockchrome/outofmemory.snippet/outofmemorydialog.css Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,47 @@ +/* OutOfMemory dialog */ + +#OutOfMemoryDialogId +{ + width: 275px; + background: -webkit-gradient(linear, left top, left bottom, from(#556c90), to(#3c4d6a)); + border: 3px solid #002447; + padding: 20px; + -webkit-border-top-left-radius: 10px; + -webkit-border-top-right-radius: 10px; + -webkit-border-bottom-left-radius: 10px; + -webkit-border-bottom-right-radius: 10px; +} + +#OutOfMemoryDialogId span.title { + font-size: 22px; + color: #fff; + margin-left: 20px; +} + +#OutOfMemoryDialogId div.textLabel { + text-align: left; + font-size: 22px; + color: #fff; + margin-top: 20px; +} + +#OutOfMemoryDialogId div.controls { + height: 40px; + text-align: center; +} + +#OutOfMemoryDialogId div.outOfMemoryDialogButton { + width: 100px; + height: 40px; + display: inline-block; + background-repeat: no-repeat; + background-repeat: center center; + } + +#OutOfMemoryDialogId div.outOfMemoryDoneButton { + background-image: url(icons/button_dialog_out_of_memory_ok_wait.png); +} + +#OutOfMemoryDialogId div.outOfMemoryDoneButton:active { + background-image: url(icons/button_dialog_out_of_memory_ok_press.png); +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/outofmemory.snippet/outofmemorydialog.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/chrome/bedrockchrome/outofmemory.snippet/outofmemorydialog.js Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,33 @@ +//outofmemorydialog.js + +function outOfMemoryDialog() +{ + window.pageController.lowMemory.connect(showOutOfMemoryDialog); + window.pageController.outOfMemory.connect(showOutOfMemoryDialog); + + this.write = writeOutOfMemoryDialog; + // do setup + this.write(); + +} + +function writeOutOfMemoryDialog() +{ + var title = window.localeDelegate.translateText("txt_browser_error_dialog_device_low"); + var message = window.localeDelegate.translateText("txt_browser_error_dialog_close_some"); + var html = + '
      ' + title + '
    ' + + '
    ' + message +'
    ' + + '
    ' + + '
    '+ + '
    ' + document.write(html); +} + +function showOutOfMemoryDialog() { + window.snippets.OutOfMemoryDialogId.show(false); +} + +function hideOutOfMemoryDialog(){ + window.snippets.OutOfMemoryDialogId.hide(); +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/icons/Thumbs.db Binary file ginebra2/chrome/bedrockchrome/prompt.snippet/icons/Thumbs.db has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/icons/button_dialog_ok_press.png Binary file ginebra2/chrome/bedrockchrome/prompt.snippet/icons/button_dialog_ok_press.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/icons/button_dialog_ok_wait.png Binary file ginebra2/chrome/bedrockchrome/prompt.snippet/icons/button_dialog_ok_wait.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/icons/icon_dialog_error.png Binary file ginebra2/chrome/bedrockchrome/prompt.snippet/icons/icon_dialog_error.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/prompt.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/chrome/bedrockchrome/prompt.snippet/prompt.css Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,55 @@ +/* Network status (error) dialog styles. */ + +.promptBox { + background: -webkit-gradient(linear, left top, left bottom, from(#546b8f), to(#3b4c69), color-stop(0.0, #aab)); + -webkit-user-select: none; + + padding: 10px; + color: #fff; + + border-radius: 7px; + + border-style: solid; + border-width: 4px; + border-color: #243447; +} + +.promptBox img { + vertical-align: middle; + padding: 0px; +} + +.promptBox ul { + margin: 0px; + padding: 0px; +} + +.promptBox li { + list-style-type: none; + margin-top: 20px; +} + +.promptBox li:first-child { + margin-top: 0px; +} + +.promptBox li:last-child { + margin-top: 4px; + margin-bottom: 0px; +} + +.promptText { + vertical-align: middle; + white-space: nowrap; + overflow: hidden; + //border: solid 1px #f00; +} + +/* Second line of URL text, truncate the text and append an ellipsis. */ +.promptText2 { + vertical-align: middle; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/prompt.snippet/prompt.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/chrome/bedrockchrome/prompt.snippet/prompt.js Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,125 @@ +/*! + \file prompt.js This module contains the promptDialog class which + displays messages. +*/ + +function promptDialog() { + var onChromeComplete = function() + { + // Get external mouse events. + snippets.PromptChromeId.externalMouseEvent.connect(this.handleExternalMouseEvent.bind(this)); + + // Watch for page load errors. + + window.pageController.databaseQuotaExceeded.connect( + function() { + update(); + showPrompt(); + } + ); + + } + + //! Add text to the given DOM element, truncate it at the given width (in pixels). + //! Returns the remainder of the string. + function truncateTextToWidth(element, text, width) + { + element.innerHTML = '' + text + ''; + if(element.offsetWidth > width) + { + var i = 1; + element.innerHTML = ''; + while(element.offsetWidth < (width) && i < text.length) + { + element.innerHTML = text.substr(0,i); + i++; + } + return text.substr(i-1); + } + return ""; + } + + //! Update text elements with error info. + var update = function() + { + // Set URL. Two lines of it are displayed, the first wraps to the second and the second + // is truncated with an ellipsis appended by CSS. + document.getElementById("promptTextUrl2Id").innerHTML = pageController.promptReserved; + + // Set error message. + if(pageController.promptMsg != undefined && pageController.promptMsg != "") { + document.getElementById("promptTextMsgId").innerHTML = pageController.promptMsg; + } + else { + document.getElementById("promptTextMsgId").innerHTML = window.localeDelegate.translateText("txt_browser_error_generic_error_msg"); + } + } + + //! Handles external mouse events - dismisses status dialog. + /*! + \param type the type of event + \param name the name of event + \param description event description + */ + this.handleExternalMouseEvent = function(type, name, description) + { + if (name == "QGraphicsSceneMousePressEvent") { + this.hidePrompt(); + } + } + + //! Show the dialog and shaded overlay. + var showPrompt = function(){ + + var snippet = snippets.PromptChromeId; + snippet.updateOwnerArea(); + snippet.show(true); + snippet.zValue = 1; + snippet.repaint(); + + } + + //! Hide the dialog and shaded overlay. + this.hidePrompt = function(){ + snippets.PromptChromeId.hide(); + } + + //! Create the DOM elements for the dialog. + this.setupPage = function(){ + var html = + '
    ' + + '
      ' + + '
    • ' + + '  ' + + '' + + window.localeDelegate.translateText("txt_browser_info_message") + + '' + + '
    • ' + + '
    • ' + + '
      ' + + '
      ' + + '
    • ' + + '
    • ' + + '' + + '
    • ' + + '
    • ' + + '
      ' + + '
    • ' + + '
    ' + + '
    '; + document.write(html); + new SimpleButton("prompt_okId", + "prompt.snippet/icons/button_dialog_ok_wait.png", + "prompt.snippet/icons/button_dialog_ok_press.png", + "", + this.onOkPressed.bind(this)); + } + + this.onOkPressed = function() { + this.hidePrompt(); + } + + this.setupPage(); + + chrome.chromeComplete.connect(onChromeComplete.bind(this)); +} diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/LegalNotice.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra2/chrome/bedrockchrome/settingsview.superpage/LegalNotice.html Tue Jul 06 14:03:49 2010 +0300 @@ -0,0 +1,22 @@ + + Nokia and Nokia Connection People are trademarks + or registered trademarks of Nokia Corporation. + +

    Copyright 2009 Nokia. All rights reserved. + +

    This product is based on Symbia n OS S60 5th Edition software. + +

    Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. + +

    This product includes certain open source software. The exact terms of the licenses, + disclaimers, acknolwegements and notices are provided below. Nokia offers to provide you + with the source code as defined in the applicable license. Plase send an e-mail + to sourcecode.request@nokia.com or written request to: + +

    Source Code Requests +

    Nokia Corporation +

    P.O.BOX 407 +

    FI-00045 Nokia Group +

    Finland + + \ No newline at end of file diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/SettingsView.html --- a/ginebra2/chrome/bedrockchrome/settingsview.superpage/SettingsView.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/settingsview.superpage/SettingsView.html Tue Jul 06 14:03:49 2010 +0300 @@ -31,10 +31,11 @@ //HIDE THE DIVS ON PAGE LOAD var settingsLoaded = window.pageController.getSettingsLoaded(); var image1; - var image2 + var image2; + var image3; var imagesrc1; var imagesrc2; - + var imagesrc3; if(settingsLoaded == 0) { @@ -43,35 +44,63 @@ image1.setAttribute("src", "icons/list_headerarrow_closed.png") imagesrc1 = "icons/list_headerarrow_closed.png"; - image2 = document.getElementById("im2"); + image2 = document.getElementById("im2"); image2.setAttribute("src", "icons/list_headerarrow_closed.png"); imagesrc2 = "icons/list_headerarrow_closed.png"; + image3 = document.getElementById("im3"); + image3.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc3 = "icons/list_headerarrow_closed.png"; + } else if(settingsLoaded == 1){ $('div.accordionButtonGS').next().show(); - image1 = document.getElementById("im1"); + image1 = document.getElementById("im1"); image1.setAttribute("src", "icons/list_headerarrow_open.png") imagesrc1 = "icons/list_headerarrow_open.png"; - image2 = document.getElementById("im2"); + image2 = document.getElementById("im2"); image2.setAttribute("src", "icons/list_headerarrow_closed.png"); imagesrc2 = "icons/list_headerarrow_closed.png"; + + image3 = document.getElementById("im3"); + image3.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc3 = "icons/list_headerarrow_closed.png"; } else if(settingsLoaded == 2) { $('div.accordionButtonCD').next().show(); image1 = document.getElementById("im1"); - image1.setAttribute("src", "icons/list_headerarrow_closed.png"); - imagesrc1 = "icons/list_headerarrow_closed.png"; + image1.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc1 = "icons/list_headerarrow_closed.png"; image2 = document.getElementById("im2"); - image2.setAttribute("src", "icons/list_headerarrow_open.png"); - imagesrc2 = "icons/list_headerarrow_open.png"; + image2.setAttribute("src", "icons/list_headerarrow_open.png"); + imagesrc2 = "icons/list_headerarrow_open.png"; + + image3 = document.getElementById("im3"); + image3.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc3 = "icons/list_headerarrow_closed.png"; + } - + else if(settingsLoaded == 3) + { + $('div.accordionButtonABT').next().show(); + + image1 = document.getElementById("im1"); + image1.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc1 = "icons/list_headerarrow_closed.png"; + + image2 = document.getElementById("im2"); + image2.setAttribute("src", "icons/list_headerarrow_closed.png"); + imagesrc2 = "icons/list_headerarrow_closed.png"; + + image3 = document.getElementById("im3"); + image3.setAttribute("src", "icons/list_headerarrow_open.png"); + imagesrc3 = "icons/list_headerarrow_open.png"; + } //ACCORDION BUTTON ACTION $('div.accordionButtonGS').click(function() { @@ -80,15 +109,17 @@ $(this).next().toggle(); $('div.accordionButtonCD').next().hide(); - + $('div.accordionButtonABT').next().hide(); + image1 = document.getElementById("im1"); image2 = document.getElementById("im2"); - + image3 = document.getElementById("im3"); + if(imagesrc1 == "icons/list_headerarrow_closed.png") // current state { imagesrc1 = "icons/list_headerarrow_open.png"; imagesrc2 = "icons/list_headerarrow_closed.png"; - + imagesrc3 = "icons/list_headerarrow_closed.png"; } else // imagesrc1 == "icons/list_headerarrow_open.png" { @@ -96,7 +127,7 @@ } image1.setAttribute("src", imagesrc1); image2.setAttribute("src", imagesrc2); - + image3.setAttribute("src", imagesrc3); }); @@ -104,14 +135,17 @@ $(this).next().toggle(); $('div.accordionButtonGS').next().hide(); + $('div.accordionButtonABT').next().hide(); image1 = document.getElementById("im1"); image2 = document.getElementById("im2"); - + image3 = document.getElementById("im3"); + if(imagesrc2 == "icons/list_headerarrow_closed.png") // current state { imagesrc2 = "icons/list_headerarrow_open.png"; - imagesrc1 = "icons/list_headerarrow_closed.png"; + imagesrc1 = "icons/list_headerarrow_closed.png"; + imagesrc3 = "icons/list_headerarrow_closed.png"; } else // imagesrc2 == "icons/list_headerarrow_open.png" @@ -119,10 +153,36 @@ imagesrc2 = "icons/list_headerarrow_closed.png"; } image1.setAttribute("src", imagesrc1); - image2.setAttribute("src", imagesrc2); + image2.setAttribute("src", imagesrc2); + image3.setAttribute("src", imagesrc3); }); + $('div.accordionButtonABT').click(function() { + + $(this).next().toggle(); + $('div.accordionButtonGS').next().hide(); + $('div.accordionButtonCD').next().hide(); + + image1 = document.getElementById("im1"); + image2 = document.getElementById("im2"); + image3 = document.getElementById("im3"); + + if(imagesrc3 == "icons/list_headerarrow_closed.png") // current state + { + imagesrc3 = "icons/list_headerarrow_open.png"; + imagesrc1 = "icons/list_headerarrow_closed.png"; + imagesrc2 = "icons/list_headerarrow_closed.png"; + } + else // imagesrc3 == "icons/list_headerarrow_open.png" + { + imagesrc3 = "icons/list_headerarrow_closed.png"; + } + image1.setAttribute("src", imagesrc1); + image2.setAttribute("src", imagesrc2); + image3.setAttribute("src", imagesrc3); + + }); @@ -138,11 +198,11 @@

    -
        General Settings
    +
        

    -
    Character Encoding
    +
    @@ -208,7 +268,7 @@
    - + @@ -226,7 +286,7 @@ -
        Clear Data
    +
        

    @@ -234,27 +294,24 @@
    - + - + - + - + + - - - - - +
    Save Browsing History
    Cache    
    Cookies    
    History    
    Bookmarks    
    Forms and Passwords  
    All    
    @@ -262,8 +319,54 @@
    -
    +
        
    +

    +
    + + + + + + + + + + + +
    Nokia Browser  
    +
    + +
    +
    + +
    +
    +
    +
    +
    diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/delete_btn.png Binary file ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/delete_btn.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/delete_btn_pressed.png Binary file ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/delete_btn_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/yes_btn.png Binary file ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/yes_btn.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/yes_btn_pressed.png Binary file ginebra2/chrome/bedrockchrome/settingsview.superpage/icons/yes_btn_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.css --- a/ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.css Tue Jul 06 14:03:49 2010 +0300 @@ -2,6 +2,7 @@ padding: 0px; margin: 0px; font-size: 20px; + background-color: #889cbf; } #wrapper { @@ -9,6 +10,12 @@ margin-right: auto; } +#BottomPad { + clear: both; + padding: 8px 10px 8px 10px; + height: 54px; + } + .accordionButton { float: left; background: #AAAAAA; @@ -39,6 +46,18 @@ cursor: pointer; } +.accordionButtonABT { + font-size: 20px; + width: 100%; + padding-top: 10px; + padding-bottom: 10px; + float: left; + color:#283F52; + background: #E1F1FF; + border-bottom: 1px solid #FFFFFF; + cursor: pointer; + } + .accordionContent { font-size: 20px; padding-left: 20px; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.js --- a/ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/settingsview.superpage/settingsview.js Tue Jul 06 14:03:49 2010 +0300 @@ -93,6 +93,10 @@ } +function localizeString(logicalString) +{ + document.getElementById(logicalString).innerHTML = window.localeDelegate.translateText(logicalString); +} function initForms() { @@ -141,22 +145,29 @@ var cs2 = document.getElementById("id2"); var cs3 = document.getElementById("id3"); var cs4 = document.getElementById("id4"); - var cs5 = document.getElementById("id5"); + //var cs5 = document.getElementById("id5"); var cs6 = document.getElementById("id6"); cs1.setAttribute("src", "icons/broom_sweep.png"); cs2.setAttribute("src", "icons/broom_sweep.png"); cs3.setAttribute("src", "icons/broom_sweep.png"); cs4.setAttribute("src", "icons/broom_sweep.png"); - cs5.setAttribute("src", "icons/broom_sweep.png"); - cs6.setAttribute("src", "icons/broom_sweep.png"); - - - if(window.chrome.displayMode == "portrait") - document.getElementById("cd2").width = "100%"; - else - document.getElementById("cd2").width = "100%"; //I need this line to handle some problems with landscape in the future. The value may be different from 100% - + //cs5.setAttribute("src", "icons/broom_sweep.png"); + cs6.setAttribute("src", "icons/broom_sweep.png"); + + localizeString("txt_browser_settings_general_settings"); + localizeString("txt_browser_settings_general_settings_character_encoding"); + localizeString("txt_browser_settings_general_settings_save_browser_history"); + localizeString("txt_browser_settings_clear_data"); + localizeString("txt_browser_settings_clear_data_cache"); + localizeString("txt_browser_settings_clear_data_cookies"); + localizeString("txt_browser_settings_clear_data_history"); + localizeString("txt_browser_settings_clear_data_bookmarks"); + //localizeString("txt_browser_settings_clear_data_form_data"); + localizeString("txt_browser_settings_clear_data_all"); + localizeString("txt_browser_settings_general_settings_about"); + + } window.onload = initForms; @@ -226,6 +237,8 @@ window.pageController.deleteCache(); var cs1 = document.getElementById("id1"); cs1.setAttribute("src", "icons/broom_sweep.gif"); + setTimeout("initForms()", 2000); + return; } if (field == "cookies") // Cookies @@ -233,7 +246,8 @@ var cs2 = document.getElementById("id2"); cs2.setAttribute("src", "icons/broom_sweep.gif"); window.pageController.deleteCookies(); - //pausecomp(5000); + setTimeout("initForms()", 2000); + return; } @@ -243,8 +257,8 @@ window.bookmarksManager.clearHistory(); var cs3 = document.getElementById("id3"); cs3.setAttribute("src", "icons/broom_sweep.gif"); - - + setTimeout("initForms()", 2000); + return; //window.views.WebView.reload(); @@ -256,36 +270,35 @@ window.bookmarksManager.clearBookmarks(); var cs4 = document.getElementById("id4"); cs4.setAttribute("src", "icons/broom_sweep.gif"); + setTimeout("initForms()", 2000); + return; //window.views.WebView.reload(); } - if (field == "forms") // forms and passwords - { - - var cs5 = document.getElementById("id5"); - cs5.setAttribute("src", "icons/broom_sweep.gif"); - ;// place holder - - } - + if (field == "all") // everything { - window.pageController.deleteCache(); + var cs6 = document.getElementById("id6"); + cs6.setAttribute("src", "icons/broom_sweep.gif"); + setTimeout("initForms();deleteData()", 2000); + return; + + } + + +} + +function deleteData() +{ + window.pageController.deleteCache(); window.pageController.deleteCookies(); window.bookmarksManager.clearHistory(); window.bookmarksManager.clearBookmarks(); window.pageController.deleteDataFiles(); - var cs6 = document.getElementById("id6"); - cs6.setAttribute("src", "icons/broom_sweep.gif"); - } - - setTimeout("initForms()", 2000); } - - function setValue(selectedIndex) { //alert(this.options[this.selectedIndex].value); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.css --- a/ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.css Tue Jul 06 14:03:49 2010 +0300 @@ -77,7 +77,7 @@ padding: 1; } -#ruler { +#sbruler { font-size:12px; font-weight: bold; visibility: hidden; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.js --- a/ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.js Tue Jul 06 14:03:49 2010 +0300 @@ -65,10 +65,10 @@ if (window.views.WebView.currentPageIsSuperPage()) { //alert(window.views.WebView.currentSuperPageName()); if (window.views.WebView.currentSuperPageName() == "BookmarkTreeView") { - setTitle(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_bookmarks"), false); + setTitle(window.localeDelegate.translateText("txt_browser_bookmarks_bookmarks"), false); } else if (window.views.WebView.currentSuperPageName() == "BookmarkHistoryView") { - setTitle(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_history"), false); + setTitle(window.localeDelegate.translateText("txt_browser_history_history"), false); } else if (window.views.WebView.currentSuperPageName() == "SettingsView") { setTitle(window.localeDelegate.translateText("txt_browser_settings_settings"), false); @@ -76,9 +76,14 @@ } else { if (window.views.current().type == "webView") { + + //enable the double click for the content view page + if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) + window.views.WebView.touchNav.doubleClickEnabled = true; + /* For new windows, show title as 'New Window' */ if ((window.pageController.currentDocTitle == "") && (window.pageController.currentRequestedUrl == "")) { - setTitle(window.localeDelegate.translateText("txt_browser_windows_new_window"), false); + setTitle(window.localeDelegate.translateText("txt_browser_content_view_new_window"), false); } else if (window.pageController.currentDocTitle == "") { if (window.pageController.currentDocUrl == "") { @@ -268,7 +273,7 @@ updateFieldWidth(htmlEncode(networkName)); document.getElementById('provider').innerHTML = htmlEncode(networkName); - // repaint if status bar exists (first call to this function, it doesn't) + // repaint if status bar exists if (window.snippets.StatusBarChromeId) window.snippets.StatusBarChromeId.repaint(); } @@ -308,7 +313,6 @@ currentState = state; document.getElementById('strength').innerHTML = networkIconSrc[currentState]; - window.snippets.StatusBarChromeId.repaint(); // if we went offline, change the provider name to "offline" if (currentState == enumNetworkStrengths.state.Offline) @@ -411,7 +415,6 @@ { document.getElementById('battery').innerHTML = batteryIconSrc[convertLevelToState(level)]; - window.snippets.StatusBarChromeId.repaint(); } } @@ -475,13 +478,8 @@ ''+ ''+ // ruler span used for getting the width of network name - // style included here because style sheet not applied early - // enough for sbNetworkStatus.showInitialNetworkName call below - // which needs text width which depends on font - ''; + ''; document.write(html); - - sbNetworkStatus.showInitialNetworkName(); } // StatusBar Constructor @@ -494,6 +492,10 @@ // This is because they don't have access to "this" as they are invoked // as functions rather than as methods. + // On chromeComplete signal, show initial network name. + window.chrome.chromeComplete.connect( + function() {sbNetworkStatus.showInitialNetworkName();}); + // Connect page controller signals to slots. window.pageController.titleChanged.connect( function(title) {sbTitle.handleTitleChange(title);}); @@ -512,13 +514,6 @@ } ); - window.ViewStack.currentViewChanged.connect( - function() { - sbTitle.handleCurrentViewChange(); - sbLockStatus.handleCurrentViewChange(); - } - ); - // Connect device delegate signals to slots. window.deviceDelegate.batteryLevelChanged.connect( function(level) {sbBatteryStatus.handleLevelChange(level);}); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/suggests.snippet/icons/bottomshadow.png Binary file ginebra2/chrome/bedrockchrome/suggests.snippet/icons/bottomshadow.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/suggests.snippet/icons/divider.png Binary file ginebra2/chrome/bedrockchrome/suggests.snippet/icons/divider.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/suggests.snippet/icons/topshadow.png Binary file ginebra2/chrome/bedrockchrome/suggests.snippet/icons/topshadow.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/suggests.snippet/suggests.js --- a/ginebra2/chrome/bedrockchrome/suggests.snippet/suggests.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/suggests.snippet/suggests.js Tue Jul 06 14:03:49 2010 +0300 @@ -84,7 +84,7 @@ { var recenturl; var recenttitle = window.localeDelegate.translateText( - "txt_browser_url_bar_drop_down_search_for"); + "txt_browser_chrome_suggests_search_for"); var snippetId = document.getElementById('SuggestsId'); var suggests = window.pageController.fetchSuggestions(input); var suggestUL = document.createElement('ul'); @@ -210,7 +210,7 @@ */ this.handleExternalMouseEvent = function(type, name, description) { - if (name == "QGraphicsSceneMousePressEvent") { + if (name == "MouseClick") { _hideSuggests(); } } @@ -236,6 +236,19 @@ } } + //! Called when URL search bar looses focus. The external mouse event + //! handler deals with most cases where the suggestion list should be + //! dismissed but we don't get those events when the list isn't visible + //! so this handler is needed to cancel the timer in those cases. + this.urlSearchLostFocus = function() + { + // if visible user may be scrolling suggestion page so ignore focus change + if (!snippets.SuggestsChromeId.visible) { + // prevent suggestion list from being displayed until URL edited again + clearTimeout(inputTimeoutId); + } + } + //! Sets the user input URL suggest delay. /*! \param to the new delay time. diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_disabled.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_disabled.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_pressed.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_clearall_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited_pressed.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB_pressed.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggleTB_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_fullTB.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_fullTB.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_fullTB_pressed.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_fullTB_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_partialTB.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_partialTB.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_partialTB_pressed.png Binary file ginebra2/chrome/bedrockchrome/toolbar.snippet/icons/icon_toggle_partialTB_pressed.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.css --- a/ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.css Tue Jul 06 14:03:49 2010 +0300 @@ -17,6 +17,7 @@ width: 58px; padding-left: 10px; padding-top: 5px; + float:left; } diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.js --- a/ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.js Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/bedrockchrome/zoombar.snippet/zoombar.js Tue Jul 06 14:03:49 2010 +0300 @@ -6,12 +6,10 @@ Class to handle displaying the zoom bar. The zoom bar is displayed when the user presses the zoom button on the toolbar. It provides access to the zoom in and out functions. It is hidden when the main toolbar is hidden on user inactivity + and on timer maintained by native code */ function ZoomBar() { - var timeoutId = 0; // inactivity timer ID - var ZB_TIMEOUT = 5000; // hide zoombar after 5 secs - var zooming = false; // true when in the process of zooming var enabled = true; // zooming enabled flag - initially enabled // Private Methods @@ -19,63 +17,30 @@ function _zoombar_write() { var html = ''+ '
    '+ - ''+ - ''+ + '
    '+ + '
    '+ + '
    '; document.write(html); } //! Create zoom in & out buttons. function _setActions() { - new ActionButton("zoomBarBtnIn", - "zoombar.snippet/icons/icon_zoom+.png", - "zoombar.snippet/icons/icon_zoom+_pressed.png", - "zoombar.snippet/icons/icon_zoom+_disabled.png", - window.views.WebView.actions.zoomIn, - true,true,true); + snippets.zoomBarBtnIn.connectAction("zoomIn", "WebView", true, true); + snippets.zoomBarBtnOut.connectAction("zoomOut", "WebView", true, true); + snippets.zoomBarBtnIn.setIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+.png"); + snippets.zoomBarBtnIn.setActiveIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+_pressed.png"); + snippets.zoomBarBtnIn.setDisabledIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+_disabled.png"); + snippets.zoomBarBtnOut.setIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-.png"); + snippets.zoomBarBtnOut.setActiveIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-_pressed.png"); + snippets.zoomBarBtnOut.setDisabledIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-_disabled.png"); - new ActionButton("zoomBarBtnOut", - "zoombar.snippet/icons/icon_zoom-.png", - "zoombar.snippet/icons/icon_zoom-_pressed.png", - "zoombar.snippet/icons/icon_zoom-_disabled.png", - window.views.WebView.actions.zoomOut, - true,true,true); - - // reset toolbar timeout each time a zoom is triggered -// window.views.WebView.actions.zoomIn.triggered.connect( -// function(checked) {handleZoom();}); -// window.views.WebView.actions.zoomOut.triggered.connect( -// function(checked) {handleZoom();}); // Connect to each action's "changed" signal. window.views.WebView.actions.zoomIn.changed.connect( createDelegate(this, handleChange)); window.views.WebView.actions.zoomOut.changed.connect( createDelegate(this, handleChange)); - } - //! Set inactivity timer when not zooming. - function handleZoom() - { - // zoom activation toggles zoom on/off - zooming = !zooming; // toggle zoom state - clearTimeout(timeoutId); - if (!zooming) { - // close zoom after 5 secs - timeoutId = setTimeout('window.snippets.ZoomBarId.hide()', ZB_TIMEOUT); - } - } - - //! Start inactivity timer when zoom bar is shown. - function handleShow() - { - timeoutId = setTimeout('window.snippets.ZoomBarId.hide()', ZB_TIMEOUT); // close zoom after 5 secs - } - - //! Clear inactivity timer when zoom bar is hidden. - function handleHide() - { - clearTimeout(timeoutId); - zooming = false; // ensure zooming state doesn't get out of sync } //! Handle action object changes. In particular we are interested in @@ -97,17 +62,11 @@ window.snippets.ZoomButtonSnippet.setEnabled(enabled); } } - function handleLoadStarted() { - window.snippets.ZoomBarId.hide() - } //! After chrome is loaded, create zoombar buttons and setup show/hide //! handlers. function _chromeLoadComplete() { _setActions(); - window.pageController.loadStarted.connect(handleLoadStarted); -// window.snippets.ZoomBarId.shown.connect(handleShow); -// window.snippets.ZoomBarId.hidden.connect(handleHide); } _zoombar_write(); diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/localpages/bedrock.png Binary file ginebra2/chrome/localpages/bedrock.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/localpages/bedrock_splash.png Binary file ginebra2/chrome/localpages/bedrock_splash.png has changed diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/localpages/relnotes.html --- a/ginebra2/chrome/localpages/relnotes.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/localpages/relnotes.html Tue Jul 06 14:03:49 2010 +0300 @@ -1,6 +1,6 @@ - Bedrock Browser Release Notes + Nokia Browser 8.0 Release Notes @@ -25,25 +25,25 @@


    Release Notes for
    - Bedrock Browser TRUNK VERSION
    + Nokia Browser 8.0 TRUNK VERSION

    - Updated: 25-May-2010
    + Updated: 2-Jun-2010

    NOTE: These release notes are for TRUNK version releases ONLY. When branched for final release, a final set of release notes will be replace this file.

    NOTE: These release notes were current as of the time the software was packaged for release. For up-to-date release notes, visit the Browser Team's Wiki pages.

    Overview of the Release:

    -

    The Bedrock Browser is Nokia's latest web browser based on the latest open-source WebKit +

    The Nokia Browser is Nokia's latest web browser based on the latest open-source WebKit engine and built using the Qt application framework.

    -

    The Bedrock project's mission is to provide a fast, easy to use, web-standards based browser +

    The Nokia ASF Browser project's mission is to provide a fast, easy to use, web-standards based browser that can compete alongside the best of the mobile browsers.

    -

    This release of Bedrock is the Alpha 3 release. While the functionality has certainly has been enhanced +

    This is the Alpha 4 release of the Nokia Browser. While the functionality has certainly has been enhanced since the Alpha 1 and 2 releases (which were released to a very limited audience) and the performance has also been improved significantly, the performance is still behind where we want and need it to be.

    Please review the rest of the Release Notes and provide feedback on this release via the feedback mechanisms on the Backstage site.

    Target Platforms/Devices:

      -
    • The Bedrock Browser is released as a signed SIS package that can be installed on N97 devices. We recommend using a CE device with the latest +
    • The Nokia Browser is released as a signed SIS package that can be installed on N97 devices. We recommend using a CE device with the latest firmware patches as opposed to an R&D / prototype devices.

    Prerequisites:

    @@ -54,7 +54,7 @@
  • NOTE: It is required for this release that you install ALL of the provided software packages on the C: drive.
  • NOTE: If you had previously installed the Alpha 1 release OR any version of the Qt framework, please review the installation notes carefully and remove older components from your device as directed..
  • Default network setup on the device. The N97 connection settings must contain a default Destination Network of "Internet" that contains the proper access points (APs). The browser will connect to the network via this "Internet" Destination Network.
  • -
  • IMPORTANT: Ensure that the default access point (as defined in the connection settings for the Destination Network) is available when running the Bedrock browser. There have been cases where an unavailable WLAN AP prevented loading of pages.
  • +
  • IMPORTANT: Ensure that the default access point (as defined in the connection settings for the Destination Network) is available when running the browser. There have been cases where an unavailable WLAN AP prevented loading of pages.
  • Functionality to Evaluate:

    The following features are a few we encourage you to try out! @@ -75,7 +75,7 @@

    Known Limitations:

      -
    • WebKit Performance: Although improved, there are a number of known issues with the Qt WebKit used in the release of Bedrock. Some have a major impact on performance of the engine. For example, rendering after a zoom-level change is known to be slow. See our wiki page for more details.
    • +
    • WebKit Performance: Although improved, there are a number of known issues with the Qt WebKit used in the release of the Browser. Some have a major impact on performance of the engine. For example, rendering after a zoom-level change is known to be slow. See our wiki page for more details.
    • Out of Memory Handling: Handling of low memory conditions is not yet optimized for browsing large web pages. In some case, loading large or image-intensive pages can cause the browser to lock-up or crash. Please report the sites/pages to us if you experience this.
    • UI Performance: We are still evaluating and responding to performance issues. When using this Alpha release, please be patient when performing actions. Avoid repeating the same actions quickly in response to a lack of response. Once a button or link is pressed or a touch gesture is applied, it may take some time for the resulting action to be reflected in the UI. Also, sometimes touch gestures are "lost" and you may need to repeat them to activate the control.
    • @@ -100,6 +100,10 @@
    • The URL entry bar is now designed to "scroll off" the top of the view when the page is scrolled up. It has been noticed that sometimes the bar will not re-display after scrolling back up.

    END OF RELEASE NOTES

    +

     

    +

     

    +

     

    +

     

    diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/localpages/startpage.css --- a/ginebra2/chrome/localpages/startpage.css Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/localpages/startpage.css Tue Jul 06 14:03:49 2010 +0300 @@ -23,7 +23,7 @@ margin-left:auto; margin-right:auto; } -img#bedrock_logo { +img#browser_logo { height:40%; display:block; margin-left:auto; diff -r 0f2326c2a325 -r 1c3b8676e58c ginebra2/chrome/localpages/startpage.html --- a/ginebra2/chrome/localpages/startpage.html Wed Jun 23 17:59:43 2010 +0300 +++ b/ginebra2/chrome/localpages/startpage.html Tue Jul 06 14:03:49 2010 +0300 @@ -1,6 +1,6 @@ - Bedrock Browser Welcome Page + Welcome Page @@ -23,7 +23,6 @@ butt2.setAttribute('class', 'button'); break; } - } @@ -32,7 +31,7 @@
    - +