diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/mainview.cpp | 96 | ||||
-rw-r--r-- | src/mainview.h | 12 | ||||
-rw-r--r-- | src/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/mainwindow.h | 1 | ||||
-rw-r--r-- | src/tabbar.cpp | 62 | ||||
-rw-r--r-- | src/tabbar.h | 8 | ||||
-rw-r--r-- | src/webpage.cpp | 49 | ||||
-rw-r--r-- | src/webpage.h | 17 |
10 files changed, 130 insertions, 132 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bb89a5bf..9530b216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ PROJECT( rekonq ) # Informations to update before to release this package. # rekonq info -SET(REKONQ_VERSION "0.2.90" ) +SET(REKONQ_VERSION "0.2.91" ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4faece61..279d9519 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,7 +64,6 @@ TARGET_LINK_LIBRARIES ( rekonq ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} - ${QT_QTUITOOLS_LIBRARY} ${KDE4_KUTILS_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} diff --git a/src/mainview.cpp b/src/mainview.cpp index 0956e3ff..04ede24c 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -68,6 +68,7 @@ MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_urlBar(new UrlBar(this)) , m_tabBar(new TabBar(this)) + , m_addTabButton(new QToolButton(this)) , m_currentTabIndex(0) { // setting tabbar @@ -97,13 +98,82 @@ MainView::MainView(QWidget *parent) // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); + QTimer::singleShot(0, this, SLOT(postLaunch())); +} + + +MainView::~MainView() +{ +} + + +void MainView::postLaunch() +{ // Session Manager connect (this, SIGNAL(tabsChanged()), Application::sessionManager(), SLOT(saveSession())); + + // Find the correct MainWindow of this tab button + MainWindowList list = Application::instance()->mainWindowList(); + Q_FOREACH(QPointer<MainWindow> w, list) + { + if (w->isAncestorOf(this)) + { + m_addTabButton->setDefaultAction(w->actionByName("new_tab")); + break; + } + } + + m_addTabButton->setAutoRaise(true); + m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); } -MainView::~MainView() +void MainView::updateTabButtonPosition() { + kDebug() << "updating new tab button position.."; + + static bool ButtonInCorner = false; + + int tabWidgetWidth = frameSize().width(); + int tabBarWidth = m_tabBar->tabSizeHint(0).width()*m_tabBar->count(); + + if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) + { + if(ButtonInCorner) + return; + setCornerWidget(m_addTabButton); + ButtonInCorner = true; + } + else + { + if(ButtonInCorner) + { + setCornerWidget(0); + m_addTabButton->show(); + ButtonInCorner = false; + } + + // detecting X position + int newPosX = tabBarWidth; + int tabWidthHint = m_tabBar->tabSizeHint(0).width(); + if (tabWidthHint < sizeHint().width()/4) + newPosX = tabWidgetWidth - m_addTabButton->width(); + + // detecting Y position + int newPosY = m_tabBar->height() - m_addTabButton->height(); + if(newPosY < 0) + newPosY = 5; // this hardcoded value is used in just ONE situation: + // the first time an user changes the "Always Show Tab Bar" settings + // try some better fixes, if you can :D + + m_addTabButton->move(newPosX, newPosY); + } +} + + +QToolButton *MainView::addTabButton() const +{ + return m_addTabButton; } @@ -138,23 +208,25 @@ void MainView::updateTabBar() if (m_tabBar->isHidden()) { m_tabBar->show(); + m_addTabButton->show(); } - m_tabBar->updateNewTabButton(); + updateTabButtonPosition(); + return; + } + + if (m_tabBar->count() == 1) + { + m_tabBar->hide(); + m_addTabButton->hide(); } else { - if (m_tabBar->count() == 1) - { - m_tabBar->hide(); - } - else + if (m_tabBar->isHidden()) { - if (m_tabBar->isHidden()) - { - m_tabBar->show(); - } - m_tabBar->updateNewTabButton(); + m_tabBar->show(); + m_addTabButton->show(); } + updateTabButtonPosition(); } } diff --git a/src/mainview.h b/src/mainview.h index c2795048..f0fe183d 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -39,6 +39,9 @@ // KDE Includes #include <KTabWidget> +// Qt Includes +#include <QtGui/QToolButton> + // Forward Declarations class QUrl; class QWebFrame; @@ -78,6 +81,8 @@ public: * */ void updateTabBar(); + + QToolButton *addTabButton() const; void clear(); /** @@ -137,10 +142,14 @@ private slots: void windowCloseRequested(); + void postLaunch(); + protected: virtual void resizeEvent(QResizeEvent *event); private: + void updateTabButtonPosition(); + /** * This function creates (if not exists) and returns a QLabel * with a loading QMovie. @@ -158,6 +167,9 @@ private: QString m_loadingGitPath; + // the new tab button + QToolButton *m_addTabButton; + int m_currentTabIndex; QList<HistoryItem> m_recentlyClosedTabs; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f079c8b9..796c2bad 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -101,6 +101,7 @@ MainWindow::MainWindow() , m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) ) , m_popup( new KPassivePopup(this) ) + , m_hidePopup( new QTimer(this) ) , m_ac( new KActionCollection(this) ) { // enable window size "auto-save" @@ -146,6 +147,7 @@ MainWindow::MainWindow() connect(Application::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)), m_popup, SLOT(hide())); m_popup->setFrameShape(QFrame::NoFrame); m_popup->setLineWidth(0); + connect(m_hidePopup, SIGNAL(timeout()), m_popup, SLOT(hide())); QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -240,7 +242,7 @@ QSize MainWindow::sizeHint() const } -KActionCollection *MainWindow::actionCollection () const +KActionCollection *MainWindow::actionCollection() const { return m_ac; } @@ -460,7 +462,7 @@ void MainWindow::setupSidePanel() void MainWindow::slotUpdateConfiguration() { // ============== General ================== - mainView()->updateTabBar(); + m_view->updateTabBar(); // =========== Fonts ============== QWebSettings *defaultSettings = QWebSettings::globalSettings(); @@ -951,12 +953,12 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) // deleting popus if empty msgs if(msg.isEmpty()) { - m_popup->hide(); + m_hidePopup->start(250); return; } - QPixmap px; - QString pixPath; + m_hidePopup->stop(); + switch(status) { @@ -976,9 +978,9 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) // setting the popup QLabel *label = new QLabel(msg); - label->setMaximumWidth(width()-2*margin); m_popup->setView(label); QSize labelSize(label->fontMetrics().width(msg)+2*margin, label->fontMetrics().height()+2*margin); + if (labelSize.width() > width()) labelSize.setWidth(width()); m_popup->setFixedSize(labelSize); m_popup->layout()->setAlignment(Qt::AlignTop); m_popup->layout()->setMargin(margin); diff --git a/src/mainwindow.h b/src/mainwindow.h index 64e2067c..50c3e7dc 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -168,6 +168,7 @@ private: QString m_lastSearch; KPassivePopup *m_popup; + QTimer *m_hidePopup; KActionCollection *m_ac; diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 65a65f7e..7e83f69d 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -64,7 +64,6 @@ TabBar::TabBar(MainView *parent) : KTabBar(parent) , m_parent(parent) - , m_addTabButton(new QToolButton(this)) , m_currentTabPreview(-1) { setElideMode(Qt::ElideRight); @@ -77,8 +76,6 @@ TabBar::TabBar(MainView *parent) connect(this, SIGNAL(contextMenu(int, const QPoint &)), this, SLOT(slotContextMenuRequested(int, const QPoint &))); connect(this, SIGNAL(emptyAreaContextMenu(const QPoint &)), this, SLOT(slotEmptyAreaContextMenu(const QPoint &))); - - QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -87,27 +84,9 @@ TabBar::~TabBar() } -void TabBar::postLaunch() -{ - // Find the correct MainWindow of this tab button - MainWindowList list = Application::instance()->mainWindowList(); - Q_FOREACH(QPointer<MainWindow> w, list) - { - if (w->isAncestorOf(this)) - { - m_addTabButton->setDefaultAction(w->actionByName("new_tab")); - break; - } - } - - m_addTabButton->setAutoRaise(true); - m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); -} - - QSize TabBar::tabSizeHint(int index) const { - int buttonSize = m_addTabButton->size().width(); + int buttonSize = m_parent->addTabButton()->size().width(); int tabBarWidth = m_parent->size().width() - buttonSize; int baseWidth = m_parent->sizeHint().width()/BASE_WIDTH_DIVISOR; int minWidth = m_parent->sizeHint().width()/MIN_WIDTH_DIVISOR; @@ -165,6 +144,10 @@ void TabBar::showTabPreview(int tab) WebView *view = m_parent->webView(tab); WebView *currentView = m_parent->webView(currentIndex()); + // should fix bug #212219 + if(!currentView) + return; + int w = tabSizeHint(tab).width(); int h = w*((0.0 + currentView->height())/currentView->width()); @@ -243,6 +226,7 @@ void TabBar::leaveEvent(QEvent *event) KTabBar::leaveEvent(event); } + void TabBar::mousePressEvent(QMouseEvent *event) { // just close tab on middle mouse click @@ -253,40 +237,6 @@ void TabBar::mousePressEvent(QMouseEvent *event) } -void TabBar::updateNewTabButton() -{ - static bool ButtonInCorner = false; - - int tabWidgetWidth = m_parent->frameSize().width(); - int tabBarWidth = tabSizeHint(0).width() * count(); - - if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) - { - if(ButtonInCorner) - return; - m_parent->setCornerWidget(m_addTabButton); - ButtonInCorner = true; - } - else - { - if(ButtonInCorner) - { - m_parent->setCornerWidget(0); - m_addTabButton->show(); - ButtonInCorner = false; - } - - int newPosX = tabWidgetWidth - m_addTabButton->width(); - int newPosY = height() - m_addTabButton->height(); - - if (tabBarWidth + m_addTabButton->width() < tabWidgetWidth) - newPosX = tabBarWidth; - - m_addTabButton->move(newPosX, newPosY); - } -} - - void TabBar::slotContextMenuRequested(int tab, const QPoint &pos) { m_actualIndex = tab; diff --git a/src/tabbar.h b/src/tabbar.h index f68528b8..1601b3b6 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -42,7 +42,6 @@ // Forward Declarations class QPoint; -class QToolButton; class QMouseEvent; class QEvent; @@ -63,7 +62,6 @@ public: ~TabBar(); void showTabPreview(int tab); - void updateNewTabButton(); signals: void cloneTab(int index); @@ -77,6 +75,7 @@ protected: * Added to fix tab dimension */ virtual QSize tabSizeHint(int index) const; + virtual void mouseMoveEvent(QMouseEvent *event); virtual void leaveEvent(QEvent *event); virtual void mousePressEvent(QMouseEvent *event); @@ -87,14 +86,13 @@ private slots: void closeOtherTabs(); void reloadTab(); - void postLaunch(); - void slotContextMenuRequested(int, const QPoint &); void slotEmptyAreaContextMenu(const QPoint &); private: + friend class MainView; + MainView *m_parent; - QToolButton *m_addTabButton; /** * the index in which we are seeing a Context menu diff --git a/src/webpage.cpp b/src/webpage.cpp index 3754444b..01e98dfd 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -49,12 +49,12 @@ #include <KUrl> #include <KDebug> #include <KToolInvocation> +#include <KProtocolManager> #include <KDE/KParts/BrowserRun> #include <KDE/KMimeTypeTrader> #include <KDE/KRun> #include <KDE/KFileDialog> -#include <KDE/KInputDialog> #include <KDE/KMessageBox> #include <KDE/KJobUiDelegate> @@ -65,8 +65,6 @@ #include <QtGui/QClipboard> #include <QtGui/QKeyEvent> -#include <QtUiTools/QUiLoader> - WebPage::WebPage(QObject *parent) : QWebPage(parent) @@ -264,39 +262,6 @@ QString WebPage::errorPage(QNetworkReply *reply) } -void WebPage::javaScriptAlert(QWebFrame *frame, const QString &msg) -{ - KMessageBox::error(frame->page()->view(), msg, i18n("JavaScript")); -} - - -bool WebPage::javaScriptConfirm(QWebFrame *frame, const QString &msg) -{ - return (KMessageBox::warningYesNo(frame->page()->view(), msg, i18n("JavaScript"), KStandardGuiItem::ok(), KStandardGuiItem::cancel()) - == KMessageBox::Yes); -} - - -bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result) -{ - bool ok = false; - *result = KInputDialog::getText(i18n("JavaScript"), msg, defaultValue, &ok, frame->page()->view()); - return ok; -} - - -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -{ - kDebug() << "create Plugin requested:"; - kDebug() << "classid:" << classId; - kDebug() << "url:" << url; - kDebug() << "paramNames:" << paramNames << " paramValues:" << paramValues; - - QUiLoader loader; - return loader.createWidget(classId, view()); -} - - // TODO FIXME: sometimes url.fileName() fails to retrieve url file name void WebPage::slotDownloadRequested(const QNetworkRequest &request) { @@ -310,3 +275,15 @@ void WebPage::slotDownloadRequested(const QNetworkRequest &request) job->addMetaData("cache", "cache"); // Use entry from cache if available. job->uiDelegate()->setAutoErrorHandlingEnabled(true); } + + +QString WebPage::userAgentForUrl(const QUrl& _url) const +{ + const KUrl url(_url); + QString userAgent = KProtocolManager::userAgentForHost((url.isLocalFile() ? "localhost" : url.host())); + + if (userAgent == KProtocolManager::defaultUserAgent()) + return QWebPage::userAgentForUrl(_url); + + return userAgent; +} diff --git a/src/webpage.h b/src/webpage.h index 86024a9d..0d9868b9 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -60,22 +60,9 @@ protected: virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); + + virtual QString userAgentForUrl(const QUrl& url) const; - void javaScriptAlert(QWebFrame *frame, - const QString &msg); - - bool javaScriptConfirm(QWebFrame *frame, - const QString &msg); - - bool javaScriptPrompt(QWebFrame *frame, - const QString &msg, - const QString &defaultValue, QString *result); - - QObject *createPlugin(const QString &classId, - const QUrl &url, - const QStringList ¶mNames, - const QStringList ¶mValues); - protected Q_SLOTS: virtual void slotHandleUnsupportedContent(QNetworkReply *reply); virtual void slotDownloadRequested(const QNetworkRequest &request); |