1 /************************************************************************ 2 ** 3 ** Copyright (C) 2015-2021 Kevin B. Hendricks, Stratford, Ontario, Canada 4 ** Copyright (C) 2012-2015 John Schember <john@nachtimwald.com> 5 ** Copyright (C) 2012 Dave Heiland 6 ** Copyright (C) 2009-2011 Strahinja Markovic <strahinja.markovic@gmail.com> 7 ** 8 ** This file is part of Sigil. 9 ** 10 ** Sigil is free software: you can redistribute it and/or modify 11 ** it under the terms of the GNU General Public License as published by 12 ** the Free Software Foundation, either version 3 of the License, or 13 ** (at your option) any later version. 14 ** 15 ** Sigil is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with Sigil. If not, see <http://www.gnu.org/licenses/>. 22 ** 23 *************************************************************************/ 24 25 #pragma once 26 #ifndef SIGIL_H 27 #define SIGIL_H 28 29 #include <QtCore/QSharedPointer> 30 #include <QtWidgets/QMainWindow> 31 32 #include "ui_main.h" 33 #include "BookManipulation/Book.h" 34 #include "BookManipulation/BookReports.h" 35 #include "Dialogs/ClipboardHistorySelector.h" 36 #include "Dialogs/IndexEditor.h" 37 #include "Dialogs/Reports.h" 38 #include "Dialogs/SpellcheckEditor.h" 39 #include "Dialogs/ViewImage.h" 40 #include "MainUI/FindReplace.h" 41 #include "MainUI/TOCModel.h" 42 #include "Parsers/CSSInfo.h" 43 #include "Misc/PasteTarget.h" 44 #include "Misc/SettingsStore.h" 45 #include "Misc/ValidationResult.h" 46 #include "MiscEditors/ClipEditorModel.h" 47 #include "MiscEditors/IndexEditorModel.h" 48 #include "MiscEditors/SearchEditorModel.h" 49 #include "Tabs/ContentTab.h" 50 #include "ViewEditors/ElementIndex.h" 51 52 const int MAX_RECENT_FILES = 5; 53 const int STATUSBAR_MSG_DISPLAY_TIME = 7000; 54 55 class QComboBox; 56 class QLabel; 57 class QSignalMapper; 58 class QSlider; 59 class QTimer; 60 class QActionGroup; 61 class FindReplace; 62 class TabManager; 63 class BookBrowser; 64 class TableOfContents; 65 class ValidationResultsView; 66 class PreviewWindow; 67 class SearchEditor; 68 class ClipEditor; 69 class ClipsWindow; 70 class SelectCharacter; 71 class ViewImage; 72 class FlowTab; 73 74 75 /** 76 * @mainpage 77 * The conversion of all source comments to Doxygen format 78 * is in progress. Some files have been converted, others have not. 79 * 80 * Be patient. 81 */ 82 83 84 /** 85 * The main window of the application. 86 * Presents the main user interface with menus, toolbars, editing panes 87 * and side panes like the Book Browser. 88 * 89 * This window is the main entry point to all functionality. 90 */ 91 class MainWindow : public QMainWindow 92 { 93 Q_OBJECT 94 95 public: 96 97 /** 98 * Constructor. 99 * 100 * @param openfilepath The path to the file that the window 101 * should load (new file loaded if empty). 102 * @param parent The window's parent object. 103 * @param flags The flags used to modify window behavior. 104 */ 105 MainWindow(const QString &openfilepath = QString(), 106 const QString version = QString(), 107 bool is_internal = false, 108 QWidget *parent = 0, 109 Qt::WindowFlags flags = Qt::WindowFlags()); 110 111 ~MainWindow(); 112 113 void maybe_fixup_dockwidget_geometry(QDockWidget * widget); 114 115 // returns true if MainWindow is Maximized or is FullScreen 116 bool isMaxOrFull(); 117 118 /** 119 * The book currently being edited. 120 * 121 * @return A shared pointer to the book. 122 */ 123 QSharedPointer<Book> GetCurrentBook(); 124 125 126 /** 127 * get BookBrowser for this book 128 * 129 * @return A pointer to the BookBrowser 130 */ 131 BookBrowser *GetBookBrowser(); 132 133 134 /** 135 * Returns a reference to the current content tab. 136 * 137 * @return A reference to the current content tab. 138 */ 139 ContentTab *GetCurrentContentTab(); 140 141 FlowTab *GetCurrentFlowTab(); 142 143 /** 144 * Returns a list of valid selected HTML resources 145 * 146 * @return List of valid selected HTML resources 147 */ 148 QList <Resource *> GetValidSelectedHTMLResources(); 149 QList <Resource *> GetValidSelectedCSSResources(); 150 151 QList <Resource *> GetTabbedHTMLResources(); 152 QList <Resource *> GetTabbedCSSResources(); 153 154 /** 155 * Returns a list of all HTML resources in book browser order 156 * 157 * @return List of all HTML resources in book browser order 158 */ 159 QList <Resource *> GetAllHTMLResources(); 160 QList <Resource *> GetAllCSSResources(); 161 162 QList <Resource *> GetOPFResource(); 163 QList <Resource *> GetNCXResource(); 164 165 /** 166 * Select resources in the Book Browser 167 * 168 */ 169 void SelectResources(QList<Resource *> resources); 170 171 /** 172 * The location of the last bookmark. 173 */ 174 struct LocationBookmark { 175 QString bookpath; 176 QString bv_caret_location_update; 177 int cv_cursor_position; 178 }; 179 180 void CloseAllTabs(); 181 182 void SaveTabData(); 183 184 SearchEditorModel *GetSearchEditorModel(); 185 186 /** 187 * Returns a map with keys being extensions of file types 188 * we can load, and the values being filters for use in file dialogs. 189 * 190 * @return The load dialog filters. 191 */ 192 static const QMap<QString, QString> GetLoadFiltersMap(); 193 194 /** 195 * Loads a book from the file specified. 196 * 197 * @param fullfilepath The path to the file to load. 198 */ 199 bool LoadFile(const QString &fullfilepath, bool is_internal = false); 200 201 void SetValidationResults(const QList<ValidationResult> &results); 202 203 static void clearMemoryCaches(); 204 205 /** 206 * Handle warning the user about undefined url fragments when splitting/merging resources. 207 */ 208 bool ProceedWithUndefinedUrlFragments(); 209 210 void sizeMenuIcons(); 211 212 QString GetCurrentFilePath(); 213 214 void DebugCurrentWidgetSizes(); 215 GetMathJaxFolder()216 QString GetMathJaxFolder() { return m_mathjaxfolder; }; 217 218 219 public slots: 220 221 bool Automate(const QStringList &commands); 222 223 void OpenUrl(const QUrl &url); 224 225 void ScrollCVToFragment(const QString &fragment); 226 227 /** 228 * Opens the specified resource in the specified view state. 229 */ 230 void OpenResource(Resource *resource, 231 int line_to_scroll_to = -1, 232 int position_to_scroll_to = -1, 233 const QString &caret_location_to_scroll_to = QString(), 234 const QUrl &fragment = QUrl(), 235 bool precede_current_tab = false); 236 237 void OpenResourceAndWaitUntilLoaded(Resource *resource, 238 int line_to_scroll_to = -1, 239 int position_to_scroll_to = -1, 240 const QString &caret_location_to_scroll_to = QString(), 241 const QUrl &fragment = QUrl(), 242 bool precede_current_tab = false); 243 244 bool UpdateManifestProperties(); 245 246 bool GenerateNCXGuideFromNav(); 247 248 bool RemoveNCXGuideFromEpub3(); 249 250 void CreateIndex(); 251 252 void runPlugin(QAction *action); 253 254 void ResourcesAddedOrDeletedOrMoved(); 255 256 void launchExternalXEditor(); 257 258 bool RepoCommit(); 259 void RepoCheckout(QString bookid="", QString destpath="", QString filename="", bool loadnow=true); 260 void RepoDiff(QString bookid=""); 261 void RepoManage(); 262 263 void RunAutomate1(); 264 void RunAutomate2(); 265 void RunAutomate3(); 266 void RunAutomate(const QString &automatefile); 267 268 void EditAutomate1(); 269 void EditAutomate2(); 270 void EditAutomate3(); 271 void EditAutomate(const QString &automatefile); 272 273 bool StandardizeEpub(); 274 275 void CreateEpubLayout(); 276 277 signals: 278 void SettingsChanged(); 279 280 protected: 281 void showEvent(QShowEvent *event); 282 283 void changeEvent(QEvent * event); 284 285 /** 286 * Workaround for Qt 4.8 bug, which does not save/restore window state 287 * correctly if maximized at the time of calling saveGeometry(). 288 */ 289 void moveEvent(QMoveEvent *event); 290 void resizeEvent(QResizeEvent *event); 291 292 /** 293 * Overrides the closeEvent handler so we can check 294 * for saved status before actually closing. 295 * 296 * @param event The close event. 297 */ 298 void closeEvent(QCloseEvent *event); 299 300 private slots: 301 302 void UpdateLastSizes(); 303 304 void RestoreLastNormalGeometry(); 305 306 bool AddCover(); 307 308 309 /** 310 * Implements New action functionality. 311 */ 312 void New(const QString version = QString()); 313 void NewDefault(); 314 void NewEpub2(); 315 void NewEpub3(); 316 317 /** 318 * Implements Open action functionality. 319 */ 320 void Open(); 321 322 /** 323 * Implements Open recent file action functionality. 324 */ 325 void OpenRecentFile(); 326 327 /** 328 * Implements Save action functionality. 329 */ 330 bool Save(); 331 332 /** 333 * Implements Save As action functionality. 334 */ 335 bool SaveAs(); 336 337 /** 338 * Implements Save A Copy action functionality. 339 */ 340 bool SaveACopy(); 341 342 void Exit(); 343 344 void ShowMessageOnStatusBar(const QString &message = "", int millisecond_duration = STATUSBAR_MSG_DISPLAY_TIME); 345 346 void ShowLastOpenFileWarnings(); 347 348 /** 349 * Implements Find action functionality. 350 */ 351 void Find(); 352 353 /** 354 * Implements Go To Line action functionality. 355 */ 356 void GoToLine(); 357 358 /** 359 * Implements Zoom In action functionality. 360 */ 361 void ZoomIn(); 362 363 /** 364 * Implements Zoom Out action functionality. 365 */ 366 void ZoomOut(); 367 368 /** 369 * Implements Zoom Reset action functionality. 370 */ 371 void ZoomReset(); 372 373 void IndexEditorDialog(IndexEditorModel::indexEntry *index_entry = NULL); 374 void SpellcheckEditorDialog(); 375 376 void ReportsDialog(); 377 378 bool DeleteCSSStyles(const QString &filename, QList<CSSInfo::CSSSelector *> css_selectors); 379 380 bool DeleteUnusedMedia(bool in_automate = false); 381 bool DeleteUnusedStyles(bool in_automate = false); 382 383 void InsertFileDialog(); 384 385 void InsertSpecialCharacter(); 386 387 void InsertId(); 388 389 void InsertHyperlink(); 390 391 void MarkForIndex(); 392 393 /** 394 * Track the last active control that had focus in the MainWindow that 395 * is a valid PasteTarget. 396 */ 397 void ApplicationFocusChanged(QWidget *old, QWidget *now); 398 399 void ApplicationPaletteChanged(); 400 401 /** 402 * Quick Launch Plugins via icon button 403 */ 404 void QuickLaunchPlugin(int i); 405 406 /** 407 * Some controls (CodeView and combo boxes in F&R) inherit PasteTarget 408 * to allow various modeless/popup dialogs like Clipboard History, Clip Editor and 409 * Insert Special Characters to insert text into the focused "PasteTarget" control. 410 * These two slots will delegate the relevant signal to the current target if any. 411 */ 412 void PasteTextIntoCurrentTarget(const QString &text); 413 void PasteClipEntriesIntoCurrentTarget(const QList<ClipEditorModel::clipEntry *> &clips); 414 void PasteClipEntriesIntoPreviousTarget(const QList<ClipEditorModel::clipEntry *> &clips); 415 void PasteClipIntoCurrentTarget(int clip_number); 416 417 /** 418 * Implements the set CodeView functionality. 419 */ 420 void CodeView(); 421 422 /** 423 * Implements Meta Editor action functionality. 424 */ 425 void MetaEditorDialog(); 426 427 /** 428 * Implements Search Editor Dialog functionality. 429 */ 430 void SearchEditorDialog(SearchEditorModel::searchEntry *search_entry = NULL); 431 432 void ClipEditorDialog(ClipEditorModel::clipEntry *clip_entry = NULL); 433 434 /** 435 * Implements User Guide action functionality. 436 */ 437 void UserGuide(); 438 439 /** 440 * Implements Donate action functionality. 441 */ 442 void Donate(); 443 444 /** 445 * Implements Sigil Website action functionality. 446 */ 447 void SigilWebsite(); 448 449 /** 450 * Implements About action functionality. 451 */ 452 void AboutDialog(); 453 454 /** 455 * Implements Preferences action functionality. 456 */ 457 void PreferencesDialog(); 458 459 460 /** 461 * Implements Preferences action functionality. 462 */ 463 void ManagePluginsDialog(); 464 465 /** 466 * Implements Validate Epub action functionality. 467 */ 468 bool WellFormedCheckEpub(); 469 470 bool ValidateStylesheetsWithW3C(); 471 472 bool ReformatAllStylesheets(bool multiple_line_format); 473 474 bool CharLessThan(const QChar &s1, const QChar &s2); 475 476 /** 477 * Disconnects all signals to the old tab 478 * and reconnects them to the new tab when the 479 * current tab is changed. 480 * 481 * @old_tab The tab that was previously in use. 482 * @new_tab The tab that is becoming current. 483 */ 484 void ChangeSignalsWhenTabChanges(ContentTab *old_tab, ContentTab *new_tab); 485 486 /** 487 * Updates the toolbars/menus based on current state 488 * and updates the tab state if requested 489 */ 490 void UpdateMWState(bool set_tab_state = true); 491 492 /** 493 * Updates the toolbars based on current tab state and changes. 494 */ 495 void UpdateUIOnTabChanges(); 496 497 /** 498 * Updates the menus based on the number of tabs open. 499 */ 500 void UpdateUIOnTabCountChange(); 501 502 /** 503 * Performs needed changes when the user switches tabs. 504 */ 505 void UpdateUIWhenTabsSwitch(); 506 507 /** 508 * Set initial state for actions in Code View 509 */ 510 void SetStateActionsCodeView(); 511 512 /** 513 * Set initial state for actions in CSS files 514 */ 515 void SetStateActionsCSSView(); 516 517 /** 518 * Set initial state for actions in Raw View 519 */ 520 void SetStateActionsRawView(); 521 522 /** 523 * Set initial state for actions in Static View 524 * (everything dead, used for viewing images etc.) 525 */ 526 void SetStateActionsStaticView(); 527 528 void UpdatePreviewRequest(); 529 void UpdatePreviewCSSRequest(); 530 void ScrollPreview(); 531 void UpdatePreview(); 532 void InspectHTML(); 533 534 /** 535 * Updates the cursor postion label to refelect the position of the 536 * cursor within the text. 537 * 538 * Use a negative value to to denote an unknown or invalid value. 539 * 540 * @param line The line the currsor is currently at. 541 * @param column The column within the line that the cursor is currently at. 542 */ 543 void UpdateCursorPositionLabel(int line, int column); 544 545 /** 546 * Zooms the current view with the new zoom slider value. 547 * 548 * @param slider_value The new value from the zoom slider. 549 */ 550 void SliderZoom(int slider_value); 551 552 /** 553 * Updates the zoom slider to reflect the new zoom factor. 554 * 555 * @new_zoom_factor The new zoom factor. 556 */ 557 void UpdateZoomSlider(float new_zoom_factor); 558 559 /** 560 * Updates the zoom label to reflect the state of the zoom slider. 561 * This is needed so the user can see to what zoom value the slider 562 * is being dragged to. 563 * 564 * @param slider_value The new value from the zoom slider. 565 */ 566 void UpdateZoomLabel(int slider_value); 567 568 /** 569 * Updates the zoom label to reflect the new zoom factor. 570 */ 571 void UpdateZoomLabel(float new_zoom_factor); 572 573 /** 574 * Creates a new tab from the section splitting operation. 575 * 576 * @param content The content of the "old" tab/resource. 577 * @param originating_resource The original resource from which the content 578 * was extracted to create the "old" tab/resource. 579 * @see FlowTab::SplitSection, FlowTab::OldTabRequest, 580 * Book::CreateSectionBreakOriginalResource 581 */ 582 void CreateSectionBreakOldTab(QString content, HTMLResource *originating_resource); 583 584 585 /** 586 * Updates the selection/highlight in the Book Browser to the resource in the current tab 587 * 588 * @see BookBrowser::UpdateSelection 589 */ 590 void UpdateBrowserSelectionToTab(); 591 592 /** 593 * Creates new section/XHTML documents. 594 */ 595 bool SplitOnSGFSectionMarkers(); 596 597 void SetAutoSpellCheck(bool new_state); 598 599 /** 600 * Reformats all the book's html resources using Book.cpp's ReformatAllHTML() function. 601 */ 602 bool MendPrettifyHTML(); 603 bool MendHTML(); 604 605 void ClearIgnoredWords(); 606 607 void RefreshSpellingHighlighting(); 608 609 void MergeResources(QList <Resource *> resources); 610 611 void LinkStylesheetsToResources(QList <Resource *> resources); 612 613 void LinkJavascriptsToResources(QList <Resource *> resources); 614 615 void ResourceUpdatedFromDisk(Resource *resource); 616 617 void UpdateWord(QString old_word, QString new_word); 618 void FindWord(QString word); 619 620 /** 621 * Return a map of stylesheets included/excluded for all given resources 622 */ 623 QList<std::pair<QString, bool>> GetStylesheetsMap(QList<Resource *> resources); 624 625 /** 626 * Return the list of stylesheets linked to the given resource 627 */ 628 QStringList GetStylesheetsAlreadyLinked(Resource *resource); 629 630 QList<std::pair<QString, bool>> GetJavascriptsMap(QList<Resource *> resources); 631 QStringList GetJavascriptsAlreadyLinked(Resource *resource); 632 633 634 void RemoveResources(QList<Resource *> resources = QList<Resource *>()); 635 636 bool GenerateTOC(bool skip_selector = false); 637 bool CreateHTMLTOC(); 638 void EditTOCDialog(); 639 640 void ChangeCasing(QAction* act); 641 642 void MarkSelection(); 643 void ClearMarkedText(ContentTab *old_tab = NULL); 644 645 void ApplyHeadingStyleToTab(QAction* act); 646 void SetPreserveHeadingAttributes(bool new_state); 647 648 void GoBackFromLinkOrStyle(); 649 void GoToBookmark(LocationBookmark *locationBookmark); 650 651 void GoToLinkedStyleDefinition(const QString &element_name, const QString &style_class_name); 652 653 void ViewImageDialog(const QUrl &url); 654 655 void BookmarkLocation(); 656 void BookmarkLinkOrStyleLocation(); 657 658 void GoToPreviewLocation(); 659 660 void ShowPasteClipboardHistoryDialog(); 661 662 void SetInsertedFileWatchResourceFile(const QString &pathname); 663 664 void DeleteReportsStyles(QList<BookReports::StyleData *> reports_styles_to_delete); 665 666 void DeleteFilenames(QStringList files_to_delete); 667 668 void OpenFile(QString file_bookpath, int line = -1, int position = -1); 669 670 void UpdateClipsUI(); 671 672 /** 673 * support for plugins 674 */ 675 void loadPluginsMenu(); 676 void unloadPluginsMenu(); 677 678 private: 679 void createJumpList(); 680 void updateToolTipsOnPluginIcons(); 681 void UpdateClipButton(QAction *ui_action); 682 void InsertFiles(const QStringList &selected_images); 683 void InsertFilesFromDisk(); 684 685 void ResetLinkOrStyleBookmark(); 686 void ResetLocationBookmark(LocationBookmark *locationBookmark); 687 688 /** 689 * Reads all the stored application settings like 690 * window position, geometry etc. 691 */ 692 void ReadSettings(); 693 694 /** 695 * Writes all the stored application settings like 696 * window position, geometry etc. 697 */ 698 void WriteSettings(); 699 700 /** 701 * Gets called on possible saves and asks the user 702 * does he want to save. 703 * If the user chooses SAVE, we save and continue 704 * If the user chooses DISCARD, we don't save and continue 705 * If the user chooses CANCEL, we don't save and stop what we were doing 706 * 707 * @return \c true if we are allowed to proceed with the current operation. 708 */ 709 bool MaybeSaveDialogSaysProceed(); 710 711 bool ProceedToOverwrite(const QString &msg, const QString &filename ); 712 713 /** 714 * Makes the provided book the current one. 715 * 716 * @param new_book The new book for editing. 717 */ 718 void SetNewBook(QSharedPointer<Book> new_book); 719 720 /** 721 * Creates a new, empty book and replaces 722 * the current one with it. 723 */ 724 void CreateNewBook(const QString version=QString(), const QStringList &book_paths=QStringList()); 725 726 /** 727 * Saves the current book to the file specified. 728 * 729 * @param fullfilepath The path to save to. 730 */ 731 bool SaveFile(const QString &fullfilepath, bool update_current_filename = true); 732 733 /** 734 * Performs zoom operations in the views using the default 735 * zoom step. Setting zoom_in to \c true zooms the views *in*, 736 * and a setting of \c false zooms them *out*. The zoom value 737 * is first wrapped to the nearest zoom step (relative to the zoom direction). 738 * 739 * @param zoom_in If \c true, zooming in. Otherwise zooming out. 740 */ 741 void ZoomByStep(bool zoom_in); 742 743 /** 744 * Sets the provided zoom factor on the active view editor. 745 * Valid values are between ZOOM_MAX and ZOOM_MIN, others are ignored. 746 * 747 * @param new_zoom_factor The new zoom factor for the view. 748 */ 749 void ZoomByFactor(float new_zoom_factor); 750 751 /** 752 * Converts a zoom factor to a value in the zoom slider range. 753 * 754 * @param zoom_factor The zoom factor being converted. 755 * @return The converted slider range value. 756 */ 757 static int ZoomFactorToSliderRange(float zoom_factor); 758 759 /** 760 * Converts a value in the zoom slider range to a zoom factor. 761 * 762 * @param slider_range_value The slider range value being converted. 763 * @return The converted zoom factor value. 764 */ 765 static float SliderRangeToZoomFactor(int slider_range_value); 766 767 float GetZoomFactor(); 768 769 /** 770 * Returns a map with keys being extensions of file types 771 * we can save, and the values being filters for use in file dialogs. 772 * 773 * @return The save dialog filters. 774 */ 775 static const QMap<QString, QString> GetSaveFiltersMap(); 776 777 /** 778 * Sets the current file in the window title and also 779 * updates the recent files list. 780 * 781 * @param fullfilepath The path to the currently edited file. 782 */ 783 void UpdateUiWithCurrentFile(const QString &fullfilepath, bool just_name = false); 784 785 /** 786 * Selects the appropriate entry in the heading combo box 787 * based on the provided name of the element. 788 * 789 * @param element_name The name of the currently selected element. 790 */ 791 void SelectEntryOnHeadingToolbar(const QString &element_name); 792 793 /** 794 * Creates and adds the recent files actions 795 * to the File menu. 796 */ 797 void CreateRecentFilesActions(); 798 799 /** 800 * Updates the recent files actions when the 801 * list of files to be listed has changed. 802 */ 803 void UpdateRecentFileActions(); 804 805 /** 806 * Performs specific changes based on the OS platform. 807 */ 808 void PlatformSpecificTweaks(); 809 810 /** 811 * Tweak default UI fonts based on the OS platform. 812 */ 813 void SetupUiFont(); 814 815 /** 816 * Extends the UI with extra widgets and tweaks. 817 * Qt Designer is not able to create all the widgets 818 * we want in the MainWindow, so we use this function 819 * to extend the UI created by the Designer. 820 */ 821 void ExtendUI(); 822 823 /** 824 * Extends all the icons with 16px versions. 825 * The prevents the use of automatic, blurry, scaled 826 * down versions that Qt creates. 827 */ 828 void ExtendIconSizes(); 829 830 /** 831 * Loads the initial file provided to the MainWindow on creation. 832 * If a file was provided to be loaded with this main window instance, 833 * that file is loaded; if not, or it can't be opened, an empty file 834 * is loaded. 835 * 836 * @param openfilepath The path to the file to load. Can be empty. 837 */ 838 void LoadInitialFile(const QString &openfilepath, const QString version=QString(), bool is_internal = false); 839 840 /** 841 * Connects all the required signals to their slots. 842 */ 843 void ConnectSignalsToSlots(); 844 845 /** 846 * Connects all the UI signals to the provided tab. 847 * 848 * @param tab The tab to connect the signals. 849 */ 850 void MakeTabConnections(ContentTab *tab); 851 852 /** 853 * Disconnects all the UI signals from the provided tab. 854 * 855 * @param tab The tab from which to disconnect the signals. 856 */ 857 void BreakTabConnections(ContentTab *tab); 858 859 void SetupPreviewTimer(); 860 861 void FixDuplicateFilenames(); 862 void MoveContentFilesToStdFolders(); 863 864 /////////////////////////////// 865 // PRIVATE MEMBER VARIABLES 866 /////////////////////////////// 867 868 /** 869 * Warning messages to be displayed to the user after opening a book 870 * if non-fatal errors occurred during loading. When Sigil is started 871 * with a filename on command line, we must store these for display 872 * after the UI main window is visible. 873 */ 874 QStringList m_LastOpenFileWarnings; 875 bool m_IsInitialLoad; 876 877 /** 878 * The path to the current file loaded. 879 */ 880 QString m_CurrentFilePath; 881 882 /** 883 * The name of the current file loaded. 884 */ 885 QString m_CurrentFileName; 886 887 /** 888 * The book currently being worked on. 889 */ 890 QSharedPointer<Book> m_Book; 891 892 /** 893 * The last folder from which the user opened or saved a file. 894 */ 895 QString m_LastFolderOpen; 896 897 /** 898 * The last filename used for Save As Copy 899 */ 900 QString m_SaveACopyFilename; 901 902 /** 903 * The last file selected from Insert File, per book 904 */ 905 QString m_LastInsertedFile; 906 907 /** 908 * The list of full filepaths 909 * for the last MAX_RECENT_FILES files. 910 * \c static because on Mac we have many MainWindows 911 */ 912 static QStringList s_RecentFiles; 913 914 /** 915 * Array of recent files actions that are in the File menu. 916 */ 917 QAction *m_RecentFileActions[ MAX_RECENT_FILES ]; 918 919 /** 920 * The tab managing object. 921 */ 922 TabManager *m_TabManager; 923 924 /** 925 * The Book Browser pane that lists all the files in the book. 926 */ 927 BookBrowser *m_BookBrowser; 928 929 ClipsWindow *m_Clips; 930 931 /** 932 * The find / replace widget. 933 */ 934 935 FindReplace *m_FindReplace; 936 937 /** 938 * The Table of Contents pane that displays a rendered view of the NCX. 939 */ 940 TableOfContents *m_TableOfContents; 941 942 /** 943 * The Validation Results pane that lists all the validation problems. 944 */ 945 ValidationResultsView *m_ValidationResultsView; 946 947 PreviewWindow *m_PreviewWindow; 948 949 /** 950 * The lable that displays the cursor position. 951 * Line and column. 952 */ 953 QLabel *m_lbCursorPosition; 954 955 /** 956 * The slider which the user can use to zoom. 957 */ 958 QSlider *m_slZoomSlider; 959 960 /** 961 * The label that displays the current zoom factor. 962 */ 963 QLabel *m_lbZoomLabel; 964 965 /** 966 * A map with keys being extensions of file types 967 * we can load, and the values being filters for use in file dialogs. 968 */ 969 const QMap<QString, QString> c_SaveFilters; 970 971 /** 972 * A map with keys being extensions of file types 973 * we can save, and the values being filters for use in file dialogs. 974 */ 975 const QMap<QString, QString> c_LoadFilters; 976 977 /** 978 * Collects signals and sends specific parameters to the connected slots. 979 */ 980 QActionGroup *m_casingChangeGroup; 981 982 /** 983 * The Search Manager dialog 984 */ 985 SearchEditor *m_SearchEditor; 986 987 /** 988 * The storage for SearchEditor 989 */ 990 SearchEditorModel *m_SearchEditorModel; 991 992 ClipEditor *m_ClipEditor; 993 994 IndexEditor *m_IndexEditor; 995 SpellcheckEditor *m_SpellcheckEditor; 996 997 SelectCharacter *m_SelectCharacter; 998 999 ViewImage *m_ViewImage; 1000 1001 Reports *m_Reports; 1002 1003 bool m_preserveHeadingAttributes; 1004 1005 LocationBookmark *m_LinkOrStyleBookmark; 1006 1007 ClipboardHistorySelector *m_ClipboardHistorySelector; 1008 int m_ClipboardHistoryLimit; 1009 1010 /** 1011 * The last widget in this window that had focus that inherited PasteTarget. 1012 */ 1013 PasteTarget *m_LastPasteTarget; 1014 1015 bool m_ZoomPreview; 1016 1017 /** 1018 * Workaround for Qt 4.8 bug, to track the last known window size when not maximized. 1019 */ 1020 QByteArray m_LastWindowSize; 1021 QByteArray m_LastState; 1022 bool m_FirstTime; 1023 bool m_PendingLastSizeUpdate; 1024 bool m_SaveLastEnabled; 1025 1026 QTimer m_PreviewTimer; 1027 1028 HTMLResource *m_PreviousHTMLResource; 1029 QString m_PreviousHTMLText; 1030 QList<ElementIndex> m_PreviousHTMLLocation; 1031 1032 /** 1033 * dynamically updated plugin menus and actions 1034 */ 1035 QMenu *m_menuPlugins; 1036 QMenu *m_menuPluginsInput; 1037 QMenu *m_menuPluginsOutput; 1038 QMenu *m_menuPluginsEdit; 1039 QMenu *m_menuPluginsValidation; 1040 QAction *m_actionManagePlugins; 1041 1042 QStringList m_pluginList; 1043 bool m_SaveCSS; 1044 bool m_IsClosing; 1045 1046 QList<QAction*> m_qlactions; 1047 1048 QList<QAction*> m_clactions; 1049 1050 1051 /** 1052 * Collects signals and sends specific parameters to the connected slots. 1053 */ 1054 QActionGroup *m_headingActionGroup; 1055 1056 QString m_mathjaxfolder; 1057 1058 bool m_FRVisible; 1059 1060 bool m_UsingAutomate; 1061 QStringList m_AutomateLog; 1062 1063 /** 1064 * Holds all the widgets Qt Designer created for us. 1065 */ 1066 Ui::MainWindow ui; 1067 }; 1068 1069 #endif // SIGIL_H 1070 1071 1072