
import sys

from kabaret.app.ui import gui

from .icons import gui as _  # register our icons.gui resourses
from .icons import flow as _  # register our icons.flow resourses


from kabaret.app.ui.gui.styles import Style
from qtpy import QtWidgets, QtGui


class MyStyle(Style):
    '''
    This is to show how to add a style to the app, and make it the default one.
    Beware that a style needs more than this to be readable (tabbed dock window and
    splitters need some luvin'!)

    '''

    def __init__(self):
        super(MyStyle, self).__init__('MyStyle')

    def apply(self, widget):

        app = QtWidgets.QApplication.instance()

        if widget is app:
            # setup the palette
            palette = QtWidgets.QApplication.palette()

            # A color to indicate a selected item or the current item. By default, the highlight color is Qt.darkBlue.
            palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(80, 0, 0))

            QtWidgets.QApplication.setPalette(palette)

# Uncomment this to activate MyStyle
# MyStyle() # install my style (the last installed is set as default)


class MyStudioGUISession(gui.KabaretStandaloneGUISession):

    pass


if __name__ == '__main__':
    argv = sys.argv[1:]  # get ride of first args wich is script filename
    (
        session_name,
        host, port, cluster_name,
        db_index, password,
        remaining_args
    ) = MyStudioGUISession.parse_command_line_args(argv)
    session = MyStudioGUISession(session_name=session_name)
    session.cmds.Cluster.connect(host, port, cluster_name, db_index, password)

    session.start()
    session.close()
