diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/application.cpp | 72 | ||||
| -rw-r--r-- | src/application.h | 1 | ||||
| -rw-r--r-- | src/history.cpp | 1 | ||||
| -rw-r--r-- | src/homepage.cpp | 12 | ||||
| -rw-r--r-- | src/main.cpp | 55 | ||||
| -rw-r--r-- | src/mainview.cpp | 17 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 104 | ||||
| -rw-r--r-- | src/mainwindow.h | 17 | ||||
| -rw-r--r-- | src/previewimage.cpp | 117 | ||||
| -rw-r--r-- | src/previewimage.h | 25 | ||||
| -rw-r--r-- | src/rekonq.kcfg | 17 | ||||
| -rw-r--r-- | src/sessionmanager.cpp | 2 | ||||
| -rw-r--r-- | src/settings.cpp | 22 | ||||
| -rw-r--r-- | src/settings_general.ui | 222 | ||||
| -rw-r--r-- | src/settings_tabs.ui | 81 | ||||
| -rw-r--r-- | src/tabbar.cpp | 9 | ||||
| -rw-r--r-- | src/tabbar.h | 1 | ||||
| -rw-r--r-- | src/urlbar.cpp | 11 | ||||
| -rw-r--r-- | src/webpage.cpp | 1 | ||||
| -rw-r--r-- | src/websnap.cpp | 30 | ||||
| -rw-r--r-- | src/websnap.h | 2 | ||||
| -rw-r--r-- | src/webview.cpp | 125 | ||||
| -rw-r--r-- | src/webview.h | 24 | 
24 files changed, 546 insertions, 423 deletions
| diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71b2d77b..4faece61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ SET( rekonq_SRCS  KDE4_ADD_UI_FILES( rekonq_SRCS      settings_general.ui +    settings_tabs.ui      settings_fonts.ui      settings_webkit.ui      cleardata.ui diff --git a/src/application.cpp b/src/application.cpp index 41fcd515..634e068f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -92,6 +92,36 @@ int Application::newInstance()      // so initialize only once      static bool first = true; +    if(args->count() == 0) +    { +        MainWindow *w = 0; +        if(first)   // we are starting rekonq, for the first time with no args: use startup behaviour +        { +            switch(ReKonfig::startupBehaviour()) +            { +                case 0: // open home page +                    w = newMainWindow(); +                    w->slotHome(); +                    break; +                case 1: // open new tab page +                    w = newMainWindow(); +                    w->homePage(); +                    break; +                case 2: // restore session +                    if(sessionManager()->restoreSession()) +                        break; +                default: +                    w = newMainWindow(); +                    w->slotHome(); +                    break; +            }     +        } +        else    // rekonq has just been started. Just open a new window +        { +            w = newMainWindow(); +        } +    } +          if (first)      {          QTimer::singleShot(0, this, SLOT(postLaunch())); @@ -106,9 +136,8 @@ int Application::newInstance()          kDebug() << "session restored";          return 1;      } - -// -------------------------------------------------------------------------- - +     +    // are there args? load them..      if (args->count() > 0)      {          // is there a window open on the current desktop ? use it! @@ -137,10 +166,6 @@ int Application::newInstance()          return 3;      } -    // creating new window -    MainWindow *w = newMainWindow(); -    w->slotHome(); -              return 0;  } @@ -177,11 +202,7 @@ void Application::slotSaveConfiguration() const  MainWindow *Application::mainWindow()  {      if(m_mainWindows.isEmpty()) -    { -        kDebug() << "No extant windows: creating one new..."; -        MainWindow *w = newMainWindow(); -        return w; -    } +        return 0;      MainWindow *active = qobject_cast<MainWindow*>(QApplication::activeWindow()); @@ -245,10 +266,7 @@ KIcon Application::icon(const KUrl &url)  {      if(!Application::instance()->mainWindowList().isEmpty()) // avoid infinite loop at startup      { -        // means it is the urlbar -        if(url.isEmpty() && Application::instance()->mainWindow()->currentTab()->url().scheme() == "rekonq") -            return KIcon("arrow-right"); -         +          if(url == KUrl("rekonq:closedTabs"))              return KIcon("tab-close");          if(url == KUrl("rekonq:history")) @@ -330,7 +348,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)      }      // loading home pages -    if (homePage(url)) +    if (mainWindow()->homePage(url))          return;      if (url.scheme() == QLatin1String("mailto")) @@ -445,23 +463,3 @@ MainWindowList Application::mainWindowList()  {      return m_mainWindows;  } - - -bool Application::homePage(const KUrl &url) -{ -    if (    url == KUrl("rekonq:closedTabs")  -         || url == KUrl("rekonq:history")  -         || url == KUrl("rekonq:bookmarks") -         || url == KUrl("rekonq:favorites") -         || url == KUrl("rekonq:home") -    ) -    { -        kDebug() << "loading home: " << url; -        MainView *view = mainWindow()->mainView();  -        WebView *w = view->currentWebView(); -        HomePage p(w); -        w->setHtml( p.rekonqHomePage(url), url); -        return true; -    } -    return false; -} diff --git a/src/application.h b/src/application.h index eadacfa0..e5616d59 100644 --- a/src/application.h +++ b/src/application.h @@ -101,7 +101,6 @@ public:      MainWindow *mainWindow();      MainWindowList mainWindowList(); -    bool homePage(const KUrl &url = KUrl("rekonq:home"));      static KIcon icon(const KUrl &url); diff --git a/src/history.cpp b/src/history.cpp index c3ccbad2..91360839 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -95,6 +95,7 @@ HistoryManager::HistoryManager(QObject *parent)  HistoryManager::~HistoryManager()  {      m_saveTimer->saveIfNeccessary(); +    delete m_completion;  } diff --git a/src/homepage.cpp b/src/homepage.cpp index 835be043..27d613ce 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -112,7 +112,7 @@ QString HomePage::fillFavorites()      QStringList names = ReKonfig::previewNames();      QStringList urls = ReKonfig::previewUrls(); -    QString speed; +    QString speed = "<div class=\"favorites\">";      for(int i=0; i<8; ++i)      {          speed += "<div class=\"thumbnail\">"; @@ -123,7 +123,8 @@ QString HomePage::fillFavorites()          speed += "</object>";          speed += "</div>";      } -     + +    speed += "</div>";      return speed;  } @@ -150,7 +151,7 @@ QString HomePage::lastVisitedSites()  QString HomePage::homePageMenu(KUrl currentUrl)  { -    QString menu = ""; +    QString menu;      KIconLoader *loader = KIconLoader::global(); @@ -244,7 +245,7 @@ QString HomePage::createBookItem(const KBookmark &bookmark)  {      if (bookmark.isGroup())      { -        QString result = QString(""); +        QString result;          KBookmarkGroup group = bookmark.toGroup();          KBookmark bm = group.first();          result += "<h3>" + bookmark.text() + "</h3>"; @@ -263,8 +264,7 @@ QString HomePage::createBookItem(const KBookmark &bookmark)          return QString("<hr />");      } -    QString books = " "; -    books += "<a href=\"" + bookmark.url().prettyUrl() + "\">" + bookmark.text() + "</a><br />"; +    QString books = "<a href=\"" + bookmark.url().prettyUrl() + "\">" + bookmark.text() + "</a><br />";      return books;  } diff --git a/src/main.cpp b/src/main.cpp index eac34538..9d7cc742 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,9 @@  * ============================================================ */ +// version include +#include "../version.h" +  // Local Includes  #include "application.h"  #include "sessionmanager.h" @@ -38,15 +41,12 @@ static const char description[] =      I18N_NOOP("A lightweight Web Browser for KDE based on WebKit"); -static const char version[] = "0.2.70"; - -  int main(int argc, char **argv)  {      KAboutData about("rekonq",                       0,                       ki18n("rekonq"), -                     version, +                     REKONQ_VERSION,                       ki18n(description),                       KAboutData::License_GPL_V3,                       ki18n("(C) 2008-2009 Andrea Diamantini"), @@ -65,11 +65,6 @@ int main(int argc, char **argv)                      "alexandr.domrachev@gmail.com",                      ""); -    about.addAuthor(ki18n("Pawel Prazak"), -                    ki18n("Developer"), -                    "kojots350@gmail.com", -                    ""); -      about.addAuthor(ki18n("Panagiotis Papadopoulos"),                      ki18n("Quite everything but code"),                      "pano_90@gmx.net", @@ -80,6 +75,21 @@ int main(int argc, char **argv)                      "megabigbug@yahoo.fr",                      ""); +    about.addAuthor(ki18n("Johannes Zellner"), +                    ki18n("Patches, suggestions, testing, bugfixing"), +                    "webmaster@nebulon.de", +                    ""); + +    about.addAuthor(ki18n("Matthieu Gicquel"), +                    ki18n("Developer, Ideas, Tabloid improvements"), +                    "matthieu@bureau.home", +                    ""); + +    about.addAuthor(ki18n("Ronny Scholz"), +                    ki18n("(Tons of ) patches, testing, bugfixing"), +                    "ronny_scholz@web.de", +                    ""); +                          // --------------- about credits -----------------------------                          about.addCredit(ki18n("Henry de Valence"),                      ki18n("Promised help on multitask rekonq"), @@ -91,11 +101,6 @@ int main(int argc, char **argv)                      "buusmail@gmail.com",                      ""); -    about.addCredit(ki18n("Johannes Zellner"), -                    ki18n("Patches, suggestions, testing, bugfixing"), -                    "webmaster@nebulon.de", -                    ""); -      about.addCredit(ki18n("Ivan Čukić"),                      ki18n("Patches, bugfixing"),                      "ivan@fomentgroup.org", @@ -105,7 +110,27 @@ int main(int argc, char **argv)                      ki18n("New tab loading animation"),                      "swiftscythe@gmail.com",                      ""); -                    + +    about.addCredit(ki18n("Pawel Prazak"), +                    ki18n("Developer"), +                    "kojots350@gmail.com", +                    ""); + +    about.addCredit(ki18n("Rohan Garg"), +                    ki18n("Handbook"), +                    "rohan16garg@gmail.com", +                    ""); +                     +    about.addCredit(ki18n("Dario Freddi"), +                    ki18n("Patches, hints, first KWallet support implementation (not yet included)"), +                    "drf@kde.org", +                    ""); + +    about.addCredit(ki18n("Jon de Andrés Frías"), +                    ki18n("first awesome bar implementation (wait next version and you'll see..)"), +                    "jondeandres@gmail.com", +                    ""); +                          // Initialize command line args      KCmdLineArgs::init(argc, argv, &about); diff --git a/src/mainview.cpp b/src/mainview.cpp index 1848e682..0956e3ff 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -307,7 +307,7 @@ void MainView::newTab()      switch(ReKonfig::newTabsBehaviour())      {      case 0: -        if(Application::instance()->homePage()) +        if(Application::instance()->mainWindow()->homePage())              break;      case 1:          urlBar()->setUrl(KUrl("")); @@ -383,8 +383,15 @@ void MainView::slotCloneTab(int index)          index = currentIndex();      if (index < 0 || index >= count())          return; -    WebView *tab = newWebView(); -    tab->setUrl(webView(index)->url()); +     +    WebView *tab = newWebView();     +    KUrl url = webView(index)->url(); +     +    // workaround against bug in webkit: +    // only set url if it is not empty +    // otherwise the current working directory will be used +    if (!url.isEmpty()) +        tab->setUrl(url);      updateTabBar();  } @@ -418,7 +425,7 @@ void MainView::slotCloseTab(int index)          hasFocus = tab->hasFocus();          //store close tab except homepage -        if (!tab->url().prettyUrl().startsWith("rekonq:") && !tab->url().isEmpty()) +        if (!tab->url().prettyUrl().startsWith( QLatin1String("rekonq:") ) && !tab->url().isEmpty())          {              QString title = tab->title();              QString url = tab->url().prettyUrl(); @@ -595,4 +602,4 @@ void MainView::resizeEvent(QResizeEvent *event)  {      updateTabBar();      KTabWidget::resizeEvent(event); -}
\ No newline at end of file +} 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;  } diff --git a/src/mainwindow.h b/src/mainwindow.h index c680cc60..7c42e58f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -69,7 +69,9 @@ public:      QAction *actionByName(const QString name);      virtual QSize sizeHint() const;      virtual KActionCollection *actionCollection () const; -     + +    bool homePage(const KUrl &url = KUrl("rekonq:home")); +  private:      void setupActions();      void setupTools(); @@ -93,16 +95,16 @@ public slots:      void notifyMessage(const QString &msg, Rekonq::Notify status = Rekonq::Info);      void printRequested(QWebFrame *frame = 0); -     -     + +  signals:      // switching tabs      void ctrlTabPressed();      void shiftCtrlTabPressed(); -     +  protected:      bool queryClose(); -     +      /**      * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed()      * to make switch tab @@ -116,7 +118,7 @@ private slots:      void slotBrowserLoading(bool);      void slotUpdateActions();      void slotUpdateWindowTitle(const QString &title = QString()); -     +      // history related      void slotOpenPrevious();      void slotOpenNext(); @@ -152,9 +154,6 @@ private slots:      void slotAboutToShowBackMenu();      void slotOpenActionUrl(QAction *action); -    // add link to the favorites shown in the rekonq homepage -    void addFavoriteLink(); -      private:      MainView *m_view;      FindBar *m_findBar; diff --git a/src/previewimage.cpp b/src/previewimage.cpp index e7f8aea5..1c554cb9 100644 --- a/src/previewimage.cpp +++ b/src/previewimage.cpp @@ -49,6 +49,7 @@  #include <QMouseEvent>  #include <QHBoxLayout>  #include <QVBoxLayout> +#include <QPainter>  PreviewImage::PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite) @@ -62,17 +63,46 @@ PreviewImage::PreviewImage(const QUrl &url, const QString &title, int index, boo      , m_button(0)      , m_imageLabel(new QLabel)      , m_textLabel(new QLabel) +    , m_backgroundLabel(new QLabel) +    , m_previewLabel(new QLabel)  { -    setMinimumSize(300,200); -     + +    int borderTop = 14; +    int borderRight = 16; +    int borderBottom = 14; +    int borderLeft = 16; + +    int previewWidth=200; +    int previewHeight=150; + +    int urlHeight=18; + +    m_size = QSize(borderLeft+previewWidth+borderRight, borderTop+previewHeight+borderBottom+urlHeight); + +    setFixedSize(m_size); +    m_previewLabel->setFixedSize(m_size); + +    m_backgroundLabel->setPixmap(renderBackground(previewWidth,previewHeight, borderTop, borderBottom, borderLeft, borderRight)); + +    m_previewLabel->setAlignment(Qt::AlignCenter); +    m_backgroundLabel->setAlignment(Qt::AlignCenter);      m_imageLabel->setAlignment(Qt::AlignCenter);      m_textLabel->setAlignment(Qt::AlignCenter); -     -    QVBoxLayout *mainLayout = new QVBoxLayout; -    mainLayout->addWidget(m_imageLabel); -    mainLayout->addWidget(m_textLabel); -    setLayout(mainLayout); -     + +    m_previewLabel->setLayout(new QVBoxLayout); +    m_previewLabel->layout()->setMargin(0); +    m_previewLabel->layout()->addWidget(m_backgroundLabel); +    m_previewLabel->layout()->addWidget(m_textLabel); +    m_previewLabel->setCursor(Qt::PointingHandCursor); + +    m_backgroundLabel->setLayout(new QVBoxLayout); +    m_backgroundLabel->layout()->addWidget(m_imageLabel); + +    setLayout(new QHBoxLayout); +    layout()->setMargin(0); +    layout()->setAlignment(Qt::AlignCenter); +    layout()->addWidget(m_previewLabel); +      loadUrlPreview(url);  } @@ -82,9 +112,38 @@ PreviewImage::~PreviewImage()      delete ws;      delete m_textLabel;      delete m_imageLabel; +    delete m_backgroundLabel; +    delete m_previewLabel;  } +QPixmap PreviewImage::renderBackground(int w, int h, int t, int b, int l, int r) +{ +    QImage backImage(KStandardDirs::locate("appdata", "pics/bg.png")); +    QImage resultImage(QSize(w + l + r, h + t + b), QImage::Format_ARGB32_Premultiplied); + +    if (!backImage.isNull()) +    { +        int sw = backImage.width() - l - r; +        int sh = backImage.height() - t - b; +        QPainter pt(&resultImage); +        pt.setCompositionMode(QPainter::CompositionMode_Source); +        pt.fillRect(resultImage.rect(), Qt::transparent); +        pt.drawImage(QRect(0, 0, l, t), backImage, QRect(0, 0, l, t)); +        pt.drawImage(QRect(l, 0, w, t), backImage, QRect(l, 0, sw, t)); +        pt.drawImage(QRect(l + w, 0, r, t), backImage, QRect(l + sw, 0, r, t)); +        pt.drawImage(QRect(0, t, l, h), backImage, QRect(0, t, l, sh)); +        pt.drawImage(QRect(l, t, w, h), backImage, QRect(l, t, sw, sh)); +        pt.drawImage(QRect(l + w, t, r, h), backImage, QRect(l + sw, t, r, sh)); +        pt.drawImage(QRect(0, t + h, l , b), backImage, QRect(0, t + sh, l , b)); +        pt.drawImage(QRect(l, t + h, w, b), backImage, QRect(l, t + sh, sw, b)); +        pt.drawImage(QRect(l + w, t + h, w, b), backImage, QRect(l + sw, t + sh, sw, b)); +        pt.end(); +    } + +    return QPixmap::fromImage(resultImage); +} +  void PreviewImage::loadUrlPreview(const QUrl& url)  { @@ -96,6 +155,8 @@ void PreviewImage::loadUrlPreview(const QUrl& url)          return;      } +    m_previewLabel->setFixedSize(m_size); //unhide +      m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true);      if(QFile::exists(m_savePath)) @@ -119,6 +180,7 @@ void PreviewImage::loadUrlPreview(const QUrl& url)          m_imageLabel->setMovie(movie);          movie->start();          m_textLabel->setText( i18n("Loading preview...") ); +        setCursor(Qt::BusyCursor);      }  } @@ -129,17 +191,19 @@ void PreviewImage::snapFinished()      QMovie *m = m_imageLabel->movie();      delete m;      m_imageLabel->setMovie(0); -     +      m_pixmap = ws->previewImage();      m_imageLabel->setPixmap(m_pixmap);      checkTitle();      m_textLabel->setText(m_title); -     + +    setCursor(Qt::PointingHandCursor); +  //     kDebug() << "m_pixmap: " << m_pixmap.size();  //     kDebug() << "text label: " << m_textLabel->size();  //     kDebug() << "image label: " << m_imageLabel->size();  //     kDebug() << "widget: " << size(); -     +      m_pixmap.save(m_savePath);      if(m_index > -1) @@ -149,7 +213,7 @@ void PreviewImage::snapFinished()          // update url (for added thumbs)          QStringList urls = ReKonfig::previewUrls(); -        // stripTrailingSlash to be sure to get the same string for same adress +        // stripTrailingSlash to be sure to get the same string for same address          urls.replace(m_index, ws->snapUrl().toString(QUrl::StripTrailingSlash));          names.replace(m_index, ws->snapTitle()); @@ -165,20 +229,21 @@ void PreviewImage::showEmptyPreview()  {      if(!m_isFavorite)          return; -     +      m_imageLabel->clear();      m_textLabel->clear(); -     -    QHBoxLayout *layout = new QHBoxLayout(m_imageLabel); -    m_button = new QToolButton(m_imageLabel); + +    m_previewLabel->setFixedSize(0,0); //hide + + +    m_button = new QToolButton();      m_button->setDefaultAction(historyMenu());      m_button->setPopupMode(QToolButton::InstantPopup);      m_button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);      m_button->setText(i18n("Add Preview"));      m_button->setAutoRaise(true);      m_button->setIconSize(QSize(48, 48)); -    layout->addWidget(m_button); -    m_imageLabel->setLayout(layout); +    layout()->addWidget(m_button);  } @@ -202,7 +267,13 @@ void PreviewImage::mousePressEvent(QMouseEvent *event)      {          Application::instance()->loadUrl(m_url);          return; -    }; +    } +    else if(event->button() == Qt::MidButton) +    { +        Application::instance()->loadUrl(m_url, Rekonq::SettingOpenTab); +        return; +    } +      QWidget::mousePressEvent(event);  } @@ -243,12 +314,12 @@ void PreviewImage::contextMenuEvent(QContextMenuEvent* event)  KActionMenu* PreviewImage::historyMenu()  { -    KActionMenu *histMenu = new KActionMenu(KIcon("insert-image"), i18n("Set page to preview"), this); +    KActionMenu *histMenu = new KActionMenu(KIcon("insert-image"), i18n("Set Page to Preview"), this);      QList<HistoryItem> history =  Application::historyManager()->history();      if(history.isEmpty())      { -        KAction *a = new KAction(i18n("History is empty"), this); +        KAction *a = new KAction(i18n("History is Empty"), this);          a->setEnabled(false);          histMenu->addAction(a);          return histMenu; @@ -300,7 +371,7 @@ void PreviewImage::setUrlFromAction()      m_url = KUrl(urlData.at(0));      m_title = urlData.at(1);      checkTitle(); -     +      if(m_button)      {          m_imageLabel->layout()->deleteLater(); @@ -314,7 +385,7 @@ void PreviewImage::setUrlFromAction()      // update url (for added thumbs)      QStringList urls = ReKonfig::previewUrls(); -    // stripTrailingSlash to be sure to get the same string for same adress +    // stripTrailingSlash to be sure to get the same string for same address      urls.replace(m_index, m_url.toString(QUrl::StripTrailingSlash));      names.replace(m_index, m_title); diff --git a/src/previewimage.h b/src/previewimage.h index d7f4d2aa..e9504210 100644 --- a/src/previewimage.h +++ b/src/previewimage.h @@ -49,44 +49,49 @@ class PreviewImage : public QWidget  public:      PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite);      ~PreviewImage(); -     +      QString guessNameFromUrl(QUrl url); -     +  public slots:      void snapFinished();      void removeMe();      void setUrlFromAction();      void refreshPreview(); -     +  protected:      void contextMenuEvent(QContextMenuEvent *event);      void mouseDoubleClickEvent(QMouseEvent *event);      void mouseMoveEvent(QMouseEvent *event);      void mousePressEvent(QMouseEvent *event);      void mouseReleaseEvent(QMouseEvent *event); -     +      void loadUrlPreview(const QUrl &url);      KActionMenu *historyMenu();      void showEmptyPreview(); -                 +  private:      void checkTitle(); -     +    QPixmap renderBackground(int w, int h, int t, int b, int l, int r); +      QPixmap m_pixmap;      WebSnap *ws; -     +      QString m_savePath;          bool loadingSnapshot; -     +      QUrl m_url;          QString m_title;      bool m_isFavorite;      int m_index; -     +      QToolButton *m_button; -     +      QLabel *m_imageLabel;      QLabel *m_textLabel; +    QLabel *m_backgroundLabel; +    QLabel *m_previewLabel; +     +    QSize m_size;  };  #endif // PREVIEW_IMAGE_H diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index c55fce9c..5505e4b2 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -23,8 +23,8 @@  <!-- General Settings -->    <group name="General"> -    <entry name="newTabHomePage" type="Bool"> -        <default>true</default> +    <entry name="startupBehaviour" type="Int"> +        <default>1</default>      </entry>      <entry name="newTabsBehaviour" type="Int">          <default>0</default> @@ -32,17 +32,21 @@      <entry name="homePage" type="String">          <default>http://www.kde.org/</default>      </entry> +    <entry name="showSideBar" type="Bool"> +        <default>false</default> +    </entry> +  </group> + +<!-- Tabs Settings --> +  <group name="Tabs">      <entry name="openTabNoWindow" type="Bool">          <default>true</default>      </entry>      <entry name="alwaysShowTabBar" type="Bool">          <default>true</default>      </entry> -    <entry name="showSideBar" type="Bool"> -        <default>false</default> -    </entry>      <entry name="openTabsBack" type="Bool"> -        <default>false</default> +        <default>true</default>      </entry>      <entry name="openTabsNearCurrent" type="Bool">          <default>false</default> @@ -52,6 +56,7 @@      </entry>    </group> +  <!-- Fonts Settings -->    <group name="Fonts">      <entry name="standardFont" type="Font"> diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 6b7d6b9e..06bcb83a 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -76,7 +76,7 @@ void SessionManager::saveSession()          MainView *mv = w->mainView();          for (int i = 0 ; i < mv->count() ; i++)          { -            out << mv->webView(i)->url().toEncoded(QUrl::StripTrailingSlash) << "\n"; +            out << mv->webView(i)->url().toEncoded() << "\n";          }      }      sessionFile.close(); diff --git a/src/settings.cpp b/src/settings.cpp index 4a6c50b8..dcd7a002 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -41,6 +41,7 @@  //Ui Includes  #include "ui_settings_general.h" +#include "ui_settings_tabs.h"  #include "ui_settings_fonts.h"  #include "ui_settings_webkit.h" @@ -60,9 +61,12 @@  class Private  {  private: +          Ui::general generalUi; +    Ui::tabs tabsUi;      Ui::fonts fontsUi;      Ui::webkit webkitUi; +          KCModuleProxy *proxyModule;      KCModuleProxy *ebrowsingModule;      KCModuleProxy *cookiesModule; @@ -86,6 +90,12 @@ Private::Private(SettingsDialog *parent)      pageItem->setIcon(KIcon("rekonq"));      widget = new QWidget; +    tabsUi.setupUi(widget); +    widget->layout()->setMargin(0); +    pageItem = parent->addPage(widget , i18n("Tabs")); +    pageItem->setIcon(KIcon("tab-duplicate")); + +    widget = new QWidget;      fontsUi.setupUi(widget);      widget->layout()->setMargin(0);      pageItem = parent->addPage(widget , i18n("Fonts")); @@ -118,7 +128,7 @@ Private::Private(SettingsDialog *parent)      pageItem = parent->addPage(ebrowsingModule, i18n(ebrowsingInfo.moduleName().toLocal8Bit()));      pageItem->setIcon(KIcon(ebrowsingInfo.icon())); -    parent->setMinimumSize(800,500); +    parent->setMinimumSize(700,500);  } @@ -129,7 +139,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)          : KConfigDialog(parent, "rekonfig", ReKonfig::self())          , d(new Private(this))  { -    setFaceType(KPageDialog::List); +    setFaceType(KPageDialog::Tree);      showButtonSeparator(true);      setWindowTitle(i18n("rekonfig...")); @@ -178,12 +188,6 @@ void SettingsDialog::setWebSettingsToolTips()  // we need this function to UPDATE the config widget data..  void SettingsDialog::readConfig()  { -    // ======= General Page -    if( ReKonfig::newTabHomePage() ) -        d->generalUi.rbUseNewTabPage->setChecked( true ); -    else -        d->generalUi.rbUseHomePage->setChecked( true ); -          // ======= Fonts      d->fontsUi.kcfg_fixedFont->setOnlyFixed(true);  } @@ -192,8 +196,6 @@ void SettingsDialog::readConfig()  // we need this function to SAVE settings in rc file..  void SettingsDialog::saveSettings()  { -    ReKonfig::setNewTabHomePage( d->generalUi.rbUseNewTabPage->isChecked() ); -      ReKonfig::self()->writeConfig();      d->ebrowsingModule->save();      d->cookiesModule->save(); diff --git a/src/settings_general.ui b/src/settings_general.ui index 5ea19b09..4de3ce09 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -6,8 +6,8 @@     <rect>      <x>0</x>      <y>0</y> -    <width>438</width> -    <height>371</height> +    <width>751</width> +    <height>523</height>     </rect>    </property>    <property name="windowTitle"> @@ -15,46 +15,113 @@    </property>    <layout class="QVBoxLayout" name="verticalLayout">     <item> -    <widget class="QGroupBox" name="groupBox"> +    <widget class="QGroupBox" name="groupBox_2">       <property name="title"> -      <string>Home Page</string> +      <string>Startup</string>       </property> -     <layout class="QVBoxLayout" name="verticalLayout_2"> +     <layout class="QHBoxLayout" name="horizontalLayout_2">        <item> -       <widget class="QRadioButton" name="rbUseNewTabPage"> -        <property name="text"> -         <string>Use new tab page</string> +       <widget class="QLabel" name="label"> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy>          </property> -        <property name="checked"> -         <bool>true</bool> +        <property name="minimumSize"> +         <size> +          <width>120</width> +          <height>0</height> +         </size> +        </property> +        <property name="baseSize"> +         <size> +          <width>0</width> +          <height>0</height> +         </size> +        </property> +        <property name="layoutDirection"> +         <enum>Qt::LeftToRight</enum> +        </property> +        <property name="text"> +         <string>When starting rekonq:</string>          </property>         </widget>        </item>        <item> -       <layout class="QHBoxLayout" name="horizontalLayout"> +       <widget class="KComboBox" name="kcfg_startupBehaviour"> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy> +        </property>          <item> -         <widget class="QRadioButton" name="rbUseHomePage"> -          <property name="text"> -           <string>Use this page:</string> -          </property> -          <property name="checked"> -           <bool>false</bool> -          </property> -         </widget> +         <property name="text"> +          <string>Open the Home Page</string> +         </property>          </item>          <item> -         <widget class="KLineEdit" name="kcfg_homePage"> -          <property name="enabled"> -           <bool>true</bool> -          </property> -          <property name="sizePolicy"> -           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> -            <horstretch>0</horstretch> -            <verstretch>0</verstretch> -           </sizepolicy> -          </property> -         </widget> +         <property name="text"> +          <string>Open the New Tab Page</string> +         </property> +        </item> +        <item> +         <property name="text"> +          <string>Restore the Last Opened Tabs</string> +         </property>          </item> +       </widget> +      </item> +     </layout> +    </widget> +   </item> +   <item> +    <widget class="QGroupBox" name="groupBox"> +     <property name="title"> +      <string>Home Page</string> +     </property> +     <layout class="QGridLayout" name="gridLayout"> +      <item row="0" column="0"> +       <widget class="QLabel" name="label_2"> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy> +        </property> +        <property name="minimumSize"> +         <size> +          <width>120</width> +          <height>0</height> +         </size> +        </property> +        <property name="baseSize"> +         <size> +          <width>120</width> +          <height>0</height> +         </size> +        </property> +        <property name="text"> +         <string>Home page URL:</string> +        </property> +       </widget> +      </item> +      <item row="0" column="1"> +       <widget class="KLineEdit" name="kcfg_homePage"> +        <property name="enabled"> +         <bool>true</bool> +        </property> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy> +        </property> +       </widget> +      </item> +      <item row="1" column="1"> +       <layout class="QHBoxLayout" name="horizontalLayout_3">          <item>           <widget class="QPushButton" name="setHomeToCurrentPageButton">            <property name="text"> @@ -62,6 +129,19 @@            </property>           </widget>          </item> +        <item> +         <spacer name="horizontalSpacer"> +          <property name="orientation"> +           <enum>Qt::Horizontal</enum> +          </property> +          <property name="sizeHint" stdset="0"> +           <size> +            <width>40</width> +            <height>20</height> +           </size> +          </property> +         </spacer> +        </item>         </layout>        </item>       </layout> @@ -72,19 +152,43 @@       <property name="title">        <string>New Tabs Behaviour</string>       </property> -     <layout class="QGridLayout" name="gridLayout_2"> -      <item row="0" column="0"> +     <layout class="QHBoxLayout" name="horizontalLayout"> +      <item>         <widget class="QLabel" name="label_4"> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy> +        </property> +        <property name="minimumSize"> +         <size> +          <width>120</width> +          <height>0</height> +         </size> +        </property> +        <property name="baseSize"> +         <size> +          <width>120</width> +          <height>0</height> +         </size> +        </property>          <property name="text">           <string>New tab opens:</string>          </property>         </widget>        </item> -      <item row="0" column="1"> +      <item>         <widget class="KComboBox" name="kcfg_newTabsBehaviour">          <property name="enabled">           <bool>true</bool>          </property> +        <property name="sizePolicy"> +         <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> +          <horstretch>0</horstretch> +          <verstretch>0</verstretch> +         </sizepolicy> +        </property>          <item>           <property name="text">            <string>New Tab Page</string> @@ -106,61 +210,17 @@      </widget>     </item>     <item> -    <widget class="QGroupBox" name="groupBox_4"> -     <property name="title"> -      <string>Tabbed Browsing</string> -     </property> -     <layout class="QVBoxLayout" name="verticalLayout_4"> -      <item> -       <widget class="QCheckBox" name="kcfg_openTabNoWindow"> -        <property name="text"> -         <string>Open links in new tab instead of in new window</string> -        </property> -       </widget> -      </item> -      <item> -       <widget class="QCheckBox" name="kcfg_alwaysShowTabBar"> -        <property name="text"> -         <string>Always show tab bar</string> -        </property> -       </widget> -      </item> -      <item> -       <widget class="QCheckBox" name="kcfg_openTabsBack"> -        <property name="text"> -         <string>Open new tabs in the background</string> -        </property> -       </widget> -      </item> -      <item> -       <widget class="QCheckBox" name="kcfg_openTabsNearCurrent"> -        <property name="text"> -         <string>Open new tabs after currently active one</string> -        </property> -       </widget> -      </item> -      <item> -       <widget class="QCheckBox" name="kcfg_alwaysShowTabPreviews"> -        <property name="text"> -         <string>Show preview when hovering tab</string> -        </property> -        <property name="checked"> -         <bool>false</bool> -        </property> -       </widget> -      </item> -     </layout> -    </widget> -   </item> -   <item>      <spacer name="verticalSpacer">       <property name="orientation">        <enum>Qt::Vertical</enum>       </property> +     <property name="sizeType"> +      <enum>QSizePolicy::Expanding</enum> +     </property>       <property name="sizeHint" stdset="0">        <size>         <width>20</width> -       <height>43</height> +       <height>40</height>        </size>       </property>      </spacer> diff --git a/src/settings_tabs.ui b/src/settings_tabs.ui new file mode 100644 index 00000000..ba903ff4 --- /dev/null +++ b/src/settings_tabs.ui @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>tabs</class> + <widget class="QWidget" name="tabs"> +  <property name="geometry"> +   <rect> +    <x>0</x> +    <y>0</y> +    <width>456</width> +    <height>329</height> +   </rect> +  </property> +  <property name="windowTitle"> +   <string>Tabs</string> +  </property> +  <layout class="QVBoxLayout" name="verticalLayout"> +   <item> +    <widget class="QGroupBox" name="groupBox_4"> +     <property name="title"> +      <string>Tabbed Browsing</string> +     </property> +     <layout class="QVBoxLayout" name="verticalLayout_4"> +      <item> +       <widget class="QCheckBox" name="kcfg_openTabNoWindow"> +        <property name="text"> +         <string>Open links in new tab instead of in new window</string> +        </property> +       </widget> +      </item> +      <item> +       <widget class="QCheckBox" name="kcfg_alwaysShowTabBar"> +        <property name="text"> +         <string>Always show tab bar</string> +        </property> +       </widget> +      </item> +      <item> +       <widget class="QCheckBox" name="kcfg_openTabsBack"> +        <property name="text"> +         <string>Open new tabs in the background</string> +        </property> +       </widget> +      </item> +      <item> +       <widget class="QCheckBox" name="kcfg_openTabsNearCurrent"> +        <property name="text"> +         <string>Open new tabs after currently active one</string> +        </property> +       </widget> +      </item> +      <item> +       <widget class="QCheckBox" name="kcfg_alwaysShowTabPreviews"> +        <property name="text"> +         <string>Show preview when hovering tab</string> +        </property> +        <property name="checked"> +         <bool>false</bool> +        </property> +       </widget> +      </item> +     </layout> +    </widget> +   </item> +   <item> +    <spacer name="verticalSpacer"> +     <property name="orientation"> +      <enum>Qt::Vertical</enum> +     </property> +     <property name="sizeHint" stdset="0"> +      <size> +       <width>20</width> +       <height>142</height> +      </size> +     </property> +    </spacer> +   </item> +  </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 73788094..40c8dc1c 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -270,6 +270,15 @@ void TabBar::leaveEvent(QEvent *event)      KTabBar::leaveEvent(event);  } +void TabBar::mousePressEvent(QMouseEvent *event) +{ +    // just close tab on middle mouse click +    if (event->button() == Qt::MidButton) +        return; +     +    KTabBar::mousePressEvent(event); +} +  void TabBar::updateNewTabButton()  { diff --git a/src/tabbar.h b/src/tabbar.h index 580021c4..57b78628 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -79,6 +79,7 @@ protected:      virtual QSize tabSizeHint(int index) const;      virtual void mouseMoveEvent(QMouseEvent *event);      virtual void leaveEvent(QEvent *event); +    virtual void mousePressEvent(QMouseEvent *event);  private slots:      void cloneTab(); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 12691519..b6340fe7 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -155,19 +155,24 @@ void UrlBar::setProgress(int progress)  void UrlBar::slotUpdateUrl()  {      // Don't change my typed url... +    // FIXME this is not a proper solution (also if it works...)      if(hasFocus())      {          kDebug() << "Don't change my typed url...";          return;      } -     + +    KIcon icon; +    if(m_currentUrl.isEmpty()) icon = KIcon("arrow-right"); +    else icon = Application::icon(m_currentUrl); +      if (count())      { -        changeUrl(0, Application::icon(m_currentUrl), m_currentUrl); +        changeUrl(0, icon, m_currentUrl);      }      else      { -        insertUrl(0, Application::icon(m_currentUrl), m_currentUrl); +        insertUrl(0, icon, m_currentUrl);      }      setCurrentIndex(0); diff --git a/src/webpage.cpp b/src/webpage.cpp index 2b622847..3754444b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -72,7 +72,6 @@ WebPage::WebPage(QObject *parent)          : QWebPage(parent)          , m_keyboardModifiers(Qt::NoModifier)          , m_pressedButtons(Qt::NoButton) -        , m_requestedUrl()  {      setPluginFactory(new WebPluginFactory(this)); diff --git a/src/websnap.cpp b/src/websnap.cpp index bb2baf49..7dcbb836 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -74,7 +74,7 @@ void WebSnap::load()  } -QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h, bool border) +QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)  {      // prepare page      page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // Why it doesn't work with one setScrollBarPolicy? @@ -111,31 +111,7 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h, bool border)      page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);      page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); -    if(!border) -        return QPixmap::fromImage(pageImage); -     -    // background image -    QSize fixedSize(w + 30, h + 26); -    QImage backImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied); -    QString backImagePath = KStandardDirs::locate("appdata", "pics/bg.png"); -    backImage.load( backImagePath ); -     -    // create target -    QImage resultImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied); -    resultImage.fill(Qt::transparent);  - -    QPainter pt(&resultImage); -    pt.setCompositionMode(QPainter::CompositionMode_Source); -    pt.fillRect(resultImage.rect(), Qt::transparent); -    pt.setCompositionMode(QPainter::CompositionMode_SourceOver); -    pt.drawImage(0, 0, backImage); -    pt.setCompositionMode(QPainter::CompositionMode_SourceOver); -    pt.drawImage(15, 13, pageImage); -    pt.setCompositionMode(QPainter::CompositionMode_DestinationOver); -    pt.fillRect(resultImage.rect(), Qt::transparent); -    pt.end(); -     -    return QPixmap::fromImage(resultImage); +    return QPixmap::fromImage(pageImage);  } @@ -148,7 +124,7 @@ void WebSnap::saveResult(bool ok)          return;      } -    m_image = renderPreview(m_page, WIDTH, HEIGHT, true); +    m_image = renderPreview(m_page, WIDTH, HEIGHT);      emit finished();  } diff --git a/src/websnap.h b/src/websnap.h index 026c236c..6c5b4af9 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -52,7 +52,7 @@ public:      ~WebSnap();      QPixmap previewImage(); -    static QPixmap renderPreview(const QWebPage &page, int w, int h, bool border = false); +    static QPixmap renderPreview(const QWebPage &page, int w, int h);      QString snapTitle();      QUrl snapUrl(); diff --git a/src/webview.cpp b/src/webview.cpp index cdbb7b11..60bb496b 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -52,17 +52,13 @@  #include <QtGui/QClipboard>  #include <QtGui/QKeyEvent>  #include <QtGui/QAction> -#include <QtCore/QTimer>  WebView::WebView(QWidget* parent)          : QWebView(parent)          , m_page(new WebPage(this))          , m_progress(0) -        , m_scrollTimer(new QTimer(this)) -        , m_scrollDirection(WebView::NoScroll) -        , m_scrollSpeedVertical(0) -        , m_scrollSpeedHorizontal(0) +        , m_mousePos(QPoint(0,0))  {      setPage(m_page); @@ -70,9 +66,6 @@ WebView::WebView(QWidget* parent)      connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));      connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotUpdateProgress(int)));      connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); - -    connect(m_scrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged())); -    m_scrollTimer->setInterval(50);  } @@ -333,8 +326,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)          menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs)));          menu.addAction(mainwindow->actionByName("page_source")); -	 -        menu.addAction(mainwindow->actionByName("add_to_favorites")); +          QAction *addBookmarkAction = Application::bookmarkProvider()->actionByName("rekonq_add_bookmark");          menu.addAction(addBookmarkAction); @@ -356,83 +348,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)      menu.exec(mapToGlobal(event->pos()));  } - -void WebView::stopScrollAnimation() -{ -    m_scrollTimer->stop(); -    m_scrollSpeedVertical = 0; -    m_scrollSpeedHorizontal = 0; -    m_scrollDirection = WebView::NoScroll; -} - - -void WebView::startScrollAnimation(ScrollDirection direction) -{ -    // if no scrollspeed, set the requested direction, otherwise it's just a slowdown or speedup -    if (m_scrollSpeedVertical == 0 && (direction == WebView::Up || direction == WebView::Down)) -        m_scrollDirection |= direction; -    if (m_scrollSpeedHorizontal == 0 && (direction == WebView::Left || direction == WebView::Right)) -        m_scrollDirection |= direction; - -    // update scrollspeed -    switch (direction) -    { -        case WebView::Up: -            --m_scrollSpeedVertical; -            break; -        case WebView::Down: -            ++m_scrollSpeedVertical; -            break; -        case WebView::Left: -            --m_scrollSpeedHorizontal; -            break; -        case WebView::Right: -            ++m_scrollSpeedHorizontal; -            break; -        default: -            break; -    } - -    if (!m_scrollTimer->isActive()) -        m_scrollTimer->start(); - -    return; -} - - -void WebView::scrollFrameChanged() -{ -    // clear finished scrolling -    if (m_scrollSpeedVertical == 0) -        m_scrollDirection &= ~WebView::Up | ~WebView::Down; -    if (m_scrollSpeedHorizontal == 0) -        m_scrollDirection &= ~WebView::Left | ~WebView::Right; - -    // all scrolling finished -    if (m_scrollDirection == WebView::NoScroll) -    { -        m_scrollTimer->stop(); -        return; -    } - -    // do the scrolling -    page()->currentFrame()->scroll(m_scrollSpeedHorizontal, m_scrollSpeedVertical); - -    // check if we reached the end -    int y = page()->currentFrame()->scrollPosition().y(); -    int x = page()->currentFrame()->scrollPosition().x(); - -    if (y == 0 || y == page()->currentFrame()->scrollBarMaximum(Qt::Vertical)) -        m_scrollSpeedVertical = 0; -    if (x == 0 || x == page()->currentFrame()->scrollBarMaximum(Qt::Horizontal)) -        m_scrollSpeedHorizontal = 0; -} - -  void WebView::mousePressEvent(QMouseEvent *event)  { -    stopScrollAnimation(); -      m_page->m_pressedButtons = event->buttons();      m_page->m_keyboardModifiers = event->modifiers(); @@ -452,17 +369,18 @@ void WebView::mousePressEvent(QMouseEvent *event)  void WebView::mouseMoveEvent(QMouseEvent *event)  { -    if( url().protocol() != "rekonq" ) -    { -        QWebView::mouseMoveEvent(event); -    } +    m_mousePos = event->pos(); +    QWebView::mouseMoveEvent(event); +} + +QPoint WebView::mousePos() +{ +    return m_mousePos;  }  void WebView::wheelEvent(QWheelEvent *event)  { -    stopScrollAnimation(); -      if (QApplication::keyboardModifiers() & Qt::ControlModifier)      {          int numDegrees = event->delta() / 8; @@ -486,13 +404,13 @@ void WebView::slotSearch()  void WebView::slotUpdateProgress(int p)  { -    m_progress=p; +    m_progress = p;  }  void WebView::slotLoadFinished(bool)  { -    m_progress=0; +    m_progress = 0;  } @@ -542,25 +460,10 @@ void WebView::keyPressEvent(QKeyEvent *event)          return;      } -    if (event->modifiers() == Qt::ShiftModifier) +    if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A))      { -        switch (event->key()) -        { -        case Qt::Key_Down: -            startScrollAnimation(WebView::Down); -            return; -        case Qt::Key_Up: -            startScrollAnimation(WebView::Up); -            return; -        case Qt::Key_Left: -            startScrollAnimation(WebView::Left); -            return; -        case Qt::Key_Right: -            startScrollAnimation(WebView::Right); -            return; -        default: -            break; -        } +        triggerPageAction(QWebPage::SelectAll); +        return;      }      QWebView::keyPressEvent(event); diff --git a/src/webview.h b/src/webview.h index d3f58f2e..03ceb739 100644 --- a/src/webview.h +++ b/src/webview.h @@ -37,24 +37,13 @@  // Forward Declarations  class WebPage; -class QTimer;  class WebView : public QWebView  {      Q_OBJECT -    Q_ENUMS(ScrollDirection)  public: -    enum ScrollDirection -    { -        NoScroll = 0, -        Up = 2, -        Down = 4, -        Left = 6, -        Right = 16 -    }; -          explicit WebView(QWidget *parent = 0);      ~WebView(); @@ -62,7 +51,8 @@ public:      KUrl url() const;      QString lastStatusBarText() const;      int progress(); - +    QPoint mousePos(); +      protected:      void contextMenuEvent(QContextMenuEvent *event);      void mousePressEvent(QMouseEvent *event); @@ -82,18 +72,12 @@ private slots:      void openLinkInNewWindow();      void openLinkInNewTab(); -    void startScrollAnimation(ScrollDirection direction); -    void stopScrollAnimation(); -    void scrollFrameChanged(); -  private:      WebPage *m_page;      int m_progress;      QString m_statusBarText; -    QTimer *m_scrollTimer; -    int m_scrollDirection; -    int m_scrollSpeedVertical; -    int m_scrollSpeedHorizontal; + +    QPoint m_mousePos;  };  #endif | 
