# eric6.Tools.TRPreviewer

Module implementing the TR Previewer main window.

### Global Attributes

noTranslationName

### Classes

TRPreviewer | Class implementing the UI Previewer main window.
Translation | Class to store the properties of a translation.
TranslationsDict | Class to store all loaded translations.
WidgetArea | Specialized MDI area to show the loaded widgets.
WidgetView | Class to show a dynamically loaded widget (or dialog).

### Functions

None

## TRPreviewer

Class implementing the UI Previewer main window.

### Derived from

E5MainWindow

### Class Attributes

None

### Class Methods

None

### Methods

TRPreviewer | Constructor
__about | Private slot to show the about information.
__aboutQt | Private slot to show info about Qt.
__initActions | Private method to define the user interface actions.
__initMenus | Private method to create the menus.
__initToolbars | Private method to create the toolbars.
__openTranslation | Private slot to handle the Open Translation action.
__openWidget | Private slot to handle the Open Dialog action.
__showWindowMenu | Private slot to handle the aboutToShow signal of the window menu.
__updateActions | Private slot to update the actions state.
__whatsThis | Private slot called in to enter Whats This mode.
closeEvent | Protected event handler for the close event.
reloadTranslations | Public slot to reload all translations.
setTranslation | Public slot to activate a translation.
show | Public slot to show this dialog.

### Static Methods

None

#### TRPreviewer (Constructor)

TRPreviewer(filenames=None, parent=None, name=None)

Constructor

filenames
  filenames of form and/or translation files to load
parent
  parent widget of this window (QWidget)
name
  name of this window (string)

#### TRPreviewer.__about

__about()

Private slot to show the about information.

#### TRPreviewer.__aboutQt

__aboutQt()

Private slot to show info about Qt.

#### TRPreviewer.__initActions

__initActions()

Private method to define the user interface actions.

#### TRPreviewer.__initMenus

__initMenus()

Private method to create the menus.

#### TRPreviewer.__initToolbars

__initToolbars()

Private method to create the toolbars.

#### TRPreviewer.__openTranslation

__openTranslation()

Private slot to handle the Open Translation action.

#### TRPreviewer.__openWidget

__openWidget()

Private slot to handle the Open Dialog action.

#### TRPreviewer.__showWindowMenu

__showWindowMenu()

Private slot to handle the aboutToShow signal of the window menu.

#### TRPreviewer.__updateActions

__updateActions()

Private slot to update the actions state.

#### TRPreviewer.__whatsThis

__whatsThis()

Private slot called in to enter Whats This mode.

#### TRPreviewer.closeEvent

closeEvent(event)

Protected event handler for the close event.

event
  close event (QCloseEvent)

#### TRPreviewer.reloadTranslations

reloadTranslations()

Public slot to reload all translations.

#### TRPreviewer.setTranslation

setTranslation(name)

Public slot to activate a translation.

name
  name (language) of the translation (string)

#### TRPreviewer.show

show()

Public slot to show this dialog.

This overloaded slot loads a UI file to be previewed after the main window has been shown. This way, previewing a dialog doesn't interfere with showing the main window.

Up

## Translation

Class to store the properties of a translation.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

Translation | Constructor

### Static Methods

None

#### Translation (Constructor)

Translation()

Constructor

Up

## TranslationsDict

Class to store all loaded translations.

### Signals

translationChanged()
  emit after a translator was set

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

TranslationsDict | Constructor
__del | Private method to delete a translator from the list of available translators.
__findFileName | Private method to find a translation by file name.
__findName | Private method to find a translation by name.
__haveFileName | Private method to check for the presence of a translation.
__haveName | Private method to check for the presence of a named translation.
__uniqueName | Private method to generate a unique name.
add | Public method to add a translation to the list.
hasTranslations | Public method to check for loaded translations.
loadTransFile | Public slot to load a translation file.
reload | Public method to reload all translators.
set | Public slot to set a translator by name.

### Static Methods

None

#### TranslationsDict (Constructor)

TranslationsDict(selector, parent)

Constructor

selector
  reference to the QComboBox used to show the available languages (QComboBox)
parent
  parent widget (QWidget)

#### TranslationsDict.__del

__del(name)

Private method to delete a translator from the list of available translators.

name
  name of the translator to delete (string)

#### TranslationsDict.__findFileName

__findFileName(transFileName)

Private method to find a translation by file name.

transFileName
  file name of the translation file (string)

Returns:
  reference to a translation object or None

#### TranslationsDict.__findName

__findName(name)

Private method to find a translation by name.

name
  name (language) of the translation (string)

Returns:
  reference to a translation object or None

#### TranslationsDict.__haveFileName

__haveFileName(transFileName)

