Пример #1
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        pagelayout = QVBoxLayout()
        button_layout = QHBoxLayout()
        self.stacklayout = QStackedLayout()

        pagelayout.addLayout(button_layout)
        pagelayout.addLayout(self.stacklayout)

        btn = QPushButton("red")
        btn.pressed.connect(self.activate_tab_1)
        button_layout.addWidget(btn)
        self.stacklayout.addWidget(Color("red"))

        btn = QPushButton("green")
        btn.pressed.connect(self.activate_tab_2)
        button_layout.addWidget(btn)
        self.stacklayout.addWidget(Color("green"))

        btn = QPushButton("yellow")
        btn.pressed.connect(self.activate_tab_3)
        button_layout.addWidget(btn)
        self.stacklayout.addWidget(Color("yellow"))

        widget = QWidget()
        widget.setLayout(pagelayout)
        self.setCentralWidget(widget)
Пример #2
0
    def __init__(self, url=None):
        super(SongDetailPage, self).__init__()
        self.url = url
        self.loading = False
        self.artwork_content = None
        self.artwork_size = 400
        self.song = None

        self.layout = QStackedLayout()
        self.layout.setMargin(0)

        self.loading_label = QLabel('Loading...', alignment=Qt.AlignCenter)
        self.layout.addWidget(self.loading_label)
        self.layout.setCurrentWidget(self.loading_label)

        self.page_widget = QScrollArea()
        self.page_widget.setWidgetResizable(True)

        widget = QWidget(self.page_widget)
        widget.setMinimumWidth(800)
        self.page_widget.setWidget(widget)

        self.page_layout = QVBoxLayout(widget, alignment=Qt.AlignTop)
        self.page_layout.setContentsMargins(25, 25, 25, 25)

        self.layout.addWidget(self.page_widget)
        self.setLayout(self.layout)

        self.thread = RunThread(self.get_song_info, self.on_song_info)
Пример #3
0
    def __init__(self):
        super(Downloads, self).__init__()
        self.history = get_download_history()
        self.history.reverse()

        self.layout = QStackedLayout()
        self.layout.setMargin(0)

        self.page_widget = QScrollArea()
        self.page_widget.setWidgetResizable(True)

        widget = QWidget(self.page_widget)
        widget.setMinimumWidth(350)
        self.page_widget.setWidget(widget)

        self.page_layout = QVBoxLayout(widget, alignment=Qt.AlignTop)
        self.page_layout.setMargin(0)
        self.page_layout.setContentsMargins(25, 25, 25, 25)
        self.layout.addWidget(self.page_widget)
        self.layout.setCurrentWidget(self.page_widget)

        if len(self.history) == 0:
            self.history_empty_label = QLabel('No downloads',
                                              alignment=Qt.AlignCenter)
            self.layout.addWidget(self.history_empty_label)
            self.layout.setCurrentWidget(self.history_empty_label)

        for item in self.history:
            self.page_layout.addWidget(DownloadItem(item=item))

        self.setLayout(self.layout)
Пример #4
0
    def __init__(self):
        super(HomeFeed, self).__init__()
        self.run_get_feed_thread()

        self.feed = []
        self.page = 1
        self.loading = False

        self.layout = QStackedLayout()
        self.layout.setMargin(0)

        self.loading_label = QLabel('Loading...', alignment=Qt.AlignCenter)
        self.layout.addWidget(self.loading_label)
        self.layout.setCurrentWidget(self.loading_label)

        self.page_widget = QScrollArea()
        self.page_widget.setWidgetResizable(True)
        self.page_widget.viewport().installEventFilter(self)

        widget = QWidget(self.page_widget)
        widget.setMinimumWidth(350)
        self.page_widget.setWidget(widget)

        self.flow_layout = FlowLayout(widget)
        self.flow_layout.setContentsMargins(25, 25, 25, 25)

        self.layout.addWidget(self.page_widget)
        self.setLayout(self.layout)
Пример #5
0
    def __init__(self):
        super(Form, self).__init__()
        self.setWindowTitle("stacked layout ")

        self.wgtA = QWidget()
        self.wgtA_vl = QVBoxLayout()
        self.btnA = QPushButton("A")
        self.btnB = QPushButton("B")
        self.btnC = QPushButton("C")
        self.wgtA_vl.addWidget(self.btnA)
        self.wgtA_vl.addWidget(self.btnB)
        self.wgtA_vl.addWidget(self.btnC)
        self.wgtA.setLayout(self.wgtA_vl)

        self.wgt1 = QWidget()
        self.wgt1_vl = QVBoxLayout()
        self.btn1 = QPushButton("1")
        self.btn2 = QPushButton("2")
        self.btn3 = QPushButton("3")
        self.wgt1_vl.addWidget(self.btn1)
        self.wgt1_vl.addWidget(self.btn2)
        self.wgt1_vl.addWidget(self.btn3)
        self.wgt1.setLayout(self.wgt1_vl)

        self.wgtGA = QWidget()
        self.wgtGA_vl = QVBoxLayout()
        self.btnGA = QPushButton("가")
        self.btnNA = QPushButton("나")
        self.btnDA = QPushButton("다")
        self.wgtGA_vl.addWidget(self.btnGA)
        self.wgtGA_vl.addWidget(self.btnNA)
        self.wgtGA_vl.addWidget(self.btnDA)
        self.wgtGA.setLayout(self.wgtGA_vl)

        self.layout = QStackedLayout()
        self.layout.addWidget(self.wgtA)
        self.layout.addWidget(self.wgt1)
        self.layout.addWidget(self.wgtGA)
        self.setLayout(self.layout)

        self.btnA.clicked.connect(
            lambda s=None, i=0: self.set_stack_index(s, i))
        self.btnB.clicked.connect(
            lambda s=None, i=1: self.set_stack_index(s, i))
        self.btnC.clicked.connect(
            lambda s=None, i=2: self.set_stack_index(s, i))

        self.btn1.clicked.connect(
            lambda s=None, i=0: self.set_stack_index(s, i))
        self.btn2.clicked.connect(
            lambda s=None, i=1: self.set_stack_index(s, i))
        self.btn3.clicked.connect(
            lambda s=None, i=2: self.set_stack_index(s, i))

        self.btnGA.clicked.connect(
            lambda s=None, i=0: self.set_stack_index(s, i))
        self.btnNA.clicked.connect(
            lambda s=None, i=1: self.set_stack_index(s, i))
        self.btnDA.clicked.connect(
            lambda s=None, i=2: self.set_stack_index(s, i))
Пример #6
0
    def initUi(self):
        self.layout = QGridLayout()

        self.categoryList = QListView()
        self.right_layout = QStackedLayout()

        self.categoryList.setMaximumWidth(175)

        self.categoryModel = QStandardItemModel(self.categoryList)

        self.categoryList.setIconSize(QSize(32, 32))

        for name, page in self.pages.items():
            page_item = QStandardItem(name)
            if name in CONST.ICONS:
                page_item.setIcon(CONST.ICONS[name])
            else:
                page_item.setIcon(CONST.ICONS["Generator"])
            page_item.setEditable(False)
            page_item.setSelectable(True)
            self.categoryModel.appendRow(page_item)
            self.right_layout.addWidget(page)

        self.initCheatLayout()
        cheat = QStandardItem("Cheat Menu")
        cheat.setIcon(CONST.ICONS["Cheat"])
        cheat.setEditable(False)
        cheat.setSelectable(True)
        self.categoryModel.appendRow(cheat)
        self.right_layout.addWidget(self.cheatPage)

        self.pluginsPage = PluginsPage()
        plugins = QStandardItem("LUA Plugins")
        plugins.setIcon(CONST.ICONS["Plugins"])
        plugins.setEditable(False)
        plugins.setSelectable(True)
        self.categoryModel.appendRow(plugins)
        self.right_layout.addWidget(self.pluginsPage)

        self.pluginsOptionsPage = PluginOptionsPage()
        pluginsOptions = QStandardItem("LUA Plugins Options")
        pluginsOptions.setIcon(CONST.ICONS["PluginsOptions"])
        pluginsOptions.setEditable(False)
        pluginsOptions.setSelectable(True)
        self.categoryModel.appendRow(pluginsOptions)
        self.right_layout.addWidget(self.pluginsOptionsPage)

        self.categoryList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.categoryList.setModel(self.categoryModel)
        self.categoryList.selectionModel().setCurrentIndex(
            self.categoryList.indexAt(QPoint(1, 1)), QItemSelectionModel.Select
        )
        self.categoryList.selectionModel().selectionChanged.connect(
            self.onSelectionChanged
        )

        self.layout.addWidget(self.categoryList, 0, 0, 1, 1)
        self.layout.addLayout(self.right_layout, 0, 1, 5, 1)

        self.setLayout(self.layout)
Пример #7
0
 def __init__(self, parent=None):
     StyleWindow.__init__(self, parent)
     self.init_window_attr()
     self.setObjectName("MainWindow")
     self._title = Title()
     self.mouse_drag_enabled = True
     self._stacked_layout = QStackedLayout()
     self._init_view()
    def __init__(self):
        super().__init__()

        self.hm_page = HomePage()
        self.mn_window = MainWindow()
        self.widget_layout = QStackedLayout()

        self.buildLayout()
        self.connections()
Пример #9
0
    def setupProcessLayout(self):
        processGroup = QGroupBox('Processing settings')
        self.processLayout = QStackedLayout()
        self.mainLayout.addLayout(self.processLayout, 1, 0)

        # Setup Processing Sublayouts
        for op in self.operations:
            index = self.createGroup(self.operations[op][0], op,
                                     self.operations[op][1])
            self.operations[op][2] = index
Пример #10
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.parent = parent
        self.supported_setups = ['TOP-DOWN']
        self.stacked_layout = QStackedLayout()
        self.__setup_widget = None
        self.__metal_main_widget = None
        self.__init_main_widget__()
        self.stacked_layout.setCurrentIndex(0)

        self.setLayout(self.stacked_layout)
Пример #11
0
class MainWindow(StyleWindow):
    def __init__(self, parent=None):
        StyleWindow.__init__(self, parent)
        self.init_window_attr()
        self.setObjectName("MainWindow")
        self._title = Title()
        self.mouse_drag_enabled = True
        self._stacked_layout = QStackedLayout()
        self._init_view()

    def init_window_attr(self):
        """
        初始化window falg & window attributes
        """
        self.setWindowFlags(Qt.FramelessWindowHint
                            | Qt.WindowMinMaxButtonsHint)

    def init_title(self, layout: QBoxLayout):
        self._title.setObjectName("MainTitle")
        self._title.setFixedHeight(40)
        self._title.title_text = self.tr("DVideoEditTools")
        self._title.close.connect(self.close)
        self._title.show_minimized.connect(self.showMinimized)
        self._title.show_maximized.connect(self.show_max_normal)
        layout.addWidget(self._title)

    def _init_view(self):
        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        main_layout.setSpacing(0)
        self.set_layout(main_layout)
        self.init_title(main_layout)
        main_layout.addLayout(self._stacked_layout)

        self._stacked_layout.addWidget(HomePage())

        # main_layout.addStretch(0)

    def move_center(self):
        screen_rect = QDesktopWidget().availableGeometry()
        x = (screen_rect.right() - self.width()) / 2
        y = (screen_rect.bottom() - self.height()) / 2
        center_pos = QPoint(int(x), int(y))
        self.move(center_pos)

    def show_max_normal(self):
        if self.isMaximized():
            self.showNormal()
        else:
            self.showMaximized()
Пример #12
0
    def createIntervalStackedLayout(self):
        self.intervalStackedLayout = QStackedLayout()

        manual = self.createManualParamsSliders()
        percentile = self.createPercentileParamsSliders()
        asymetric = self.createAsymetricParamsSliders()
        zscale = self.createZscaleParamsSliders()
        self.intervalStackedLayout.addWidget(zscale)
        self.intervalStackedLayout.addWidget(QLabel(""))
        self.intervalStackedLayout.addWidget(manual)
        self.intervalStackedLayout.addWidget(percentile)
        self.intervalStackedLayout.addWidget(asymetric)

        return self.intervalStackedLayout
Пример #13
0
    def initUi(self):
        self.layout = QGridLayout()

        self.categoryList = QListView()
        self.right_layout = QStackedLayout()

        self.categoryList.setMaximumWidth(175)

        self.categoryModel = QStandardItemModel(self.categoryList)

        difficulty = QStandardItem("Difficulty")
        difficulty.setIcon(CONST.ICONS["Missile"])
        difficulty.setEditable(False)
        difficulty.setSelectable(True)

        generator = QStandardItem("Mission Generator")
        generator.setIcon(CONST.ICONS["Generator"])
        generator.setEditable(False)
        generator.setSelectable(True)

        cheat = QStandardItem("Cheat Menu")
        cheat.setIcon(CONST.ICONS["Cheat"])
        cheat.setEditable(False)
        cheat.setSelectable(True)

        self.categoryList.setIconSize(QSize(32, 32))
        self.categoryModel.appendRow(difficulty)
        self.categoryModel.appendRow(generator)
        self.categoryModel.appendRow(cheat)

        self.categoryList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.categoryList.setModel(self.categoryModel)
        self.categoryList.selectionModel().setCurrentIndex(
            self.categoryList.indexAt(QPoint(1, 1)),
            QItemSelectionModel.Select)
        self.categoryList.selectionModel().selectionChanged.connect(
            self.onSelectionChanged)

        self.initDifficultyLayout()
        self.initGeneratorLayout()
        self.initCheatLayout()

        self.right_layout.addWidget(self.difficultyPage)
        self.right_layout.addWidget(self.generatorPage)
        self.right_layout.addWidget(self.cheatPage)

        self.layout.addWidget(self.categoryList, 0, 0, 1, 1)
        self.layout.addLayout(self.right_layout, 0, 1, 5, 1)

        self.setLayout(self.layout)
