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