WebBrowser/UrlBar/StackedUrlBar.py

branch
QtWebEngine
changeset 4709
8612533a223f
parent 4631
5c1a96925da4
child 5389
9b1c800daff3
equal deleted inserted replaced
4702:bd7d781db729 4709:8612533a223f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a widget to stack url bars.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtWidgets import QStackedWidget, QSizePolicy
13
14
15 class StackedUrlBar(QStackedWidget):
16 """
17 Class implementing a widget to stack URL bars.
18 """
19 def __init__(self, parent=None):
20 """
21 Constructor
22
23 @param parent reference to the parent widget (QWidget)
24 """
25 super(StackedUrlBar, self).__init__(parent)
26
27 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
28 sizePolicy.setHorizontalStretch(6)
29 sizePolicy.setVerticalStretch(0)
30 self.setSizePolicy(sizePolicy)
31 self.setMinimumSize(200, 22)
32
33 def currentUrlBar(self):
34 """
35 Public method to get a reference to the current URL bar.
36
37 @return reference to the current URL bar (UrlBar)
38 """
39 return self.urlBar(self.currentIndex())
40
41 def urlBar(self, index):
42 """
43 Public method to get a reference to the URL bar for a given index.
44
45 @param index index of the url bar (integer)
46 @return reference to the URL bar for the given index (UrlBar)
47 """
48 return self.widget(index)
49
50 def moveBar(self, from_, to_):
51 """
52 Public slot to move an URL bar.
53
54 @param from_ index of URL bar to be moved (integer)
55 @param to_ index to move the URL bar to (integer)
56 """
57 fromBar = self.widget(from_)
58 self.removeWidget(fromBar)
59 self.insertWidget(to_, fromBar)
60
61 def urlBars(self):
62 """
63 Public method to get a list of references to all URL bars.
64
65 @return list of references to URL bars (list of UrlBar)
66 """
67 urlBars = []
68 for index in range(self.count()):
69 urlBars.append(self.widget(index))
70 return urlBars

eric ide

mercurial