Пример #14
0
 def __init__(self, *args, **kwargs):
     super(Sidebar, self).__init__(*args, **kwargs)
     self.settings_scroll_area = QScrollArea()
     self.settings_scroll_area.setWidgetResizable(True)
     self.navigation = ImagesNav(parent=self)
     self.log = QTextEdit()
     self.log.setReadOnly(True)
     self.tabs = QTabWidget()
     self.tabs.addTab(self.navigation, "Images list")
     self.tabs.addTab(self.log, "Application log")
     self.layout = QStackedLayout()
     self.layout.addWidget(self.settings_scroll_area)
     self.layout.addWidget(self.tabs)
     self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.MinimumExpanding)
     self.setLayout(self.layout)
     self.layout.setCurrentWidget(self.tabs)
    def __setup_ui(self):
        self.stacked_layout = QStackedLayout()

        self.main_menu_widget = MainMenuWidget(self)
        self.stacked_layout.addWidget(self.main_menu_widget)

        self.settings_widget = SettingsWidget(self)
        self.stacked_layout.addWidget(self.settings_widget)

        self.face_loading_widget = FaceLoadingWidget(self)
        self.stacked_layout.addWidget(self.face_loading_widget)

        self.face_authentication_widget = FaceAuthenticationWidget(self)
        self.stacked_layout.addWidget(self.face_authentication_widget)

        self.setLayout(self.stacked_layout)
Пример #16
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.parent = parent
     self.supported_setups = ['BOTTOM-UP', 'TOP-DOWN']
     self.supported_projectors = ['VisitechLRSWQ', 'VisitechLRS4KA']
     self.supported_motors = ['ClearpathSDSK', 'ClearpathSCSK', 'Nanostage']
     self.selected_setup = self.supported_setups[0]
     self.selected_projector = self.supported_projectors[0]
     self.selected_motor = self.supported_motors[0]
     self.stacked_layout = QStackedLayout()
     self.__setup_widget = None
     self.__dlp_main_widget = None
     if not self.__load_settings__():
         self.__init_configuration_selection_widget__()
         self.__init_projector_selection_widget__()
         self.__init_motor_selection_widget__()
         self.stacked_layout.setCurrentIndex(0)
     self.setLayout(self.stacked_layout)
Пример #17
0
    def __init__(self, app):
        QWidget.__init__(self)
        log.info('Creating MainWidget')

        # Configurar janela e sessão requests
        self.setWindowTitle('Desafio Upload')
        self.setWindowIcon(QIcon("icon.png"))
        self.session = requests.Session()

        # Configurar telas mostradas em StackedLayout
        self.stackedLayout = QStackedLayout()

        self.login_layout = LoginWidget(self.session)
        self.login_layout.did_login.connect(self.go_to_main_ui)
        self.setFixedSize(self.login_layout.size())

        self.main_layout = UploadViewWidget(self.session)

        self.stackedLayout.addWidget(self.login_layout)
        self.stackedLayout.addWidget(self.main_layout)

        self.setLayout(self.stackedLayout)

        # Inicializar variáveis relacionadas ao comportamento de system tray
        self.closeEvent = self.on_close
        self.system_tray = QSystemTrayIcon()
        self.system_tray.setContextMenu(QMenu('Hi!', self))

        # Tray menu
        self.tray = QSystemTrayIcon(QIcon("icon.png"), self)
        self.tray_menu = QMenu(self)

        action_show_window = QAction("Mostrar janela principal", self)
        action_show_window.triggered.connect(self.on_show_main_window)
        self.tray_menu.addAction(action_show_window)

        action_exit = QAction("Fechar", self)
        action_exit.triggered.connect(app.exit)
        self.tray_menu.addAction(action_exit)

        self.tray.setContextMenu(self.tray_menu)
        self.tray.activated.connect(self.on_tray_activated)
        self.tray.hide()
Пример #18
0
class ApplicationWindow(QWidget):
    def __init__(self):
        super().__init__()

        self.hm_page = HomePage()
        self.mn_window = MainWindow()
        self.widget_layout = QStackedLayout()

        self.buildLayout()
        self.connections()

        #self.setStyleSheet('background-color: white')
        #self.hm_page.setStyleSheet('background-color: #2e3843')

    def buildLayout(self):
        self.widget_layout = QStackedLayout()
        self.widget_layout.addWidget(self.hm_page)
        self.widget_layout.addWidget(self.mn_window)
        self.setLayout(self.widget_layout)

    def connections(self):
        self.hm_page.changePage.connect(
            lambda: self.widget_layout.setCurrentIndex(1))
        self.mn_window.changePage.connect(
            lambda: self.widget_layout.setCurrentIndex(0))
Пример #19
0
    def init_ui(self):
        self.setMinimumSize(600, 400)
        self.setWindowTitle('Sandy Screen')

        # Menu widget
        self.menu = SandyMenu(self)

        # Sandbox container widget and its background and canvas label stack
        self.sandbox = QWidget(self)
        self.sandbox.setGeometry(0, 0, 600, 400)
        self.sandbox_bg = QLabel(self.sandbox)
        self.sandbox_bg.setGeometry(0, 0, 600, 400)
        self.sandbox_bg.setPixmap(
            QPixmap(['1 1 1 1', '1 c #000000',
                     '1']).scaled(self.sandbox_bg.size()))
        self.canvases = [QLabel(self.sandbox), QLabel(self.sandbox)]
        for c in self.canvases:
            c.setAlignment(Qt.AlignCenter)
            c.setGeometry(0, 0, 600, 400)
        self.canvases[1].setPixmap(QPixmap(generate_xpm(self.sandpile)[0]))
        self.sandpile.topple_step()
        self.canvases[0].setPixmap(QPixmap(generate_xpm(self.sandpile)[0]))

        # Opacity effect on the upper frame label
        self.opeff = QGraphicsOpacityEffect(self.canvases[-1])
        self.opeff.setOpacity(1)
        self.canvases[-1].setGraphicsEffect(self.opeff)

        # Main stack layout
        self.layout = QStackedLayout(self)
        self.layout.addWidget(self.sandbox)
        self.layout.addWidget(self.menu)

        # Overlay pause icon label
        self.pause_label = QLabel(self)
        self.pause_label.setAlignment(Qt.AlignCenter)
        self.pause_label.setPixmap(QPixmap(ImageQt.ImageQt(self.pause_icon)))
Пример #20
0
    def createStretchStackedLayout(self):
        self.stretchStackedLayout = QStackedLayout()
        asinh = self.createAsinhParamsSliders()
        contrastbias = self.createContrastbiasParamsSliders()
        histogram = QLabel('')
        linear = QLabel('')
        log = self.createLogSliders()
        powerdist = self.createPowerdistSliders()
        power = self.createPowerSliders()
        sinh = self.createSinhSliders()
        sqrt = QLabel('')
        square = QLabel('')
        self.stretchStackedLayout.addWidget(powerdist)
        self.stretchStackedLayout.addWidget(asinh)
        self.stretchStackedLayout.addWidget(contrastbias)
        self.stretchStackedLayout.addWidget(histogram)
        self.stretchStackedLayout.addWidget(linear)
        self.stretchStackedLayout.addWidget(log)
        self.stretchStackedLayout.addWidget(power)
        self.stretchStackedLayout.addWidget(sinh)
        self.stretchStackedLayout.addWidget(sqrt)
        self.stretchStackedLayout.addWidget(square)

        return self.stretchStackedLayout
Пример #21
0
class ApplicationPaginationWidget(QWidget):
    def __init__(self, {name}):
        QWidget.__init__(self)
        self.{name} = {name}
        self.layout = QHBoxLayout()
        self.listLayout = QVBoxLayout()
        self.pageLayout = QStackedLayout()
        self.layout.addLayout(self.listLayout)
        self.layout.addLayout(self.pageLayout)
        self.setLayout(self.layout)

        self.pageList = QListWidget()
        self.pageList.itemSelectionChanged.connect(self.changePage)
        self.listLayout.addWidget(self.pageList)
        self.pages = []
        self.activePage = None
Пример #22
0
class Workspace:

    widget = QWidget()
    layout = QStackedLayout()
    previous = None

    @classmethod
    def build(cls):
        cls.widget.setLayout(cls.layout)
        cls.layout.addWidget(LogView.build())
        cls.layout.addWidget(AboutView.build())
        cls.layout.addWidget(SettingsView.build())
        cls.layout.addWidget(QuitView.build())
        cls.layout.addWidget(EditView.build())

        LogView.connect(on_edit=cls.set_mode_edit)
        EditView.connect(on_done=cls.edit_done)

        return cls.widget

    @classmethod
    def set_mode_timelog(cls):
        cls.layout.setCurrentIndex(0)
        LogView.refresh()

    @classmethod
    def set_mode_about(cls):
        cls.layout.setCurrentIndex(1)

    @classmethod
    def set_mode_settings(cls):
        cls.layout.setCurrentIndex(2)

    @classmethod
    def set_mode_quit(cls):
        cls.layout.setCurrentIndex(3)

    @classmethod
    def set_mode_edit(cls, entry):
        cls.layout.setCurrentIndex(4)
        EditView.load_item(entry)

    @classmethod
    def edit_done(cls):
        LogView.unselected()
        cls.set_mode_timelog()
Пример #23
0
    def setup_ui(self, proj_path=None):
        switch = QStackedLayout()

        get_proj = GetProject()
        manager_wig = ManagerWidget()

        switch.addWidget(get_proj)
        switch.addWidget(manager_wig)

        @get_proj.submit.connect
        def submit(proj, path):
            manager_wig.set_project(proj, path)
            switch.setCurrentWidget(manager_wig)

        @manager_wig.back.connect
        def back():
            switch.setCurrentWidget(get_proj)

        self.setLayout(switch)

        if proj_path:
            get_proj.try_open(proj_path)
Пример #24
0
class DynamicView(Widget):
    def __init__(self):
        super().__init__()
        self.__stacked_layout = QStackedLayout()
        self._layout.addLayout(self.__stacked_layout)

        self.__widgets = []

    def add_item(self, item: Widget):
        w = QWidget()
        w.setLayout(item.get_layout())
        self.__stacked_layout.addWidget(w)
        self.__widgets.append(w)

    def remove_item(self, idx: int):
        self.__stacked_layout.takeAt(idx)
        del self.__widgets[idx]

    def clear(self):
        for i in range(len(self.__widgets) - 1):
            self.remove_item(i)

    def set_index(self, idx: int):
        self.__stacked_layout.setCurrentIndex(idx)
