Add sidebar template
Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
parent
8754a8c37d
commit
0b06fe04f2
13
sidebar/falkon-python-sidebar.desktop
Normal file
13
sidebar/falkon-python-sidebar.desktop
Normal file
@ -0,0 +1,13 @@
|
||||
[General]
|
||||
Name=Sidebar
|
||||
Comment=Sidebar class for Falkon webbrowser
|
||||
Category=Python/Falkon
|
||||
Language=Python
|
||||
Type=Other
|
||||
Files=Implementation
|
||||
OptionsFile=options.kcfg
|
||||
|
||||
[Implementation]
|
||||
Name=Implementation
|
||||
File=sidebar.py
|
||||
OutputFile={{ class_name }}.py
|
21
sidebar/options.kcfg
Normal file
21
sidebar/options.kcfg
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||
<kcfgfile arg="true"/>
|
||||
<group name="Sidebar">
|
||||
<entry name="class_name" type="String">
|
||||
<label>Class name</label>
|
||||
<default>Sidebar</default>
|
||||
</entry>
|
||||
<entry name="title" type="String">
|
||||
<label>Title</label>
|
||||
<default></default>
|
||||
</entry>
|
||||
<entry name="shortcut" type="String">
|
||||
<label>Keyboard shortcut</label>
|
||||
<default></default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
46
sidebar/sidebar.py
Normal file
46
sidebar/sidebar.py
Normal file
@ -0,0 +1,46 @@
|
||||
{% load kdev_filters %}
|
||||
{% block license_header %}
|
||||
{% if license %}
|
||||
{{ license|lines_prepend:"# " }}
|
||||
{% endif %}
|
||||
{% endblock license_header %}
|
||||
|
||||
|
||||
import Falkon
|
||||
from PySide2 import QtGui, QtWidgets
|
||||
|
||||
|
||||
class {{ class_name }}(Falkon.SideBarInterface):
|
||||
def title(self):
|
||||
{% if title %}
|
||||
return "{{ title }}"
|
||||
{% else %}
|
||||
return "{{ class_name }}"
|
||||
{% endif %}
|
||||
|
||||
|
||||
def createMenuAction(self):
|
||||
{% if title %}
|
||||
action = Falkon.Action("{{ title }}")
|
||||
{% else %}
|
||||
action = Falkon.Action("{{ class_name }}")
|
||||
{% endif %}
|
||||
action.setCheckable(True)
|
||||
{% if shortcut %}
|
||||
action.setShortcut(QtGui.QKeySequence("{{ shortcut }}"))
|
||||
{% endif %}
|
||||
|
||||
|
||||
return action
|
||||
|
||||
|
||||
def createSideBarWidget(self, window):
|
||||
widget = QtWidgets.QWidget()
|
||||
button = QtWidgets.QPushButton("Button in sidebar")
|
||||
layout = QtWidgets.QVBoxLayout(widget)
|
||||
layout.addWidget(button)
|
||||
widget.setLayout(layout)
|
||||
|
||||
|
||||
return widget
|
||||
|
Loading…
Reference in New Issue
Block a user