OpenSecurity/bin/about.py
author om
Wed, 11 Dec 2013 10:39:14 +0000
changeset 39 77509ad4f2e9
parent 38 560882d3d3c0
child 92 bc1255abd544
permissions -rwxr-xr-x
beautified About dialog
     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 # ------------------------------------------------------------
    45 # vars
    46 
    47 
    48 ABOUT_TEXT = """
    49 <html>
    50 
    51 <style type="text/css">
    52     .header { margin-bottom: 24px; }
    53     .about_text { margin-bottom: 100px; margin-left: 64px; margin-right: 64px; }
    54     .logo { vertical-align: top; margin-bottom: 24px; }
    55     .footer { margin-top: 100px; }
    56 </style>
    57 
    58 <body bgcolor="#FFFFFF">
    59 <div align="center">
    60 
    61 <h1 class="header">
    62     <a href="http://www.opensecurity.at"><img src="image:opensecurity_logo.jpg"/></a><br/><br/>
    63     OpenSecurity Demo V0.1
    64 </h1>
    65 
    66 <div class="about_text" align="justify">
    67     Blah ...<br/>
    68 </div>
    69 
    70 <div class="logo">
    71     <a href="http://www.ait.ac.at"><img src="image:ait_logo_no_claim.png"/></a>
    72     <a href="http://www.x-net.at"><img src="image:x-net_logo.jpg"/></a>
    73     <a href="http://www.ikarussecurity.com"><img src="image:ikarus_logo.jpg"/></a>
    74 </div>
    75 
    76 <div class="logo">
    77     <a href="http://www.liqua.net"><img src="image:liqua_logo.jpg"/></a>
    78     <a href="http://www.linz.at"><img src="image:linz_logo.jpg"/></a>
    79     <a href="http://www.bmvit.gv.at"><img src="image:bmvit_logo.jpg"/></a>
    80 </div>
    81 
    82 <div class="logo">
    83     <a href="http://www.ffg.at"><img src="image:ffg_logo.jpg"/></a>
    84     <a href="http://www.kiras.at"><img src="image:kiras_logo.jpg"/></a>
    85 </div>
    86 
    87 <div class="footer" align="left">
    88     Copyright (C) 2013, AIT Austrian Institute of Technology<br/>
    89     AIT Austrian Institute of Technology GmbH<br/>
    90     Donau-City-Strasse 1 | 1220 Vienna | Austria<br/>
    91     <a href="http://www.ait.ac.at">http://www.ait.ac.at</a>
    92 </div>
    93 
    94 </div>
    95 </body>
    96 </html>
    97 """;
    98 
    99 
   100 # ------------------------------------------------------------
   101 # code
   102 
   103 
   104 class About(QtGui.QDialog):
   105     
   106     """Show some about stuff."""
   107     
   108     def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
   109         
   110         # super call and widget init
   111         super(About, self).__init__(parent, flags)
   112         
   113         # setup image search path
   114         QtCore.QDir.setSearchPaths("image", QtCore.QStringList(os.path.join(Environment('opensecurity').data_path, '..', 'gfx')));
   115         
   116         self.setWindowTitle('About OpenSecurity ...')
   117         self.setup_ui()
   118         
   119 
   120     def setup_ui(self):
   121         
   122         """Create the widgets."""
   123         
   124         lyMain = QtGui.QVBoxLayout(self)
   125         lyMain.setContentsMargins(8, 8, 8, 8)
   126         
   127         lbAbout = QtGui.QLabel()
   128         lbAbout.setStyleSheet("QWidget { background: white; color: black; };")
   129         lbAbout.setText(ABOUT_TEXT)
   130         lbAbout.setContentsMargins(12, 12, 12, 12)
   131         
   132         scAbout = QtGui.QScrollArea()
   133         scAbout.setWidget(lbAbout)
   134         scAbout.viewport().setStyleSheet("QWidget { background: white; color: black; };")
   135         lyMain.addWidget(scAbout)
   136         
   137         # buttons
   138         lyButton = QtGui.QHBoxLayout()
   139         lyMain.addLayout(lyButton)
   140         
   141         lyButton.addStretch(1)
   142         btnOk = QtGui.QPushButton('&Ok', self)
   143         btnOk.setMinimumWidth(100)
   144         lyButton.addWidget(btnOk)
   145         
   146         # connectors
   147         btnOk.clicked.connect(self.accept)
   148         
   149         # reduce to the max
   150         self.setMinimumSize(600, 400)
   151         self.resize(lyMain.minimumSize())
   152