1

Add sidebar template

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-06-13 16:05:07 +02:00
parent 8754a8c37d
commit 0b06fe04f2
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07
3 changed files with 80 additions and 0 deletions

View 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
View 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
View 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