# eric7.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

EricMainWindow

### 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.
__setTranslation | Private slot to activate a translation.
__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.
show | Public slot to show this dialog.

### Static Methods

None

#### TRPreviewer (Constructor)

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

Constructor

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

#### 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.__setTranslation

__setTranslation(index)

Private slot to activate a translation.

index (int)
  index of the selected entry

#### 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 (QCloseEvent)
  close event

#### TRPreviewer.reloadTranslations

reloadTranslations()

Public slot to reload all translations.

#### 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

None

### Class Attributes

fileName
name
translator

### Class Methods

None

### Methods

None

### Static Methods

None

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 (QComboBox)
  reference to the QComboBox used to show the available languages
parent (QWidget)
  parent widget

#### TranslationsDict.__del

__del(name)

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

name (str)
  name of the translator to delete

#### TranslationsDict.__findFileName

__findFileName(transFileName)

Private method to find a translation by file name.

transFileName (str)
  file name of the translation file

Return:
  reference to a translation object or None

Return Type:
  QTranslator

#### TranslationsDict.__findName

__findName(name)

Private method to find a translation by name.

name (str)
  name (language) of the translation

Return:
  reference to a translation object or None

Return Type:
  QTranslator

#### TranslationsDict.__haveFileName

__haveFileName(transFileName)

Private method to check for the presence of a translation.

transFileName (str)
  file name of the translation file

Return:
  flag indicating the presence of the translation

Return Type:
  bool

#### TranslationsDict.__haveName

__haveName(name)

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

name (str)
  name (language) of the translation

Return:
  flag indicating the presence of the translation

Return Type:
  bool

#### TranslationsDict.__uniqueName

__uniqueName(transFileName)

Private method to generate a unique name.

transFileName (str)
  file name of the translation file

Return:
  unique name

Return Type:
  str

#### 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 (str)
  name of the translation file to be added
setTranslation (bool)
  flag indicating, if this should be set as the active translation

#### TranslationsDict.hasTranslations

hasTranslations()

Public method to check for loaded translations.

Return:
  flag signaling if any translation was loaded

Return Type:
  bool

#### TranslationsDict.loadTransFile

loadTransFile(transFileName)

Public slot to load a translation file.

transFileName (str)
  file name of the translation file

Return:
  reference to the new translator object

Return Type:
  QTranslator

#### TranslationsDict.reload

reload()

Public method to reload all translators.

#### TranslationsDict.set

set(name)

Public slot to set a translator by name.

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

Up

## WidgetArea

Specialized MDI area to show the loaded widgets.

### Signals

lastWidgetClosed()
  emitted after the last widget was closed
rebuildWidgets()
  emitted to indicate a change of loaded widgets

### 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 (QWidget)
  parent widget

#### WidgetArea.__findWidget

__findWidget(uiFileName)

Private method to find a specific widget view.

uiFileName (str)
  filename of the loaded UI file

Return:
  reference to the widget or None

Return Type:
  WidgetView

#### WidgetArea.__toggleWidget

__toggleWidget(w)

Private method to toggle a workspace window.

w (QWidget)
  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 (QObject)
  object, that generated the event
ev (QEvent)
  the event, that was generated by object

Return:
  flag indicating if event was filtered out

Return Type:
  bool

#### WidgetArea.hasWidgets

hasWidgets()

Public method to check for loaded widgets.

Return:
  flag signaling if any widget was loaded

Return Type:
  bool

#### WidgetArea.loadWidget

loadWidget(uiFileName)

Public slot to load a UI file.

uiFileName (str)
  name of the UI file to load

#### WidgetArea.showWindowMenu

showWindowMenu(windowMenu)

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

windowMenu (QMenu)
  reference to the window menu

#### WidgetArea.toggleSelectedWidget

toggleSelectedWidget(act)

Public method to handle the toggle of a window.

act (QAction)
  reference to the action that triggered

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 (str)
  name of the UI file to load
parent (QWidget)
  parent widget
name (str)
  name of this widget

#### 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.

Return:
  flag indicating the validity

Return Type:
  bool

#### WidgetView.uiFileName

uiFileName()

Public method to retrieve the name of the UI file.

Return:
  filename of the loaded UI file

Return Type:
  str

Up