ait/os/bin/opensecurityd/about.py
author om
Tue, 12 Nov 2013 11:31:34 +0100
branchom
changeset 2 c9bf2537109a
permissions -rwxr-xr-x
added C/C++ and Python sources
     1 #!/bin/env python
     2 # -*- coding: utf-8 -*-
     3 
     4 # ------------------------------------------------------------
     5 # about-dialog
     6 # 
     7 # tell the user about the project
     8 #
     9 # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    10 #
    11 # Copyright (C) 2013 AIT Austrian Institute of Technology
    12 # AIT Austrian Institute of Technology GmbH
    13 # Donau-City-Strasse 1 | 1220 Vienna | Austria
    14 # http://www.ait.ac.at
    15 #
    16 # This program is free software; you can redistribute it and/or
    17 # modify it under the terms of the GNU General Public License
    18 # as published by the Free Software Foundation version 2.
    19 # 
    20 # This program is distributed in the hope that it will be useful,
    21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23 # GNU General Public License for more details.
    24 # 
    25 # You should have received a copy of the GNU General Public License
    26 # along with this program; if not, write to the Free Software
    27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    28 # Boston, MA  02110-1301, USA.
    29 # ------------------------------------------------------------
    30 
    31 
    32 # ------------------------------------------------------------
    33 # imports
    34 
    35 from PyQt4 import QtCore
    36 from PyQt4 import QtGui
    37 
    38 # local
    39 from environment import Environment
    40 
    41 # ------------------------------------------------------------
    42 # vars
    43 
    44 
    45 ABOUT_TEXT = """
    46 <html>
    47 <body bgcolor="#FFFFFF">
    48 
    49 <div align="center">
    50 <p/>
    51 <img src="image:ait_logo_no_claim.png"/>
    52 <p/>
    53 <h1>OpenSecurity</h1>
    54 <p/>
    55 </div>
    56 <p/>
    57 Blah ...<br/>
    58 
    59 <p>
    60 Copyright (C) 2013, AIT Austrian Institute of Technology<br/>
    61 AIT Austrian Institute of Technology GmbH<br/>
    62 Donau-City-Strasse 1 | 1220 Vienna | Austria<br/>
    63 <a href="http://www.ait.ac.at">http://www.ait.ac.at</a>
    64 </p>
    65 </div>
    66 
    67 </body>
    68 </html>
    69 """;
    70 
    71 
    72 # ------------------------------------------------------------
    73 # code
    74 
    75 
    76 class About(QtGui.QDialog):
    77     
    78     """Show some about stuff."""
    79     
    80     def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
    81         
    82         # super call and widget init
    83         super(About, self).__init__(parent, flags)
    84         
    85         # setup image search path
    86         QtCore.QDir.setSearchPaths("image", QtCore.QStringList(Environment('opensecurity').image_path));
    87         
    88         self.setWindowTitle('About OpenSecuirty ...')
    89         self.setup_ui()
    90         
    91 
    92     def setup_ui(self):
    93         
    94         """Create the widgets."""
    95         
    96         lyMain = QtGui.QVBoxLayout(self)
    97         lyMain.setContentsMargins(8, 8, 8, 8)
    98         
    99         lbAbout = QtGui.QLabel()
   100         lbAbout.setStyleSheet("QWidget { background: white; color: black; };")
   101         lbAbout.setText(ABOUT_TEXT)
   102         lbAbout.setContentsMargins(12, 12, 12, 12)
   103         
   104         scAbout = QtGui.QScrollArea()
   105         scAbout.setWidget(lbAbout)
   106         scAbout.viewport().setStyleSheet("QWidget { background: white; color: black; };")
   107         lyMain.addWidget(scAbout)
   108         
   109         # buttons
   110         lyButton = QtGui.QHBoxLayout()
   111         lyMain.addLayout(lyButton)
   112         
   113         lyButton.addStretch(1)
   114         btnOk = QtGui.QPushButton('&Ok', self)
   115         btnOk.setMinimumWidth(100)
   116         lyButton.addWidget(btnOk)
   117         
   118         # connectors
   119         btnOk.clicked.connect(self.accept)
   120         
   121         # reduce to the max
   122         self.setMinimumSize(400, 200)
   123         self.resize(lyMain.minimumSize())
   124