Пример #25
0
class QSettingsWindow(QDialog):

    def __init__(self, game: Game):
        super(QSettingsWindow, self).__init__()

        self.game = game

        self.setModal(True)
        self.setWindowTitle("Settings")
        self.setWindowIcon(CONST.ICONS["Settings"])
        self.setMinimumSize(600, 250)

        self.initUi()

    def initUi(self):
        self.layout = QGridLayout()

        self.categoryList = QListView()
        self.right_layout = QStackedLayout()

        self.categoryList.setMaximumWidth(175)

        self.categoryModel = QStandardItemModel(self.categoryList)

        difficulty = QStandardItem("Difficulty")
        difficulty.setIcon(CONST.ICONS["Missile"])
        difficulty.setEditable(False)
        difficulty.setSelectable(True)

        generator = QStandardItem("Mission Generator")
        generator.setIcon(CONST.ICONS["Generator"])
        generator.setEditable(False)
        generator.setSelectable(True)

        cheat = QStandardItem("Cheat Menu")
        cheat.setIcon(CONST.ICONS["Cheat"])
        cheat.setEditable(False)
        cheat.setSelectable(True)

        self.categoryList.setIconSize(QSize(32, 32))
        self.categoryModel.appendRow(difficulty)
        self.categoryModel.appendRow(generator)
        self.categoryModel.appendRow(cheat)

        self.categoryList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.categoryList.setModel(self.categoryModel)
        self.categoryList.selectionModel().setCurrentIndex(self.categoryList.indexAt(QPoint(1,1)), QItemSelectionModel.Select)
        self.categoryList.selectionModel().selectionChanged.connect(self.onSelectionChanged)

        self.initDifficultyLayout()
        self.initGeneratorLayout()
        self.initCheatLayout()

        self.right_layout.addWidget(self.difficultyPage)
        self.right_layout.addWidget(self.generatorPage)
        self.right_layout.addWidget(self.cheatPage)

        self.layout.addWidget(self.categoryList, 0, 0, 1, 1)
        self.layout.addLayout(self.right_layout, 0, 1, 5, 1)

        self.setLayout(self.layout)

    def init(self):
        pass

    def initDifficultyLayout(self):

        self.difficultyPage = QWidget()
        self.difficultyLayout = QGridLayout()
        self.difficultyLayout.setAlignment(Qt.AlignTop)
        self.difficultyPage.setLayout(self.difficultyLayout)

        self.playerCoalitionSkill = QComboBox()
        self.enemyCoalitionSkill = QComboBox()
        self.enemyAASkill = QComboBox()
        for skill in CONST.SKILL_OPTIONS:
            self.playerCoalitionSkill.addItem(skill)
            self.enemyCoalitionSkill.addItem(skill)
            self.enemyAASkill.addItem(skill)

        self.playerCoalitionSkill.setCurrentIndex(CONST.SKILL_OPTIONS.index(self.game.settings.player_skill))
        self.enemyCoalitionSkill.setCurrentIndex(CONST.SKILL_OPTIONS.index(self.game.settings.enemy_skill))
        self.enemyAASkill.setCurrentIndex(CONST.SKILL_OPTIONS.index(self.game.settings.enemy_vehicle_skill))

        self.playerCoalitionSkill.currentIndexChanged.connect(self.applySettings)
        self.enemyCoalitionSkill.currentIndexChanged.connect(self.applySettings)
        self.enemyAASkill.currentIndexChanged.connect(self.applySettings)

        self.difficultyLayout.addWidget(QLabel("Player coalition skill"), 0, 0)
        self.difficultyLayout.addWidget(self.playerCoalitionSkill, 0, 1, Qt.AlignRight)
        self.difficultyLayout.addWidget(QLabel("Enemy skill"), 1, 0)
        self.difficultyLayout.addWidget(self.enemyCoalitionSkill, 1, 1, Qt.AlignRight)
        self.difficultyLayout.addWidget(QLabel("Enemy AA and vehicles skill"), 2, 0)
        self.difficultyLayout.addWidget(self.enemyAASkill, 2, 1, Qt.AlignRight)

        self.difficultyLabel = QComboBox()
        [self.difficultyLabel.addItem(t) for t in CONST.LABELS_OPTIONS]
        self.difficultyLabel.setCurrentIndex(CONST.LABELS_OPTIONS.index(self.game.settings.labels))
        self.difficultyLabel.currentIndexChanged.connect(self.applySettings)

        self.difficultyLayout.addWidget(QLabel("In Game Labels"), 3, 0)
        self.difficultyLayout.addWidget(self.difficultyLabel, 3, 1, Qt.AlignRight)

        self.noNightMission = QCheckBox()
        self.noNightMission.setChecked(self.game.settings.night_disabled)
        self.noNightMission.toggled.connect(self.applySettings)
        self.difficultyLayout.addWidget(QLabel("No night missions"), 4, 0)
        self.difficultyLayout.addWidget(self.noNightMission, 4, 1, Qt.AlignRight)

        self.mapVisibiitySelection = QComboBox()
        self.mapVisibiitySelection.addItem("All", ForcedOptions.Views.All)
        if self.game.settings.map_coalition_visibility == ForcedOptions.Views.All:
            self.mapVisibiitySelection.setCurrentIndex(0)
        self.mapVisibiitySelection.addItem("Fog of War", ForcedOptions.Views.Allies)
        if self.game.settings.map_coalition_visibility == ForcedOptions.Views.Allies:
            self.mapVisibiitySelection.setCurrentIndex(1)
        self.mapVisibiitySelection.addItem("Allies Only", ForcedOptions.Views.OnlyAllies)
        if self.game.settings.map_coalition_visibility == ForcedOptions.Views.OnlyAllies:
            self.mapVisibiitySelection.setCurrentIndex(2)
        self.mapVisibiitySelection.addItem("Own Aircraft Only", ForcedOptions.Views.MyAircraft)
        if self.game.settings.map_coalition_visibility == ForcedOptions.Views.MyAircraft:
            self.mapVisibiitySelection.setCurrentIndex(3)
        self.mapVisibiitySelection.addItem("Map Only", ForcedOptions.Views.OnlyMap)
        if self.game.settings.map_coalition_visibility == ForcedOptions.Views.OnlyMap:
            self.mapVisibiitySelection.setCurrentIndex(4)
        self.mapVisibiitySelection.currentIndexChanged.connect(self.applySettings)
        self.difficultyLayout.addWidget(QLabel("Map visibility options"), 5, 0)
        self.difficultyLayout.addWidget(self.mapVisibiitySelection, 5, 1, Qt.AlignRight)

        self.ext_views = QCheckBox()
        self.ext_views.setChecked(self.game.settings.external_views_allowed)
        self.ext_views.toggled.connect(self.applySettings)
        self.difficultyLayout.addWidget(QLabel("Allow external views"), 6, 0)
        self.difficultyLayout.addWidget(self.ext_views, 6, 1, Qt.AlignRight)


    def initGeneratorLayout(self):
        self.generatorPage = QWidget()
        self.generatorLayout = QVBoxLayout()
        self.generatorLayout.setAlignment(Qt.AlignTop)
        self.generatorPage.setLayout(self.generatorLayout)

        self.gameplay = QGroupBox("Gameplay")
        self.gameplayLayout = QGridLayout();
        self.gameplayLayout.setAlignment(Qt.AlignTop)
        self.gameplay.setLayout(self.gameplayLayout)

        self.supercarrier = QCheckBox()
        self.supercarrier.setChecked(self.game.settings.supercarrier)
        self.supercarrier.toggled.connect(self.applySettings)

        self.generate_marks = QCheckBox()
        self.generate_marks.setChecked(self.game.settings.generate_marks)
        self.generate_marks.toggled.connect(self.applySettings)


        if not hasattr(self.game.settings, "include_jtac_if_available"):
            self.game.settings.include_jtac_if_available = True

        self.include_jtac_if_available = QCheckBox()
        self.include_jtac_if_available.setChecked(self.game.settings.include_jtac_if_available)
        self.include_jtac_if_available.toggled.connect(self.applySettings)

        self.gameplayLayout.addWidget(QLabel("Use Supercarrier Module"), 0, 0)
        self.gameplayLayout.addWidget(self.supercarrier, 0, 1, Qt.AlignRight)
        self.gameplayLayout.addWidget(QLabel("Put Objective Markers on Map"), 1, 0)
        self.gameplayLayout.addWidget(self.generate_marks, 1, 1, Qt.AlignRight)
        self.gameplayLayout.addWidget(QLabel("Include JTAC (If available)"), 2, 0)
        self.gameplayLayout.addWidget(self.include_jtac_if_available, 2, 1, Qt.AlignRight)

        self.performance = QGroupBox("Performance")
        self.performanceLayout = QGridLayout()
        self.performanceLayout.setAlignment(Qt.AlignTop)
        self.performance.setLayout(self.performanceLayout)

        self.smoke = QCheckBox()
        self.smoke.setChecked(self.game.settings.perf_smoke_gen)
        self.smoke.toggled.connect(self.applySettings)

        self.red_alert = QCheckBox()
        self.red_alert.setChecked(self.game.settings.perf_red_alert_state)
        self.red_alert.toggled.connect(self.applySettings)

        self.arti = QCheckBox()
        self.arti.setChecked(self.game.settings.perf_artillery)
        self.arti.toggled.connect(self.applySettings)

        self.moving_units = QCheckBox()
        self.moving_units.setChecked(self.game.settings.perf_moving_units)
        self.moving_units.toggled.connect(self.applySettings)

        self.infantry = QCheckBox()
        self.infantry.setChecked(self.game.settings.perf_infantry)
        self.infantry.toggled.connect(self.applySettings)

        self.ai_parking_start = QCheckBox()
        self.ai_parking_start.setChecked(self.game.settings.perf_ai_parking_start)
        self.ai_parking_start.toggled.connect(self.applySettings)

        self.destroyed_units = QCheckBox()
        self.destroyed_units.setChecked(self.game.settings.perf_destroyed_units)
        self.destroyed_units.toggled.connect(self.applySettings)

        self.culling = QCheckBox()
        self.culling.setChecked(self.game.settings.perf_culling)
        self.culling.toggled.connect(self.applySettings)

        self.culling_distance = QSpinBox()
        self.culling_distance.setMinimum(50)
        self.culling_distance.setMaximum(10000)
        self.culling_distance.setValue(self.game.settings.perf_culling_distance)
        self.culling_distance.valueChanged.connect(self.applySettings)

        self.performanceLayout.addWidget(QLabel("Smoke visual effect on frontline"), 0, 0)
        self.performanceLayout.addWidget(self.smoke, 0, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("SAM starts in RED alert mode"), 1, 0)
        self.performanceLayout.addWidget(self.red_alert, 1, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("Artillery strikes"), 2, 0)
        self.performanceLayout.addWidget(self.arti, 2, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("Moving ground units"), 3, 0)
        self.performanceLayout.addWidget(self.moving_units, 3, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("Generate infantry squads along vehicles"), 4, 0)
        self.performanceLayout.addWidget(self.infantry, 4, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("AI planes parking start (AI starts in flight if disabled)"), 5, 0)
        self.performanceLayout.addWidget(self.ai_parking_start, 5, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("Include destroyed units carcass"), 6, 0)
        self.performanceLayout.addWidget(self.destroyed_units, 6, 1, alignment=Qt.AlignRight)

        self.performanceLayout.addWidget(QHorizontalSeparationLine(), 7, 0, 1, 2)
        self.performanceLayout.addWidget(QLabel("Culling of distant units enabled"), 8, 0)
        self.performanceLayout.addWidget(self.culling, 8, 1, alignment=Qt.AlignRight)
        self.performanceLayout.addWidget(QLabel("Culling distance (km)"), 9, 0)
        self.performanceLayout.addWidget(self.culling_distance, 9, 1, alignment=Qt.AlignRight)

        self.generatorLayout.addWidget(self.gameplay)
        self.generatorLayout.addWidget(QLabel("Disabling settings below may improve performance, but will impact the overall quality of the experience."))
        self.generatorLayout.addWidget(self.performance)


    def initCheatLayout(self):

        self.cheatPage = QWidget()
        self.cheatLayout = QGridLayout()
        self.cheatPage.setLayout(self.cheatLayout)

        self.moneyCheatBox = QGroupBox("Money Cheat")
        self.moneyCheatBox.setAlignment(Qt.AlignTop)
        self.moneyCheatBoxLayout = QGridLayout()
        self.moneyCheatBox.setLayout(self.moneyCheatBoxLayout)

        self.cheat25M = QPushButton("Cheat +25M")
        self.cheat50M = QPushButton("Cheat +50M")
        self.cheat100M = QPushButton("Cheat +100M")
        self.cheat200M = QPushButton("Cheat +200M")
        self.cheat500M = QPushButton("Cheat +500M")
        self.cheat1000M = QPushButton("Cheat +1000M")

        self.cheat25M.clicked.connect(lambda: self.cheatMoney(25))
        self.cheat50M.clicked.connect(lambda: self.cheatMoney(50))
        self.cheat100M.clicked.connect(lambda: self.cheatMoney(100))
        self.cheat200M.clicked.connect(lambda: self.cheatMoney(200))
        self.cheat500M.clicked.connect(lambda: self.cheatMoney(500))
        self.cheat1000M.clicked.connect(lambda: self.cheatMoney(1000))

        self.moneyCheatBoxLayout.addWidget(self.cheat25M, 0, 0)
        self.moneyCheatBoxLayout.addWidget(self.cheat50M, 0, 1)
        self.moneyCheatBoxLayout.addWidget(self.cheat100M, 1, 0)
        self.moneyCheatBoxLayout.addWidget(self.cheat200M, 1, 1)
        self.moneyCheatBoxLayout.addWidget(self.cheat500M, 2, 0)
        self.moneyCheatBoxLayout.addWidget(self.cheat1000M, 2, 1)

        self.cheatLayout.addWidget(self.moneyCheatBox, 0, 0)

    def cheatMoney(self, amount):
        self.game.budget += amount
        self.game.informations.append(Information("CHEATER", "You are a cheater and you should feel bad", self.game.turn))
        GameUpdateSignal.get_instance().updateGame(self.game)

    def applySettings(self):
        self.game.settings.player_skill = CONST.SKILL_OPTIONS[self.playerCoalitionSkill.currentIndex()]
        self.game.settings.enemy_skill = CONST.SKILL_OPTIONS[self.enemyCoalitionSkill.currentIndex()]
        self.game.settings.enemy_vehicle_skill = CONST.SKILL_OPTIONS[self.enemyAASkill.currentIndex()]
        self.game.settings.labels = CONST.LABELS_OPTIONS[self.difficultyLabel.currentIndex()]
        self.game.settings.night_disabled = self.noNightMission.isChecked()
        self.game.settings.map_coalition_visibility = self.mapVisibiitySelection.currentData()
        self.game.settings.external_views_allowed = self.ext_views.isChecked()
        self.game.settings.generate_marks = self.generate_marks.isChecked()
        self.game.settings.include_jtac_if_available = self.include_jtac_if_available.isChecked()

        print(self.game.settings.map_coalition_visibility)

        self.game.settings.supercarrier = self.supercarrier.isChecked()

        self.game.settings.perf_red_alert_state = self.red_alert.isChecked()
        self.game.settings.perf_smoke_gen = self.smoke.isChecked()
        self.game.settings.perf_artillery = self.arti.isChecked()
        self.game.settings.perf_moving_units = self.moving_units.isChecked()
        self.game.settings.perf_infantry = self.infantry.isChecked()
        self.game.settings.perf_ai_parking_start = self.ai_parking_start.isChecked()
        self.game.settings.perf_destroyed_units = self.destroyed_units.isChecked()

        self.game.settings.perf_culling = self.culling.isChecked()
        self.game.settings.perf_culling_distance = int(self.culling_distance.value())

        GameUpdateSignal.get_instance().updateGame(self.game)

    def onSelectionChanged(self):
        index = self.categoryList.selectionModel().currentIndex().row()
        self.right_layout.setCurrentIndex(index)
Пример #26
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle("Stacked Layout")

        layout = QStackedLayout()
        layout.addWidget(Color("red"))
        layout.addWidget(Color("green"))
        layout.addWidget(Color("blue"))
        layout.addWidget(Color("yellow"))

        layout.setCurrentIndex(2)

        widget = QWidget()
        widget.setLayout(layout)

        self.setCentralWidget(widget)
Пример #27
0
    def buildLayout(self):
        stacked_layout_1 = QStackedLayout()
        # stacked_layout_1.addWidget(QWidget())
        stacked_layout_1.addWidget(self.p_top_bar)
        stacked_layout_1.addWidget(self.s_top_bar)

        stacked_layout_2 = QStackedLayout()
        # stacked_layout_2.addWidget(QWidget())
        stacked_layout_2.addWidget(self.p_options_1)
        stacked_layout_2.addWidget(self.p_options_2)
        stacked_layout_2.addWidget(self.p_options_3)
        stacked_layout_2.addWidget(self.p_options_4)
        stacked_layout_2.addWidget(self.p_options_5)
        stacked_layout_2.addWidget(self.p_options_6)
        stacked_layout_2.addWidget(self.s_options_1)
        stacked_layout_2.addWidget(self.s_options_2)
        stacked_layout_2.addWidget(self.s_options_3)
        stacked_layout_2.addWidget(self.s_options_4)

        self.stacked_layout_3 = QStackedLayout()
        self.stacked_layout_3.addWidget(self.scroll_area_1)
        self.stacked_layout_3.addWidget(self.scroll_area_2)

        central_widget_layout = QVBoxLayout()
        central_widget_layout.addWidget(self.bar_widget)
        central_widget_layout.addLayout(self.stacked_layout_3)

        self.central_widget.setLayout(central_widget_layout)
        self.bar_widget.setLayout(stacked_layout_1)
        self.options_widget.setLayout(stacked_layout_2)
