ginebra2/ContentViews/ContentViewContextMenu.cpp
changeset 16 3c88a81ff781
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
       
     1 
       
     2 #include <QDebug>
       
     3 #include <QWebHitTestResult>
       
     4 
       
     5 #include "ContentViewContextMenu.h"
       
     6 #include "webpagecontroller.h"
       
     7 #include "Downloads.h"
       
     8 
       
     9 namespace GVA {
       
    10 
       
    11 ContentViewContextMenu::ContentViewContextMenu(QWebHitTestResult *hitTest, QWidget *parent) :
       
    12     ContextMenu(parent),
       
    13     m_menu(parent),
       
    14     m_hitTest(hitTest)
       
    15 {
       
    16     if(m_hitTest->linkUrl().isValid()) {
       
    17         addAction("Open in New Window", this, SLOT(onOpenLink()));
       
    18         addAction("Share Link", this, SLOT(onShareLink()));
       
    19     }
       
    20     if(m_hitTest->imageUrl().isValid()) {
       
    21         addAction("View Image", this, SLOT(onViewImage()));
       
    22         addAction("Save Image", this, SLOT(onSaveImage()));
       
    23         addAction("Share Image", this, SLOT(onShareImage()));
       
    24 
       
    25     }
       
    26 }
       
    27 
       
    28 void ContentViewContextMenu::onOpenLink() {
       
    29     WebPageController::getSingleton()->LoadInNewWindow(m_hitTest->linkUrl().toString());
       
    30 }
       
    31 
       
    32 void ContentViewContextMenu::onViewImage() {
       
    33     WebPageController::getSingleton()->LoadInNewWindow(m_hitTest->imageUrl().toString());
       
    34 }
       
    35 
       
    36 void ContentViewContextMenu::onShareImage() {
       
    37     WebPageController::getSingleton()->share(m_hitTest->imageUrl().toString());
       
    38 }
       
    39 
       
    40 void ContentViewContextMenu::onSaveImage() {
       
    41 }
       
    42 
       
    43 void ContentViewContextMenu::onShareLink() {
       
    44     WebPageController::getSingleton()->share(m_hitTest->linkUrl().toString());
       
    45 
       
    46 }
       
    47 
       
    48 }  // GVA namespace