~ubuntu-branches/ubuntu/oneiric/apturl/oneiric-updates

« back to all changes in this revision

Viewing changes to AptUrl/kde/KdeUI.py

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2009-09-01 21:02:20 UTC
  • Revision ID: james.westby@ubuntu.com-20090901210220-12hfhfd5xo939zpq
Tags: 0.4.0ubuntu3
* Make KDE frontend use a Qt UI file (should make it easier to maintain)
* Enable KDE frontend to few HTML when about to enable a software channel
* Clean-up setup.py
* Make apturl script fall back to KDE frontend when -gtk is not installed even
  if KDE_FULL_SESSION is not set
* Resolve self-relations of apturl binary package
* fix crash on ctrl-c (in KDE frontend)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
from PyQt4.QtCore import *
4
4
from PyQt4.QtGui import *
 
5
from PyQt4.QtWebKit import QWebView
5
6
from PyQt4 import uic
6
7
from PyKDE4.kdeui import *
7
8
from PyKDE4.kdecore import *
36
37
    def __init__(self):
37
38
        self.dialog = AptUrlDialog()
38
39
 
39
 
        self.mainwidget = QWidget(self.dialog)
40
 
        self.dialog.setMainWidget(self.mainwidget)
41
 
 
42
 
        self.hlayout = QHBoxLayout(self.mainwidget)
43
 
        self.image_label = QLabel(self.mainwidget)
44
 
        self.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))
45
 
        self.hlayout.addWidget(self.image_label)
46
 
 
47
 
        self.vlayout = QVBoxLayout()
48
 
        self.hlayout.addLayout(self.vlayout)
49
 
 
50
 
        self.header_label = QLabel(self.mainwidget)
51
 
        self.header_label.setTextFormat(Qt.RichText)
52
 
        self.vlayout.addWidget(self.header_label)
53
 
 
54
 
        self.body_label = QLabel(self.mainwidget)
55
 
        self.vlayout.addWidget(self.body_label)
56
 
 
57
 
        #self.description_button = QPushButton(self.mainwidget)
58
 
        #self.description_button.setText("Description")
59
 
        #self.layout.addWidget(self.description_button)
60
 
 
61
 
        self.description_edit = KTextEdit(self.mainwidget)
62
 
        self.description_edit.setReadOnly(True)
63
 
        self.description_edit.hide()
64
 
        self.vlayout.addWidget(self.description_edit)
65
 
 
66
 
        #QObject.connect(self.description_button ,SIGNAL("clicked()"),self.description_edit.show)
 
40
        self.d = QWidget(self.dialog)
 
41
        self.dialog.setMainWidget(self.d)
 
42
 
 
43
        uic.loadUi('/usr/share/apturl/apturl.ui', self.d)
 
44
        self.d.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))
67
45
 
68
46
    # generic dialogs
69
47
    def _get_dialog(self, dialog_type, summary, msg="", buttons=KDialog.Close):
70
48
        self.dialog.setButtons(KDialog.ButtonCode(buttons))
71
 
        self.header_label.setText(summary)
72
 
        self.body_label.setText(msg)
 
49
        self.d.header_label.setText(summary)
 
50
        self.d.body_label.setText(msg)
73
51
        # TODO: title = empty
74
52
        # TODO: keep above maintain across events
75
53
        # TODO: d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
90
68
    def yesNoQuestion(self, summary, msg, title="", default='no'):
91
69
        self._get_dialog('', summary, msg,
92
70
                             buttons=KDialog.Yes | KDialog.No)
93
 
        self.dialog.setWindowTitle(title)
 
71
        self.d.setWindowTitle(title)
94
72
        res = self.dialog.exec_()
95
73
        if res != KDialog.Accepted:
96
74
            return False
98
76
 
99
77
    # specific dialogs
100
78
    def askEnableChannel(self, channel, channel_info_html):
101
 
        summary = _("Enable additional software channel")
 
79
        summary = "<h2>" + _("Enable additional software channel") + "</h2>"
102
80
        msg = _("Do you want to enable the following "
103
81
                "software channel: '%s'?") % channel
104
82
        self._get_dialog('', summary, msg,
105
83
                             buttons=KDialog.Yes | KDialog.No)
106
 
        # TODO: HTML!!!
 
84
        webview = QWebView()
 
85
        webview.setHtml(channel_info_html)
 
86
        webview.setFixedSize(400,200)
 
87
        self.d.vlayout_right.addWidget(webview)
107
88
        res = self.dialog.exec_()
108
89
        if res != KDialog.Accepted:
109
90
            return False
110
91
        return True
111
92
 
112
 
        #if channel_info_html:
113
 
            #try:
114
 
                #import gtkhtml2
115
 
                #doc=gtkhtml2.Document()
116
 
                #doc.open_stream("text/html")
117
 
                #doc.write_stream(channel_info_html)
118
 
                #doc.close_stream()
119
 
                #v=gtkhtml2.View()
120
 
                #v.set_document(doc)
121
 
                #sw = gtk.ScrolledWindow()
122
 
                #sw.add(v)
123
 
                #d.get_content_area().pack_start(sw)
124
 
                #sw.show_all()
125
 
                #v.set_size_request(400,200)
126
 
            #except ImportError, e:
127
 
                #pass
128
 
 
129
93
    def doEnableSection(self, sections):
130
94
        cmd = ["kdesudo",
131
95
               "--",
166
130
        body = _("Do you want to install package '%s'?") % package
167
131
        desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
168
132
 
169
 
        self.header_label.setText(header)
170
 
        self.body_label.setText(body)
 
133
        self.d.header_label.setText(header)
 
134
        self.d.body_label.setText(body)
171
135
        #self.description_edit.show()
172
136
        #self.description_edit.setText(desc)
173
137