Пример #28
0
class MainWindow(QMainWindow):
    changePage = Signal(bool)

    def __init__(self):
        super().__init__()
        self.setWindowTitle('Petro-Explorer v1.0')
        win_icon = QIcon('icons/Logo.ico')
        self.setWindowIcon(win_icon)
        self.setStyleSheet('background-color: #363f49;')

        self.header = Header()
        self.navigation = Navigation()
        self.p_top_bar = PetrophysicsTopBar()
        self.s_top_bar = StatisticsTopBar()
        self.p_options_1 = PetrophysicsOptions(_mode='KCarman')
        self.p_options_2 = PetrophysicsOptions(_mode='TCoates')
        self.p_options_3 = PetrophysicsOptions(_mode='Winland')
        self.p_options_4 = PetrophysicsOptions(_mode='RQIFZI')
        self.p_options_5 = PetrophysicsOptions(_mode='Lucia')
        self.p_options_6 = PetrophysicsOptions(_mode='DParsons')
        self.s_options_1 = StatisticsOptions(_mode='Regression')
        self.s_options_2 = StatisticsOptions(_mode='Statistics')
        self.s_options_3 = StatisticsOptions(_mode='Histogram')
        self.s_options_4 = StatisticsOptions(_mode='Boxplot')
        self.sp_controls = SpreadsheetControls()
        self.plot_controls = PlotControls()
        self.plot_viewer = PlotViewer()
        self.spreadsheet = Spreadsheet()
        self.status_bar = QStatusBar()

        self.scroll_area_1 = QScrollArea()
        self.scroll_area_1.setWidget(self.spreadsheet)
        self.scroll_area_1.setWidgetResizable(True)

        self.scroll_area_2 = QScrollArea()
        self.scroll_area_2.setWidget(self.plot_viewer)
        self.scroll_area_2.setWidgetResizable(True)

        self.bar_widget = QWidget()
        self.bar_widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)

        self.central_widget = QWidget()
        self.options_widget = QWidget()

        self.docking_options = QDockWidget()
        self.docking_options.setWidget(self.options_widget)
        self.docking_options.setTitleBarWidget(
            DockWidgetRibbon(' Opções de cálculo'))

        self.docking_options2 = QDockWidget()
        self.docking_options2.setWidget(self.sp_controls)
        self.docking_options2.setTitleBarWidget(
            DockWidgetRibbon(' Controles de visualização'))

        self.setCentralWidget(self.central_widget)
        self.setStatusBar(self.status_bar)
        self.addToolBar(self.navigation)
        self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea,
                           self.docking_options)
        self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea,
                           self.docking_options2)
        self.connections()
        self.buildLayout()

        self.centralWidget().setStyleSheet('background-color: #2e3843')
        self.spreadsheet.setStyleSheet('background-color: white')
        self.status_bar.setStyleSheet('color: white')

    def buildLayout(self):
        stacked_layout_1 = QStackedLayout()
        # stacked_layout_1.addWidget(QWidget())
        stacked_layout_1.addWidget(self.p_top_bar)
        stacked_layout_1.addWidget(self.s_top_bar)

        stacked_layout_2 = QStackedLayout()
        # stacked_layout_2.addWidget(QWidget())
        stacked_layout_2.addWidget(self.p_options_1)
        stacked_layout_2.addWidget(self.p_options_2)
        stacked_layout_2.addWidget(self.p_options_3)
        stacked_layout_2.addWidget(self.p_options_4)
        stacked_layout_2.addWidget(self.p_options_5)
        stacked_layout_2.addWidget(self.p_options_6)
        stacked_layout_2.addWidget(self.s_options_1)
        stacked_layout_2.addWidget(self.s_options_2)
        stacked_layout_2.addWidget(self.s_options_3)
        stacked_layout_2.addWidget(self.s_options_4)

        self.stacked_layout_3 = QStackedLayout()
        self.stacked_layout_3.addWidget(self.scroll_area_1)
        self.stacked_layout_3.addWidget(self.scroll_area_2)

        central_widget_layout = QVBoxLayout()
        central_widget_layout.addWidget(self.bar_widget)
        central_widget_layout.addLayout(self.stacked_layout_3)

        self.central_widget.setLayout(central_widget_layout)
        self.bar_widget.setLayout(stacked_layout_1)
        self.options_widget.setLayout(stacked_layout_2)

    def connections(self):
        self.navigation.PetroAnalysis.connect(
            lambda: self.bar_widget.layout().setCurrentIndex(0))
        self.navigation.StatsAnalysis.connect(
            lambda: self.bar_widget.layout().setCurrentIndex(1))
        self.navigation.Save.connect(lambda: self.saveDialog())
        self.navigation.Import.connect(lambda: self.importDialog())
        self.navigation.About.connect(lambda: self.aboutDialog())
        self.navigation.Help.connect(lambda: self.helpDialog())
        self.navigation.header.HomePage.connect(
            lambda: self.changePage.emit(True))
        self.navigation.ViewSheet.connect(lambda: self.displaySheet())
        self.navigation.ViewPlot.connect(lambda: self.displayPltE())
        self.navigation.New.connect(lambda: self.spreadsheet.addBlankSheet())

        self.p_top_bar.KCarman.connect(
            lambda: self.options_widget.layout().setCurrentIndex(0))
        self.p_top_bar.TCoates.connect(
            lambda: self.options_widget.layout().setCurrentIndex(1))
        self.p_top_bar.Winland.connect(
            lambda: self.options_widget.layout().setCurrentIndex(2))
        self.p_top_bar.DParsons.connect(
            lambda: self.options_widget.layout().setCurrentIndex(5))
        self.p_top_bar.Lucia.connect(
            lambda: self.options_widget.layout().setCurrentIndex(4))
        self.p_top_bar.RF.connect(
            lambda: self.options_widget.layout().setCurrentIndex(3))

        self.s_top_bar.Regr.connect(
            lambda: self.options_widget.layout().setCurrentIndex(6))
        self.s_top_bar.StatDesc.connect(
            lambda: self.options_widget.layout().setCurrentIndex(7))
        self.s_top_bar.Boxplt.connect(
            lambda: self.options_widget.layout().setCurrentIndex(9))
        self.s_top_bar.Hist.connect(
            lambda: self.options_widget.layout().setCurrentIndex(8))

        self.s_options_1.run_button.clicked.connect(self.startRegr)
        self.s_options_2.run_button.clicked.connect(self.startStat)
        self.s_options_3.run_button.clicked.connect(self.startHist)
        self.s_options_4.run_button.clicked.connect(self.startBxpl)

        self.p_options_1.run.clicked.connect(self.startKCoz)
        self.p_options_2.run.clicked.connect(self.startTCoa)
        self.p_options_3.run.clicked.connect(self.startWinl)
        self.p_options_4.run.clicked.connect(self.startFZIR)
        self.p_options_5.run.clicked.connect(self.startLuci)
        self.p_options_6.run.clicked.connect(self.startDyks)

        self.sp_controls.AddColumn.connect(
            lambda: self.spreadsheet.addColumn())
        self.sp_controls.AddRow.connect(lambda: self.spreadsheet.addRow())
        self.sp_controls.DeleteRow.connect(
            lambda: self.spreadsheet.deleteRow())
        self.sp_controls.DeleteColumn.connect(
            lambda: self.spreadsheet.deleteColumn())

        self.plot_controls.run_button.clicked.connect(lambda: self.startPltE())
        self.plot_controls.erasePlot.connect(
            lambda: self.plot_viewer.erasePlot())

        self.plot_viewer.feedPlotControls.connect(
            self.plot_controls.fillFromJson)

    def startPltE(self):
        old_json = self.plot_viewer.json_data
        title = self.plot_controls.modify_title.text()
        xtype = self.plot_controls.modify_x_axis_type.currentText()
        ytype = self.plot_controls.modify_y_axis_type.currentText()
        xlabel = self.plot_controls.modify_x_axis_label.text()
        ylabel = self.plot_controls.modify_y_axis_label.text()

        if len(self.plot_controls.modify_lower_x_range.text()) > 0:
            lxrange = float(self.plot_controls.modify_lower_x_range.text())
        else:
            lxrange = None
        if len(self.plot_controls.modify_upper_x_range.text()) > 0:
            uxrange = float(self.plot_controls.modify_upper_x_range.text())
        else:
            uxrange = None
        if len(self.plot_controls.modify_lower_y_range.text()) > 0:
            lyrange = float(self.plot_controls.modify_lower_y_range.text())
        else:
            lyrange = None
        if len(self.plot_controls.modify_upper_y_range.text()) > 0:
            uyrange = float(self.plot_controls.modify_upper_y_range.text())
        else:
            uyrange = None

        if len(self.plot_controls.add_x_trace.text()) > 0 and len(
                self.plot_controls.add_y_trace.text()):
            trace_type = self.plot_controls.type_of_trace.currentText()
            x_trace = self.spreadsheet.model.input_data[:,
                                                        self.spreadsheet.model.
                                                        header_info.index(
                                                            self.plot_controls.
                                                            add_x_trace.text(
                                                            ))]
            y_trace = self.spreadsheet.model.input_data[:,
                                                        self.spreadsheet.model.
                                                        header_info.index(
                                                            self.plot_controls.
                                                            add_y_trace.text(
                                                            ))]
            trace_name = self.plot_controls.trace_name.text()
        else:
            trace_type = None
            x_trace = None
            y_trace = None
            trace_name = None

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.loadPltE(io_operations_handler.results))
        io_operations_handler.loadParameters(f=pceManifold,
                                             _args=[
                                                 old_json, title, xtype, ytype,
                                                 xlabel, ylabel, lxrange,
                                                 uxrange, lyrange, uyrange,
                                                 trace_type, x_trace, y_trace,
                                                 trace_name
                                             ])
        io_operations_handler.start()

    def loadPltE(self, results, typ='Regressão'):
        self.plot_viewer.loadPlot(results[0], results[1], _type=typ)
        self.displayPltE()

    def displayPltE(self):
        self.stacked_layout_3.setCurrentIndex(1)
        self.docking_options2.setWidget(self.plot_controls)
        #self.removeDockWidget(self.docking_options3)
        #self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options2)

    def loadSheet(self, df):
        self.spreadsheet.changeModel(data=df, header=list(df.keys()))
        self.displaySheet()

    def displaySheet(self):
        self.stacked_layout_3.setCurrentIndex(0)
        self.docking_options2.setWidget(self.sp_controls)
        self.status_bar.clearMessage()
        #self.removeDockWidget(self.docking_options2)
        #self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options3)

    def importDialog(self):
        func = None
        file_settings = QFileDialog().getOpenFileName(
            self,
            'Importar Arquivo',
            filter=
            "Todos os arquivos (*);; Arquivo de Texto (*.txt);; Arquivo CSV (*.csv);; "
            "Planilha Excel (*.xlsx)")
        if ".txt" in file_settings[0]:
            func = Data.readTXT
        if ".csv" in file_settings[0]:
            func = Data.readCSV
        if ".xlsx" in file_settings[0]:
            func = Data.readExcel

        self.status_bar.showMessage('Importando arquivo. Aguarde.')
        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.loadSheet(io_operations_handler.results))
        io_operations_handler.loadParameters(f=func,
                                             _args=[
                                                 file_settings[0],
                                             ])
        io_operations_handler.start()

    def saveDialog(self):
        func = None
        file_settings = QFileDialog().getSaveFileName(
            self,
            "Salvar Arquivo",
            filter="Arquivo de Texto (*.txt);; Arquivo CSV (*.csv);; "
            "Planilha Excel (*.xlsx)")
        if ".txt" in file_settings[0]:
            func = Data.toTXT
        if ".csv" in file_settings[0]:
            func = Data.toCSV
        if ".xlsx" in file_settings[0]:
            func = Data.toExcel

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.loadParameters(
            f=func, _args=[self.spreadsheet.retrieveModel(), file_settings[0]])
        io_operations_handler.start()

    def aboutDialog(self):
        icon = QIcon(r'icons/sobre.png')
        text = "O Petro-Explorer é um software desenvolvido no Laboratório de Exploração e Produção de Petróleo (" \
               "LENEP) da UENF para análises petrofísicas e estatísticas de dados de rocha. "
        msg = QMessageBox()
        msg.setWindowTitle('Sobre Petro-Explorer')
        msg.setWindowIcon(icon)
        msg.setText(text)
        msg.exec_()

    def helpDialog(self):
        icon = QIcon(r'icons/ajuda.png')
        text = r"Para utilizar o Petro-Explorer de maneira correta siga os seguintes passos:" \
               "\n1 - Clique no botão Novo na barra de navegação, isto irá limpar quaisquer dados de antigas análises.\n" \
               "2 - Para começar a sua análise é preciso importar os dados, assim, clique no botão Importar para escolher o seu arquivo. Atente para o fato que somente três tipos de arquivo são suportados (i.e. *.txt, *.csv, *.xlsx). Depois da sua escolha, os dados devem aparecer na planilha do software.\n" \
               "3 - Se você desejar realizar uma análise petrofísica, clique no botão de Análise Petrofísica na barra de navegação. Caso queira realizar uma análise estatística, clique no botão de Análise Estatística na barra de navegação.\n" \
               "4 - Selecione na barra superior à planilha, a análise que desejas realizar sobre seus dados.\n" \
               "5 - No canto direito da janela, selecione os parâmetros de sua análise assim como o destino de seus resultados. Clique no botão 'Começar Análise' para continuar.\n" \
               "6 - Analise seus resultados na planilha, e, quando disponível, no gráfico também.\n" \
               "7 - Quando terminar, clique no botão Salvar para salvar os resultados de suas análises no disco.\n" \
               "8 - Caso queira realizar outra análise, clique no botão \"Novo\" e comece novamente.\n"
        msg = QMessageBox()
        msg.setWindowTitle('Ajuda')
        msg.setWindowIcon(icon)
        msg.setText(text)
        msg.exec_()

    def startRegr(self):
        xdata = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.s_options_1.
                                                        payload['x_column'])]
        ydata = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.s_options_1.
                                                        payload['y_column'])]
        _type = self.s_options_1.payload['calculate']
        dgr = self.s_options_1.degree.value()

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayRegr(self.s_options_1.payload['output_column'],
                                     io_operations_handler.results))
        io_operations_handler.loadParameters(f=regressionManifold,
                                             _args=[xdata, ydata, dgr, _type])
        io_operations_handler.start()

    def startStat(self):
        xdata = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.s_options_2.
                                                        payload['x_column'])]
        mthd = self.s_options_2.payload['calculate']
        qtl = self.s_options_2.quartile.value()
        pctl = self.s_options_2.percentile.value()

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayStat(self.s_options_2.payload['output_column'],
                                     io_operations_handler.results))
        io_operations_handler.loadParameters(f=statisticsManifold,
                                             _args=[xdata, mthd, qtl, pctl])
        io_operations_handler.start()

    def startHist(self):
        xdata = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.s_options_3.
                                                        payload['x_column'])]
        nbins = self.s_options_3.payload['y_column']

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayHist(io_operations_handler.results))
        io_operations_handler.loadParameters(f=histogramManifold,
                                             _args=[xdata, nbins])
        io_operations_handler.start()

    def startBxpl(self):
        indexes = []
        columns = self.s_options_4.payload['column_range']
        for col in columns:
            indexes.append(self.spreadsheet.model.header_info.index(col))
        xdata = self.spreadsheet.model.input_data[:, indexes]
        box_orientation = self.s_options_4.payload['y_column']

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayBxpl(io_operations_handler.results))
        io_operations_handler.loadParameters(f=boxplotManifold,
                                             _args=[xdata, box_orientation])
        io_operations_handler.start()

    def startKCoz(self):
        #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr

        k = None
        phi = None
        svgr = None

        prp = self.p_options_1.payload['calculate']

        if prp == 'Permeabilidade (mD)':
            phi = self.spreadsheet.model.input_data[:,
                                                    self.spreadsheet.model.
                                                    header_info.
                                                    index(self.p_options_1.
                                                          payload['x_column'])]
            svgr = self.spreadsheet.model.input_data[:,
                                                     self.spreadsheet.model.
                                                     header_info.index(
                                                         self.p_options_1.
                                                         payload['y_column'])]
        elif prp == 'SVgr (cm-1)':
            k = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.p_options_1.
                                                        payload['x_column'])]
            phi = self.spreadsheet.model.input_data[:,
                                                    self.spreadsheet.model.
                                                    header_info.
                                                    index(self.p_options_1.
                                                          payload['y_column'])]
        else:
            k = self.spreadsheet.model.input_data[:,
                                                  self.spreadsheet.model.
                                                  header_info.
                                                  index(self.p_options_1.
                                                        payload['x_column'])]
            phi = self.spreadsheet.model.input_data[:,
                                                    self.spreadsheet.model.
                                                    header_info.
                                                    index(self.p_options_1.
                                                          payload['y_column'])]

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayKCoz(io_operations_handler.results))
        io_operations_handler.loadParameters(f=kCarmanManifold,
                                             _args=[k, phi, svgr, prp])
        io_operations_handler.start()

    def startTCoa(self):
        #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr
        prp = self.p_options_2.payload['calculate']

        if prp == "Swir (%)":
            xdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_2.
                                                          payload['x_column'])]
            ydata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_2.
                                                          payload['y_column'])]
            zdata = None
        else:
            xdata = None
            ydata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_2.
                                                          payload['y_column'])]
            zdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_2.
                                                          payload['x_column'])]

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayTCoa(io_operations_handler.results))
        io_operations_handler.loadParameters(f=tCoatesManifold,
                                             _args=[xdata, ydata, zdata, prp])
        io_operations_handler.start()

    def startWinl(self):
        #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr
        if self.p_options_3.payload['x_column'] != '':
            xdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_3.
                                                          payload['x_column'])]
        else:
            xdata = []
        if self.p_options_3.payload['y_column'] != '':
            ydata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_3.
                                                          payload['y_column'])]
        else:
            ydata = []

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayWinl(io_operations_handler.results))
        io_operations_handler.loadParameters(f=winlandManifold,
                                             _args=[xdata, ydata])
        io_operations_handler.start()

    def startFZIR(self):
        # you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr
        if self.p_options_4.payload['x_column'] != '':
            xdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_4.
                                                          payload['x_column'])]
        else:
            xdata = None
        if self.p_options_4.payload['y_column'] != '':
            ydata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_4.
                                                          payload['y_column'])]
        else:
            ydata = None
        if self.p_options_4.payload['z_column'] != '':
            zdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_4.
                                                          payload['z_column'])]
        else:
            zdata = None

        prp = self.p_options_4.payload['calculate']
        un = self.p_options_4.payload['column_range']

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayFZIR(io_operations_handler.results))
        io_operations_handler.loadParameters(
            f=fzManifold, _args=[xdata, ydata, zdata, un, prp])
        io_operations_handler.start()

    def startLuci(self):
        #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr
        if self.p_options_5.payload['x_column'] != '':
            xdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_5.
                                                          payload['x_column'])]
        else:
            xdata = []
        if self.p_options_5.payload['y_column'] != '':
            ydata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_5.
                                                          payload['y_column'])]
        else:
            ydata = []

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayLuci(io_operations_handler.results))
        io_operations_handler.loadParameters(f=luciaManifold,
                                             _args=[xdata, ydata])
        io_operations_handler.start()

    def startDyks(self):
        #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr
        if self.p_options_6.payload['x_column'] != '':
            xdata = self.spreadsheet.model.input_data[:,
                                                      self.spreadsheet.model.
                                                      header_info.index(
                                                          self.p_options_6.
                                                          payload['x_column'])]
        else:
            xdata = []
        prp = self.p_options_6.payload['calculate']

        io_operations_handler = HandlerThread()
        io_operations_handler.messageSent.connect(self.status_bar.showMessage)
        io_operations_handler.daemon = True
        io_operations_handler.hasFinished.connect(
            lambda: self.displayDyks(io_operations_handler.results))
        io_operations_handler.loadParameters(f=dParsonsManifold,
                                             _args=[xdata, prp])
        io_operations_handler.start()

    def displayKCoz(self, content):
        content = list(content)
        content.insert(0, 'Resultados - Kozeny-Carman')
        self.spreadsheet.addColumn(content)

    def displayWinl(self, content):
        self.loadPltE(content[:2])
        content[2].insert(0, 'R35 - Winland')
        content[3].insert(0, 'Ports - Winland')
        self.spreadsheet.addColumn(content[2])
        self.spreadsheet.addColumn(content[3])

    def displayTCoa(self, content):
        content.insert(0, 'Resultados - Timur Coates')
        self.spreadsheet.addColumn(content)

    def displayDyks(self, content):
        content.insert(0, 'Resultados - Dykstra-Parsons')
        self.spreadsheet.addColumn(content)
        self.p_options_6.results.setText(
            'Atenção! Resultado pode ser diferente do coeficiente calculado através do gráfico de probabilidade. \n'
            + str(content[0]) + ': ' + str(content[1]))

    def displayLuci(self, results):
        self.loadPltE(results[:2])
        results[2].insert(0, 'Resultados - RFN/Lucia')
        self.spreadsheet.addColumn(results[2])

    def displayFZIR(self, results):
        results[0].insert(0, 'Resultados - RQI (μm)')
        self.spreadsheet.addColumn(results[0])
        results[1].insert(0, 'Resultados - PhiZ')
        self.spreadsheet.addColumn(results[1])
        self.loadPltE(results[2:])

    def displayRegr(self, display_name, results):
        self.s_options_1.results.setText(str(results[0]))
        self.loadPltE(results[-2:])

    def displayStat(self, display_name, results):
        self.s_options_2.results.setText(str(results))

    def displayHist(self, results):
        self.loadPltE(results, 'Histograma')

    def displayBxpl(self, results):
        self.loadPltE(results, 'Boxplot')
