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;
39class FormPreviewView;
40class MessageEditor;
41class PhraseView;
42class SourceCodeView;
43class Statistics;
44class TranslateDialog;
46
47class MainWindow : public QMainWindow
48{
50public:
53
56
57 bool openFiles(const QStringList &names, bool readWrite = true);
58 static RecentFiles &recentFiles();
59 static QString friendlyString(const QString &str);
60
61public slots:
62 void updateViewMenu();
63
64protected:
65 void readConfig();
66 void writeConfig();
67 void closeEvent(QCloseEvent *) override;
68 bool eventFilter(QObject *object, QEvent *event) override;
69
70private slots:
71 void done();
72 void doneAndNext();
73 void prev();
74 void next();
75 void recentFileActivated(QAction *action);
76 void setupRecentFilesMenu();
77 void open();
78 void openAux();
79 void saveAll();
80 void save();
81 void saveAs();
82 void releaseAll();
83 void release();
84 void releaseAs();
85 void closeFile();
86 bool closeAll();
87 void showTranslateDialog();
88 void showBatchTranslateDialog();
89 void showTranslationSettings();
90 void updateTranslateHit(bool &hit);
91 void translate(int mode);
92 void newPhraseBook();
93 void openPhraseBook();
94 void closePhraseBook(QAction *action);
95 void editPhraseBook(QAction *action);
96 void addToPhraseBook();
97 void manual();
98 void resetSorting();
99 void about();
100 void aboutQt();
101
102 void fileAboutToShow();
103 void editAboutToShow();
104
105 void showContextDock();
106 void showMessagesDock();
107 void showPhrasesDock();
108 void showSourceCodeDock();
109 void showErrorDock();
110
111 void setupPhrase();
112 bool maybeSaveAll();
113 bool maybeSave(int model);
114 void updateProgress();
115 void maybeUpdateStatistics(const MultiDataIndex &);
116 void translationChanged(const MultiDataIndex &);
117 void updateCaption();
118 void updateLatestModel(const QModelIndex &index);
119 void selectedContextChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex);
120 void selectedMessageChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex);
121 void setCurrentMessageFromGuess(int modelIndex, const Candidate &tm);
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 updateActiveModel(int);
128 void refreshItemViews();
129 void toggleFinished(const QModelIndex &index);
130 void prevUnfinished();
131 void nextUnfinished();
132 void findNext(const QString &text, DataModel::FindLocation where,
133 FindDialog::FindOptions options, int statusFilter);
134 void revalidate();
135 void toggleStatistics();
136 void toggleVisualizeWhitespace();
137 void onWhatsThis();
138 void updatePhraseDicts();
139 void updatePhraseDict(int model);
140
141#if QT_CONFIG(printsupport)
142 void print();
144#endif
145
146private:
147 QModelIndex nextContext(const QModelIndex &index) const;
148 QModelIndex prevContext(const QModelIndex &index) const;
149 QModelIndex nextMessage(const QModelIndex &currentIndex, bool checkUnfinished = false) const;
150 QModelIndex prevMessage(const QModelIndex &currentIndex, bool checkUnfinished = false) const;
151 bool doNext(bool checkUnfinished);
152 bool doPrev(bool checkUnfinished);
153 void findAgain(FindDirection direction = FindNext);
154
155 void updateStatistics();
156 void initViewHeaders();
157 void modelCountChanged();
158 void setupMenuBar();
159 void setupToolBars();
160 void setCurrentMessage(const QModelIndex &index);
161 void setCurrentMessage(const QModelIndex &index, int model);
162 QModelIndex setMessageViewRoot(const QModelIndex &index);
163 QModelIndex currentContextIndex() const;
164 QModelIndex currentMessageIndex() const;
165 PhraseBook *doOpenPhraseBook(const QString &name);
166 bool isPhraseBookOpen(const QString &name);
167 bool savePhraseBook(QString *name, PhraseBook &pb);
168 bool maybeSavePhraseBook(PhraseBook *phraseBook);
169 bool maybeSavePhraseBooks();
170 QStringList pickTranslationFiles();
171 void doShowTranslationSettings(int model);
172 void doUpdateLatestModel(int model);
173 void updateSourceView(int model, MessageItem *item);
174 void updatePhraseBookActions();
175 void updatePhraseDictInternal(int model);
176 void releaseInternal(int model);
177 void saveInternal(int model);
178
179#if QT_CONFIG(printsupport)
180 QPrinter *printer();
181#endif
182
183 // FIXME: move to DataModel
184 void updateDanger(const MultiDataIndex &index, bool verbose);
185
186 bool searchItem(DataModel::FindLocation where, const QString &searchWhat);
187
188 QProcess *m_assistantProcess;
189 QTreeView *m_contextView;
190 QTreeView *m_messageView;
191 MultiDataModel *m_dataModel;
192 MessageModel *m_messageModel;
193 QSortFilterProxyModel *m_sortedContextsModel;
194 QSortFilterProxyModel *m_sortedMessagesModel;
195 MessageEditor *m_messageEditor;
196 PhraseView *m_phraseView;
197 QStackedWidget *m_sourceAndFormView;
198 SourceCodeView *m_sourceCodeView;
199 FormPreviewView *m_formPreviewView;
200 ErrorsView *m_errorsView;
201 QLabel *m_progressLabel;
202 QLabel *m_modifiedLabel;
203 FocusWatcher *m_focusWatcher;
204 QString m_phraseBookDir;
205 // model : keyword -> list of appropriate phrases in the phrasebooks
207 QList<PhraseBook *> m_phraseBooks;
208 QMap<QAction *, PhraseBook *> m_phraseBookMenu[3];
209#if QT_CONFIG(printsupport)
210 QPrinter *m_printer = nullptr;
211#endif
212
213 FindDialog *m_findDialog;
214 QString m_findText;
215 FindDialog::FindOptions m_findOptions;
216 int m_findStatusFilter = -1;
217 DataModel::FindLocation m_findWhere;
218
219 TranslateDialog *m_translateDialog;
220 QString m_latestFindText;
221 int m_latestCaseSensitivity;
222 int m_remainingCount;
223 int m_hitCount;
224
225 BatchTranslationDialog *m_batchTranslateDialog;
226 TranslationSettingsDialog *m_translationSettingsDialog;
227
228 bool m_settingCurrentMessage;
229 int m_fileActiveModel;
230 int m_editActiveModel;
231 MultiDataIndex m_currentIndex;
232
233 QDockWidget *m_contextDock;
234 QDockWidget *m_messagesDock;
235 QDockWidget *m_phrasesDock;
236 QDockWidget *m_sourceAndFormDock;
237 QDockWidget *m_errorsDock;
238
239 Ui::MainWindow m_ui; // menus and actions
240 Statistics *m_statistics;
241};
242
243QT_END_NAMESPACE
244
245#endif
int main(int argc, char *argv[])
[2]
Definition buffer.cpp:77
void closeEvent(QCloseEvent *event) override
[21]
bool openFiles(const QStringList &names, bool readWrite=true)
~MainWindow() override
void writeConfig()
static RecentFiles & recentFiles()
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
static QString friendlyString(const QString &str)
void readConfig()
Combined button and popup list for selecting options.