Script hosting base class. More...
#include <basegui.h>
Public Slots | |
| virtual boost::shared_ptr < pdfobjects::CPdf > | getBasePdfInstance (const QString &filename, const QString &openMode=QString::null, bool askPassword=true) |
| void | processEvents () |
| QString | askPassword (const QString &title=QString::null) |
| void | setItemText (const QString &name, const QString &newText) |
| QString | getItemText (const QString &name) |
| void | about () |
| void | addAnnotation (QSPage *page, double x1, double y1, double w, double h) |
| void | addAnnotation (QObject *page, double x1, double y1, double w, double h) |
| void | addObjectDialog (QSIProperty *container=NULL) |
| void | addObjectDialog (QObject *container) |
| void | checkItem (const QString &name, bool check) |
| void | clearConsole () |
| void | closeAll () |
| bool | closeFile (bool askSave, bool onlyAsk=false) |
| void | createMenuItem (const QString &parentName, const QString &name, const QString &caption, const QString &action, const QString &accel=QString::null, const QString &icon=QString::null, const QStringList &classes=QStringList()) |
| void | createNewWindow () |
| void | enableItem (const QString &name, bool enable) |
| QString | filename () |
| QString | fileOpenDialog () |
| QString | fileSaveDialog (const QString &oldName=QString::null) |
| QString | fileSaveDialogDiffer (const QString &origName) |
| QString | fileSaveDialogXml (const QString &oldName=QString::null) |
| QVariant | getColor (const QString &colorName) |
| QString | getEditText (const QString &textName) |
| double | getNumber (const QString &name) |
| void | help (const QString &topic=QString::null) |
| bool | isVisible (const QString &widgetName) |
| void | message (const QString &msg) |
| QVariant | mergeDialog () |
| QVariant | selectPagesDialog (const QString &filename) const |
| bool | modified () |
| bool | openFile (const QString &name, bool askPassword=true) |
| void | openFileNew (const QString &name) |
| void | options () |
| QSPage * | page () |
| int | pageNumber () |
| QVariant | pickColor () |
| QSMenu * | popupMenu (const QString &menuName=QString::null) |
| bool | question (const QString &msg) |
| int | question_ync (const QString &msg) |
| void | restoreWindowState () |
| bool | save () |
| bool | saveCopy (const QString &name) |
| bool | saveRevision () |
| void | saveWindowState () |
| void | setColor (const QString &colorName, const QVariant &newColor) |
| void | setEditText (const QString &textName, const QString &newText) |
| void | setNumber (const QString &name, double number) |
| void | setPredefs (const QString &name, const QString &predefs) |
| void | setTooltip (const QString &name, const QString &tip) |
| void | setPredefs (const QString &name, const QStringList &predefs) |
| void | setRevision (int revision) |
| void | setVisible (const QString &widgetName, bool visible) |
| void | showItem (const QString &name, bool show) |
| QSTreeItem * | treeRoot () |
| QSTreeItem * | treeRootMain () |
| void | warn (const QString &str) |
| QSTreeItem * | firstSelectedItem (const QString &name=QString::null) |
| QSTreeItem * | nextSelectedItem () |
| QSCObject * | firstSelected (const QString &name=QString::null) |
| QSCObject * | nextSelected () |
| QProgressBar * | progressBar () |
| double | convertPixmapPosToPdfPos_x (double fromX, double fromY) |
| double | convertPixmapPosToPdfPos_y (double fromX, double fromY) |
| double | convertPdfPosToPixmapPos_x (double fromX, double fromY) |
| double | convertPdfPosToPixmapPos_y (double fromX, double fromY) |
Public Member Functions | |
| BaseGUI (PdfEditWindow *parent) | |
| virtual | ~BaseGUI () |
| void | runInitScript () |
| void | addColorTool (ColorTool *tool) |
| void | addEditTool (EditTool *tool) |
| void | addSelectTool (SelectTool *tool) |
| void | addNumberTool (NumberTool *tool) |
| void | treeItemDeleted (TreeItemAbstract *theItem) |
Protected Member Functions | |
| virtual void | addScriptingObjects () |
| virtual void | removeScriptingObjects () |
| virtual void | preRun (const QString &script, bool callback=false) |
| virtual void | postRun () |
Private Slots | |
| void | toolChangeValue (const QString &toolName) |
Private Member Functions | |
| QWidget * | getWidgetByName (const QString &widgetName) |
Private Attributes | |
| ConsoleWriterGui * | consoleWriter |
| PdfEditWindow * | w |
| QMap< QString, ColorTool * > | colorPickers |
| QMap< QString, EditTool * > | editTools |
| QMap< QString, NumberTool * > | numberTools |
| QMap< QString, SelectTool * > | selectTools |
Script hosting base class.
Class that host scripts and contain static script functions
This class is also responsible for garbage collection of scripting objects and interaction of editor and scripts
| gui::BaseGUI::BaseGUI | ( | PdfEditWindow * | parent | ) |
Create new Base class
| parent | Parent editor window containing this class |
| gui::BaseGUI::~BaseGUI | ( | ) | [virtual] |
destructor
References gui::PdfEditWindow::cmdLine, gui::PdfEditWindow::pagespc, and w.
| void gui::BaseGUI::about | ( | ) | [slot] |
Shows "About" window
| void gui::BaseGUI::addAnnotation | ( | QObject * | page, | |
| double | x1, | |||
| double | y1, | |||
| double | w, | |||
| double | h | |||
| ) | [slot] |
Invoke dialog for adding annotation to page
| page | Page in which the annotation will be added | |
| x1 | X coordinate of the annotation rectangle lower left point | |
| y1 | Y coordinate of the annotation rectangle lower left point | |
| w | Width of annotation rectangle | |
| h | Height of annotation rectangle |
| void gui::BaseGUI::addAnnotation | ( | QSPage * | page, | |
| double | x1, | |||
| double | y1, | |||
| double | w, | |||
| double | h | |||
| ) | [slot] |
Invoke dialog for adding annotation to page
| page | Page in which the annotation will be added | |
| x1 | X coordinate of the annotation rectangle lower left point | |
| y1 | Y coordinate of the annotation rectangle lower left point | |
| w | Width of annotation rectangle | |
| h | Height of annotation rectangle |
| void gui::BaseGUI::addColorTool | ( | ColorTool * | tool | ) |
Add color selection tool to list of "known color selection tools"
| tool | Tool to add |
Referenced by gui::PdfEditWindow::addNumberTool().
| void gui::BaseGUI::addEditTool | ( | EditTool * | tool | ) |
Add edit tool to list of "known edit tools"
| tool | Tool to add |
Referenced by gui::PdfEditWindow::addSelectTool().
| void gui::BaseGUI::addNumberTool | ( | NumberTool * | tool | ) |
Add number tool to list of "known number tools"
| tool | Tool to add |
Referenced by gui::PdfEditWindow::menuActivated().
| void gui::BaseGUI::addObjectDialog | ( | QObject * | container | ) | [slot] |
Show dialog for adding objects into given container.
Container must be Dict or Array, otherwise the dialog is not created. If Container is NULL, currently selected object ihn property editor will be attempted to use as container..
After creating, dialog is shown and usable and this function immediately returns.
| container | Dict or Array into which objects will be added |
| void gui::BaseGUI::addObjectDialog | ( | QSIProperty * | container = NULL |
) | [slot] |
Show dialog for adding objects into given container.
Container must be Dict or Array, otherwise the dialog is not created. If Container is NULL, currently selected object ihn property editor will be attempted to use as container..
After creating, dialog is shown and usable and this function immediately returns.
| container | Dict or Array into which objects will be added |
| void gui::BaseGUI::addScriptingObjects | ( | ) | [protected, virtual] |
Create objects that should be available to scripting from current CPdf and related objects
Reimplemented from gui::BaseCore.
| void gui::BaseGUI::addSelectTool | ( | SelectTool * | tool | ) |
Add select tool to list of "known select tools"
| tool | Tool to add |
| QString gui::BaseGUI::askPassword | ( | const QString & | title = QString::null |
) | [slot] |
Shows dialog that will ask user for password.
| title | Title of the dialog. If not specified, some default like "Enter password" is used. |
| void gui::BaseGUI::checkItem | ( | const QString & | name, | |
| bool | check | |||
| ) | [slot] |
Check or uncheck item in toolbar and/or menu, given its name
Note: Toolbuttons will automatically convert to Togglable toolbuttons this way and will start togling itself automatically on each succesive click
| name | Name of item | |
| check | True to check, false to uncheck |
References gui::PasswordDialog::ask().
| void gui::BaseGUI::clearConsole | ( | ) | [slot] |
Clear the console output window
| void gui::BaseGUI::closeAll | ( | ) | [slot] |
application exit handler invoked when "Quit" is selected in menu/toolbar/etc ...
| bool gui::BaseGUI::closeFile | ( | bool | askSave, | |
| bool | onlyAsk = false | |||
| ) | [slot] |
Closes file currently opened in editor.
| askSave | Ask about saving changes? | |
| onlyAsk | Only ask about closing/saving work, do not actually close file |
| double gui::BaseGUI::convertPdfPosToPixmapPos_x | ( | double | fromX, | |
| double | fromY | |||
| ) | [slot] |
Function return X position on viewed page from position in pdf page (apply rotation, viewing dpi, ...)
| fromX | X position in pdf page. | |
| fromY | Y position in pdf page. |
| double gui::BaseGUI::convertPdfPosToPixmapPos_y | ( | double | fromX, | |
| double | fromY | |||
| ) | [slot] |
Function return Y position on viewed page from position in pdf page (apply rotation, viewing dpi, ...)
| fromX | X position in pdf page. | |
| fromY | Y position in pdf page. |
| double gui::BaseGUI::convertPixmapPosToPdfPos_x | ( | double | fromX, | |
| double | fromY | |||
| ) | [slot] |
Function return X position in pdf page from position of viewed page on screen (unapply rotation, viewing dpi, ...)
| fromX | X position on viewed page. | |
| fromY | Y position on viewed page. |
| double gui::BaseGUI::convertPixmapPosToPdfPos_y | ( | double | fromX, | |
| double | fromY | |||
| ) | [slot] |
Function return Y position in pdf page from position of viewed page on screen (unapply rotation, viewing dpi, ...)
| fromX | X position on viewed page. | |
| fromY | Y position on viewed page. |
| void gui::BaseGUI::createMenuItem | ( | const QString & | parentName, | |
| const QString & | name, | |||
| const QString & | caption, | |||
| const QString & | action, | |||
| const QString & | accel = QString::null, |
|||
| const QString & | icon = QString::null, |
|||
| const QStringList & | classes = QStringList() | |||
| ) | [slot] |
Load one menu or toolbar item and insert it into parent menu or toolbar. If inserting into toolbar and name refers to special toobar item, that item is inserted and rest of parameters are ignored
| parentName | Name of parent menu/toolbar. If NULL/empty, main menubar is the parent | |
| name | Name of the item. Have to be unique. ("" or "-" will insert separator and ignore rest of parameters) | |
| caption | Caption of item | |
| action | Script to execute when the item is selected | |
| accel | Keyboard Accelerator | |
| icon | Name of icon | |
| classes | Item classes |
| void gui::BaseGUI::createNewWindow | ( | ) | [slot] |
create new empty editor window and display it
| void gui::BaseGUI::enableItem | ( | const QString & | name, | |
| bool | enable | |||
| ) | [slot] |
Enable or disable item in toolbar and/or menu, given its name
| name | Name of item | |
| enable | True to enable, false to disable |
| QString gui::BaseGUI::filename | ( | ) | [slot] |
Return name of file loaded in editor. Return empty string if the document have no name (if it is not loaded from disk and have not yet been saved)
| QString gui::BaseGUI::fileOpenDialog | ( | ) | [slot] |
Show "open file" dialog and return file selected, or NULL if dialog was cancelled
| QString gui::BaseGUI::fileSaveDialog | ( | const QString & | oldName = QString::null |
) | [slot] |
Show "save file" dialog and return file selected, or NULL if dialog was cancelled
| oldName | Old name of the file (if known) - will be preselected |
| QString gui::BaseGUI::fileSaveDialogDiffer | ( | const QString & | origName | ) | [slot] |
Show "save file" dialog and return file selected, or NULL if dialog was cancelled Name must be different than origName
| origName | Original name of the file |
| QString gui::BaseGUI::fileSaveDialogXml | ( | const QString & | oldName = QString::null |
) | [slot] |
Show "save file" dialog and return file selected, or NULL if dialog was cancelled
| oldName | Old name of the file (if known) - will be preselected |
| QSCObject * gui::BaseGUI::firstSelected | ( | const QString & | name = QString::null |
) | [slot] |
Return object held in first selected tree item from specified tree Return NULL, if no item is selected
| name | Name of tree to get selection from |
| QSTreeItem * gui::BaseGUI::firstSelectedItem | ( | const QString & | name = QString::null |
) | [slot] |
Return first selected tree item from specified tree Return NULL, if no item is selected
| name | Name of tree to get selection from |
| boost::shared_ptr< pdfobjects::CPdf > gui::BaseGUI::getBasePdfInstance | ( | const QString & | filename, | |
| const QString & | openMode = QString::null, |
|||
| bool | askPassword = true | |||
| ) | [virtual, slot] |
Open PDF instance. Specific password solicitation (GUI, console) should be implemented in subclasses - BaseGUI ands BaseConsole
| filename | filename to open | |
| openMode | Mode in which to open the file (advanced, readonly and readwrite - default) | |
| askPassword | if true, attempt to ask user for password would be made if document is encrypted |
Reimplemented from gui::Base.
| QVariant gui::BaseGUI::getColor | ( | const QString & | colorName | ) | [slot] |
Get color from color picker with given name
| colorName | Name of color picker |
| QString gui::BaseGUI::getEditText | ( | const QString & | textName | ) | [slot] |
Get text from text edit box or select text box with given name
| textName | Name of text edit box |
| QString gui::BaseGUI::getItemText | ( | const QString & | name | ) | [slot] |
Given name of toolbar or menu item, return its text This will return original (untranslated) text (in english) Setting it back with setTextByName will translate it according to the translation file
| name | Name of the item |
| double gui::BaseGUI::getNumber | ( | const QString & | name | ) | [slot] |
Get number from number edit box with given name
| name | Name of edit box |
| QWidget * gui::BaseGUI::getWidgetByName | ( | const QString & | widgetName | ) | [private] |
For given name return widget represented by that name
| widgetName | Widget name |
| void gui::BaseGUI::help | ( | const QString & | topic = QString::null |
) | [slot] |
Invokes program help. Optional parameter is topic - if invalid or not defined, help title page will be invoked
| topic | Starting help topic |
| bool gui::BaseGUI::isVisible | ( | const QString & | widgetName | ) | [slot] |
Check if a widget is visible
| widgetName | name of widget |
| QVariant gui::BaseGUI::mergeDialog | ( | ) | [slot] |
Brings up "merge documents" dialog and return the results
Result is array of three elements: First element is array with page numbers Second element is array with page positions Third is filename of the document to be merged in
| void gui::BaseGUI::message | ( | const QString & | msg | ) | [slot] |
Brings up informational messagebox with given message
| msg | Message to display |
| bool gui::BaseGUI::modified | ( | ) | [slot] |
Check whether currently opened document was modified since it was opened or last saved
| QSCObject * gui::BaseGUI::nextSelected | ( | ) | [slot] |
Return object held in next selected tree item from specified tree Return NULL, if no next item is selected
| QSTreeItem * gui::BaseGUI::nextSelectedItem | ( | ) | [slot] |
Return next selected tree item from specified tree Return NULL, if no next item is selected
| bool gui::BaseGUI::openFile | ( | const QString & | name, | |
| bool | askPassword = true | |||
| ) | [slot] |
Open file in editor.
| name | Name of file to open | |
| askPassword | Ask user directly for password? If not, password have to be set other ways if necessary (via script for example) |
| void gui::BaseGUI::openFileNew | ( | const QString & | name | ) | [slot] |
Open file in a new editor window.
| name | Name of file to open |
| void gui::BaseGUI::options | ( | ) | [slot] |
Show options dialog. Does not wait for dialog to finish.
| QSPage * gui::BaseGUI::page | ( | ) | [slot] |
Return currently shown page
| int gui::BaseGUI::pageNumber | ( | ) | [slot] |
Return number of currently shown page
| QVariant gui::BaseGUI::pickColor | ( | ) | [slot] |
Invoke dialog to select color. Last selected color is remembered and offered as default next time. The 'initial default color' is red
| QSMenu * gui::BaseGUI::popupMenu | ( | const QString & | menuName = QString::null |
) | [slot] |
Create and return new popup menu, build from menu list/item identified by this name. If no item specified, menu is initially empty
| menuName | Name of menu inconfiguration to use as template |
| void gui::BaseGUI::postRun | ( | ) | [protected, virtual] |
Function to be run after the script is executed
Reimplemented from gui::BaseCore.
| void gui::BaseGUI::preRun | ( | const QString & | script, | |
| bool | callback = false | |||
| ) | [protected, virtual] |
Function to be run before the script is executed
| script | Script code; | |
| callback | is it callback from script? |
Reimplemented from gui::BaseCore.
| void gui::BaseGUI::processEvents | ( | ) | [slot] |
Call QApplication::processEvents, to process any events (redrawing, etc) May be useful if you perform some lengthy operation to allow GUI to redraw
| QProgressBar * gui::BaseGUI::progressBar | ( | ) | [slot] |
Returns progress bar which can be used to provide visualization of progress. Uses common progress bar from PdfEditWindow class. User should keep in mind, that also someone alse can use this progress bar in same time and he should set total steps before each setProgress method.
| bool gui::BaseGUI::question | ( | const QString & | msg | ) | [slot] |
Asks question with Yes/No answer. "Yes" is default. Return true if user selected "yes", false if user selected "no"
| msg | Question to display |
| int gui::BaseGUI::question_ync | ( | const QString & | msg | ) | [slot] |
Asks question with Yes/No/Cancel answer. "Yes" is default.
Return one of these three according to user selection:
Yes : return 1
No : return 0
Cancel : return -1
| msg | Question to display |
| void gui::BaseGUI::removeScriptingObjects | ( | ) | [protected, virtual] |
Removes objects added with addScriptingObjects
Reimplemented from gui::BaseCore.
References gui::BaseCore::treeReloadFlag.
| void gui::BaseGUI::restoreWindowState | ( | ) | [slot] |
Restores window state from application settings
| void gui::BaseGUI::runInitScript | ( | ) |
Run all initscripts. Gets name of initscripts from settings
| bool gui::BaseGUI::save | ( | ) | [slot] |
Save currently edited document to disk
| bool gui::BaseGUI::saveCopy | ( | const QString & | name | ) | [slot] |
Save currently edited document to disk, using provided filename
| name | New filename to save document under |
| bool gui::BaseGUI::saveRevision | ( | ) | [slot] |
Save currently edited document to disk, while creating a new revisiion
| void gui::BaseGUI::saveWindowState | ( | ) | [slot] |
Saves window state to application settings
| QVariant gui::BaseGUI::selectPagesDialog | ( | const QString & | filename | ) | const [slot] |
Bring up "select pages" dialog.
| void gui::BaseGUI::setColor | ( | const QString & | colorName, | |
| const QVariant & | newColor | |||
| ) | [slot] |
Set color of color picker with given name
| colorName | Name of color picker | |
| newColor | New color to set |
| void gui::BaseGUI::setEditText | ( | const QString & | textName, | |
| const QString & | newText | |||
| ) | [slot] |
Set text of text edit box with given name
| textName | Name of text edit box | |
| newText | New text to set |
| void gui::BaseGUI::setItemText | ( | const QString & | name, | |
| const QString & | newText | |||
| ) | [slot] |
Set text on toolbar or menu item with given name. If both text and menu item exist with same name, both are updated. Note: the text wilol be translated according to the translation file, so english text should be used and any translation should be put into the translation file
| name | Name of the item | |
| newText | text on the item |
| void gui::BaseGUI::setNumber | ( | const QString & | name, | |
| double | number | |||
| ) | [slot] |
Set number in number edit box with given name
| name | Name of edit box | |
| number | New number to set |
| void gui::BaseGUI::setPredefs | ( | const QString & | name, | |
| const QStringList & | predefs | |||
| ) | [slot] |
Set predefined values to choose from for number edit box or select text box with given name. For number edit box, the user is still able to type its own numbers.
| name | Name of edit box | |
| predefs | List of predefined numbers, separated with commas |
| void gui::BaseGUI::setPredefs | ( | const QString & | name, | |
| const QString & | predefs | |||
| ) | [slot] |
Set predefined values to choose from for number edit box or select text box with given name. For number edit box, the user is still able to type its own numbers.
| name | Name of edit box | |
| predefs | List of predefined numbers, separated with commas |
| void gui::BaseGUI::setRevision | ( | int | revision | ) | [slot] |
Change active revision in current PDF document
| revision | number of revision to activate |
| void gui::BaseGUI::setTooltip | ( | const QString & | name, | |
| const QString & | tip | |||
| ) | [slot] |
Set tooltip for specified number edit box or select text box with given name.
| name | Name of edit box | |
| tip | text used as tooltip |
| void gui::BaseGUI::setVisible | ( | const QString & | widgetName, | |
| bool | visible | |||
| ) | [slot] |
Set widget to be either visible or invisible
| widgetName | name of widget | |
| visible | action to be performed (true = show, false = hide) |
| void gui::BaseGUI::showItem | ( | const QString & | name, | |
| bool | show | |||
| ) | [slot] |
Show or hide item in toolbar, given its name.
Items in menu can't be show or hidden this way
| name | Name of item | |
| show | True to show, false to hide |
| void gui::BaseGUI::toolChangeValue | ( | const QString & | toolName | ) | [private, slot] |
Slot called when any of tools (color tool, edit tool, etc ...) change it's value
| toolName | Name of the tool affected |
| void gui::BaseGUI::treeItemDeleted | ( | TreeItemAbstract * | theItem | ) |
Callback from main window when the treeitem got just deleted This will look for script wrappers containing the mentioned item and invalidate them, so they will not cause a crash
| theItem | deleted tree item |
| QSTreeItem * gui::BaseGUI::treeRoot | ( | ) | [slot] |
Return root item of currently selected tree
| QSTreeItem * gui::BaseGUI::treeRootMain | ( | ) | [slot] |
Return root item of main tree
| void gui::BaseGUI::warn | ( | const QString & | str | ) | [slot] |
Show this string as a warning in a messagebox and also print it to console, followed by newline
| str | String to use as warning |
QMap<QString,ColorTool*> gui::BaseGUI::colorPickers [private] |
Map with color picker tools
ConsoleWriterGui* gui::BaseGUI::consoleWriter [private] |
Console writer class writing to command window
QMap<QString,EditTool*> gui::BaseGUI::editTools [private] |
Map with edit tools
QMap<QString,NumberTool*> gui::BaseGUI::numberTools [private] |
Map with number tools
QMap<QString,SelectTool*> gui::BaseGUI::selectTools [private] |
Map with select tools
PdfEditWindow* gui::BaseGUI::w [private] |
Editor window in which this class exist
Referenced by ~BaseGUI().