Changeset View
Changeset View
Standalone View
Standalone View
addons/katebuild-plugin/plugin_katebuild.h
Show All 23 Lines | |||||
24 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 24 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
25 | ** MA 02110-1301, USA. | 25 | ** MA 02110-1301, USA. | ||
26 | */ | 26 | */ | ||
27 | 27 | | |||
28 | #include <QRegularExpression> | 28 | #include <QRegularExpression> | ||
29 | #include <QString> | 29 | #include <QString> | ||
30 | #include <QStack> | 30 | #include <QStack> | ||
31 | #include <QPointer> | 31 | #include <QPointer> | ||
32 | #include <QTimer> | ||||
32 | #include <KProcess> | 33 | #include <KProcess> | ||
33 | 34 | | |||
34 | #include <KTextEditor/MainWindow> | 35 | #include <KTextEditor/MainWindow> | ||
35 | #include <KTextEditor/Document> | 36 | #include <KTextEditor/Document> | ||
36 | #include <KTextEditor/Plugin> | 37 | #include <KTextEditor/Plugin> | ||
37 | #include <KTextEditor/View> | 38 | #include <KTextEditor/View> | ||
38 | #include <KTextEditor/SessionConfigInterface> | 39 | #include <KTextEditor/SessionConfigInterface> | ||
39 | #include <KTextEditor/Message> | 40 | #include <KTextEditor/Message> | ||
41 | #include <KTextEditor/ConfigPage> | ||||
40 | 42 | | |||
41 | #include <KXMLGUIClient> | 43 | #include <KXMLGUIClient> | ||
42 | #include <KConfigGroup> | 44 | #include <KConfigGroup> | ||
43 | 45 | | |||
44 | #include "ui_build.h" | 46 | #include "ui_build.h" | ||
47 | #include "ui_katebuild_config_page.h" | ||||
45 | #include "targets.h" | 48 | #include "targets.h" | ||
46 | 49 | | |||
47 | /******************************************************************/ | 50 | /******************************************************************/ | ||
48 | class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface | 51 | class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface | ||
49 | { | 52 | { | ||
50 | Q_OBJECT | 53 | Q_OBJECT | ||
51 | Q_INTERFACES(KTextEditor::SessionConfigInterface) | 54 | Q_INTERFACES(KTextEditor::SessionConfigInterface) | ||
52 | Q_PROPERTY(QUrl docUrl READ docUrl) | 55 | Q_PROPERTY(QUrl docUrl READ docUrl) | ||
Show All 18 Lines | 57 | public: | |||
71 | }; | 74 | }; | ||
72 | 75 | | |||
73 | KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw); | 76 | KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw); | ||
74 | ~KateBuildView() override; | 77 | ~KateBuildView() override; | ||
75 | 78 | | |||
76 | // reimplemented: read and write session config | 79 | // reimplemented: read and write session config | ||
77 | void readSessionConfig(const KConfigGroup& config) override; | 80 | void readSessionConfig(const KConfigGroup& config) override; | ||
78 | void writeSessionConfig(KConfigGroup& config) override; | 81 | void writeSessionConfig(KConfigGroup& config) override; | ||
82 | // The settings from the config page | ||||
83 | void readConfig(); | ||||
79 | 84 | | |||
80 | bool buildCurrentTarget(); | 85 | bool buildCurrentTarget(); | ||
81 | 86 | | |||
82 | QUrl docUrl(); | 87 | QUrl docUrl(); | ||
83 | 88 | | |||
84 | private Q_SLOTS: | 89 | private Q_SLOTS: | ||
85 | 90 | | |||
86 | // Building | 91 | // Building | ||
Show All 38 Lines | |||||
125 | private: | 130 | private: | ||
126 | void processLine(const QString &); | 131 | void processLine(const QString &); | ||
127 | void addError(const QString &filename, const QString &line, | 132 | void addError(const QString &filename, const QString &line, | ||
128 | const QString &column, const QString &message); | 133 | const QString &column, const QString &message); | ||
129 | bool startProcess(const QString &dir, const QString &command); | 134 | bool startProcess(const QString &dir, const QString &command); | ||
130 | bool checkLocal(const QUrl &dir); | 135 | bool checkLocal(const QUrl &dir); | ||
131 | void clearBuildResults(); | 136 | void clearBuildResults(); | ||
132 | 137 | | |||
133 | void displayBuildResult(const QString &message, KTextEditor::Message::MessageType level); | 138 | /** | ||
139 | * Display a user information on the current active view. | ||||
140 | * @parm message the text to show | ||||
141 | * @parm type the message type | ||||
142 | * @parm autoHideDelay the time the message will be shown. When 0 is the | ||||
143 | * delay set to a sane default, when -1 is auto hide disabled | ||||
144 | * @parm updateOnly when true will an already shown message text updated | ||||
145 | * to @p message and the parameter @p type and @p autoHideDelay | ||||
146 | * will be ignored. Should there no old message exist will a new | ||||
147 | * message created with respect of all arguments | ||||
148 | * | ||||
149 | * @see KTextEditor::message | ||||
150 | */ | ||||
151 | void postMessage(const QString &message, KTextEditor::Message::MessageType type, int autoHideDelay = 0, bool updateOnly = false); | ||||
134 | 152 | | |||
135 | KTextEditor::MainWindow *m_win; | 153 | KTextEditor::MainWindow *m_win; | ||
136 | QWidget *m_toolView; | 154 | QWidget *m_toolView; | ||
137 | Ui::build m_buildUi; | 155 | Ui::build m_buildUi; | ||
138 | QWidget *m_buildWidget; | 156 | QWidget *m_buildWidget; | ||
139 | int m_outputWidgetWidth; | 157 | int m_outputWidgetWidth; | ||
140 | TargetsUi *m_targetsUi; | 158 | TargetsUi *m_targetsUi; | ||
141 | KProcess m_proc; | 159 | KProcess m_proc; | ||
142 | QString m_stdOut; | 160 | QString m_stdOut; | ||
143 | QString m_stdErr; | 161 | QString m_stdErr; | ||
144 | QString m_currentlyBuildingTarget; | 162 | QString m_currentlyBuildingTarget; | ||
163 | int m_hideViewOnSuccess = 0; //!< Hide view when > 0 | ||||
164 | bool m_troubleOnLastRun = false; //!< Hide view when true | ||||
145 | bool m_buildCancelled; | 165 | bool m_buildCancelled; | ||
146 | int m_displayModeBeforeBuild; | 166 | int m_displayModeBeforeBuild; | ||
147 | QString m_make_dir; | 167 | QString m_make_dir; | ||
148 | QStack<QString> m_make_dir_stack; | 168 | QStack<QString> m_make_dir_stack; | ||
149 | QRegularExpression m_filenameDetector; | 169 | QRegularExpression m_filenameDetector; | ||
150 | QRegularExpression m_filenameDetectorIcpc; | 170 | QRegularExpression m_filenameDetectorIcpc; | ||
151 | bool m_filenameDetectorGccWorked; | 171 | bool m_filenameDetectorGccWorked; | ||
152 | QRegularExpression m_newDirDetector; | 172 | QRegularExpression m_newDirDetector; | ||
153 | unsigned int m_numErrors; | 173 | unsigned int m_numErrors; | ||
154 | unsigned int m_numWarnings; | 174 | unsigned int m_numWarnings; | ||
155 | QString m_prevItemContent; | 175 | QString m_prevItemContent; | ||
156 | QModelIndex m_previousIndex; | 176 | QModelIndex m_previousIndex; | ||
157 | QPointer<KTextEditor::Message> m_infoMessage; | 177 | QPointer<KTextEditor::Message> m_infoMessage; | ||
158 | 178 | QTimer m_progressLimiter; //!< Single shot, as long running, don't update progess info | |||
sars: use QElapsedTimer in stead of a QTimer.
start() the timer in the constructor and when a… | |||||
159 | | ||||
160 | /** | | |||
161 | * current project plugin view, if any | | |||
162 | */ | | |||
163 | QObject *m_projectPluginView = nullptr; | 179 | QObject *m_projectPluginView = nullptr; | ||
180 | | ||||
181 | // Config Page Settings | ||||
182 | bool m_isSetAutoHide = false; | ||||
183 | bool m_isSetNoToolTip = false; | ||||
184 | bool m_isSetNoPopUp = false; | ||||
164 | }; | 185 | }; | ||
165 | 186 | | |||
166 | 187 | | |||
167 | typedef QList<QVariant> VariantList; | 188 | typedef QList<QVariant> VariantList; | ||
168 | 189 | | |||
169 | /******************************************************************/ | 190 | /******************************************************************/ | ||
170 | class KateBuildPlugin : public KTextEditor::Plugin | 191 | class KateBuildPlugin : public KTextEditor::Plugin | ||
171 | { | 192 | { | ||
172 | Q_OBJECT | 193 | Q_OBJECT | ||
173 | 194 | | |||
174 | public: | 195 | public: | ||
175 | explicit KateBuildPlugin(QObject* parent = nullptr, const VariantList& = VariantList()); | 196 | explicit KateBuildPlugin(QObject* parent = nullptr, const VariantList& = VariantList()); | ||
176 | ~KateBuildPlugin() override {} | 197 | ~KateBuildPlugin() override {} | ||
177 | 198 | | |||
178 | QObject *createView(KTextEditor::MainWindow *mainWindow) override; | 199 | QObject *createView(KTextEditor::MainWindow *mainWindow) override; | ||
200 | int configPages() const override; | ||||
201 | KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; | ||||
202 | void readConfig(); | ||||
203 | | ||||
204 | private: | ||||
205 | QVector<KateBuildView*> m_views; // FIXME Only to track config page changes, do all this smarter! | ||||
206 | }; | ||||
207 | | ||||
208 | //BEGIN ConfigPage | ||||
209 | class KateBuildPluginConfigPage : public KTextEditor::ConfigPage | ||||
210 | , private Ui::ConfigPage | ||||
211 | { | ||||
212 | Q_OBJECT | ||||
213 | | ||||
214 | public: | ||||
215 | explicit KateBuildPluginConfigPage(QWidget *parent, KateBuildPlugin *plugin); | ||||
216 | ~KateBuildPluginConfigPage() override; | ||||
217 | | ||||
218 | QString name() const override; | ||||
219 | QString fullName() const override; | ||||
220 | QIcon icon() const override; | ||||
221 | | ||||
222 | void apply() override; | ||||
223 | void reset() override { loadSettings(); } | ||||
224 | void defaults() override { ; } | ||||
225 | | ||||
226 | void loadSettings(); | ||||
227 | | ||||
228 | private Q_SLOTS: | ||||
229 | void modified(); | ||||
230 | | ||||
231 | private: | ||||
232 | bool m_modified = false; | ||||
233 | KateBuildPlugin *m_plugin; | ||||
234 | | ||||
179 | }; | 235 | }; | ||
236 | //END ConfigPage | ||||
180 | 237 | | |||
181 | #endif | 238 | #endif | ||
182 | 239 | |
use QElapsedTimer in stead of a QTimer.
start() the timer in the constructor and when a message is to be displayed check eapsed() and start() the timer again when the message is displayed.