forked from arasweb/qterminal-ninja-plugin
/
terminal.py
80 lines (61 loc) · 2.58 KB
/
terminal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
# PEP8:OK, LINT:OK, PY3:OK
#############################################################################
## This file may be used under the terms of the GNU General Public
## License version 2.0 or 3.0 as published by the Free Software Foundation
## and appearing in the file LICENSE.GPL included in the packaging of
## this file. Please review the following information to ensure GNU
## General Public Licensing requirements will be met:
## http:#www.fsf.org/licensing/licenses/info/GPLv2.html and
## http:#www.gnu.org/copyleft/gpl.html.
##
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#############################################################################
# metadata
' Terminal for Ninja-IDE '
__version__ = ' 0.2 '
__license__ = ' GPL '
__author__ = ' juancarlospaco '
__email__ = ' juancarlospaco@ubuntu.com '
__url__ = ''
__date__ = ' 30/05/2013 '
__prj__ = ' terminal '
__docformat__ = 'html'
__source__ = ''
__full_licence__ = ''
# imports
from sip import setapi
from PyQt4.QtGui import QIcon, QLabel, QDockWidget
try:
from PyKDE4.kdecore import KPluginLoader
from PyKDE4.kparts import *
except ImportError:
pass
from ninja_ide.core import plugin
# API 2
(setapi(a, 2) for a in ("QDate", "QDateTime", "QString", "QTime", "QUrl",
"QTextStream", "QVariant"))
###############################################################################
class Terminal(plugin.Plugin):
" Terminal Class "
def initialize(self):
" Init Class Terminal "
self.terminal = QDockWidget()
self.terminal.setFeatures(QDockWidget.DockWidgetFloatable |
QDockWidget.DockWidgetMovable)
self.terminal.setWindowTitle(__doc__)
self.terminal.setStyleSheet('QDockWidget::title{text-align: center;}')
try:
self.factory = KPluginLoader("libkonsolepart").factory()
self.terminal.setWidget(self.factory.create(self).widget())
except:
self.terminal.setWidget(QLabel(""" <center> <h3>ಠ_ಠ<br>
ERROR: Please, install Konsole Terminal and PyKDE ! </h3><br>
<br><i> (Sorry, cant embed non-Qt Terminal Apps). </i><center>"""))
self.misc = self.locator.get_service('misc')
self.misc.add_widget(self.terminal,
QIcon.fromTheme("utilities-terminal"), __doc__)
###############################################################################
if __name__ == "__main__":
print(__doc__)