~ubuntu-branches/ubuntu/lucid/mythtv/lucid

« back to all changes in this revision

Viewing changes to libs/libmythui/mythuiwebbrowser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello, Mario Limonciello, John Baab
  • Date: 2009-09-29 01:33:23 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20090929013323-6pvn8encm757zbxw
Tags: 0.22.0~trunk22101-0ubuntu1
[ Mario Limonciello ]
* New upstream checkout (r22101)
* Try to guard and make sure that ~mythtv is read from /etc/passwd 
  rather than assuming it's /home/mythtv.

[ John Baab ]
* debian/mythtv-common.postinst:
  - Added symlink for /home/mythtv/.mythtv/config.xml

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * \brief Provide a web browser widget.
5
5
 *
6
6
 * This requires qt4.4.0 or later to function properly.
7
 
 * There is a dummy class so to make it optimal.
8
 
 * Qt 4.3.x users can still compile MythTV but with reduced functionality.
9
7
 * 
10
8
 */
11
9
 
12
 
#ifdef USING_QTWEBKIT
 
10
#include "mythuiwebbrowser.h"
13
11
 
14
12
// qt
15
13
#include <QApplication>
32
30
#include "mythdirs.h"
33
31
#include "mythuihelper.h"
34
32
 
35
 
#include "mythuiwebbrowser.h"
36
 
 
37
33
/**
38
34
 * @class MythWebView
39
35
 * @brief Subclass of QWebView
149
145
 *  \param name the name of this widget
150
146
 */
151
147
MythUIWebBrowser::MythUIWebBrowser(MythUIType *parent, const QString &name)
152
 
    : MythUIType(parent, name),
153
 
#ifdef USING_QTWEBKIT
154
 
      m_browser(NULL),
155
 
#endif
 
148
    : MythUIType(parent, name), m_browser(NULL),
156
149
      m_image(NULL),         m_active(false),
157
150
      m_initialized(false),  m_lastUpdateTime(QTime()),
158
151
      m_updateInterval(0),   m_zoom(1.0),
701
694
        else if (action == "NEXTLINK")
