SpeedCrunch
0.11
|
00001 // This file is part of the SpeedCrunch project 00002 // Copyright (C) 2004 Ariya Hidayat <ariya@kde.org> 00003 // Copyright (C) 2005, 2006 Johan Thelin <e8johan@gmail.com> 00004 // Copyright (C) 2007-2014 Helder Correia <helder.pereira.correia@gmail.com> 00005 // 00006 // This program is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU General Public License 00008 // as published by the Free Software Foundation; either version 2 00009 // of the License, or (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; see the file COPYING. If not, write to 00018 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 // Boston, MA 02110-1301, USA. 00020 00021 #ifndef GUI_MAINWINDOW_H 00022 #define GUI_MAINWINDOW_H 00023 00024 #include <QMainWindow> 00025 #include <QSystemTrayIcon> 00026 00027 class AutoHideLabel; 00028 class BitFieldWidget; 00029 class BookDock; 00030 class Constants; 00031 class ConstantsDock; 00032 class Editor; 00033 class Evaluator; 00034 class FunctionRepo; 00035 class FunctionsDock; 00036 class HistoryDock; 00037 class ManualWindow; 00038 class ResultDisplay; 00039 class Settings; 00040 class VariablesDock; 00041 class UserFunctionsDock; 00042 00043 class QActionGroup; 00044 class QHBoxLayout; 00045 class QLabel; 00046 class QPlainTextEdit; 00047 class QPushButton; 00048 class QTranslator; 00049 class QVBoxLayout; 00050 00051 class MainWindow : public QMainWindow { 00052 Q_OBJECT 00053 00054 public: 00055 MainWindow(); 00056 ~MainWindow(); 00057 00058 signals: 00059 void angleUnitChanged(); 00060 void colorSchemeChanged(); 00061 void languageChanged(); 00062 void radixCharacterChanged(); 00063 void resultFormatChanged(); 00064 void resultPrecisionChanged(); 00065 void syntaxHighlightingChanged(); 00066 00067 public slots: 00068 void copy(); 00069 00070 private slots: 00071 void activate(); 00072 void applySelectedColorScheme(); 00073 void clearEditor(); 00074 void clearHistory(); 00075 void copyResultToClipboard(); 00076 void cycleAngleUnits(); 00077 void cycleResultFormats(); 00078 void decreaseOpacity(); 00079 void deleteVariables(); 00080 void deleteUserFunctions(); 00081 void evaluateEditorExpression(); 00082 void exportHtml(); 00083 void exportPlainText(); 00084 void handleCopyAvailable(bool copyAvailable); 00085 void handleBitsChanged(const QString&str); 00086 void handleEditorTextChange(); 00087 void handleDisplaySelectionChange(); 00088 void handleEditorSelectionChange(); 00089 void handleManualClosed(); 00090 void handleSystemTrayIconActivation(QSystemTrayIcon::ActivationReason); 00091 void hideStateLabel(); 00092 void increaseOpacity(); 00093 void insertConstantIntoEditor(const QString&); 00094 void insertFunctionIntoEditor(const QString&); 00095 void insertTextIntoEditor(const QString&); 00096 void insertVariableIntoEditor(const QString&); 00097 void insertUserFunctionIntoEditor(const QString&); 00098 void minimizeToSystemTray(); 00099 void openUpdatesURL(); 00100 void openFeedbackURL(); 00101 void openCommunityURL(); 00102 void openNewsURL(); 00103 void retranslateText(); 00104 void saveSession(); 00105 void selectEditorExpression(); 00106 void setAlwaysOnTopEnabled(bool); 00107 void setAngleModeDegree(); 00108 void setAngleModeRadian(); 00109 void setAutoAnsEnabled(bool); 00110 void setAutoCalcEnabled(bool); 00111 void setAutoCompletionEnabled(bool); 00112 void setBitfieldVisible(bool); 00113 void setConstantsDockVisible(bool); 00114 void setFormulaBookDockVisible(bool); 00115 void setFullScreenEnabled(bool); 00116 void setFunctionsDockVisible(bool); 00117 void setHistoryDockVisible(bool); 00118 void setHistorySaveEnabled(bool); 00119 void setLeaveLastExpressionEnabled(bool); 00120 void setRadixCharacterAutomatic(); 00121 void setRadixCharacter(char); 00122 void setRadixCharacterComma(); 00123 void setRadixCharacterDot(); 00124 void setResultFormatBinary(); 00125 void setResultFormat(char); 00126 void setResultFormatEngineering(); 00127 void setResultFormatFixed(); 00128 void setResultFormatGeneral(); 00129 void setResultFormatHexadecimal(); 00130 void setResultFormatOctal(); 00131 void setResultFormatScientific(); 00132 void setResultPrecision15Digits(); 00133 void setResultPrecision2Digits(); 00134 void setResultPrecision3Digits(); 00135 void setResultPrecision50Digits(); 00136 void setResultPrecision8Digits(); 00137 void setResultPrecisionAutomatic(); 00138 void setResultPrecision(int); 00139 void setStatusBarVisible(bool); 00140 void setSyntaxHighlightingEnabled(bool); 00141 void setDigitGrouping(QAction*); 00142 void setAutoResultToClipboardEnabled(bool); 00143 void setParseAllRadixChar(bool); 00144 void setStrictDigitGrouping(bool); 00145 void setSystemTrayIconEnabled(bool); 00146 void setVariableSaveEnabled(bool); 00147 void setUserFunctionSaveEnabled(bool b); 00148 void setVariablesDockVisible(bool); 00149 void setUserFunctionsDockVisible(bool); 00150 void setWindowPositionSaveEnabled(bool); 00151 void setWidgetsDirection(); 00152 void showAboutDialog(); 00153 void showStateLabel(const QString&); 00154 void showFontDialog(); 00155 void showLanguageChooserDialog(); 00156 void showManualWindow(); 00157 void showReadyMessage(); 00158 void showResultFormatContextMenu(const QPoint&); 00159 void showSessionImportDialog(); 00160 void showSessionLoadDialog(); 00161 void showSystemTrayMessage(); 00162 void increaseDisplayFontPointSize(); 00163 void decreaseDisplayFontPointSize(); 00164 00165 protected: 00166 virtual void closeEvent(QCloseEvent*); 00167 virtual bool event(QEvent*); 00168 virtual bool eventFilter(QObject*, QEvent*); 00169 00170 private: 00171 Q_DISABLE_COPY(MainWindow) 00172 00173 void clearTextEditSelection(QPlainTextEdit*); 00174 void createUi(); 00175 void createActions(); 00176 void createActionGroups(); 00177 void createActionShortcuts(); 00178 void createMenus(); 00179 void createStatusBar(); 00180 void createFixedWidgets(); 00181 void createBitField(); 00182 void createBookDock(); 00183 void createConstantsDock(); 00184 void createFunctionsDock(); 00185 void createHistoryDock(); 00186 void createVariablesDock(); 00187 void createUserFunctionsDock(); 00188 void createFixedConnections(); 00189 void applySettings(); 00190 void checkInitialResultFormat(); 00191 void checkInitialResultPrecision(); 00192 void checkInitialLanguage(); 00193 void checkInitialDigitGrouping(); 00194 void restoreHistory(); 00195 void restoreVariables(); 00196 void restoreUserFunctions(); 00197 void deleteStatusBar(); 00198 void deleteBitField(); 00199 void deleteBookDock(); 00200 void deleteConstantsDock(); 00201 void deleteFunctionsDock(); 00202 void deleteHistoryDock(); 00203 void deleteVariablesDock(); 00204 void deleteUserFunctionsDock(); 00205 void saveSettings(); 00206 void setActionsText(); 00207 void setMenusText(); 00208 void setStatusBarText(); 00209 00210 static QTranslator* createTranslator(const QString& langCode); 00211 00212 struct { 00213 QAction* sessionLoad; 00214 QAction* sessionSave; 00215 QAction* sessionImport; 00216 QAction* sessionExportHtml; 00217 QAction* sessionExportPlainText; 00218 QAction* sessionQuit; 00219 QAction* editCopy; 00220 QAction* editCopyLastResult; 00221 QAction* editPaste; 00222 QAction* editSelectExpression; 00223 QAction* editInsertFunction; 00224 QAction* editInsertVariable; 00225 QAction* editDeleteVariable; 00226 QAction* editInsertUserFunction; 00227 QAction* editDeleteUserFunction; 00228 QAction* editClearExpression; 00229 QAction* editClearHistory; 00230 QAction* viewFormulaBook; 00231 QAction* viewConstants; 00232 QAction* viewFunctions; 00233 QAction* viewVariables; 00234 QAction* viewUserFunctions; 00235 QAction* viewHistory; 00236 QAction* viewStatusBar; 00237 QAction* viewFullScreenMode; 00238 QAction* viewBitfield; 00239 QAction* settingsResultFormatGeneral; 00240 QAction* settingsResultFormatFixed; 00241 QAction* settingsResultFormatEngineering; 00242 QAction* settingsResultFormatScientific; 00243 QAction* settingsResultFormatAutoPrecision; 00244 QAction* settingsResultFormat2Digits; 00245 QAction* settingsResultFormat3Digits; 00246 QAction* settingsResultFormat8Digits; 00247 QAction* settingsResultFormat15Digits; 00248 QAction* settingsResultFormat50Digits; 00249 QAction* settingsResultFormatBinary; 00250 QAction* settingsResultFormatOctal; 00251 QAction* settingsResultFormatHexadecimal; 00252 QAction* settingsAngleUnitRadian; 00253 QAction* settingsAngleUnitDegree; 00254 QAction* settingsBehaviorSaveHistoryOnExit; 00255 QAction* settingsBehaviorSaveVariablesOnExit; 00256 QAction* settingsBehaviorSaveUserFunctionsOnExit; 00257 QAction* settingsBehaviorSaveWindowPositionOnExit; 00258 QAction* settingsBehaviorPartialResults; 00259 QAction* settingsBehaviorAutoCompletion; 00260 QAction* settingsBehaviorSyntaxHighlighting; 00261 QAction* settingsBehaviorDigitGroupingNone; 00262 QAction* settingsBehaviorDigitGroupingOneSpace; 00263 QAction* settingsBehaviorDigitGroupingTwoSpaces; 00264 QAction* settingsBehaviorDigitGroupingThreeSpaces; 00265 QAction* settingsBehaviorAutoAns; 00266 QAction* settingsBehaviorLeaveLastExpression; 00267 QAction* settingsBehaviorAlwaysOnTop; 00268 QAction* settingsBehaviorMinimizeToTray; 00269 QAction* settingsBehaviorAutoResultToClipboard; 00270 QAction* settingsBehaviorParseAllRadixChar; 00271 QAction* settingsBehaviorStrictDigitGrouping; 00272 QAction* settingsDisplayZoomIn; 00273 QAction* settingsDisplayZoomOut; 00274 QAction* settingsDisplayFont; 00275 QAction* settingsDisplayColorSchemeStandard; 00276 QAction* settingsDisplayColorSchemeSublime; 00277 QAction* settingsDisplayColorSchemeTerminal; 00278 QAction* settingsDisplayColorSchemeSolarizedDark; 00279 QAction* settingsDisplayColorSchemeSolarizedLight; 00280 QAction* settingsRadixCharDefault; 00281 QAction* settingsRadixCharDot; 00282 QAction* settingsRadixCharComma; 00283 QAction* settingsLanguage; 00284 QAction* helpManual; 00285 QAction* helpUpdates; 00286 QAction* helpFeedback; 00287 QAction* helpCommunity; 00288 QAction* helpNews; 00289 QAction* helpAbout; 00290 } m_actions; 00291 00292 struct { 00293 QActionGroup* angle; 00294 QActionGroup* colorScheme; 00295 QActionGroup* digits; 00296 QActionGroup* resultFormat; 00297 QActionGroup* radixChar; 00298 QActionGroup* digitGrouping; 00299 } m_actionGroups; 00300 00301 struct { 00302 QMenu* angleUnit; 00303 QMenu* behavior; 00304 QMenu* colorScheme; 00305 QMenu* decimal; 00306 QMenu* digitGrouping; 00307 QMenu* display; 00308 QMenu* edit; 00309 QMenu* resultFormat; 00310 QMenu* help; 00311 QMenu* precision; 00312 QMenu* radixChar; 00313 QMenu* session; 00314 QMenu* sessionExport; 00315 QMenu* settings; 00316 QMenu* trayIcon; 00317 QMenu* view; 00318 } m_menus; 00319 00320 struct { 00321 QVBoxLayout* root; 00322 } m_layouts; 00323 00324 struct { 00325 QLabel* state; 00326 ResultDisplay* display; 00327 Editor* editor; 00328 QWidget* root; 00329 QSystemTrayIcon* trayIcon; 00330 ManualWindow* manual; 00331 BitFieldWidget* bitField; 00332 } m_widgets; 00333 00334 struct { 00335 BookDock* book; 00336 ConstantsDock* constants; 00337 FunctionsDock* functions; 00338 HistoryDock* history; 00339 VariablesDock* variables; 00340 UserFunctionsDock* userFunctions; 00341 } m_docks; 00342 00343 struct { 00344 bool trayNotify; 00345 bool autoAns; 00346 } m_conditions; 00347 00348 struct { 00349 QPushButton* angleUnit; 00350 QPushButton* resultFormat; 00351 } m_status; 00352 00353 Constants* m_constants; 00354 Evaluator* m_evaluator; 00355 FunctionRepo* m_functions; 00356 Settings* m_settings; 00357 QTranslator* m_translator; 00358 QPlainTextEdit* m_copyWidget; 00359 }; 00360 00361 #endif // GUI_MAINWINDOW_H