Restored Q/viewport tool code to what it was