Пример #29
0
    def __init__(self):
        super(SidePanel, self).__init__()

        # Internal variables
        self._coverdir = path.join("data", "images", "covers")
        self._id = 0
        self._imagedata = ""
        size = [220, 16]  # Width, Height (for QLineEdits/QTextEdits)

        # QDockWidget settings
        self.setAllowedAreas(Qt.RightDockWidgetArea)
        self.setFeatures(QDockWidget.DockWidgetClosable)
        self.setFixedWidth(350)
        self.setVisible(False)

        # Fonts
        bold = QFont()
        bold.setBold(True)
        boldUnderline = QFont()
        boldUnderline.setBold(True)
        boldUnderline.setUnderline(True)

        # Horizontal line
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)

        """Widgets"""
        # Cover
        self.cover = QLabel()
        self.cover.setAlignment(Qt.AlignCenter)
        self.cover.setMinimumHeight(200)
        self.cover.setMaximumSize(self.width(), 250)
        # Buttons
        self.fetchInfoButton = QPushButton("Fetch missing info")
        self.fetchInfoButton.setToolTip("Try to fetch info from MobyGames")
        self.fetchInfoButton.clicked.connect(self._fetchInfo)
        self.editDetailsButton = QPushButton("Edit")
        self.editDetailsButton.setCheckable(True)
        self.editDetailsButton.clicked.connect(self._editDetails)
        self.saveDetailsButton = QPushButton("Save")
        self.saveDetailsButton.clicked.connect(self._saveInfo)
        self.fetchPriceButton = QPushButton("Update price data")
        self.fetchPriceButton.setToolTip("Try to update price data from Pricecharting")
        self.fetchPriceButton.clicked.connect(self._fetchPriceData)
        self.savePriceButton = QPushButton("Save")
        self.savePriceButton.clicked.connect(self._saveInfo)

        # Info layout widgets
        self.nameInfoLabel = QLabel("Name:")
        self.nameInfoLabel.setFont(bold)
        self.nameDataLabel = QLabel()
        self.nameDataLabel.setWordWrap(True)
        self.platformInfoLabel = QLabel("Platform:")
        self.platformInfoLabel.setFont(bold)
        self.platformDataLabel = QLabel()
        self.publisherInfoLabel = QLabel("Publisher:")
        self.publisherInfoLabel.setFont(bold)
        self.publisherDataLabel = QLabel()
        self.developerInfoLabel = QLabel("Developer:")
        self.developerInfoLabel.setFont(bold)
        self.developerDataLabel = QLabel()
        self.regionInfoLabel = QLabel("Region:")
        self.regionInfoLabel.setFont(bold)
        self.regionDataLabel = QLabel()
        self.codeInfoLabel = QLabel("Code:")
        self.codeInfoLabel.setFont(bold)
        self.codeDataLabel = QLabel()
        self.codeDataLabel.setWordWrap(True)
        self.itemInfoLabel = QLabel("Game:")
        self.itemInfoLabel.setFont(bold)
        self.itemDataLabel = QLabel()
        self.boxInfoLabel = QLabel("Box:")
        self.boxInfoLabel.setFont(bold)
        self.boxDataLabel = QLabel()
        self.manualInfoLabel = QLabel("Manual:")
        self.manualInfoLabel.setFont(bold)
        self.manualDataLabel = QLabel()
        self.genreInfoLabel = QLabel("Genre:")
        self.genreInfoLabel.setFont(bold)
        self.genreDataLabel = QLabel()
        self.yearInfoLabel = QLabel("Year:")
        self.yearInfoLabel.setFont(bold)
        self.yearDataLabel = QLabel()
        self.commentInfoLabel = QLabel("Comment:")
        self.commentInfoLabel.setFont(bold)
        self.commentDataLabel = QLabel()
        self.commentDataLabel.setWordWrap(True)
        self.platformsInfoLabel = QLabel("Available for:")
        self.platformsInfoLabel.setFont(bold)
        self.platformsDataLabel = QLabel()
        self.platformsDataLabel.setWordWrap(True)
        self.platformsDataLabel.setMaximumHeight(50)  # Can get quite large otherwise

        # Edit layout widgets
        self.nameEditLabel = QLabel("Name:")
        self.nameEditLabel.setFont(bold)
        self.nameDataTE = QTextEdit()
        self.nameDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformEditLabel = QLabel("Platform:")
        self.platformEditLabel.setFont(bold)
        self.platformDataLE = QLineEdit()
        self.platformDataLE.setMaximumSize(size[0], size[1])
        self.publisherEditLabel = QLabel("Publisher:")
        self.publisherEditLabel.setFont(bold)
        self.publisherDataLE = QLineEdit()
        self.publisherDataLE.setMaximumSize(size[0], size[1])
        self.developerEditLabel = QLabel("Developer:")
        self.developerEditLabel.setFont(bold)
        self.developerDataLE = QLineEdit()
        self.developerDataLE.setMaximumSize(size[0], size[1])
        self.regionEditLabel = QLabel("Region:")
        self.regionEditLabel.setFont(bold)
        self.regionDataCoB = QComboBox()
        self.regionDataCoB.addItems(("NTSC (JP)", "NTSC (NA)", "PAL"))
        self.regionDataCoB.setMinimumWidth(size[0])  # If not set it will be too small
        self.regionDataCoB.setMaximumSize(size[0], size[1])
        self.codeEditLabel = QLabel("Code:")
        self.codeEditLabel.setFont(bold)
        self.codeDataLE = QLineEdit()
        self.codeDataLE.setMaximumSize(size[0], size[1])
        self.itemEditLabel = QLabel("Game:")
        self.itemEditLabel.setFont(bold)
        self.itemDataCB = QCheckBox()
        self.itemDataCB.setChecked(False)
        self.boxEditLabel = QLabel("Box:")
        self.boxEditLabel.setFont(bold)
        self.boxDataCB = QCheckBox()
        self.boxDataCB.setChecked(False)
        self.manualEditLabel = QLabel("Manual:")
        self.manualEditLabel.setFont(bold)
        self.manualDataCB = QCheckBox()
        self.manualDataCB.setChecked(False)
        self.genreEditLabel = QLabel("Genre:")
        self.genreEditLabel.setFont(bold)
        self.genreDataLE = QLineEdit()
        self.genreDataLE.setMaximumSize(size[0], size[1])
        self.yearEditLabel = QLabel("Year:")
        self.yearEditLabel.setFont(bold)
        self.yearDataLE = QLineEdit()
        self.yearDataLE.setMaximumSize(size[0], size[1])
        self.commentEditLabel = QLabel("Comment:")
        self.commentEditLabel.setFont(bold)
        self.commentDataTE = QTextEdit()
        self.commentDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformsEditLabel = QLabel("Available for:")
        self.platformsEditLabel.setFont(bold)
        self.platformsDataTE = QTextEdit()
        self.platformsDataTE.setMaximumSize(size[0], size[1] * 2)

        # Price widgets
        self.paidPriceLabel = QLabel("Paid:")
        self.paidPriceLabel.setFont(bold)
        self.paidPriceDataLE = QLineEdit()
        self.paidPriceDataLE.setMaximumSize(60, size[1])
        self.paidPriceDataLE.setAlignment(Qt.AlignRight)
        self.loosePriceLabel = QLabel("Loose:")
        self.loosePriceLabel.setFont(bold)
        self.loosePriceDataLabel = QLabel()
        self.loosePriceDataLabel.setAlignment(Qt.AlignRight)
        self.cibPriceLabel = QLabel("CIB:")
        self.cibPriceLabel.setFont(bold)
        self.cibPriceDataLabel = QLabel()
        self.cibPriceDataLabel.setAlignment(Qt.AlignRight)
        self.newPriceLabel = QLabel("New:")
        self.newPriceLabel.setFont(bold)
        self.newPriceDataLabel = QLabel()
        self.newPriceDataLabel.setAlignment(Qt.AlignRight)

        """Layouts"""
        # Cover
        self.coverVbox = QVBoxLayout()
        self.coverVbox.addWidget(self.cover, 1)
        self.coverVbox.addWidget(hline, 0)

        # Buttons
        self.detailsButtonHbox = QHBoxLayout()
        self.detailsButtonHbox.addWidget(self.fetchInfoButton, 0)
        self.detailsButtonHbox.addWidget(self.editDetailsButton, 0)
        self.detailsButtonHbox.addWidget(self.saveDetailsButton, 0)
        self.priceButtonHbox = QHBoxLayout()
        self.priceButtonHbox.addWidget(self.fetchPriceButton, 0)
        self.priceButtonHbox.addWidget(self.savePriceButton, 0)

        # Info layouts
        self.nameInfoHbox = QHBoxLayout()
        self.nameInfoHbox.addWidget(self.nameInfoLabel, 0)
        self.nameInfoHbox.addWidget(self.nameDataLabel, 0)
        self.platformInfoHbox = QHBoxLayout()
        self.platformInfoHbox.addWidget(self.platformInfoLabel, 0)
        self.platformInfoHbox.addWidget(self.platformDataLabel, 0)
        self.publisherInfoHbox = QHBoxLayout()
        self.publisherInfoHbox.addWidget(self.publisherInfoLabel, 0)
        self.publisherInfoHbox.addWidget(self.publisherDataLabel, 0)
        self.developerInfoHbox = QHBoxLayout()
        self.developerInfoHbox.addWidget(self.developerInfoLabel, 0)
        self.developerInfoHbox.addWidget(self.developerDataLabel, 0)
        self.regionInfoHbox = QHBoxLayout()
        self.regionInfoHbox.addWidget(self.regionInfoLabel, 0)
        self.regionInfoHbox.addWidget(self.regionDataLabel, 0)
        self.codeInfoHbox = QHBoxLayout()
        self.codeInfoHbox.addWidget(self.codeInfoLabel, 0)
        self.codeInfoHbox.addWidget(self.codeDataLabel, 0)
        self.itemInfoHbox = QHBoxLayout()
        self.itemInfoHbox.addWidget(self.itemInfoLabel, 0)
        self.itemInfoHbox.addWidget(self.itemDataLabel, 0)
        self.boxInfoHbox = QHBoxLayout()
        self.boxInfoHbox.addWidget(self.boxInfoLabel, 0)
        self.boxInfoHbox.addWidget(self.boxDataLabel, 0)
        self.manualInfoHbox = QHBoxLayout()
        self.manualInfoHbox.addWidget(self.manualInfoLabel, 0)
        self.manualInfoHbox.addWidget(self.manualDataLabel, 0)
        self.genreInfoHbox = QHBoxLayout()
        self.genreInfoHbox.addWidget(self.genreInfoLabel, 0)
        self.genreInfoHbox.addWidget(self.genreDataLabel, 0)
        self.yearInfoHbox = QHBoxLayout()
        self.yearInfoHbox.addWidget(self.yearInfoLabel, 0)
        self.yearInfoHbox.addWidget(self.yearDataLabel, 0)
        self.commentInfoHbox = QHBoxLayout()
        self.commentInfoHbox.addWidget(self.commentInfoLabel, 0)
        self.commentInfoHbox.addWidget(self.commentDataLabel, 0)
        self.platformsInfoHbox = QHBoxLayout()
        self.platformsInfoHbox.addWidget(self.platformsInfoLabel, 0)
        self.platformsInfoHbox.addWidget(self.platformsDataLabel, 0)

        # Edit layouts
        self.nameEditHbox = QHBoxLayout()
        self.nameEditHbox.addWidget(self.nameEditLabel, 0)
        self.nameEditHbox.addWidget(self.nameDataTE, 0)
        self.platformEditHbox = QHBoxLayout()
        self.platformEditHbox.addWidget(self.platformEditLabel, 0)
        self.platformEditHbox.addWidget(self.platformDataLE, 0)
        self.publisherEditHbox = QHBoxLayout()
        self.publisherEditHbox.addWidget(self.publisherEditLabel, 0)
        self.publisherEditHbox.addWidget(self.publisherDataLE, 0)
        self.developerEditHbox = QHBoxLayout()
        self.developerEditHbox.addWidget(self.developerEditLabel, 0)
        self.developerEditHbox.addWidget(self.developerDataLE, 0)
        self.regionEditHbox = QHBoxLayout()
        self.regionEditHbox.addWidget(self.regionEditLabel, 0)
        self.regionEditHbox.addWidget(self.regionDataCoB, 0)
        self.codeEditHbox = QHBoxLayout()
        self.codeEditHbox.addWidget(self.codeEditLabel, 0)
        self.codeEditHbox.addWidget(self.codeDataLE, 0)
        self.itemEditHbox = QHBoxLayout()
        self.itemEditHbox.addWidget(self.itemEditLabel, 0)
        self.itemEditHbox.addWidget(self.itemDataCB, 0)
        self.itemEditHbox.addSpacing(135)
        self.boxEditHbox = QHBoxLayout()
        self.boxEditHbox.addWidget(self.boxEditLabel, 0)
        self.boxEditHbox.addWidget(self.boxDataCB, 0)
        self.boxEditHbox.addSpacing(135)
        self.manualEditHbox = QHBoxLayout()
        self.manualEditHbox.addWidget(self.manualEditLabel, 0)
        self.manualEditHbox.addWidget(self.manualDataCB, 0)
        self.manualEditHbox.addSpacing(135)
        self.genreEditHbox = QHBoxLayout()
        self.genreEditHbox.addWidget(self.genreEditLabel, 0)
        self.genreEditHbox.addWidget(self.genreDataLE, 0)
        self.yearEditHbox = QHBoxLayout()
        self.yearEditHbox.addWidget(self.yearEditLabel, 0)
        self.yearEditHbox.addWidget(self.yearDataLE, 0)
        self.commentEditHbox = QHBoxLayout()
        self.commentEditHbox.addWidget(self.commentEditLabel, 0)
        self.commentEditHbox.addWidget(self.commentDataTE, 0)
        self.platformsEditHbox = QHBoxLayout()
        self.platformsEditHbox.addWidget(self.platformsEditLabel, 0)
        self.platformsEditHbox.addWidget(self.platformsDataTE, 0)

        # Price layouts
        self.paidPriceHbox = QHBoxLayout()
        self.paidPriceHbox.addWidget(self.paidPriceLabel, 0)
        self.paidPriceHbox.addWidget(self.paidPriceDataLE, 0)
        self.loosePriceHbox = QHBoxLayout()
        self.loosePriceHbox.addWidget(self.loosePriceLabel, 0)
        self.loosePriceHbox.addWidget(self.loosePriceDataLabel, 0)
        self.cibPriceHbox = QHBoxLayout()
        self.cibPriceHbox.addWidget(self.cibPriceLabel, 0)
        self.cibPriceHbox.addWidget(self.cibPriceDataLabel, 0)
        self.newPriceHbox = QHBoxLayout()
        self.newPriceHbox.addWidget(self.newPriceLabel, 0)
        self.newPriceHbox.addWidget(self.newPriceDataLabel, 0)

        # Info layout
        self.infoLayout = QVBoxLayout()
        self.infoLayout.addLayout(self.nameInfoHbox, 0)
        self.infoLayout.addLayout(self.platformInfoHbox, 0)
        self.infoLayout.addLayout(self.publisherInfoHbox, 0)
        self.infoLayout.addLayout(self.developerInfoHbox, 0)
        self.infoLayout.addLayout(self.genreInfoHbox, 0)
        self.infoLayout.addLayout(self.regionInfoHbox, 0)
        self.infoLayout.addLayout(self.yearInfoHbox, 0)
        self.infoLayout.addLayout(self.codeInfoHbox, 0)
        self.infoLayout.addLayout(self.itemInfoHbox, 0)
        self.infoLayout.addLayout(self.boxInfoHbox, 0)
        self.infoLayout.addLayout(self.manualInfoHbox, 0)
        self.infoLayout.addLayout(self.commentInfoHbox, 0)
        self.infoLayout.addLayout(self.platformsInfoHbox, 0)

        # Edit layout
        self.editLayout = QVBoxLayout()
        self.editLayout.addLayout(self.nameEditHbox, 0)
        self.editLayout.addLayout(self.platformEditHbox, 0)
        self.editLayout.addLayout(self.publisherEditHbox, 0)
        self.editLayout.addLayout(self.developerEditHbox, 0)
        self.editLayout.addLayout(self.genreEditHbox, 0)
        self.editLayout.addLayout(self.regionEditHbox, 0)
        self.editLayout.addLayout(self.yearEditHbox, 0)
        self.editLayout.addLayout(self.codeEditHbox, 0)
        self.editLayout.addLayout(self.itemEditHbox, 0)
        self.editLayout.addLayout(self.boxEditHbox, 0)
        self.editLayout.addLayout(self.manualEditHbox, 0)
        self.editLayout.addLayout(self.commentEditHbox, 0)
        self.editLayout.addLayout(self.platformsEditHbox, 0)

        # Price layout
        self.priceLayout = QVBoxLayout()
        self.priceLayout.addLayout(self.paidPriceHbox, 0)
        self.priceLayout.addLayout(self.loosePriceHbox, 0)
        self.priceLayout.addLayout(self.cibPriceHbox, 0)
        self.priceLayout.addLayout(self.newPriceHbox, 0)
        self.priceLayout.addStretch(1)
        self.priceLayout.addLayout(self.priceButtonHbox, 0)

        """Main layout"""
        self.infoWidget = QWidget()
        self.infoWidget.setLayout(self.infoLayout)
        self.editWidget = QWidget()
        self.editWidget.setLayout(self.editLayout)
        # Add info and edit widgets to a stacked layout so we can switch layouts when editing
        self.stackedLayout = QStackedLayout()
        self.stackedLayout.addWidget(self.infoWidget)
        self.stackedLayout.addWidget(self.editWidget)
        self.stackedLayout.setCurrentIndex(0)  # Default to info layout

        self.detailsLayout = QVBoxLayout()
        self.detailsLayout.addLayout(self.coverVbox, 1)
        self.detailsLayout.addLayout(self.stackedLayout, 0)
        self.detailsLayout.addLayout(self.detailsButtonHbox, 0)
        self.detailsWidget = QWidget()
        self.detailsWidget.setLayout(self.detailsLayout)

        self.priceWidget = QWidget()
        self.priceWidget.setLayout(self.priceLayout)

        self.tab = QTabWidget()
        self.tab.addTab(self.detailsWidget, "Details")
        self.tab.addTab(self.priceWidget, "Price info")
        self.setWidget(self.tab)
