OpenSecurity/bin/about.py
author om
Tue, 10 Dec 2013 17:45:07 +0100
changeset 38 560882d3d3c0
parent 16 e16d64b5e008
child 39 77509ad4f2e9
permissions -rwxr-xr-x
fixed closing systray on About dialog close
     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 import os
    36 
    37 from PyQt4 import QtCore
    38 from PyQt4 import QtGui
    39 
    40 # local
    41 from environment import Environment
    42 
    43 # ------------------------------------------------------------
    44 # vars
    45 
    46 
    47 ABOUT_TEXT = """
    48 <html>
    49 <body bgcolor="#FFFFFF">
    50 
    51 <div align="center">
    52 <p/>
    53 <img src="image:ait_logo_no_claim.png"/>
    54 <p/>
    55 <h1>OpenSecurity</h1>
    56 <p/>
    57 </div>
    58 <p/>
    59 Blah ...<br/>
    60 
    61 <p>
    62 Copyright (C) 2013, AIT Austrian Institute of Technology<br/>
    63 AIT Austrian Institute of Technology GmbH<br/>
    64 Donau-City-Strasse 1 | 1220 Vienna | Austria<br/>
    65 <a href="http://www.ait.ac.at">http://www.ait.ac.at</a>
    66 </p>
    67 </div>
    68 
    69 </body>
    70 </html>
    71 """;
    72 
    73 
    74 # ------------------------------------------------------------
    75 # code
    76 
    77 
    78 class About(QtGui.QDialog):
    79     
    80     """Show some about stuff."""
    81     
    82     def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
    83         
    84         # super call and widget init
    85         super(About, self).__init__(parent, flags)
    86         
    87         # setup image search path
    88         QtCore.QDir.setSearchPaths("image", QtCore.QStringList(os.path.join(Environment('opensecurity').data_path, '..', 'gfx')));
    89         
    90         self.setWindowTitle('About OpenSecurity ...')
    91         self.setup_ui()
    92         
    93 
    94     def setup_ui(self):
    95         
    96         """Create the widgets."""
    97         
    98         lyMain = QtGui.QVBoxLayout(self)
    99         lyMain.setContentsMargins(8, 8, 8, 8)
   100         
   101         lbAbout = QtGui.QLabel()
   102         lbAbout.setStyleSheet("QWidget { background: white; color: black; };")
   103         lbAbout.setText(ABOUT_TEXT)
   104         lbAbout.setContentsMargins(12, 12, 12, 12)
   105         
   106         scAbout = QtGui.QScrollArea()
   107         scAbout.setWidget(lbAbout)
   108         scAbout.viewport().setStyleSheet("QWidget { background: white; color: black; };")
   109         lyMain.addWidget(scAbout)
   110         
   111         # buttons
   112         lyButton = QtGui.QHBoxLayout()
   113         lyMain.addLayout(lyButton)
   114         
   115         lyButton.addStretch(1)
   116         btnOk = QtGui.QPushButton('&Ok', self)
   117         btnOk.setMinimumWidth(100)
   118         lyButton.addWidget(btnOk)
   119         
   120         # connectors
   121         btnOk.clicked.connect(self.accept)
   122         
   123         # reduce to the max
   124         self.setMinimumSize(400, 200)
   125         self.resize(lyMain.minimumSize())
   126