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()
39
self.mainwidget = QWidget(self.dialog)
40
self.dialog.setMainWidget(self.mainwidget)
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)
47
self.vlayout = QVBoxLayout()
48
self.hlayout.addLayout(self.vlayout)
50
self.header_label = QLabel(self.mainwidget)
51
self.header_label.setTextFormat(Qt.RichText)
52
self.vlayout.addWidget(self.header_label)
54
self.body_label = QLabel(self.mainwidget)
55
self.vlayout.addWidget(self.body_label)
57
#self.description_button = QPushButton(self.mainwidget)
58
#self.description_button.setText("Description")
59
#self.layout.addWidget(self.description_button)
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)
66
#QObject.connect(self.description_button ,SIGNAL("clicked()"),self.description_edit.show)
40
self.d = QWidget(self.dialog)
41
self.dialog.setMainWidget(self.d)
43
uic.loadUi('/usr/share/apturl/apturl.ui', self.d)
44
self.d.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))
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:
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)
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:
112
#if channel_info_html:
115
#doc=gtkhtml2.Document()
116
#doc.open_stream("text/html")
117
#doc.write_stream(channel_info_html)
121
#sw = gtk.ScrolledWindow()
123
#d.get_content_area().pack_start(sw)
125
#v.set_size_request(400,200)
126
#except ImportError, e:
129
93
def doEnableSection(self, sections):
166
130
body = _("Do you want to install package '%s'?") % package
167
131
desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
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)