Пример #30
0
class SidePanel(QDockWidget):
    saved = Signal(dict)

    def __init__(self):
        super(SidePanel, self).__init__()

        # Internal variables
        self._coverdir = path.join("data", "images", "covers")
        self._id = 0
        self._imagedata = ""
        size = [220, 16]  # Width, Height (for QLineEdits/QTextEdits)

        # QDockWidget settings
        self.setAllowedAreas(Qt.RightDockWidgetArea)
        self.setFeatures(QDockWidget.DockWidgetClosable)
        self.setFixedWidth(350)
        self.setVisible(False)

        # Fonts
        bold = QFont()
        bold.setBold(True)
        boldUnderline = QFont()
        boldUnderline.setBold(True)
        boldUnderline.setUnderline(True)

        # Horizontal line
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)

        """Widgets"""
        # Cover
        self.cover = QLabel()
        self.cover.setAlignment(Qt.AlignCenter)
        self.cover.setMinimumHeight(200)
        self.cover.setMaximumSize(self.width(), 250)
        # Buttons
        self.fetchInfoButton = QPushButton("Fetch missing info")
        self.fetchInfoButton.setToolTip("Try to fetch info from MobyGames")
        self.fetchInfoButton.clicked.connect(self._fetchInfo)
        self.editDetailsButton = QPushButton("Edit")
        self.editDetailsButton.setCheckable(True)
        self.editDetailsButton.clicked.connect(self._editDetails)
        self.saveDetailsButton = QPushButton("Save")
        self.saveDetailsButton.clicked.connect(self._saveInfo)
        self.fetchPriceButton = QPushButton("Update price data")
        self.fetchPriceButton.setToolTip("Try to update price data from Pricecharting")
        self.fetchPriceButton.clicked.connect(self._fetchPriceData)
        self.savePriceButton = QPushButton("Save")
        self.savePriceButton.clicked.connect(self._saveInfo)

        # Info layout widgets
        self.nameInfoLabel = QLabel("Name:")
        self.nameInfoLabel.setFont(bold)
        self.nameDataLabel = QLabel()
        self.nameDataLabel.setWordWrap(True)
        self.platformInfoLabel = QLabel("Platform:")
        self.platformInfoLabel.setFont(bold)
        self.platformDataLabel = QLabel()
        self.publisherInfoLabel = QLabel("Publisher:")
        self.publisherInfoLabel.setFont(bold)
        self.publisherDataLabel = QLabel()
        self.developerInfoLabel = QLabel("Developer:")
        self.developerInfoLabel.setFont(bold)
        self.developerDataLabel = QLabel()
        self.regionInfoLabel = QLabel("Region:")
        self.regionInfoLabel.setFont(bold)
        self.regionDataLabel = QLabel()
        self.codeInfoLabel = QLabel("Code:")
        self.codeInfoLabel.setFont(bold)
        self.codeDataLabel = QLabel()
        self.codeDataLabel.setWordWrap(True)
        self.itemInfoLabel = QLabel("Game:")
        self.itemInfoLabel.setFont(bold)
        self.itemDataLabel = QLabel()
        self.boxInfoLabel = QLabel("Box:")
        self.boxInfoLabel.setFont(bold)
        self.boxDataLabel = QLabel()
        self.manualInfoLabel = QLabel("Manual:")
        self.manualInfoLabel.setFont(bold)
        self.manualDataLabel = QLabel()
        self.genreInfoLabel = QLabel("Genre:")
        self.genreInfoLabel.setFont(bold)
        self.genreDataLabel = QLabel()
        self.yearInfoLabel = QLabel("Year:")
        self.yearInfoLabel.setFont(bold)
        self.yearDataLabel = QLabel()
        self.commentInfoLabel = QLabel("Comment:")
        self.commentInfoLabel.setFont(bold)
        self.commentDataLabel = QLabel()
        self.commentDataLabel.setWordWrap(True)
        self.platformsInfoLabel = QLabel("Available for:")
        self.platformsInfoLabel.setFont(bold)
        self.platformsDataLabel = QLabel()
        self.platformsDataLabel.setWordWrap(True)
        self.platformsDataLabel.setMaximumHeight(50)  # Can get quite large otherwise

        # Edit layout widgets
        self.nameEditLabel = QLabel("Name:")
        self.nameEditLabel.setFont(bold)
        self.nameDataTE = QTextEdit()
        self.nameDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformEditLabel = QLabel("Platform:")
        self.platformEditLabel.setFont(bold)
        self.platformDataLE = QLineEdit()
        self.platformDataLE.setMaximumSize(size[0], size[1])
        self.publisherEditLabel = QLabel("Publisher:")
        self.publisherEditLabel.setFont(bold)
        self.publisherDataLE = QLineEdit()
        self.publisherDataLE.setMaximumSize(size[0], size[1])
        self.developerEditLabel = QLabel("Developer:")
        self.developerEditLabel.setFont(bold)
        self.developerDataLE = QLineEdit()
        self.developerDataLE.setMaximumSize(size[0], size[1])
        self.regionEditLabel = QLabel("Region:")
        self.regionEditLabel.setFont(bold)
        self.regionDataCoB = QComboBox()
        self.regionDataCoB.addItems(("NTSC (JP)", "NTSC (NA)", "PAL"))
        self.regionDataCoB.setMinimumWidth(size[0])  # If not set it will be too small
        self.regionDataCoB.setMaximumSize(size[0], size[1])
        self.codeEditLabel = QLabel("Code:")
        self.codeEditLabel.setFont(bold)
        self.codeDataLE = QLineEdit()
        self.codeDataLE.setMaximumSize(size[0], size[1])
        self.itemEditLabel = QLabel("Game:")
        self.itemEditLabel.setFont(bold)
        self.itemDataCB = QCheckBox()
        self.itemDataCB.setChecked(False)
        self.boxEditLabel = QLabel("Box:")
        self.boxEditLabel.setFont(bold)
        self.boxDataCB = QCheckBox()
        self.boxDataCB.setChecked(False)
        self.manualEditLabel = QLabel("Manual:")
        self.manualEditLabel.setFont(bold)
        self.manualDataCB = QCheckBox()
        self.manualDataCB.setChecked(False)
        self.genreEditLabel = QLabel("Genre:")
        self.genreEditLabel.setFont(bold)
        self.genreDataLE = QLineEdit()
        self.genreDataLE.setMaximumSize(size[0], size[1])
        self.yearEditLabel = QLabel("Year:")
        self.yearEditLabel.setFont(bold)
        self.yearDataLE = QLineEdit()
        self.yearDataLE.setMaximumSize(size[0], size[1])
        self.commentEditLabel = QLabel("Comment:")
        self.commentEditLabel.setFont(bold)
        self.commentDataTE = QTextEdit()
        self.commentDataTE.setMaximumSize(size[0], size[1] * 2)
        self.platformsEditLabel = QLabel("Available for:")
        self.platformsEditLabel.setFont(bold)
        self.platformsDataTE = QTextEdit()
        self.platformsDataTE.setMaximumSize(size[0], size[1] * 2)

        # Price widgets
        self.paidPriceLabel = QLabel("Paid:")
        self.paidPriceLabel.setFont(bold)
        self.paidPriceDataLE = QLineEdit()
        self.paidPriceDataLE.setMaximumSize(60, size[1])
        self.paidPriceDataLE.setAlignment(Qt.AlignRight)
        self.loosePriceLabel = QLabel("Loose:")
        self.loosePriceLabel.setFont(bold)
        self.loosePriceDataLabel = QLabel()
        self.loosePriceDataLabel.setAlignment(Qt.AlignRight)
        self.cibPriceLabel = QLabel("CIB:")
        self.cibPriceLabel.setFont(bold)
        self.cibPriceDataLabel = QLabel()
        self.cibPriceDataLabel.setAlignment(Qt.AlignRight)
        self.newPriceLabel = QLabel("New:")
        self.newPriceLabel.setFont(bold)
        self.newPriceDataLabel = QLabel()
        self.newPriceDataLabel.setAlignment(Qt.AlignRight)

        """Layouts"""
        # Cover
        self.coverVbox = QVBoxLayout()
        self.coverVbox.addWidget(self.cover, 1)
        self.coverVbox.addWidget(hline, 0)

        # Buttons
        self.detailsButtonHbox = QHBoxLayout()
        self.detailsButtonHbox.addWidget(self.fetchInfoButton, 0)
        self.detailsButtonHbox.addWidget(self.editDetailsButton, 0)
        self.detailsButtonHbox.addWidget(self.saveDetailsButton, 0)
        self.priceButtonHbox = QHBoxLayout()
        self.priceButtonHbox.addWidget(self.fetchPriceButton, 0)
        self.priceButtonHbox.addWidget(self.savePriceButton, 0)

        # Info layouts
        self.nameInfoHbox = QHBoxLayout()
        self.nameInfoHbox.addWidget(self.nameInfoLabel, 0)
        self.nameInfoHbox.addWidget(self.nameDataLabel, 0)
        self.platformInfoHbox = QHBoxLayout()
        self.platformInfoHbox.addWidget(self.platformInfoLabel, 0)
        self.platformInfoHbox.addWidget(self.platformDataLabel, 0)
        self.publisherInfoHbox = QHBoxLayout()
        self.publisherInfoHbox.addWidget(self.publisherInfoLabel, 0)
        self.publisherInfoHbox.addWidget(self.publisherDataLabel, 0)
        self.developerInfoHbox = QHBoxLayout()
        self.developerInfoHbox.addWidget(self.developerInfoLabel, 0)
        self.developerInfoHbox.addWidget(self.developerDataLabel, 0)
        self.regionInfoHbox = QHBoxLayout()
        self.regionInfoHbox.addWidget(self.regionInfoLabel, 0)
        self.regionInfoHbox.addWidget(self.regionDataLabel, 0)
        self.codeInfoHbox = QHBoxLayout()
        self.codeInfoHbox.addWidget(self.codeInfoLabel, 0)
        self.codeInfoHbox.addWidget(self.codeDataLabel, 0)
        self.itemInfoHbox = QHBoxLayout()
        self.itemInfoHbox.addWidget(self.itemInfoLabel, 0)
        self.itemInfoHbox.addWidget(self.itemDataLabel, 0)
        self.boxInfoHbox = QHBoxLayout()
        self.boxInfoHbox.addWidget(self.boxInfoLabel, 0)
        self.boxInfoHbox.addWidget(self.boxDataLabel, 0)
        self.manualInfoHbox = QHBoxLayout()
        self.manualInfoHbox.addWidget(self.manualInfoLabel, 0)
        self.manualInfoHbox.addWidget(self.manualDataLabel, 0)
        self.genreInfoHbox = QHBoxLayout()
        self.genreInfoHbox.addWidget(self.genreInfoLabel, 0)
        self.genreInfoHbox.addWidget(self.genreDataLabel, 0)
        self.yearInfoHbox = QHBoxLayout()
        self.yearInfoHbox.addWidget(self.yearInfoLabel, 0)
        self.yearInfoHbox.addWidget(self.yearDataLabel, 0)
        self.commentInfoHbox = QHBoxLayout()
        self.commentInfoHbox.addWidget(self.commentInfoLabel, 0)
        self.commentInfoHbox.addWidget(self.commentDataLabel, 0)
        self.platformsInfoHbox = QHBoxLayout()
        self.platformsInfoHbox.addWidget(self.platformsInfoLabel, 0)
        self.platformsInfoHbox.addWidget(self.platformsDataLabel, 0)

        # Edit layouts
        self.nameEditHbox = QHBoxLayout()
        self.nameEditHbox.addWidget(self.nameEditLabel, 0)
        self.nameEditHbox.addWidget(self.nameDataTE, 0)
        self.platformEditHbox = QHBoxLayout()
        self.platformEditHbox.addWidget(self.platformEditLabel, 0)
        self.platformEditHbox.addWidget(self.platformDataLE, 0)
        self.publisherEditHbox = QHBoxLayout()
        self.publisherEditHbox.addWidget(self.publisherEditLabel, 0)
        self.publisherEditHbox.addWidget(self.publisherDataLE, 0)
        self.developerEditHbox = QHBoxLayout()
        self.developerEditHbox.addWidget(self.developerEditLabel, 0)
        self.developerEditHbox.addWidget(self.developerDataLE, 0)
        self.regionEditHbox = QHBoxLayout()
        self.regionEditHbox.addWidget(self.regionEditLabel, 0)
        self.regionEditHbox.addWidget(self.regionDataCoB, 0)
        self.codeEditHbox = QHBoxLayout()
        self.codeEditHbox.addWidget(self.codeEditLabel, 0)
        self.codeEditHbox.addWidget(self.codeDataLE, 0)
        self.itemEditHbox = QHBoxLayout()
        self.itemEditHbox.addWidget(self.itemEditLabel, 0)
        self.itemEditHbox.addWidget(self.itemDataCB, 0)
        self.itemEditHbox.addSpacing(135)
        self.boxEditHbox = QHBoxLayout()
        self.boxEditHbox.addWidget(self.boxEditLabel, 0)
        self.boxEditHbox.addWidget(self.boxDataCB, 0)
        self.boxEditHbox.addSpacing(135)
        self.manualEditHbox = QHBoxLayout()
        self.manualEditHbox.addWidget(self.manualEditLabel, 0)
        self.manualEditHbox.addWidget(self.manualDataCB, 0)
        self.manualEditHbox.addSpacing(135)
        self.genreEditHbox = QHBoxLayout()
        self.genreEditHbox.addWidget(self.genreEditLabel, 0)
        self.genreEditHbox.addWidget(self.genreDataLE, 0)
        self.yearEditHbox = QHBoxLayout()
        self.yearEditHbox.addWidget(self.yearEditLabel, 0)
        self.yearEditHbox.addWidget(self.yearDataLE, 0)
        self.commentEditHbox = QHBoxLayout()
        self.commentEditHbox.addWidget(self.commentEditLabel, 0)
        self.commentEditHbox.addWidget(self.commentDataTE, 0)
        self.platformsEditHbox = QHBoxLayout()
        self.platformsEditHbox.addWidget(self.platformsEditLabel, 0)
        self.platformsEditHbox.addWidget(self.platformsDataTE, 0)

        # Price layouts
        self.paidPriceHbox = QHBoxLayout()
        self.paidPriceHbox.addWidget(self.paidPriceLabel, 0)
        self.paidPriceHbox.addWidget(self.paidPriceDataLE, 0)
        self.loosePriceHbox = QHBoxLayout()
        self.loosePriceHbox.addWidget(self.loosePriceLabel, 0)
        self.loosePriceHbox.addWidget(self.loosePriceDataLabel, 0)
        self.cibPriceHbox = QHBoxLayout()
        self.cibPriceHbox.addWidget(self.cibPriceLabel, 0)
        self.cibPriceHbox.addWidget(self.cibPriceDataLabel, 0)
        self.newPriceHbox = QHBoxLayout()
        self.newPriceHbox.addWidget(self.newPriceLabel, 0)
        self.newPriceHbox.addWidget(self.newPriceDataLabel, 0)

        # Info layout
        self.infoLayout = QVBoxLayout()
        self.infoLayout.addLayout(self.nameInfoHbox, 0)
        self.infoLayout.addLayout(self.platformInfoHbox, 0)
        self.infoLayout.addLayout(self.publisherInfoHbox, 0)
        self.infoLayout.addLayout(self.developerInfoHbox, 0)
        self.infoLayout.addLayout(self.genreInfoHbox, 0)
        self.infoLayout.addLayout(self.regionInfoHbox, 0)
        self.infoLayout.addLayout(self.yearInfoHbox, 0)
        self.infoLayout.addLayout(self.codeInfoHbox, 0)
        self.infoLayout.addLayout(self.itemInfoHbox, 0)
        self.infoLayout.addLayout(self.boxInfoHbox, 0)
        self.infoLayout.addLayout(self.manualInfoHbox, 0)
        self.infoLayout.addLayout(self.commentInfoHbox, 0)
        self.infoLayout.addLayout(self.platformsInfoHbox, 0)

        # Edit layout
        self.editLayout = QVBoxLayout()
        self.editLayout.addLayout(self.nameEditHbox, 0)
        self.editLayout.addLayout(self.platformEditHbox, 0)
        self.editLayout.addLayout(self.publisherEditHbox, 0)
        self.editLayout.addLayout(self.developerEditHbox, 0)
        self.editLayout.addLayout(self.genreEditHbox, 0)
        self.editLayout.addLayout(self.regionEditHbox, 0)
        self.editLayout.addLayout(self.yearEditHbox, 0)
        self.editLayout.addLayout(self.codeEditHbox, 0)
        self.editLayout.addLayout(self.itemEditHbox, 0)
        self.editLayout.addLayout(self.boxEditHbox, 0)
        self.editLayout.addLayout(self.manualEditHbox, 0)
        self.editLayout.addLayout(self.commentEditHbox, 0)
        self.editLayout.addLayout(self.platformsEditHbox, 0)

        # Price layout
        self.priceLayout = QVBoxLayout()
        self.priceLayout.addLayout(self.paidPriceHbox, 0)
        self.priceLayout.addLayout(self.loosePriceHbox, 0)
        self.priceLayout.addLayout(self.cibPriceHbox, 0)
        self.priceLayout.addLayout(self.newPriceHbox, 0)
        self.priceLayout.addStretch(1)
        self.priceLayout.addLayout(self.priceButtonHbox, 0)

        """Main layout"""
        self.infoWidget = QWidget()
        self.infoWidget.setLayout(self.infoLayout)
        self.editWidget = QWidget()
        self.editWidget.setLayout(self.editLayout)
        # Add info and edit widgets to a stacked layout so we can switch layouts when editing
        self.stackedLayout = QStackedLayout()
        self.stackedLayout.addWidget(self.infoWidget)
        self.stackedLayout.addWidget(self.editWidget)
        self.stackedLayout.setCurrentIndex(0)  # Default to info layout

        self.detailsLayout = QVBoxLayout()
        self.detailsLayout.addLayout(self.coverVbox, 1)
        self.detailsLayout.addLayout(self.stackedLayout, 0)
        self.detailsLayout.addLayout(self.detailsButtonHbox, 0)
        self.detailsWidget = QWidget()
        self.detailsWidget.setLayout(self.detailsLayout)

        self.priceWidget = QWidget()
        self.priceWidget.setLayout(self.priceLayout)

        self.tab = QTabWidget()
        self.tab.addTab(self.detailsWidget, "Details")
        self.tab.addTab(self.priceWidget, "Price info")
        self.setWidget(self.tab)

    def _editDetails(self):
        if self.editDetailsButton.isChecked():
            self._updateWidgetData(1)
            self.stackedLayout.setCurrentIndex(1)
        else:
            self._updateWidgetData(0)
            self.stackedLayout.setCurrentIndex(0)

    def _fetchInfo(self):
        name = self.nameDataLabel.text()
        platform = self.platformDataLabel.text()
        region = self.regionDataLabel.text()
        info = getMobyRelease(name, platform, region)
        if "image" in info.keys() and info["image"] != "":
            self._imagedata = requests.get(info["image"]).content
            pixmap = QPixmap()
            pixmap.loadFromData(self._imagedata)
            w = self.cover.width()
            h = self.cover.height()
            self.cover.setPixmap(pixmap.scaled(w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation))

        if self.publisherDataLabel.text() == "":
            self.publisherDataLabel.setText(info["publisher"])
        if self.developerDataLabel.text() == "":
            self.developerDataLabel.setText(info["developer"])
        if self.genreDataLabel.text() == "":
            self.genreDataLabel.setText(info["genre"])
        if self.yearDataLabel.text() == "":
            self.yearDataLabel.setText(info["year"])
        if self.codeDataLabel.text() == "":
            self.codeDataLabel.setText(info["code"])
        if self.platformsDataLabel.text() == "":
            self.platformsDataLabel.setText(info["platforms"])
        # Update edit widgets if we're editing:
        if self.editDetailsButton.isChecked():
            self._updateWidgetData(1)

    def _fetchPriceData(self):
        name = self.nameDataLabel.text()
        platform = self.platformDataLabel.text()
        region = self.regionDataLabel.text()
        prices = getPriceData(name, platform, region)

        self.loosePriceDataLabel.setText(prices["loose"])
        self.cibPriceDataLabel.setText(prices["cib"])
        self.newPriceDataLabel.setText(prices["new"])

    def _saveInfo(self):
        if self.editDetailsButton.isChecked():
            self._updateWidgetData(0)

        paidPrice = str(self.paidPriceDataLE.text()).replace(",", ".")  # Better use '.' as decimal denominator

        info = {"id": self._id,
                "name": self.nameDataLabel.text(),
                "platform": self.platformDataLabel.text(),
                "publisher": self.publisherDataLabel.text(),
                "developer": self.developerDataLabel.text(),
                "genre": self.genreDataLabel.text(),
                "region": self.regionDataLabel.text(),
                "year": self.yearDataLabel.text(),
                "code": self.codeDataLabel.text(),
                "item": self.itemDataLabel.text(),
                "box": self.boxDataLabel.text(),
                "manual": self.manualDataLabel.text(),
                "comment": self.commentDataLabel.text(),
                "platforms": self.platformsDataLabel.text(),
                "price": ",".join((paidPrice, self.loosePriceDataLabel.text(),
                                   self.cibPriceDataLabel.text(), self.newPriceDataLabel.text()))}

        # Save imagedata to file
        if self._imagedata != "" and not path.exists(path.join(self._coverdir, str(self._id) + ".jpg")):
            with open(path.join(self._coverdir, str(self._id) + ".jpg"), "wb") as f:
                f.write(self._imagedata)

        self.saved.emit(info)

    def _updateWidgetData(self, layoutIndex: int):
        if layoutIndex == 0:
            self.nameDataLabel.setText(self.nameDataTE.toPlainText())
            self.platformDataLabel.setText(self.platformDataLE.text())
            self.publisherDataLabel.setText(self.publisherDataLE.text())
            self.developerDataLabel.setText(self.developerDataLE.text())
            self.genreDataLabel.setText(self.genreDataLE.text())
            self.regionDataLabel.setText(self.regionDataCoB.currentText())
            self.yearDataLabel.setText(self.yearDataLE.text())
            self.codeDataLabel.setText(self.codeDataLE.text())
            self.itemDataLabel.setText("Yes") if self.itemDataCB.isChecked() else self.itemDataLabel.setText("No")
            self.boxDataLabel.setText("Yes") if self.boxDataCB.isChecked() else self.boxDataLabel.setText("No")
            self.manualDataLabel.setText("Yes") if self.manualDataCB.isChecked() else self.manualDataLabel.setText("No")
            self.commentDataLabel.setText(self.commentDataTE.toPlainText())
            self.platformsDataLabel.setText(self.platformsDataTE.toPlainText())
        else:
            self.nameDataTE.setText(self.nameDataLabel.text())
            self.platformDataLE.setText(self.platformDataLabel.text())
            self.publisherDataLE.setText(self.publisherDataLabel.text())
            self.developerDataLE.setText(self.developerDataLabel.text())
            self.genreDataLE.setText(self.genreDataLabel.text())
            self.regionDataCoB.setCurrentIndex(0) if self.regionDataLabel.text == "NTSC (JP)"\
                else self.regionDataCoB.setCurrentIndex(1) if self.regionDataLabel.text == "NTSC (NA)"\
                else self.regionDataCoB.setCurrentIndex(2)
            self.yearDataLE.setText(self.yearDataLabel.text())
            self.codeDataLE.setText(self.codeDataLabel.text())
            self.itemDataCB.setChecked(True) if self.itemDataLabel.text() == "Yes" \
                else self.itemDataCB.setChecked("False")
            self.boxDataCB.setChecked(True) if self.boxDataLabel.text() == "Yes" \
                else self.boxDataCB.setChecked(False)
            self.manualDataCB.setChecked(True) if self.manualDataLabel.text() == "Yes" \
                else self.manualDataCB.setChecked(False)
            self.commentDataTE.setText(self.commentDataLabel.text())
            self.platformsDataTE.setText(self.platformsDataLabel.text())

    def showDetails(self, info: dict):
        if not self.isVisible():
            self.setVisible(True)
            self.tab.setCurrentIndex(0)  # Show details tab initially
        if self.editDetailsButton.isChecked():
            self.editDetailsButton.setChecked(False)
        self.stackedLayout.setCurrentIndex(0)  # Show info layout initially

        self._id = info["id"]
        self._imagedata = ""
        pixmap = path.join(self._coverdir, "none.png")
        if path.exists(path.join(self._coverdir, str(self._id) + ".jpg")) and info["table"] == "games":
            pixmap = path.join(self._coverdir, str(self._id) + ".jpg")
        p = QPixmap(pixmap)
        w = self.cover.width()
        h = self.cover.height()
        self.cover.setPixmap(p.scaled(w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation))

        # Price data is stored in form $x,$x,$x,$x [paid, loose, cib, new]
        paidPrice, loosePrice, cibPrice, newPrice = info["price"].split(",")

        self.nameDataLabel.setText(info["name"])
        self.platformDataLabel.setText(info["platform"])
        self.regionDataLabel.setText(info["region"])
        self.boxDataLabel.setText(info["box"])
        self.manualDataLabel.setText(info["manual"])
        self.yearDataLabel.setText(str(info["year"]))
        self.commentDataLabel.setText(info["comment"])
        self.paidPriceDataLE.setText(paidPrice)
        self.loosePriceDataLabel.setText(loosePrice)
        self.cibPriceDataLabel.setText(cibPrice)
        self.newPriceDataLabel.setText(newPrice)
        if info["table"] == "games":
            self.publisherDataLabel.setText(info["publisher"])
            self.developerDataLabel.setText(info["developer"])
            self.genreInfoLabel.setText("Genre:")
            self.genreEditLabel.setText("Genre:")
            self.genreDataLabel.setText(info["genre"])
            self.codeInfoLabel.setText("Code:")
            self.codeInfoLabel.setVisible(True)
            self.codeEditLabel.setText("Code")
            self.codeEditLabel.setVisible(True)
            self.codeDataLabel.setText(info["code"])
            self.codeDataLabel.setVisible(True)
            self.codeDataLE.setVisible(True)
            self.itemInfoLabel.setText("Game:")
            self.itemEditLabel.setText("Game:")
            self.itemDataLabel.setText(info["game"])
            self.platformsDataLabel.setText(info["platforms"])
            self.platformsDataLabel.setVisible(True)
            self.platformsInfoLabel.setVisible(True)
            self.fetchInfoButton.setEnabled(True)
            self.fetchInfoButton.setVisible(True)
            self.fetchInfoButton.setToolTip("Try to fetch info from MobyGames")
            self.saveDetailsButton.setEnabled(True)
            self.saveDetailsButton.setVisible(True)
        elif info["table"] == "consoles":
            self.genreInfoLabel.setText("Country:")
            self.genreEditLabel.setText("Country:")
            self.genreDataLabel.setText(info["country"])
            self.codeInfoLabel.setText("Serial Number:")
            self.codeInfoLabel.setVisible(True)
            self.codeEditLabel.setText("Serial Number:")
            self.codeEditLabel.setVisible(True)
            self.codeDataLabel.setText(info["serial number"])
            self.codeDataLabel.setVisible(True)
            self.codeDataLE.setVisible(True)
            self.itemInfoLabel.setText("Console:")
            self.itemEditLabel.setText("Console:")
            self.itemDataLabel.setText(info["console"])
            self.platformsInfoLabel.setVisible(False)
            self.platformsDataLabel.setVisible(False)
            self.fetchInfoButton.setEnabled(False)
            self.fetchInfoButton.setToolTip("Not available for Consoles tab")
        elif info["table"] == "accessories":
            self.genreInfoLabel.setText("Country:")
            self.genreEditLabel.setText("Country:")
            self.genreDataLabel.setText(info["country"])
            self.itemInfoLabel.setText("Accessory:")
            self.itemEditLabel.setText("Accessory:")
            self.itemDataLabel.setText(info["accessory"])
            self.codeInfoLabel.setVisible(False)
            self.codeEditLabel.setVisible(False)
            self.codeDataLabel.setVisible(False)
            self.codeDataLE.setVisible(False)
            self.platformsInfoLabel.setVisible(False)
            self.platformsDataLabel.setVisible(False)
            self.fetchInfoButton.setEnabled(False)
            self.fetchInfoButton.setToolTip("Not avaiable for Accessories tab")

    def hideDetails(self):
        self.setVisible(False)