Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
mainwindow.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef MAINWINDOW_H
5#define MAINWINDOW_H
6
7#include "phrase.h"
8#include "ui_mainwindow.h"
9#include "recentfiles.h"
10#include "messagemodel.h"
11#include "finddialog.h"
12
13#include <QtCore/private/qconfig_p.h>
14
15#include <QtCore/QHash>
16#include <QtCore/QMap>
17#include <QtCore/QLocale>
18
19#include <QtWidgets/QMainWindow>
20
22
23class QPixmap;
24class QAction;
25class QDialog;
26class QLabel;
27class QMenu;
28class QPrinter;
29class QProcess;
30class QIcon;
31class QSortFilterProxyModel;
32class QStackedWidget;
33class QTableView;
34class QTreeView;
35
37class ErrorsView;
38class FocusWatcher;
41class MessageEditor;
42class PhraseView;
43class SourceCodeView;
44class Statistics;
45class TranslateDialog;
49
50class MainWindow : public QMainWindow
51{
53public:
56
59
60 bool openFiles(const QStringList &names);
61
62protected:
63 void readConfig();
64 void writeConfig();
65 void closeEvent(QCloseEvent *) override;
66 bool eventFilter(QObject *object, QEvent *event) override;
67
68private slots:
69 void done();
70 void doneAndNext();
71 void prev();
72 void next();
73 void recentFileActivated(QAction *action);
74 void setupRecentFilesMenu();
75 void open();
76 void openAux();
77 void saveAll();
78 void save();
79 void saveAs();
80 void releaseAll();
81 void release();
82 void releaseAs();
83 void closeFile();
84 bool closeAll();
85 void showTranslateDialog();
86 void showBatchTranslateDialog();
87 void showTranslationSettings();
88 void updateTranslateHit(bool &hit);
89 void translate(int mode);
90 void newPhraseBook();
91 void openPhraseBook();
92 void closePhraseBook(QAction *action);
93 void editPhraseBook(QAction *action);
94 void addToPhraseBook();
95 void manual();
96 void resetSorting();
97 void about();
98 void aboutQt();
99
100 void fileAboutToShow();
101 void editAboutToShow();
102
103 void showContextDock();
104 void showMessagesDock();
105 void showPhrasesDock();
106 void showSourceCodeDock();
107 void showErrorDock();
108
109 void setupPhrase();
110 bool maybeSaveAll();
111 bool maybeSave(int model);
112 void updateProgress();
113 void maybeUpdateStatistics(const MultiDataIndex &);
114 void translationChanged(const MultiDataIndex &);
115 void updateCaption();
116 void updateLatestModel(const QModelIndex &index);
117 void selectedContextChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex);
118 void selectedLabelChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex);
119 void selectedMessageChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex);
120 void setCurrentMessageFromGuess(int modelIndex, const Candidate &tm);
121 void contextAndLabelTabChanged();
122
123 // To synchronize from the message editor to the model ...
124 void updateTranslation(const QStringList &translations);
125 void updateTranslatorComment(const QString &comment);
126
127 void updateVisibleColumns();
128 void updateActiveModel(int);
129 void refreshItemViews();
130 void toggleFinished(const QModelIndex &index);
131 void openMachineTranslateDialog();
132 void prevUnfinished();
133 void nextUnfinished();
134 void findNext(const QString &text, DataModel::FindLocation where,
135 FindDialog::FindOptions options, int statusFilter);
136 void revalidate();
137 void showStatistics();
138 void toggleQmlPreview();
139 void toggleVisualizeWhitespace();
140 void onWhatsThis();
141 void updatePhraseDicts();
142 void updatePhraseDict(int model);
143
144#if QT_CONFIG(printsupport)
145 void print();
147#endif
148
149private:
150
151 friend class SortedGroupsModel;
152 QModelIndex nextGroup(const QModelIndex &index) const;
153 QModelIndex prevGroup(const QModelIndex &index) const;
154 QModelIndex firstMessage() const;
155 QModelIndex nextMessage(const QModelIndex &currentIndex, bool checkUnfinished = false) const;
156 QModelIndex prevMessage(const QModelIndex &currentIndex, bool checkUnfinished = false) const;
157 bool doNext(bool checkUnfinished);
158 bool doPrev(bool checkUnfinished);
159 void findAgain(FindDirection direction = FindNext);
160
161 void updateStatistics();
162 void initViewHeaders();
163 void modelCountChanged();
164 void setupMenuBar();
165 void setupToolBars();
166 void setCurrentMessage(const QModelIndex &index);
167 void setCurrentMessage(const QModelIndex &index, int model);
168 QModelIndex setMessageViewRoot(const QModelIndex &index);
169 QModelIndex currentMessageIndex() const;
170 PhraseBook *doOpenPhraseBook(const QString &name);
171 bool isPhraseBookOpen(const QString &name);
172 bool savePhraseBook(QString *name, PhraseBook &pb);
173 bool maybeSavePhraseBook(PhraseBook *phraseBook);
174 bool maybeSavePhraseBooks();
175 void pickTranslationFiles();
176 void doShowTranslationSettings(int model);
177 void doUpdateLatestModel(int model);
178 void updateSourceView(int model, MessageItem *item);
179 void updatePhraseBookActions();
180 void updatePhraseDictInternal(int model);
181 void releaseInternal(int model);
182 void saveInternal(int model);
183
184#if QT_CONFIG(printsupport)
185 QPrinter *printer();
186#endif
187
188 // FIXME: move to DataModel
189 void updateDanger(const MultiDataIndex &index, bool verbose);
190 void updateIcons();
191 bool searchItem(DataModel::FindLocation where, const QString &searchWhat);
192
193#if QT_CONFIG(process)
195#endif // QT_CONFIG(process)
196 QTreeView *m_contextView;
197 QTreeView *m_labelView;
198 QTreeView *m_messageView;
199 MultiDataModel *m_dataModel;
200 MessageModel *m_idBasedMessageModel;
201 MessageModel *m_textBasedMessageModel;
202 MessageModel *m_activeMessageModel;
203 QSortFilterProxyModel *m_sortedContextsModel;
204 QSortFilterProxyModel *m_sortedLabelsModel;
205 QSortFilterProxyModel *m_activeSortedGroupsModel;
206 QSortFilterProxyModel *m_sortedIdBasedMessagesModel;
207 QSortFilterProxyModel *m_sortedTextBasedMessagesModel;
208 QSortFilterProxyModel *m_activeSortedMessagesModel;
209 MessageEditor *m_messageEditor;
210 PhraseView *m_phraseView;
211 QStackedWidget *m_sourceAndFormView;
212 QTabWidget *m_contextAndLabelView;
213 SourceCodeView *m_sourceCodeView;
214 UiFormPreviewView *m_uiFormPreviewView;
215 QmlFormPreviewView *m_qmlFormPreviewView;
216 ErrorsView *m_errorsView;
217 QLabel *m_progressLabel;
218 QLabel *m_modifiedLabel;
219 FocusWatcher *m_focusWatcher;
220 QString m_phraseBookDir;
221 // model : keyword -> list of appropriate phrases in the phrasebooks
223 QList<PhraseBook *> m_phraseBooks;
224 QMap<QAction *, PhraseBook *> m_phraseBookMenu[3];
225#if QT_CONFIG(printsupport)
226 QPrinter *m_printer = nullptr;
227#endif
228
229 FindDialog *m_findDialog;
230 QString m_findText;
231 FindDialog::FindOptions m_findOptions;
232 int m_findStatusFilter = -1;
233 DataModel::FindLocation m_findWhere;
234
235 TranslateDialog *m_translateDialog;
236 QString m_latestFindText;
237 int m_latestCaseSensitivity;
238 QModelIndex m_searchIndex;
239 int m_hitCount;
240
241 BatchTranslationDialog *m_batchTranslateDialog;
242 TranslationSettingsDialog *m_translationSettingsDialog;
243
244 bool m_settingCurrentMessage;
245 std::optional<TranslationType> m_activeTranslationType;
246 int m_fileActiveModel;
247 int m_editActiveModel;
248 MultiDataIndex m_currentIndex;
249 QDockWidget *m_contextAndLabelDock;
250 QDockWidget *m_messagesDock;
251 QDockWidget *m_phrasesDock;
252 QDockWidget *m_sourceAndFormDock;
253 QDockWidget *m_errorsDock;
254
255 Ui::MainWindow m_ui; // menus and actions
256 Statistics *m_statistics;
257 RecentFiles m_recentFiles;
258 MachineTranslationDialog *m_machineTranslationDialog = 0;
259 bool m_globalReadWrite = true;
260#ifdef Q_OS_WASM
262#endif // Q_OS_WASM
263};
264
265QT_END_NAMESPACE
266
267#endif
~MainWindow() override
void writeConfig()
void closeEvent(QCloseEvent *e) override
This event handler is called with the given event when Qt receives a window close request for a top-l...
bool openFiles(const QStringList &names)
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
void readConfig()
int main(int argc, char *argv[])
[ctor_close]