diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 104 |
1 files changed, 48 insertions, 56 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4e9c4b26..e26b39bd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -46,6 +46,7 @@ #include "sidepanel.h" #include "urlbar.h" #include "tabbar.h" +#include "homepage.h" // Ui Includes #include "ui_cleardata.h" @@ -86,11 +87,11 @@ #include <QtGui/QPrinter> #include <QtGui/QPrintDialog> #include <QtGui/QPrintPreviewDialog> +#include <QtGui/QFontMetrics> #include <QtWebKit/QWebHistory> - MainWindow::MainWindow() : KMainWindow() , m_view(new MainView(this)) @@ -147,7 +148,6 @@ MainWindow::~MainWindow() { Application::instance()->removeMainWindow(this); delete m_popup; -// delete m_view; } @@ -259,7 +259,9 @@ void MainWindow::setupActions() // we all like "short" shortcuts.. ;) a = KStandardAction::fullScreen(this, SLOT(slotViewFullScreen(bool)), this, actionCollection()); - a->setShortcut(KShortcut(Qt::Key_F11, Qt::CTRL + Qt::SHIFT + Qt::Key_F)); + QList<QKeySequence> shortcutFullScreenList; + shortcutFullScreenList << KStandardShortcut::fullScreen() << QKeySequence( Qt::Key_F11 ); + a->setShortcuts( shortcutFullScreenList ); KStandardAction::home(this, SLOT(slotHome()), actionCollection()); KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection()); @@ -381,11 +383,6 @@ void MainWindow::setupActions() bmMenu->setIcon(KIcon("bookmarks")); bmMenu->setDelayed(false); actionCollection()->addAction(QLatin1String("bookmarksActionMenu"), bmMenu); - - // Add to favorites - a = new KAction(KIcon("rating"), i18n("Add to Favorites"), this); - actionCollection()->addAction(QLatin1String("add_to_favorites"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(addFavoriteLink())); } @@ -394,6 +391,7 @@ void MainWindow::setupTools() KActionMenu *toolsMenu = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); toolsMenu->setDelayed(false); + toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); @@ -497,6 +495,8 @@ void MainWindow::slotUpdateConfiguration() // ====== load Settings on main classes Application::historyManager()->loadSettings(); + + defaultSettings = 0; } @@ -576,8 +576,8 @@ void MainWindow::slotUpdateWindowTitle(const QString &title) void MainWindow::slotFileOpen() { QString filePath = KFileDialog::getOpenFileName(KUrl(), - i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n" \ - "*.*|All files (*.*)"), + i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n" + "*.*|All files (*.*)"), this, i18n("Open Web Resource")); @@ -772,14 +772,7 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - if(ReKonfig::newTabHomePage()) - { - Application::instance()->homePage(); - } - else - { - currentTab()->load( QUrl(ReKonfig::homePage()) ); - } + currentTab()->load( QUrl(ReKonfig::homePage()) ); } @@ -970,31 +963,47 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) break; } + int margin = 4; + + // setting the popup m_popup->setFrameShape(QFrame::NoFrame); QLabel *label = new QLabel(msg); - label->setMaximumWidth(width()-8); + label->setMaximumWidth(width()-2*margin); m_popup->setLineWidth(0); m_popup->setView(label); m_popup->setFixedSize(0, 0); m_popup->layout()->setAlignment(Qt::AlignTop); - m_popup->layout()->setMargin(4); + m_popup->layout()->setMargin(margin); - // setting popus in bottom-left position - int pageHeight = m_view->currentWebView()->page()->viewportSize().height(); - int labelHeight = KGlobalSettings::generalFont().pointSize()*2 + 7; + // useful values + QSize labelSize(label->fontMetrics().width(msg)+2*margin, label->fontMetrics().height()+2*margin); bool scrollbarIsVisible = m_view->currentWebView()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); int scrollbarSize = 0; - if (scrollbarIsVisible) scrollbarSize = 17; //TODO: detect QStyle size + if (scrollbarIsVisible) + { + //TODO: detect QStyle size + scrollbarSize = 17; + } + QPoint webViewOrigin = m_view->currentWebView()->mapToGlobal(QPoint(0,0)); + int bottomLeftY=webViewOrigin.y() + m_view->currentWebView()->page()->viewportSize().height() - labelSize.height() - scrollbarSize; + // setting popup in bottom-left position int x = geometry().x(); - int y = m_view->currentWebView()->mapToGlobal(QPoint(0,pageHeight)).y() - labelHeight -scrollbarSize; + int y = bottomLeftY; + + QPoint mousePos = m_view->currentWebView()->mapToGlobal(m_view->currentWebView()->mousePos()); + if(QRect(webViewOrigin.x(),bottomLeftY,labelSize.width(),labelSize.height()).contains(mousePos)) + { + // setting popup above the mouse + y = bottomLeftY - labelSize.height(); + } + QPoint p(x,y); m_popup->show(p); if(popup_sav) delete popup_sav; - } @@ -1102,37 +1111,20 @@ void MainWindow::slotOpenActionUrl(QAction *action) } -void MainWindow::addFavoriteLink() +bool MainWindow::homePage(const KUrl &url) { - QString name = currentTab()->title(); - QString url = currentTab()->url().prettyUrl(KUrl::RemoveTrailingSlash); - - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - - for (int i = 0; i < 8 && i < urls.size() ; ++i) + if ( url == KUrl("rekonq:closedTabs") + || url == KUrl("rekonq:history") + || url == KUrl("rekonq:bookmarks") + || url == KUrl("rekonq:favorites") + || url == KUrl("rekonq:home") + ) { - if(urls.at(i).isEmpty() || urls.at(i) == url) - { - names.replace(i, name); - urls.replace(i, url); - break; - } - if(i == 7) - { - names.prepend(name); - if(names.count() > 8) - names.removeLast(); - - urls.prepend(url); - if(urls.count() > 8) - urls.removeLast(); - - break; - } + kDebug() << "loading home: " << url; + WebView *w = currentTab(); + HomePage p(w); + w->setHtml( p.rekonqHomePage(url), url); + return true; } - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); + return false; } |