Beispiel #1
0
    def __init__(self):
        qtgui.QMainWindow.__init__(self)
        AbstractBeeMaster.__init__(self)

        # set defaults
        settings = qtcore.QSettings("BeeDraw", "Hive")

        self.config["port"], ok = settings.value("port", 8333).toInt()
        self.config["width"], ok = settings.value("width", 600).toInt()
        self.config["height"], ok = settings.value("height", 400).toInt()
        self.config["networkhistorysize"], ok = settings.value("networkhistorysize", 20).toInt()
        self.config["password"] = settings.value("password").toString()
        self.config["autolog"] = False

        # Initialize values
        self.nextclientid = 1
        self.nextclientidmutex = qtcore.QMutex()

        self.passwordlock = qtcore.QReadWriteLock()

        # setup interface
        self.ui = Ui_HiveMasterSpec()
        self.ui.setupUi(self)
        self.show()

        # setup queues used for all thread communication
        self.routinginput = Queue(0)
        self.routingthread = HiveRoutingThread(self)
        self.routingthread.start()

        # this will be keyed on the client ids and values will be queue objects
        self.clientwriterqueues = {}
        self.socketsmap = {}

        self.readerthreads = {}
        self.writerthreads = {}

        # this dictionary will be keyed on id and map to the username
        self.clientnames = {}

        # set up client list mutex for messing with either of the above 2 dictinoaries
        self.clientslistmutex = qtcore.QReadWriteLock()

        # default value stuff that needs to be here
        self.fgcolor = qtgui.QColor(0, 0, 0)
        self.bgcolor = qtgui.QColor(255, 255, 255)

        # drawing window which holds the current state of the network session
        self.curwindow = None
        self.serverthread = None

        # restore window position
        self.restoreGeometry(settings.value("geometry").toByteArray())
        self.restoreState(settings.value("windowState").toByteArray())
Beispiel #2
0
	def __init__(self):
		# set the parent for all windows here, currently none
		self.topwinparent=None

		qtgui.QMainWindow.__init__(self)
		AbstractBeeMaster.__init__(self)

		settings=qtcore.QSettings("BeeDraw","BeeDraw")

		# set default config values
		self.config['username']=settings.value("username").toString()
		self.config['server']=settings.value("server","localhost").toString()
		self.config['port'],ok=settings.value("port",8333).toInt()
		self.config['autolog']=settings.value("autolog",False).toBool()
		self.config['autosave']=settings.value("autosave",False).toBool()
		self.config['debug']=settings.value("debug",False).toBool()
		self.config['maxundo'],ok=settings.value("maxundo",30).toInt()

		# read tool options from file if needed
		toolconfigfilename=os.path.join("config","tooloptions.xml")
		toolconfigfile=qtcore.QFile(toolconfigfilename)
		if toolconfigfile.exists():
			if toolconfigfile.open(qtcore.QIODevice.ReadOnly):
				parser=BeeToolConfigParser(toolconfigfile)
				parser.loadToToolBox(self.toolbox)

		# setup interface according to designer code
		self.ui=Ui_BeeMasterMdiSpec()
		self.ui.setupUi(self)
		self.show()

		# list to hold drawing windows and lock for it
		self.curwindow=None
		self.drawingwindows=[]
		self.drawingwindowslock=qtcore.QReadWriteLock()

		self.curpointertype=-1
		self.curtoolname=self.toolbox.getCurToolDesc().name

		self.clipboardimage=None
		self.clipboardlock=qtcore.QReadWriteLock()

		self.pointertoolmap={}
		# set some initial default values for tool pointers
		self.pointertoolmap[1]="brush"
		self.pointertoolmap[3]="eraser"

		# setup foreground and background swatches
		#self.ui.FGSwatch=FGSwatch(self,replacingwidget=self.ui.FGSwatch)
		#self.setFGColor(qtgui.QColor(0,0,0))

		#self.ui.BGSwatch=BGSwatch(self,replacingwidget=self.ui.BGSwatch)
		#self.setBGColor(qtgui.QColor(255,255,255))

		# vars for dialog windows that there should only be one of each
		self.layerswindow=BeeLayersWindow(self)

		# keep track of current ID so each window gets a unique ID
		self.nextwindowid=0

		# setup window with tool options
		self.tooloptionswindow=ToolOptionsWindow(self)
		self.tooloptionswindow.updateCurrentTool()

		self.initializedwindows=True

		# default foreground color to black and background color to white
		self.fgcolor=qtgui.QColor(0,0,0)
		self.bgcolor=qtgui.QColor(255,255,255)

		# setup window with colors
		self.palettewindow=PaletteWindow(self)

		self.toolselectwindow=ToolSelectionWindow(self)

		self.setCorner(qtcore.Qt.TopLeftCorner,qtcore.Qt.LeftDockWidgetArea)
		self.setCorner(qtcore.Qt.TopRightCorner,qtcore.Qt.RightDockWidgetArea)
		self.setCorner(qtcore.Qt.BottomLeftCorner,qtcore.Qt.LeftDockWidgetArea)
		self.setCorner(qtcore.Qt.BottomRightCorner,qtcore.Qt.RightDockWidgetArea)

		# by default have the windows docked in the main window
		self.addDockWidget(qtcore.Qt.LeftDockWidgetArea,self.toolselectwindow)
		self.addDockWidget(qtcore.Qt.LeftDockWidgetArea,self.palettewindow)
		self.addDockWidget(qtcore.Qt.RightDockWidgetArea,self.tooloptionswindow)
		self.addDockWidget(qtcore.Qt.RightDockWidgetArea,self.layerswindow)

		# restore settings
		self.restoreGeometry(settings.value("geometry").toByteArray())
		self.restoreState(settings.value("windowState").toByteArray())

		# set menu settings according to the new restored settings
		if not self.layerswindow.isVisible():
			self.uncheckWindowLayerBox()
		else:
			self.checkWindowLayerBox()

		if not self.palettewindow.isVisible():
			self.uncheckWindowPaletteBox()
		else:
			self.checkWindowPaletteBox()

		if not self.toolselectwindow.isVisible():
			self.uncheckWindowToolSelectBox()
		else:
			self.checkWindowToolSelectBox()

		if not self.tooloptionswindow.isVisible():
			self.uncheckWindowToolOptionsBox()
		else:
			self.checkWindowToolOptionsBox()