~ubuntu-core-dev/software-properties/main

« back to all changes in this revision

Viewing changes to softwareproperties/kde/DialogAdd.py

  • Committer: Simon Quigley
  • Date: 2018-07-14 10:11:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1049.
  • Revision ID: tsimonq2@ubuntu.com-20180714101132-jpm43js9q13vplzm
Use sed to make everything say Qt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#  Qt 4 based frontend to software-properties
2
 
#
3
 
#  Copyright (c) 2007 Canonical Ltd.
4
 
#
5
 
#  Author: Jonathan Riddell <jriddell@ubuntu.com>
6
 
#
7
 
#  This program is free software; you can redistribute it and/or
8
 
#  modify it under the terms of the GNU General Public License as
9
 
#  published by the Free Software Foundation; either version 2 of the
10
 
#  License, or (at your option) any later version.
11
 
#
12
 
#  This program is distributed in the hope that it will be useful,
13
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#  GNU General Public License for more details.
16
 
#
17
 
#  You should have received a copy of the GNU General Public License
18
 
#  along with this program; if not, write to the Free Software
19
 
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
 
#  USA
21
 
 
22
 
from __future__ import absolute_import
23
 
 
24
 
from gettext import gettext as _
25
 
 
26
 
from PyQt5.QtCore import *
27
 
from PyQt5.QtGui import *
28
 
from PyQt5 import uic
29
 
 
30
 
from aptsources.sourceslist import SourceEntry
31
 
 
32
 
from .I18nHelper import *
33
 
 
34
 
UIDIR = '/home/jr/src/software-properties/deneutral'
35
 
 
36
 
class DialogAdd(QDialog):
37
 
 
38
 
  def __init__(self, parent, sourceslist, datadir, distro):
39
 
    QDialog.__init__(self, parent)
40
 
    self.sourceslist = sourceslist
41
 
    self.distro = distro
42
 
    uic.loadUi("%s/designer/dialog_add.ui" % datadir, self)
43
 
 
44
 
    self.button_edit_ok = self.buttonBox.button(QDialogButtonBox.Ok)
45
 
    self.button_edit_ok.setEnabled(False)
46
 
 
47
 
    if self.distro:
48
 
        example = "%s %s %s %s" % (self.distro.binary_type,
49
 
                                   self.distro.source_template.base_uri,
50
 
                                   self.distro.codename,
51
 
                                   self.distro.source_template.components[0].name)
52
 
    else:
53
 
        example = "deb http://ftp.debian.org sarge main"
54
 
    # L10N: the example is of the format: deb http://ftp.debian.org sarge main
55
 
    primary = _('Enter the complete APT line of the repository that '
56
 
             'you want to add.')
57
 
    secondary = _("Include the type, location and components of the "
58
 
                "repository. Example: %s") % example
59
 
    text = "%s<br /><br /><small>%s</small>" % (primary, secondary)
60
 
    self.label_example_line.setWordWrap(True)
61
 
    self.label_example_line.setText(text)
62
 
 
63
 
    translate_widget(self)
64
 
 
65
 
    self.entry.textChanged.connect(self.check_line)
66
 
 
67
 
  def check_line(self, text):
68
 
    """Check for a valid apt line and set the enabled value of the
69
 
       button 'add' accordingly"""
70
 
    line = self.entry.text()
71
 
    if line.startswith("ppa:"):
72
 
      self.button_edit_ok.setEnabled(True)
73
 
      return
74
 
    source_entry = SourceEntry(line)
75
 
    if source_entry.invalid == True or source_entry.disabled == True:
76
 
      self.button_edit_ok.setEnabled(False)
77
 
    else:
78
 
      self.button_edit_ok.setEnabled(True)
79
 
 
80
 
  def run(self):
81
 
    result = self.exec_()
82
 
    if result == QDialog.Accepted:
83
 
        line = self.entry.text()
84
 
    else:
85
 
        line = None
86
 
    return line