#!/usr/bin/env python
#-*- coding: utf-8 -*-

import sys
from PyQt4.Qt import *
from lineedit import LineEdit


class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.frame = QFrame(self)
        p = QPalette(self.palette())
        p.setColor(QPalette.Background, QColor(250,250,250))
        self.frame.setAutoFillBackground(True)
        self.frame.setPalette(p)
        self.setCentralWidget(self.frame)
        self.style_map = {}
        
        self.main_layout = QVBoxLayout()
        self.frame.setLayout(self.main_layout)
        
        self.input_layout = QHBoxLayout()
        pix1 = QPixmap("icons/ic_arrow_forward_black_24dp/web/ic_arrow_forward_black_24dp_1x.png")
        lab = QLabel()
        lab.setPixmap(pix1)
        self.input_file_lineedit = LineEdit()
        self.input_file_lineedit.setText("/home/rbianchi/log_0398.dat")
        self.input_layout.addWidget(lab)
        self.input_layout.addWidget(self.input_file_lineedit)
        self.main_layout.addLayout(self.input_layout)

        self.output_layout = QHBoxLayout()
        pix1 = QPixmap("icons/ic_arrow_back_black_24dp/web/ic_arrow_back_black_24dp_1x.png")
        lab = QLabel()
        lab.setPixmap(pix1)
        self.output_prefix_lineedit = LineEdit()
        self.output_prefix_lineedit.setText("/home/rbianchi/report")
        self.output_layout.addWidget(lab)
        self.output_layout.addWidget(self.output_prefix_lineedit)
        self.main_layout.addLayout(self.output_layout)

        
class App(QApplication):
    def __init__(self, *args):
        import os.path
        QApplication.__init__(self, *args)
        self.main = MainWindow()
        
        if os.path.exists("material.qss"):
            ss = open("material.qss","r")
            self.setStyleSheet(ss.read())
        
        W = 400
        H = 200
        self.main.setGeometry(W, H, W, H)
        self.main.show()
        self.connect( self, SIGNAL("lastWindowClosed()"), self.byebye )
    def byebye( self ):
        self.exit(0)

def main(args):
    global app
    app = App(args)
    app.exec_()

if __name__ == "__main__":
    main(sys.argv)