702
695
        {
703
696
            QKeyEvent tabKey(event->type(), Qt::Key_Tab,
704
 
                             event->modifiers(), QString::null,
 
697
                             event->modifiers(), QString(),
705
698
                             event->isAutoRepeat(), event->count());
706
699
 
707
700
            *event = tabKey;
712
705
        else if (action == "PREVIOUSLINK")
713
706
        {
714
707
            QKeyEvent shiftTabKey(event->type(), Qt::Key_Tab,
715
 
                          event->modifiers() | Qt::ShiftModifier,QString::null,
 
708
                          event->modifiers() | Qt::ShiftModifier,QString(),
716
709
                          event->isAutoRepeat(), event->count());
717
710
 
718
711
            *event = shiftTabKey;
722
715
        else if (action == "FOLLOWLINK")
723
716
        {
724
717
            QKeyEvent returnKey(event->type(), Qt::Key_Return,
725
 
                                event->modifiers(), QString::null,
 
718
                                event->modifiers(), QString(),
726
719
                                event->isAutoRepeat(), event->count());
727
720
            *event = returnKey;
728
721
 
855
848
    MythUIWebBrowser *browser = new MythUIWebBrowser(parent, objectName());
856
849
    browser->CopyFrom(this);
857
850
}
858
 
 
859
 
 
860
 
#else // USING_QTWEBKIT
861
 
///////////////////////////////////////////////////////////////////////////////
862
 
// fake MythUIWebBrowser
863
 
// remove when we require qtwebkit
864
 
///////////////////////////////////////////////////////////////////////////////
865
 
 
866
 
// qt
867
 
#include <QPainter>
868
 
 
869
 
// myth
870
 
#include "mythpainter.h"
871
 
#include "mythfontproperties.h"
872
 
#include "mythverbose.h"
873
 
#include "mythmainwindow.h"
874
 
#include "mythimage.h"
875
 
 
876
 
#include "mythuiwebbrowser.h"
877
 
 
878
 
MythUIWebBrowser::MythUIWebBrowser(MythUIType *parent, const QString &name)
879
 
                : MythUIType(parent, name)
880
 
{
881
 
    m_zoom = 1.0;
882
 
    m_image = NULL;
883
 
 
884
 
    m_initialized = false;
885
 
    m_active = false;
886
 
 
887
 
    SetCanTakeFocus(false);
888
 
}
889
 
 
890
 
void MythUIWebBrowser::Init(void)
891
 
{
892
 
    QImage image = QImage(m_Area.size(), QImage::Format_ARGB32);
893
 
    m_image = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
894
 
    m_image->Assign(image);
895
 
 
896
 
    QRect area(0, 0, m_Area.width(), m_Area.height());
897
 
    QPainter painter((QImage*)m_image);
898
 
    painter.fillRect(area, QColor(Qt::white));
899
 
    painter.setPen(Qt::black);
900
 
    painter.setFont(QFont("Arial", 30));
901
 
    painter.drawText(area, Qt::AlignCenter|Qt::TextWordWrap,
902
 
                     "This feature requires QtWebKit from Qt 4.4.0 or later");
903
 
    painter.end();
904
 
 
905
 
    m_initialized = true;
906
 
}
907
 
 
908
 
void MythUIWebBrowser::Finalize(void)
909
 
{
910
 
    Init();
911
 
 
912
 
    MythUIType::Finalize();
913
 
}
914
 
 
915
 
MythUIWebBrowser::~MythUIWebBrowser()
916
 
{
917
 
    if (m_image)
918
 
    {
919
 
        m_image->DownRef();
920
 
        m_image = NULL;
921
 
    }
922
 
}
923
 
 
924
 
void MythUIWebBrowser::LoadPage(QUrl url)
925
 
{
926
 
    (void) url;
927
 
}
928
 
 
929
 
void MythUIWebBrowser::SetHtml(const QString &html, const QUrl &baseUrl)
930
 
{
931
 
    (void) html;
932
 
    (void) baseUrl;
933
 
}
934
 
 
935
 
void MythUIWebBrowser::SetBackgroundColor(QColor color)
936
 
{
937
 
    (void) color;
938
 
}
939
 
 
940
 
void MythUIWebBrowser::SetActive(bool active)
941
 
{
942
 
    (void) active;
943
 
}
944
 
 
945
 
void SetHtml(const QString &html, const QUrl &baseUrl)
946
 
{
947
 
}
948
 
 
949
 
void MythUIWebBrowser::ZoomIn(void)
950
 
{
951
 
}
952
 
 
953
 
void MythUIWebBrowser::ZoomOut(void)
954
 
{
955
 
}
956
 
 
957
 
void MythUIWebBrowser::SetZoom(float zoom)
958
 
{
959
 
    (void) zoom;
960
 
}
961
 
 
962
 
float MythUIWebBrowser::GetZoom(void)
963
 
{
964
 
    return 1.0;
965
 
}
966
 
 
967
 
bool MythUIWebBrowser::CanGoForward(void)
968
 
{
969
 
    return false;
970
 
}
971
 
 
972
 
bool MythUIWebBrowser::CanGoBack(void)
973
 
{
974
 
    return false;
975
 
}
976
 
 
977
 
void MythUIWebBrowser::Back(void)
978
 
{
979
 
}
980
 
 
981
 
void MythUIWebBrowser::Forward(void)
982
 
{
983
 
}
984
 
 
985
 
QIcon MythUIWebBrowser::GetIcon(void)
986
 
{
987
 
    return QIcon();
988
 
}
989
 
 
990
 
QUrl MythUIWebBrowser::GetUrl(void)
991
 
{
992
 
    return QUrl();
993
 
}
994
 
 
995
 
void MythUIWebBrowser::slotLoadStarted(void)
996
 
{
997
 
}
998
 
 
999
 
void MythUIWebBrowser::slotLoadFinished(bool ok)
1000
 
{
1001
 
    (void) ok;
1002
 
}
1003
 
 
1004
 
void MythUIWebBrowser::slotLoadProgress(int progress)
1005
 
{
1006
 
    (void) progress;
1007
 
}
1008
 
 
1009
 
void MythUIWebBrowser::slotTitleChanged(const QString &title)
1010
 
{
1011
 
    (void) title;
1012
 
}
1013
 
 
1014
 
void MythUIWebBrowser::slotStatusBarMessage(const QString &text)
1015
 
{
1016
 
    (void) text;
1017
 
}
1018
 
 
1019
 
void MythUIWebBrowser::slotIconChanged(void)
1020
 
{
1021
 
}
1022
 
 
1023
 
void MythUIWebBrowser::slotTakingFocus(void)
1024
 
{
1025
 
}
1026
 
 
1027
 
void MythUIWebBrowser::slotLosingFocus(void)
1028
 
{
1029
 
}
1030
 
 
1031
 
void MythUIWebBrowser::UpdateBuffer(void)
1032
 
{
1033
 
}
1034
 
 
1035
 
void MythUIWebBrowser::Pulse(void)
1036
 
{
1037
 
}
1038
 
 
1039
 
void MythUIWebBrowser::DrawSelf(MythPainter *p, int xoffset, int yoffset,
1040
 
                       int alphaMod, QRect clipRegion)
1041
 
{
1042
 
    if (!m_initialized)
1043
 
        Init();
1044
 
 
1045
 
 
1046
 
    QRect area = m_Area;
1047
 
    area.translate(xoffset, yoffset);
1048
 
 
1049
 
    p->DrawImage(area.x(), area.y(), m_image, alphaMod);
1050
 
}
1051
 
 
1052
 
bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event)
1053
 
{
1054
 
    return false;
1055
 
}
1056
 
 
1057
 
void MythUIWebBrowser::HandleMouseAction(const QString &action)
1058
 
{
1059
 
    (void) action;
1060
 
}
1061
 
 
1062
 
bool MythUIWebBrowser::ParseElement(QDomElement &element)
1063
 
{
1064
 
    return MythUIType::ParseElement(element);
1065
 
}
1066
 
 
1067
 
void MythUIWebBrowser::CopyFrom(MythUIType *base)
1068
 
{
1069
 
    MythUIWebBrowser *browser = dynamic_cast<MythUIWebBrowser *>(base);
1070
 
    if (!browser)
1071
 
    {
1072
 
        VERBOSE(VB_IMPORTANT, "ERROR, bad parsing");
1073
 
        return;
1074
 
    }
1075
 
 
1076
 
    MythUIType::CopyFrom(base);
1077
 
}
1078
 
 
1079
 
void MythUIWebBrowser::CreateCopy(MythUIType *parent)
1080
 
{
1081
 
    MythUIWebBrowser *browser = new MythUIWebBrowser(parent, objectName());
1082
 
    browser->CopyFrom(this);
1083
 
}
1084
 
 
1085
 
#endif // USING_QTWEBKIT