Commit 0c098f15 authored by Dan Pascu's avatar Dan Pascu

Reworked the server tools window


- added navigation capabilities to the Web viewer
- implemented missing functionality (opening external links and SIP URLs)
- enhanced the window look to better fit Blink's overall theme
parent be9d7114
This diff is collapsed.
from __future__ import division
from PyQt5.QtCore import QEvent, QRectF, QSize
from PyQt5.QtSvg import QSvgWidget
from blink.resources import Resources
from blink.widgets.util import QtDynamicProperty
__all__ = ['Spinner']
class Spinner(QSvgWidget):
icon_file = QtDynamicProperty('icon_file', type=unicode)
icon_size = QtDynamicProperty('icon_size', type=QSize)
icon_crop = QtDynamicProperty('icon_crop', type=int)
def __init__(self, parent=None, icon='icons/spinner.svg'):
super(Spinner, self).__init__(parent)
self._original_viewbox = QRectF()
self.icon_crop = 0
self.icon_size = None
self.icon_file = Resources.get(icon)
def load(self, svg):
super(Spinner, self).load(svg)
self._original_viewbox = self.renderer().viewBoxF()
self._update_viewbox(self.size())
def event(self, event):
if event.type() == QEvent.DynamicPropertyChange:
if event.propertyName() == 'icon_crop':
self._update_viewbox(self.size())
elif event.propertyName() == 'icon_file':
self.load(self.icon_file)
elif event.propertyName() == 'icon_size':
self.updateGeometry()
return super(Spinner, self).event(event)
def resizeEvent(self, event):
super(Spinner, self).resizeEvent(event)
self._update_viewbox(event.size())
def sizeHint(self):
return self.icon_size or super(Spinner, self).sizeHint()
def _update_viewbox(self, size):
if self._original_viewbox.isEmpty() or size.isEmpty():
return
viewbox = self._original_viewbox.adjusted(self.icon_crop, self.icon_crop, -self.icon_crop, -self.icon_crop)
width = size.width()
height = size.height()
if height >= width:
new_viewbox = QRectF(viewbox.x(), viewbox.y() + viewbox.height()/2 * (1 - height/width), viewbox.width(), viewbox.height() * height/width)
else:
new_viewbox = QRectF(viewbox.x() + viewbox.width()/2 * (1 - width/height), viewbox.y(), viewbox.width() * width/height, viewbox.height())
self.renderer().setViewBox(new_viewbox)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg4146"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="spinner.svg">
<defs
id="defs4148">
<linearGradient
inkscape:collect="always"
id="linearGradient5620">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5622" />
<stop
id="stop5624"
offset="0.85714287"
style="stop-color:#000000;stop-opacity:1" />
<stop
style="stop-color:#000000;stop-opacity:0"
offset="0.85714287"
id="stop5626" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop5628" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5620"
id="linearGradient5226"
x1="16"
y1="30"
x2="16"
y2="16"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5620"
id="linearGradient5234"
gradientUnits="userSpaceOnUse"
x1="16"
y1="30"
x2="16"
y2="16"
gradientTransform="translate(0,-32)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="29.1875"
inkscape:cx="16"
inkscape:cy="16"
inkscape:document-units="px"
inkscape:current-layer="g5954"
showgrid="true"
units="px"
inkscape:window-width="1850"
inkscape:window-height="1168"
inkscape:window-x="2"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true">
<inkscape:grid
type="xygrid"
id="grid4694"
spacingx="0.5"
spacingy="0.5"
empspacing="10" />
</sodipodi:namedview>
<metadata
id="metadata4151">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="g5954"
inkscape:label="Spinner dual color"
style="display:inline;opacity:1">
<circle
r="12.5"
cy="16"
cx="16"
id="circle4307"
style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient5226);stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1" />
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
<circle
r="12.5"
cy="-16"
cx="16"
style="opacity:0.3;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient5234);stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1"
id="circle4305"
transform="scale(1,-1)" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg4146"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="spinner.svg">
<defs
id="defs4148">
<linearGradient
inkscape:collect="always"
id="linearGradient5620">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5622" />
<stop
id="stop5624"
offset="0.85714287"
style="stop-color:#000000;stop-opacity:1" />
<stop
style="stop-color:#000000;stop-opacity:0"
offset="0.85714287"
id="stop5626" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop5628" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient4255">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4257" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4259" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4255"
id="linearGradient4261"
x1="16"
y1="2"
x2="16"
y2="30"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5620"
id="linearGradient5226"
x1="16"
y1="30"
x2="16"
y2="16"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5620"
id="linearGradient5234"
gradientUnits="userSpaceOnUse"
x1="16"
y1="30"
x2="16"
y2="16"
gradientTransform="translate(0,-32)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="29.1875"
inkscape:cx="16"
inkscape:cy="16"
inkscape:document-units="px"
inkscape:current-layer="g5954"
showgrid="true"
units="px"
inkscape:window-width="1850"
inkscape:window-height="1168"
inkscape:window-x="2"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true">
<inkscape:grid
type="xygrid"
id="grid4694"
spacingx="0.5"
spacingy="0.5"
empspacing="10" />
</sodipodi:namedview>
<metadata
id="metadata4151">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="Spinner"
style="display:none;opacity:1">
<circle
style="opacity:0.2;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1"
id="circle4147"
cx="16"
cy="16"
r="12.5" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.6;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 16,2 C 8.2857805,2 2,8.2857805 2,16 l 3,0 C 5,9.9071008 9.9071008,5 16,5 22.092899,5 27,9.9071008 27,16 l 3,0 C 30,8.2857805 23.71422,2 16,2 Z"
id="circle6611"
inkscape:connector-curvature="0">
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
</path>
</g>
<g
inkscape:groupmode="layer"
id="g4236"
inkscape:label="Spinner 180"
style="display:none;opacity:1">
<path
d="M 28.5,16 A 12.5,12.5 0 0 1 22.25,26.825318 12.5,12.5 0 0 1 9.7499997,26.825317 12.5,12.5 0 0 1 3.5,15.999999"
sodipodi:open="true"
sodipodi:end="3.1415927"
sodipodi:start="0"
sodipodi:ry="12.5"
sodipodi:rx="12.5"
sodipodi:cy="16"
sodipodi:cx="16"
sodipodi:type="arc"
style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1"
id="circle4238">
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
</path>
</g>
<g
style="display:none;opacity:1"
inkscape:label="Spinner 270"
id="g4221"
inkscape:groupmode="layer">
<path
id="circle4223"
style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1"
sodipodi:type="arc"
sodipodi:cx="15.999502"
sodipodi:cy="16.000498"
sodipodi:rx="12.500498"
sodipodi:ry="12.500498"
sodipodi:start="0"
sodipodi:end="4.712389"
sodipodi:open="true"
d="M 28.5,16.000498 A 12.500498,12.500498 0 0 1 20.783236,27.549452 12.500498,12.500498 0 0 1 7.1603153,24.839685 12.500498,12.500498 0 0 1 4.4505482,11.216764 12.500498,12.500498 0 0 1 15.999502,3.5">
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
</path>
</g>
<g
style="display:none;opacity:1"
inkscape:label="Spinner gradient"
id="g4240"
inkscape:groupmode="layer">
<circle
r="12.5"
cy="16"
cx="16"
id="circle4242"
style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4261);stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1">
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
</circle>
</g>
<g
inkscape:groupmode="layer"
id="g5954"
inkscape:label="Spinner dual color"
style="display:inline;opacity:1">
<animateTransform
attributeName="transform"
type="rotate"
from="0 16 16"
to="360 16 16"
repeatCount="indefinite"
dur="0.8s" />
<circle
r="12.5"
cy="16"
cx="16"
id="circle4307"
style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient5226);stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1" />
<circle
r="12.5"
cy="-16"
cx="16"
style="opacity:0.3;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient5234);stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:3.55200005;stroke-opacity:1"
id="circle4305"
transform="scale(1,-1)" />
</g>
</svg>
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>670</height>
<width>720</width>
<height>730</height>
</rect>
</property>
<property name="windowTitle">
......@@ -21,46 +21,40 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="account_selector" native="true">
<layout class="QHBoxLayout" name="account_layout">
<widget class="QWidget" name="navigation_widget" native="true">
<layout class="QHBoxLayout" name="navigation_layout">
<property name="spacing">
<number>3</number>
<number>6</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
<number>0</number>
</property>
<item>
<widget class="ToolButton" name="account_button">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
<string>user@domain</string>
</property>
<property name="icon">
<iconset>
......@@ -75,44 +69,29 @@
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="separator">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="location_frame">
<widget class="QWidget" name="location_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string>QFrame#location_frame {
background: #2060c0;
border-style: outset;
border-width: 1px;
border-radius: 4px;
border-color: #104080;
margin-top: 4px;
margin-bottom: 4px;
padding-left: 2px;
padding-right: 2px;
color: white;
}
QWidget {
color: white;
}
</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="location_layout">
<property name="spacing">
<number>7</number>
......@@ -124,62 +103,97 @@ QWidget {
<number>0</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>7</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="account_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QToolButton" name="back_button">
<property name="text">
<string>Back</string>
</property>
<property name="icon">
<iconset theme="draw-arrow-back">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="forward_button">
<property name="text">
<string>Forward</string>
</property>
<property name="icon">
<iconset theme="draw-arrow-forward">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progress_bar">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>12</height>
</size>
<widget class="QToolButton" name="home_button">
<property name="text">
<string>Home</string>
</property>
<property name="styleSheet">
<string>QProgressBar {
border: 1px solid white;
border-radius: 2px;
}
QProgressBar::chunk {
background-color: #2060c0;
width: 3px;
margin-right: 1px;
}</string>
<property name="icon">
<iconset theme="go-home">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="value">
<number>30</number>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<property name="textVisible">
<bool>false</bool>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="spinner_label">
<property name="pixmap">
<pixmap>icons/servertools-spinner.mng</pixmap>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Spinner" name="spinner" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="icon_size" stdset="0">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon_crop" stdset="0">
<number>0</number>
</property>
</widget>
</item>
......@@ -190,35 +204,46 @@ QProgressBar::chunk {
</widget>
</item>
<item>
<widget class="QTabWidget" name="tab_widget">
<property name="currentIndex">
<number>0</number>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<property name="tabsClosable">
<bool>true</bool>
<widget class="ServerToolsWebView" name="web_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="movable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKitWidgets/QWebView</header>
</customwidget>
<customwidget>
<class>ServerToolsWebView</class>
<extends>QWebView</extends>
<header>blink.accounts</header>
</customwidget>
<customwidget>
<class>ToolButton</class>
<extends>QToolButton</extends>
<header>blink.widgets.buttons</header>
</customwidget>
<customwidget>
<class>Spinner</class>
<extends>QWidget</extends>
<header>blink.widgets.spinner</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>web_view</tabstop>
<tabstop>account_button</tabstop>
<tabstop>back_button</tabstop>
<tabstop>forward_button</tabstop>
<tabstop>home_button</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment