1 /* 2 This file contains the dockwidgets at the left/bottom side of txs 3 */ 4 #ifndef Header_Tool_Widget 5 #define Header_Tool_Widget 6 7 #include "mostQtHeaders.h" 8 9 #ifdef INTERNAL_TERMINAL 10 #include <qtermwidget5/qtermwidget.h> 11 #endif 12 13 #include "titledpanel.h" 14 #include "logeditor.h" 15 #include "latexlog.h" 16 #include "latexlogwidget.h" 17 #include "searchresultwidget.h" 18 19 class InternalTerminalConfig; 20 21 class PreviewWidget : public QScrollArea 22 { 23 Q_OBJECT 24 25 public: 26 explicit PreviewWidget(QWidget *parent = nullptr); 27 28 public slots: 29 void previewLatex(const QPixmap &previewImage); 30 void fitImage(bool fit); 31 void centerImage(bool center); 32 void scaleImage(double factor); 33 void zoomOut(); 34 void zoomIn(); 35 void resetZoom(); 36 void contextMenu(QPoint point); 37 38 protected: 39 void wheelEvent(QWheelEvent *event); 40 41 private: 42 QLabel *preViewer; 43 double pvscaleFactor; 44 bool mCenter; 45 bool mFit; 46 }; 47 48 #ifdef INTERNAL_TERMINAL 49 class TerminalWidget : public QWidget 50 { 51 Q_OBJECT 52 53 public: 54 explicit TerminalWidget(QWidget *parent = nullptr, InternalTerminalConfig *terminalConfig = nullptr); 55 ~TerminalWidget(); 56 void setCurrentFileName(const QString &filename); 57 void updateSettings(bool noreset=false); 58 bool eventFilter(QObject *watched, QEvent *event); 59 virtual void showEvent(QShowEvent *event); 60 private slots: 61 void qTermWidgetFinished(); 62 63 private : 64 QString curShell; 65 void initQTermWidget(); 66 QTermWidget *qTermWidget; 67 QHBoxLayout *layout; 68 InternalTerminalConfig *terminalConfig; 69 }; 70 #endif 71 72 class OutputViewWidget: public TitledPanel 73 { 74 Q_OBJECT 75 76 public: 77 explicit OutputViewWidget(QWidget *parent = nullptr, InternalTerminalConfig *terminalConfig = nullptr); 78 79 const QString MESSAGES_PAGE; 80 const QString LOG_PAGE; 81 const QString PREVIEW_PAGE; 82 const QString TERMINAL_PAGE; 83 const QString SEARCH_RESULT_PAGE; 84 getLogWidget()85 LatexLogWidget *getLogWidget() { return logWidget; } getSearchResultWidget()86 SearchResultWidget *getSearchResultWidget() { return searchResultWidget; } 87 #ifdef INTERNAL_TERMINAL getTerminalWidget()88 TerminalWidget *getTerminalWidget() { return terminalWidget; } 89 #endif 90 bool isPreviewPanelVisible(); 91 void setMessage(const QString &message); //set the message text (don't change page and no auto-show) 92 bool childHasFocus(); 93 94 virtual void changeEvent(QEvent *event); 95 96 public slots: 97 void copy(); 98 void resetMessages(bool noTabChange = false); //remove all messages and jumps to the message page (stays hidden if not visible) 99 void resetMessagesAndLog(bool noTabChange = false); 100 void selectLogEntry(int logEntryNumber, bool makeVisible = true); 101 void previewLatex(const QPixmap &pixmap); 102 103 void insertMessageLine(const QString &message); //inserts the message text (don't change page and no auto-show) 104 105 signals: 106 107 private: 108 PreviewWidget *previewWidget; 109 #ifdef INTERNAL_TERMINAL 110 TerminalWidget *terminalWidget; 111 #endif 112 LatexLogWidget *logWidget; 113 SearchResultWidget *searchResultWidget; 114 LogEditor *OutputMessages; 115 116 void retranslateUi(); 117 }; 118 119 120 /*! 121 * Subclassed TitledPanel to get a reasonable default width 122 */ 123 class SidePanel: public TitledPanel 124 { 125 Q_OBJECT 126 127 public: TitledPanel(parent)128 SidePanel(QWidget *parent = nullptr) : TitledPanel(parent) { setFrameStyle(QFrame::NoFrame); } sizeHint()129 QSize sizeHint() const { return QSize(280, 0); } 130 }; 131 132 133 class CustomWidgetList: public QWidget 134 { 135 Q_OBJECT 136 137 public: 138 CustomWidgetList(QWidget *parent = nullptr); 139 void addWidget(QWidget *widget, const QString &id, const QString &text, const QString &iconName); 140 void setWidgetText(const QString &id, const QString &text); 141 void setWidgetText(QWidget *widget, const QString &text); 142 void setWidgetIcon(const QString &id, const QString &icon); 143 void setWidgetIcon(QWidget *widget, const QString &icon); 144 int widgetCount() const; 145 void setHiddenWidgets(const QString &hidden); 146 QString hiddenWidgets() const; 147 QWidget *widget(int i) const; 148 QWidget *widget(const QString &id) const; 149 QList<QWidget *> getWidgets() const; 150 void setCurrentWidget(QWidget *widget); 151 QWidget *currentWidget() const; 152 int currentIndex() const; 153 154 signals: 155 void widgetContextMenuRequested(QWidget *widget, const QPoint &globalPosition); 156 void titleChanged(const QString &); 157 void currentWidgetChanged(QWidget* widget); 158 159 public slots: 160 void showWidgets(); 161 void setToolbarIconSize(int sz); 162 163 private slots: 164 void showPageFromAction(); 165 void toggleWidgetFromAction(bool on); 166 void customContextMenuRequested(const QPoint &localPosition); 167 void notifyChangedWidget(int index); 168 169 private: 170 void showWidget(const QString &id); 171 void hideWidget(const QString &id); 172 QString widgetId(QWidget *widget) const; 173 174 175 QStringList hiddenWidgetsIds; 176 QList<QWidget *> widgets; 177 178 //new layout 179 QStackedWidget *stack; 180 QToolBar *toolbar; 181 }; 182 183 #endif 184