Private method to check for the presence of a translation.

transFileName
  file name of the translation file (string)

Returns:
  flag indicating the presence of the translation (boolean)

#### TranslationsDict.__haveName

__haveName(name)

Private method to check for the presence of a named translation.

name
  name (language) of the translation (string)

Returns:
  flag indicating the presence of the translation (boolean)

#### TranslationsDict.__uniqueName

__uniqueName(transFileName)

Private method to generate a unique name.

transFileName
  file name of the translation file (string)

Returns:
  unique name (string or None)

#### TranslationsDict.add

add(fileName, setTranslation=True)

Public method to add a translation to the list.

If the translation file (*.qm) has not been loaded yet, it will be loaded automatically.

fileName
  name of the translation file to be added (string)
setTranslation
  flag indicating, if this should be set as the active translation (boolean)

#### TranslationsDict.hasTranslations

hasTranslations()

Public method to check for loaded translations.

Returns:
  flag signaling if any translation was loaded (boolean)

#### TranslationsDict.loadTransFile

loadTransFile(transFileName)

Public slot to load a translation file.

transFileName
  file name of the translation file (string)

Returns:
  reference to the new translator object (QTranslator)

#### TranslationsDict.reload

reload()

Public method to reload all translators.

#### TranslationsDict.set

set(name)

Public slot to set a translator by name.

name
  name (language) of the translator to set (string)

Up

## WidgetArea

Specialized MDI area to show the loaded widgets.

### Signals

lastWidgetClosed()
  emitted after last widget was closed

### Derived from

QMdiArea

### Class Attributes

None

### Class Methods

None

### Methods

WidgetArea | Constructor
__findWidget | Private method to find a specific widget view.
__toggleWidget | Private method to toggle a workspace window.
closeAllWidgets | Public slot to close all windows.
closeWidget | Public slot to close the active window.
eventFilter | Public method called to filter an event.
hasWidgets | Public method to check for loaded widgets.
loadWidget | Public slot to load a UI file.
showWindowMenu | Public method to set up the widgets part of the Window menu.
toggleSelectedWidget | Public method to handle the toggle of a window.

### Static Methods

None

#### WidgetArea (Constructor)

WidgetArea(parent=None)

Constructor

parent
  parent widget (QWidget)

#### WidgetArea.__findWidget

__findWidget(uiFileName)

Private method to find a specific widget view.

uiFileName
  filename of the loaded UI file (string)

Returns:
  reference to the widget (WidgetView) or None

#### WidgetArea.__toggleWidget

__toggleWidget(w)

Private method to toggle a workspace window.

w
  window to be toggled

#### WidgetArea.closeAllWidgets

closeAllWidgets()

Public slot to close all windows.

#### WidgetArea.closeWidget

closeWidget()

Public slot to close the active window.

#### WidgetArea.eventFilter

eventFilter(obj, ev)

Public method called to filter an event.

obj
  object, that generated the event (QObject)
ev
  the event, that was generated by object (QEvent)

Returns:
  flag indicating if event was filtered out

#### WidgetArea.hasWidgets

hasWidgets()

Public method to check for loaded widgets.

Returns:
  flag signaling if any widget was loaded (boolean)

#### WidgetArea.loadWidget

loadWidget(uiFileName)

Public slot to load a UI file.

uiFileName
  name of the UI file to load (string)

#### WidgetArea.showWindowMenu

showWindowMenu(windowMenu)

Public method to set up the widgets part of the Window menu.

windowMenu
  reference to the window menu

#### WidgetArea.toggleSelectedWidget

toggleSelectedWidget(act)

Public method to handle the toggle of a window.

act
  reference to the action that triggered (QAction)

Up

## WidgetView

Class to show a dynamically loaded widget (or dialog).

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

WidgetView | Constructor
__rebuildWidget | Private method to schedule a rebuild of the widget.
buildWidget | Public slot to load a UI file.
isValid | Public method to return the validity of this widget view.
uiFileName | Public method to retrieve the name of the UI file.

### Static Methods

None

#### WidgetView (Constructor)

WidgetView(uiFileName, parent=None, name=None)

Constructor

uiFileName
  name of the UI file to load (string)
parent
  parent widget (QWidget)
name
  name of this widget (string)

#### WidgetView.__rebuildWidget

__rebuildWidget()

Private method to schedule a rebuild of the widget.

#### WidgetView.buildWidget

buildWidget()

Public slot to load a UI file.

#### WidgetView.isValid

isValid()

Public method to return the validity of this widget view.

Returns:
  flag indicating the validity (boolean)

#### WidgetView.uiFileName

uiFileName()

Public method to retrieve the name of the UI file.

Returns:
  filename of the loaded UI file (string)

Up