From a80a494efee7979c28ab1090734270e5c0515352 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 18 Sep 2022 20:19:47 +0900 Subject: Added main window menubar GUI. The logic of each action has not been implemented yet. Signed-off-by: Michele Calgaro --- CMakeLists.txt | 1 + config.h.cmake | 3 + icons/CMakeLists.txt | 22 + icons/__TODO/Icon1.png | Bin 0 -> 237 bytes icons/__TODO/Icons.qrc | 48 + icons/__TODO/accessories-text-editor.png | Bin 0 -> 995 bytes icons/__TODO/applications-system.png | Bin 0 -> 1488 bytes icons/__TODO/banner.png | Bin 0 -> 142927 bytes icons/__TODO/edit-select-all.png | Bin 0 -> 631 bytes icons/__TODO/format-justify-left.png | Bin 0 -> 515 bytes icons/__TODO/help.png | Bin 0 -> 2231 bytes icons/__TODO/icon2.ico | Bin 0 -> 1214 bytes icons/__TODO/icon2.png | Bin 0 -> 237 bytes icons/__TODO/icon3.png | Bin 0 -> 257 bytes icons/__TODO/language-de.png | Bin 0 -> 545 bytes icons/__TODO/language-en.png | Bin 0 -> 496 bytes icons/__TODO/language-fr.png | Bin 0 -> 545 bytes icons/__TODO/language-ja.png | Bin 0 -> 420 bytes icons/__TODO/language-ru.png | Bin 0 -> 420 bytes icons/__TODO/language-uk.png | Bin 0 -> 446 bytes icons/__TODO/language-zh_CN.png | Bin 0 -> 472 bytes icons/__TODO/language-zh_TW.png | Bin 0 -> 465 bytes icons/__TODO/load_indent_cfg.png | Bin 0 -> 1673 bytes icons/__TODO/qt_logo.png | Bin 0 -> 984 bytes icons/__TODO/save_indent_cfg.png | Bin 0 -> 1666 bytes icons/__TODO/shell.png | Bin 0 -> 474 bytes icons/__TODO/system-software-update.png | Bin 0 -> 2216 bytes icons/__TODO/view-refresh.png | Bin 0 -> 2024 bytes icons/document-open.png | Bin 0 -> 1437 bytes icons/document-properties.png | Bin 0 -> 1115 bytes icons/document-save-as.png | Bin 0 -> 1837 bytes icons/document-save.png | Bin 0 -> 1971 bytes icons/edit-clear.png | Bin 0 -> 1682 bytes icons/exporthtml.png | Bin 0 -> 1561 bytes icons/exportpdf.png | Bin 0 -> 1594 bytes icons/info.png | Bin 0 -> 825 bytes icons/live-preview.png | Bin 0 -> 2566 bytes icons/preferences-system.png | Bin 0 -> 1151 bytes icons/syntax-highlight.png | Bin 0 -> 821 bytes icons/system-log-out.png | Bin 0 -> 1269 bytes icons/tooltip.png | Bin 0 -> 852 bytes icons/universalIndentGUI.ico | Bin 0 -> 1278 bytes icons/universalIndentGUI.svg | 110 ++ icons/universalIndentGUI_32x32.xpm | 120 ++ icons/universalIndentGUI_512x512.png | Bin 0 -> 14312 bytes icons/universalIndentGUI_64x64.png | Bin 0 -> 1269 bytes resources/Icon1.png | Bin 237 -> 0 bytes resources/Icons.qrc | 48 - resources/UniversalIndentGUI.icns | Bin 73214 -> 0 bytes resources/accessories-text-editor.png | Bin 995 -> 0 bytes resources/applications-system.png | Bin 1488 -> 0 bytes resources/banner.png | Bin 142927 -> 0 bytes resources/document-open.png | Bin 1437 -> 0 bytes resources/document-properties.png | Bin 1115 -> 0 bytes resources/document-save-as.png | Bin 1837 -> 0 bytes resources/document-save.png | Bin 1971 -> 0 bytes resources/edit-clear.png | Bin 1682 -> 0 bytes resources/edit-select-all.png | Bin 631 -> 0 bytes resources/exporthtml.png | Bin 1561 -> 0 bytes resources/exportpdf.png | Bin 1594 -> 0 bytes resources/format-justify-left.png | Bin 515 -> 0 bytes resources/help.png | Bin 2231 -> 0 bytes resources/icon2.ico | Bin 1214 -> 0 bytes resources/icon2.png | Bin 237 -> 0 bytes resources/icon3.png | Bin 257 -> 0 bytes resources/info.png | Bin 825 -> 0 bytes resources/language-de.png | Bin 545 -> 0 bytes resources/language-en.png | Bin 496 -> 0 bytes resources/language-fr.png | Bin 545 -> 0 bytes resources/language-ja.png | Bin 420 -> 0 bytes resources/language-ru.png | Bin 420 -> 0 bytes resources/language-uk.png | Bin 446 -> 0 bytes resources/language-zh_CN.png | Bin 472 -> 0 bytes resources/language-zh_TW.png | Bin 465 -> 0 bytes resources/live-preview.png | Bin 2566 -> 0 bytes resources/load_indent_cfg.png | Bin 1673 -> 0 bytes resources/preferences-system.png | Bin 1151 -> 0 bytes resources/programicon.rc | 108 -- resources/qt_logo.png | Bin 984 -> 0 bytes resources/save_indent_cfg.png | Bin 1666 -> 0 bytes resources/shell.png | Bin 474 -> 0 bytes resources/syntax-highlight.png | Bin 821 -> 0 bytes resources/system-log-out.png | Bin 1269 -> 0 bytes resources/system-software-update.png | Bin 2216 -> 0 bytes resources/tooltip.png | Bin 852 -> 0 bytes resources/universalIndentGUI.ico | Bin 1278 -> 0 bytes resources/universalIndentGUI.svg | 110 -- resources/universalIndentGUI_32x32.xpm | 120 -- resources/universalIndentGUI_512x512.png | Bin 14312 -> 0 bytes resources/universalIndentGUI_64x64.png | Bin 1269 -> 0 bytes resources/view-refresh.png | Bin 2024 -> 0 bytes src/AboutDialog.cpp | 169 --- src/AboutDialog.h | 54 - src/AboutDialog.ui | 218 ---- src/AboutDialogGraphicsView.cpp | 220 ---- src/AboutDialogGraphicsView.h | 57 - src/CMakeLists.txt | 3 +- src/FindDialog.ui | 121 -- src/IndentHandler.cpp | 2044 ------------------------------ src/IndentHandler.h | 195 --- src/MainWindow.cpp | 328 ++--- src/MainWindow.h | 35 +- src/MainWindow.ui | 488 ------- src/MainWindowBase.ui | 383 ++++++ src/SettingsPaths.cpp | 309 ----- src/SettingsPaths.h | 50 - src/TemplateBatchScript.cpp | 171 --- src/TemplateBatchScript.h | 32 - src/ToolBarWidget.ui | 124 -- src/UiGuiErrorMessage.cpp | 93 -- src/UiGuiErrorMessage.h | 44 - src/UiGuiHighlighter.cpp | 604 --------- src/UiGuiHighlighter.h | 75 -- src/UiGuiIndentServer.cpp | 175 --- src/UiGuiIndentServer.h | 55 - src/UiGuiIniFileParser.cpp | 160 --- src/UiGuiIniFileParser.h | 53 - src/UiGuiSettings.cpp | 933 -------------- src/UiGuiSettings.h | 95 -- src/UiGuiSettingsDialog.cpp | 205 --- src/UiGuiSettingsDialog.h | 55 - src/UiGuiSettingsDialog.ui | 625 --------- src/UiGuiSystemInfo.cpp | 317 ----- src/UiGuiSystemInfo.h | 35 - src/UpdateCheckDialog.cpp | 356 ------ src/UpdateCheckDialog.h | 74 -- src/UpdateCheckDialog.ui | 51 - src/__TODO/AboutDialog.cpp | 169 +++ src/__TODO/AboutDialog.h | 54 + src/__TODO/AboutDialog.ui | 218 ++++ src/__TODO/AboutDialogGraphicsView.cpp | 220 ++++ src/__TODO/AboutDialogGraphicsView.h | 57 + src/__TODO/FindDialog.ui | 121 ++ src/__TODO/IndentHandler.cpp | 2044 ++++++++++++++++++++++++++++++ src/__TODO/IndentHandler.h | 195 +++ src/__TODO/MainWindow.ui | 157 +++ src/__TODO/SettingsPaths.cpp | 309 +++++ src/__TODO/SettingsPaths.h | 50 + src/__TODO/TemplateBatchScript.cpp | 171 +++ src/__TODO/TemplateBatchScript.h | 32 + src/__TODO/ToolBarWidget.ui | 124 ++ src/__TODO/UiGuiErrorMessage.cpp | 93 ++ src/__TODO/UiGuiErrorMessage.h | 44 + src/__TODO/UiGuiHighlighter.cpp | 604 +++++++++ src/__TODO/UiGuiHighlighter.h | 75 ++ src/__TODO/UiGuiIndentServer.cpp | 175 +++ src/__TODO/UiGuiIndentServer.h | 55 + src/__TODO/UiGuiIniFileParser.cpp | 160 +++ src/__TODO/UiGuiIniFileParser.h | 53 + src/__TODO/UiGuiSettings.cpp | 933 ++++++++++++++ src/__TODO/UiGuiSettings.h | 94 ++ src/__TODO/UiGuiSettingsDialog.cpp | 205 +++ src/__TODO/UiGuiSettingsDialog.h | 55 + src/__TODO/UiGuiSettingsDialog.ui | 625 +++++++++ src/__TODO/UiGuiSystemInfo.cpp | 317 +++++ src/__TODO/UiGuiSystemInfo.h | 35 + src/__TODO/UpdateCheckDialog.cpp | 356 ++++++ src/__TODO/UpdateCheckDialog.h | 74 ++ src/__TODO/UpdateCheckDialog.ui | 51 + 159 files changed, 8805 insertions(+), 8816 deletions(-) create mode 100644 icons/CMakeLists.txt create mode 100755 icons/__TODO/Icon1.png create mode 100755 icons/__TODO/Icons.qrc create mode 100755 icons/__TODO/accessories-text-editor.png create mode 100755 icons/__TODO/applications-system.png create mode 100755 icons/__TODO/banner.png create mode 100755 icons/__TODO/edit-select-all.png create mode 100755 icons/__TODO/format-justify-left.png create mode 100755 icons/__TODO/help.png create mode 100755 icons/__TODO/icon2.ico create mode 100755 icons/__TODO/icon2.png create mode 100755 icons/__TODO/icon3.png create mode 100755 icons/__TODO/language-de.png create mode 100755 icons/__TODO/language-en.png create mode 100755 icons/__TODO/language-fr.png create mode 100755 icons/__TODO/language-ja.png create mode 100755 icons/__TODO/language-ru.png create mode 100755 icons/__TODO/language-uk.png create mode 100755 icons/__TODO/language-zh_CN.png create mode 100755 icons/__TODO/language-zh_TW.png create mode 100755 icons/__TODO/load_indent_cfg.png create mode 100755 icons/__TODO/qt_logo.png create mode 100755 icons/__TODO/save_indent_cfg.png create mode 100755 icons/__TODO/shell.png create mode 100755 icons/__TODO/system-software-update.png create mode 100755 icons/__TODO/view-refresh.png create mode 100755 icons/document-open.png create mode 100755 icons/document-properties.png create mode 100755 icons/document-save-as.png create mode 100755 icons/document-save.png create mode 100755 icons/edit-clear.png create mode 100755 icons/exporthtml.png create mode 100755 icons/exportpdf.png create mode 100755 icons/info.png create mode 100755 icons/live-preview.png create mode 100755 icons/preferences-system.png create mode 100755 icons/syntax-highlight.png create mode 100755 icons/system-log-out.png create mode 100755 icons/tooltip.png create mode 100755 icons/universalIndentGUI.ico create mode 100755 icons/universalIndentGUI.svg create mode 100755 icons/universalIndentGUI_32x32.xpm create mode 100755 icons/universalIndentGUI_512x512.png create mode 100755 icons/universalIndentGUI_64x64.png delete mode 100755 resources/Icon1.png delete mode 100755 resources/Icons.qrc delete mode 100755 resources/UniversalIndentGUI.icns delete mode 100755 resources/accessories-text-editor.png delete mode 100755 resources/applications-system.png delete mode 100755 resources/banner.png delete mode 100755 resources/document-open.png delete mode 100755 resources/document-properties.png delete mode 100755 resources/document-save-as.png delete mode 100755 resources/document-save.png delete mode 100755 resources/edit-clear.png delete mode 100755 resources/edit-select-all.png delete mode 100755 resources/exporthtml.png delete mode 100755 resources/exportpdf.png delete mode 100755 resources/format-justify-left.png delete mode 100755 resources/help.png delete mode 100755 resources/icon2.ico delete mode 100755 resources/icon2.png delete mode 100755 resources/icon3.png delete mode 100755 resources/info.png delete mode 100755 resources/language-de.png delete mode 100755 resources/language-en.png delete mode 100755 resources/language-fr.png delete mode 100755 resources/language-ja.png delete mode 100755 resources/language-ru.png delete mode 100755 resources/language-uk.png delete mode 100755 resources/language-zh_CN.png delete mode 100755 resources/language-zh_TW.png delete mode 100755 resources/live-preview.png delete mode 100755 resources/load_indent_cfg.png delete mode 100755 resources/preferences-system.png delete mode 100755 resources/programicon.rc delete mode 100755 resources/qt_logo.png delete mode 100755 resources/save_indent_cfg.png delete mode 100755 resources/shell.png delete mode 100755 resources/syntax-highlight.png delete mode 100755 resources/system-log-out.png delete mode 100755 resources/system-software-update.png delete mode 100755 resources/tooltip.png delete mode 100755 resources/universalIndentGUI.ico delete mode 100755 resources/universalIndentGUI.svg delete mode 100755 resources/universalIndentGUI_32x32.xpm delete mode 100755 resources/universalIndentGUI_512x512.png delete mode 100755 resources/universalIndentGUI_64x64.png delete mode 100755 resources/view-refresh.png delete mode 100644 src/AboutDialog.cpp delete mode 100644 src/AboutDialog.h delete mode 100755 src/AboutDialog.ui delete mode 100644 src/AboutDialogGraphicsView.cpp delete mode 100644 src/AboutDialogGraphicsView.h delete mode 100755 src/FindDialog.ui delete mode 100644 src/IndentHandler.cpp delete mode 100644 src/IndentHandler.h delete mode 100755 src/MainWindow.ui create mode 100755 src/MainWindowBase.ui delete mode 100644 src/SettingsPaths.cpp delete mode 100644 src/SettingsPaths.h delete mode 100644 src/TemplateBatchScript.cpp delete mode 100644 src/TemplateBatchScript.h delete mode 100755 src/ToolBarWidget.ui delete mode 100644 src/UiGuiErrorMessage.cpp delete mode 100644 src/UiGuiErrorMessage.h delete mode 100644 src/UiGuiHighlighter.cpp delete mode 100644 src/UiGuiHighlighter.h delete mode 100644 src/UiGuiIndentServer.cpp delete mode 100644 src/UiGuiIndentServer.h delete mode 100644 src/UiGuiIniFileParser.cpp delete mode 100644 src/UiGuiIniFileParser.h delete mode 100644 src/UiGuiSettings.cpp delete mode 100644 src/UiGuiSettings.h delete mode 100644 src/UiGuiSettingsDialog.cpp delete mode 100644 src/UiGuiSettingsDialog.h delete mode 100755 src/UiGuiSettingsDialog.ui delete mode 100644 src/UiGuiSystemInfo.cpp delete mode 100644 src/UiGuiSystemInfo.h delete mode 100644 src/UpdateCheckDialog.cpp delete mode 100644 src/UpdateCheckDialog.h delete mode 100755 src/UpdateCheckDialog.ui create mode 100644 src/__TODO/AboutDialog.cpp create mode 100644 src/__TODO/AboutDialog.h create mode 100755 src/__TODO/AboutDialog.ui create mode 100644 src/__TODO/AboutDialogGraphicsView.cpp create mode 100644 src/__TODO/AboutDialogGraphicsView.h create mode 100755 src/__TODO/FindDialog.ui create mode 100644 src/__TODO/IndentHandler.cpp create mode 100644 src/__TODO/IndentHandler.h create mode 100755 src/__TODO/MainWindow.ui create mode 100644 src/__TODO/SettingsPaths.cpp create mode 100644 src/__TODO/SettingsPaths.h create mode 100644 src/__TODO/TemplateBatchScript.cpp create mode 100644 src/__TODO/TemplateBatchScript.h create mode 100755 src/__TODO/ToolBarWidget.ui create mode 100644 src/__TODO/UiGuiErrorMessage.cpp create mode 100644 src/__TODO/UiGuiErrorMessage.h create mode 100644 src/__TODO/UiGuiHighlighter.cpp create mode 100644 src/__TODO/UiGuiHighlighter.h create mode 100644 src/__TODO/UiGuiIndentServer.cpp create mode 100644 src/__TODO/UiGuiIndentServer.h create mode 100644 src/__TODO/UiGuiIniFileParser.cpp create mode 100644 src/__TODO/UiGuiIniFileParser.h create mode 100644 src/__TODO/UiGuiSettings.cpp create mode 100644 src/__TODO/UiGuiSettings.h create mode 100644 src/__TODO/UiGuiSettingsDialog.cpp create mode 100644 src/__TODO/UiGuiSettingsDialog.h create mode 100755 src/__TODO/UiGuiSettingsDialog.ui create mode 100644 src/__TODO/UiGuiSystemInfo.cpp create mode 100644 src/__TODO/UiGuiSystemInfo.h create mode 100644 src/__TODO/UpdateCheckDialog.cpp create mode 100644 src/__TODO/UpdateCheckDialog.h create mode 100755 src/__TODO/UpdateCheckDialog.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 75375e2..ab6768f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ##### directories +add_subdirectory( icons ) add_subdirectory( src ) diff --git a/config.h.cmake b/config.h.cmake index 33d4bd8..4154741 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,5 +1,8 @@ #define VERSION "@VERSION@" +// application icons location +#define APP_ICONS_PATH "@SHARE_INSTALL_PREFIX@/universal-indent-gui-tqt/icons/" + // Defined if you have fvisibility and fvisibility-inlines-hidden support. #cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt new file mode 100644 index 0000000..7d86613 --- /dev/null +++ b/icons/CMakeLists.txt @@ -0,0 +1,22 @@ +install( + FILES + document-open.png + document-properties.png + document-save.png + document-save-as.png + edit-clear.png + exporthtml.png + exportpdf.png + info.png + live-preview.png + preferences-system.png + syntax-highlight.png + system-log-out.png + tooltip.png + universalIndentGUI.ico + universalIndentGUI.svg + universalIndentGUI_32x32.xpm + universalIndentGUI_64x64.png + universalIndentGUI_512x512.png + DESTINATION ${SHARE_INSTALL_PREFIX}/universal-indent-gui-tqt/icons +) diff --git a/icons/__TODO/Icon1.png b/icons/__TODO/Icon1.png new file mode 100755 index 0000000..7144147 Binary files /dev/null and b/icons/__TODO/Icon1.png differ diff --git a/icons/__TODO/Icons.qrc b/icons/__TODO/Icons.qrc new file mode 100755 index 0000000..71ffec5 --- /dev/null +++ b/icons/__TODO/Icons.qrc @@ -0,0 +1,48 @@ + + + qt_logo.png + banner.png + + + language-de.png + language-en.png + language-fr.png + language-ru.png + language-uk.png + language-zh_CN.png + language-zh_TW.png + language-ja.png + + + document-properties.png + Icon1.png + universalIndentGUI.svg + document-open.png + document-save-as.png + document-save.png + edit-clear.png + exporthtml.png + exportpdf.png + format-justify-left.png + help.png + icon2.png + icon3.png + info.png + live-preview.png + load_indent_cfg.png + preferences-system.png + save_indent_cfg.png + shell.png + syntax-highlight.png + system-log-out.png + system-software-update.png + tooltip.png + view-refresh.png + + + accessories-text-editor.png + applications-system.png + icon3.png + syntax-highlight.png + + diff --git a/icons/__TODO/accessories-text-editor.png b/icons/__TODO/accessories-text-editor.png new file mode 100755 index 0000000..c3d245d Binary files /dev/null and b/icons/__TODO/accessories-text-editor.png differ diff --git a/icons/__TODO/applications-system.png b/icons/__TODO/applications-system.png new file mode 100755 index 0000000..4decc89 Binary files /dev/null and b/icons/__TODO/applications-system.png differ diff --git a/icons/__TODO/banner.png b/icons/__TODO/banner.png new file mode 100755 index 0000000..d0884d6 Binary files /dev/null and b/icons/__TODO/banner.png differ diff --git a/icons/__TODO/edit-select-all.png b/icons/__TODO/edit-select-all.png new file mode 100755 index 0000000..107fc60 Binary files /dev/null and b/icons/__TODO/edit-select-all.png differ diff --git a/icons/__TODO/format-justify-left.png b/icons/__TODO/format-justify-left.png new file mode 100755 index 0000000..ba0e914 Binary files /dev/null and b/icons/__TODO/format-justify-left.png differ diff --git a/icons/__TODO/help.png b/icons/__TODO/help.png new file mode 100755 index 0000000..d60425f Binary files /dev/null and b/icons/__TODO/help.png differ diff --git a/icons/__TODO/icon2.ico b/icons/__TODO/icon2.ico new file mode 100755 index 0000000..c784369 Binary files /dev/null and b/icons/__TODO/icon2.ico differ diff --git a/icons/__TODO/icon2.png b/icons/__TODO/icon2.png new file mode 100755 index 0000000..337d353 Binary files /dev/null and b/icons/__TODO/icon2.png differ diff --git a/icons/__TODO/icon3.png b/icons/__TODO/icon3.png new file mode 100755 index 0000000..b6b6a9e Binary files /dev/null and b/icons/__TODO/icon3.png differ diff --git a/icons/__TODO/language-de.png b/icons/__TODO/language-de.png new file mode 100755 index 0000000..ac4a977 Binary files /dev/null and b/icons/__TODO/language-de.png differ diff --git a/icons/__TODO/language-en.png b/icons/__TODO/language-en.png new file mode 100755 index 0000000..3a7311d Binary files /dev/null and b/icons/__TODO/language-en.png differ diff --git a/icons/__TODO/language-fr.png b/icons/__TODO/language-fr.png new file mode 100755 index 0000000..8332c4e Binary files /dev/null and b/icons/__TODO/language-fr.png differ diff --git a/icons/__TODO/language-ja.png b/icons/__TODO/language-ja.png new file mode 100755 index 0000000..325fbad Binary files /dev/null and b/icons/__TODO/language-ja.png differ diff --git a/icons/__TODO/language-ru.png b/icons/__TODO/language-ru.png new file mode 100755 index 0000000..47da421 Binary files /dev/null and b/icons/__TODO/language-ru.png differ diff --git a/icons/__TODO/language-uk.png b/icons/__TODO/language-uk.png new file mode 100755 index 0000000..09563a2 Binary files /dev/null and b/icons/__TODO/language-uk.png differ diff --git a/icons/__TODO/language-zh_CN.png b/icons/__TODO/language-zh_CN.png new file mode 100755 index 0000000..8914414 Binary files /dev/null and b/icons/__TODO/language-zh_CN.png differ diff --git a/icons/__TODO/language-zh_TW.png b/icons/__TODO/language-zh_TW.png new file mode 100755 index 0000000..f31c654 Binary files /dev/null and b/icons/__TODO/language-zh_TW.png differ diff --git a/icons/__TODO/load_indent_cfg.png b/icons/__TODO/load_indent_cfg.png new file mode 100755 index 0000000..b51c82d Binary files /dev/null and b/icons/__TODO/load_indent_cfg.png differ diff --git a/icons/__TODO/qt_logo.png b/icons/__TODO/qt_logo.png new file mode 100755 index 0000000..332f2ad Binary files /dev/null and b/icons/__TODO/qt_logo.png differ diff --git a/icons/__TODO/save_indent_cfg.png b/icons/__TODO/save_indent_cfg.png new file mode 100755 index 0000000..2276121 Binary files /dev/null and b/icons/__TODO/save_indent_cfg.png differ diff --git a/icons/__TODO/shell.png b/icons/__TODO/shell.png new file mode 100755 index 0000000..da59c67 Binary files /dev/null and b/icons/__TODO/shell.png differ diff --git a/icons/__TODO/system-software-update.png b/icons/__TODO/system-software-update.png new file mode 100755 index 0000000..470b5d4 Binary files /dev/null and b/icons/__TODO/system-software-update.png differ diff --git a/icons/__TODO/view-refresh.png b/icons/__TODO/view-refresh.png new file mode 100755 index 0000000..606ea9e Binary files /dev/null and b/icons/__TODO/view-refresh.png differ diff --git a/icons/document-open.png b/icons/document-open.png new file mode 100755 index 0000000..2b135a1 Binary files /dev/null and b/icons/document-open.png differ diff --git a/icons/document-properties.png b/icons/document-properties.png new file mode 100755 index 0000000..fa697db Binary files /dev/null and b/icons/document-properties.png differ diff --git a/icons/document-save-as.png b/icons/document-save-as.png new file mode 100755 index 0000000..5c9f6b3 Binary files /dev/null and b/icons/document-save-as.png differ diff --git a/icons/document-save.png b/icons/document-save.png new file mode 100755 index 0000000..db5c52b Binary files /dev/null and b/icons/document-save.png differ diff --git a/icons/edit-clear.png b/icons/edit-clear.png new file mode 100755 index 0000000..5542948 Binary files /dev/null and b/icons/edit-clear.png differ diff --git a/icons/exporthtml.png b/icons/exporthtml.png new file mode 100755 index 0000000..af03a38 Binary files /dev/null and b/icons/exporthtml.png differ diff --git a/icons/exportpdf.png b/icons/exportpdf.png new file mode 100755 index 0000000..5cfddff Binary files /dev/null and b/icons/exportpdf.png differ diff --git a/icons/info.png b/icons/info.png new file mode 100755 index 0000000..51c5e55 Binary files /dev/null and b/icons/info.png differ diff --git a/icons/live-preview.png b/icons/live-preview.png new file mode 100755 index 0000000..5414bda Binary files /dev/null and b/icons/live-preview.png differ diff --git a/icons/preferences-system.png b/icons/preferences-system.png new file mode 100755 index 0000000..cc91d65 Binary files /dev/null and b/icons/preferences-system.png differ diff --git a/icons/syntax-highlight.png b/icons/syntax-highlight.png new file mode 100755 index 0000000..fb6e297 Binary files /dev/null and b/icons/syntax-highlight.png differ diff --git a/icons/system-log-out.png b/icons/system-log-out.png new file mode 100755 index 0000000..780411d Binary files /dev/null and b/icons/system-log-out.png differ diff --git a/icons/tooltip.png b/icons/tooltip.png new file mode 100755 index 0000000..e4cdb05 Binary files /dev/null and b/icons/tooltip.png differ diff --git a/icons/universalIndentGUI.ico b/icons/universalIndentGUI.ico new file mode 100755 index 0000000..db25009 Binary files /dev/null and b/icons/universalIndentGUI.ico differ diff --git a/icons/universalIndentGUI.svg b/icons/universalIndentGUI.svg new file mode 100755 index 0000000..44532ee --- /dev/null +++ b/icons/universalIndentGUI.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/icons/universalIndentGUI_32x32.xpm b/icons/universalIndentGUI_32x32.xpm new file mode 100755 index 0000000..fd01f5e --- /dev/null +++ b/icons/universalIndentGUI_32x32.xpm @@ -0,0 +1,120 @@ +/* XPM */ +static char * universalIndentGUI_32x32_xpm[] = { +"32 32 85 1", +" c None", +". c #DFDFDF", +"+ c #EEEEEE", +"@ c #DEDEDE", +"# c #F0F0F0", +"$ c #FFFFFF", +"% c #EFEFEF", +"& c #7878E4", +"* c #6565EE", +"= c #9191E7", +"- c #6C6CF0", +"; c #5555FF", +"> c #8888F0", +", c #E9F1E9", +"' c #DEEBDE", +") c #F8FAF8", +"! c #55D655", +"~ c #00D400", +"{ c #ADEAAD", +"] c #8080E5", +"^ c #6F6FEE", +"/ c #9898E8", +"( c #69DF69", +"_ c #24D324", +": c #FEFEFE", +"< c #AEEAAE", +"[ c #32D632", +"} c #FDFEFD", +"| c #84E084", +"1 c #CFF7CF", +"2 c #33DD33", +"3 c #75DE75", +"4 c #03D503", +"5 c #ABE8AB", +"6 c #C3F5C3", +"7 c #05D205", +"8 c #96E796", +"9 c #51D851", +"0 c #DDF4DD", +"a c #C8F2C8", +"b c #20CB20", +"c c #65D165", +"d c #0AD30A", +"e c #68DD68", +"f c #D9F3D9", +"g c #03D303", +"h c #4DD94D", +"i c #B5EBB5", +"j c #FCFDFC", +"k c #22D322", +"l c #83E283", +"m c #EAF6EA", +"n c #01D301", +"o c #44D844", +"p c #B6ECB6", +"q c #2ED52E", +"r c #BEEBBE", +"s c #D3F8D3", +"t c #44DF44", +"u c #80E180", +"v c #67DC67", +"w c #F9FCF9", +"x c #82DF82", +"y c #5CDB5C", +"z c #C4F2C4", +"A c #10C910", +"B c #5BCF5B", +"C c #1AD31A", +"D c #F3FAF3", +"E c #91E691", +"F c #15D215", +"G c #F6FBF6", +"H c #58DC58", +"I c #9DE89D", +"J c #9C9CF5", +"K c #8E8EFF", +"L c #AFAFF5", +"M c #D0F4D0", +"N c #BBF4BB", +"O c #EFFAEF", +"P c #6E6EE3", +"Q c #5A5AEE", +"R c #8989E5", +"S c #EDEDED", +"T c #DCDCDC", +".++++++++++++++++++++++++++++++@", +"#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$$$$$$$$$$&**************=$$%", +"#$$$$$$$$$$$$-;;;;;;;;;;;;;;>$$%", +"#$$$,')$$$$$$-;;;;;;;;;;;;;;>$$%", +"#$$$!~{$$$$$$]^^^^^^^^^^^^^^/$$%", +"#$$$!~($$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~_:$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~~<$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~~[}$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~~~|$$$$$$$$$12222222223$$%", +"#$$$!~~~45$$$$$$$$6~~~~~~~~~!$$%", +"#$$$!~~~~78$$$$$$$6~~~~~~~~~!$$%", +"#$$$!~~~~~~90$$$$$abbbbbbbbbc$$%", +"#$$$!~~~~~~~def$$$$$$$$$$$$$$$$%", +"#$$$!~~~~~~~~~ghij$$$$$$$$$$$$$%", +"#$$$!~~~~~~~~~~klm$$$$$$$$$$$$$%", +"#$$$!~~~~~~~nopj$$$$$$$$$$$$$$$%", +"#$$$!~~~~~~qr$$$$$stttttttttu$$%", +"#$$$!~~~~~vw$$$$$$6~~~~~~~~~!$$%", +"#$$$!~~~~x$$$$$$$$6~~~~~~~~~!$$%", +"#$$$!~~~y$$$$$$$$$zAAAAAAAAAB$$%", +"#$$$!~~CD$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~~E$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~FG$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~H$$$$$$$$$$$$$$$$$$$$$$$$%", +"#$$$!~I$$$$$$JKKKKKKKKKKKKKKL$$%", +"#$$$MNO$$$$$$-;;;;;;;;;;;;;;>$$%", +"#$$$$$$$$$$$$-;;;;;;;;;;;;;;>$$%", +"#$$$$$$$$$$$$PQQQQQQQQQQQQQQR$$%", +"#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%", +"@SSSSSSSSSSSSSSSSSSSSSSSSSSSSSST"}; diff --git a/icons/universalIndentGUI_512x512.png b/icons/universalIndentGUI_512x512.png new file mode 100755 index 0000000..9c6a0df Binary files /dev/null and b/icons/universalIndentGUI_512x512.png differ diff --git a/icons/universalIndentGUI_64x64.png b/icons/universalIndentGUI_64x64.png new file mode 100755 index 0000000..c251538 Binary files /dev/null and b/icons/universalIndentGUI_64x64.png differ diff --git a/resources/Icon1.png b/resources/Icon1.png deleted file mode 100755 index 7144147..0000000 Binary files a/resources/Icon1.png and /dev/null differ diff --git a/resources/Icons.qrc b/resources/Icons.qrc deleted file mode 100755 index 71ffec5..0000000 --- a/resources/Icons.qrc +++ /dev/null @@ -1,48 +0,0 @@ - - - qt_logo.png - banner.png - - - language-de.png - language-en.png - language-fr.png - language-ru.png - language-uk.png - language-zh_CN.png - language-zh_TW.png - language-ja.png - - - document-properties.png - Icon1.png - universalIndentGUI.svg - document-open.png - document-save-as.png - document-save.png - edit-clear.png - exporthtml.png - exportpdf.png - format-justify-left.png - help.png - icon2.png - icon3.png - info.png - live-preview.png - load_indent_cfg.png - preferences-system.png - save_indent_cfg.png - shell.png - syntax-highlight.png - system-log-out.png - system-software-update.png - tooltip.png - view-refresh.png - - - accessories-text-editor.png - applications-system.png - icon3.png - syntax-highlight.png - - diff --git a/resources/UniversalIndentGUI.icns b/resources/UniversalIndentGUI.icns deleted file mode 100755 index c7f0294..0000000 Binary files a/resources/UniversalIndentGUI.icns and /dev/null differ diff --git a/resources/accessories-text-editor.png b/resources/accessories-text-editor.png deleted file mode 100755 index c3d245d..0000000 Binary files a/resources/accessories-text-editor.png and /dev/null differ diff --git a/resources/applications-system.png b/resources/applications-system.png deleted file mode 100755 index 4decc89..0000000 Binary files a/resources/applications-system.png and /dev/null differ diff --git a/resources/banner.png b/resources/banner.png deleted file mode 100755 index d0884d6..0000000 Binary files a/resources/banner.png and /dev/null differ diff --git a/resources/document-open.png b/resources/document-open.png deleted file mode 100755 index 2b135a1..0000000 Binary files a/resources/document-open.png and /dev/null differ diff --git a/resources/document-properties.png b/resources/document-properties.png deleted file mode 100755 index fa697db..0000000 Binary files a/resources/document-properties.png and /dev/null differ diff --git a/resources/document-save-as.png b/resources/document-save-as.png deleted file mode 100755 index 5c9f6b3..0000000 Binary files a/resources/document-save-as.png and /dev/null differ diff --git a/resources/document-save.png b/resources/document-save.png deleted file mode 100755 index db5c52b..0000000 Binary files a/resources/document-save.png and /dev/null differ diff --git a/resources/edit-clear.png b/resources/edit-clear.png deleted file mode 100755 index 5542948..0000000 Binary files a/resources/edit-clear.png and /dev/null differ diff --git a/resources/edit-select-all.png b/resources/edit-select-all.png deleted file mode 100755 index 107fc60..0000000 Binary files a/resources/edit-select-all.png and /dev/null differ diff --git a/resources/exporthtml.png b/resources/exporthtml.png deleted file mode 100755 index af03a38..0000000 Binary files a/resources/exporthtml.png and /dev/null differ diff --git a/resources/exportpdf.png b/resources/exportpdf.png deleted file mode 100755 index 5cfddff..0000000 Binary files a/resources/exportpdf.png and /dev/null differ diff --git a/resources/format-justify-left.png b/resources/format-justify-left.png deleted file mode 100755 index ba0e914..0000000 Binary files a/resources/format-justify-left.png and /dev/null differ diff --git a/resources/help.png b/resources/help.png deleted file mode 100755 index d60425f..0000000 Binary files a/resources/help.png and /dev/null differ diff --git a/resources/icon2.ico b/resources/icon2.ico deleted file mode 100755 index c784369..0000000 Binary files a/resources/icon2.ico and /dev/null differ diff --git a/resources/icon2.png b/resources/icon2.png deleted file mode 100755 index 337d353..0000000 Binary files a/resources/icon2.png and /dev/null differ diff --git a/resources/icon3.png b/resources/icon3.png deleted file mode 100755 index b6b6a9e..0000000 Binary files a/resources/icon3.png and /dev/null differ diff --git a/resources/info.png b/resources/info.png deleted file mode 100755 index 51c5e55..0000000 Binary files a/resources/info.png and /dev/null differ diff --git a/resources/language-de.png b/resources/language-de.png deleted file mode 100755 index ac4a977..0000000 Binary files a/resources/language-de.png and /dev/null differ diff --git a/resources/language-en.png b/resources/language-en.png deleted file mode 100755 index 3a7311d..0000000 Binary files a/resources/language-en.png and /dev/null differ diff --git a/resources/language-fr.png b/resources/language-fr.png deleted file mode 100755 index 8332c4e..0000000 Binary files a/resources/language-fr.png and /dev/null differ diff --git a/resources/language-ja.png b/resources/language-ja.png deleted file mode 100755 index 325fbad..0000000 Binary files a/resources/language-ja.png and /dev/null differ diff --git a/resources/language-ru.png b/resources/language-ru.png deleted file mode 100755 index 47da421..0000000 Binary files a/resources/language-ru.png and /dev/null differ diff --git a/resources/language-uk.png b/resources/language-uk.png deleted file mode 100755 index 09563a2..0000000 Binary files a/resources/language-uk.png and /dev/null differ diff --git a/resources/language-zh_CN.png b/resources/language-zh_CN.png deleted file mode 100755 index 8914414..0000000 Binary files a/resources/language-zh_CN.png and /dev/null differ diff --git a/resources/language-zh_TW.png b/resources/language-zh_TW.png deleted file mode 100755 index f31c654..0000000 Binary files a/resources/language-zh_TW.png and /dev/null differ diff --git a/resources/live-preview.png b/resources/live-preview.png deleted file mode 100755 index 5414bda..0000000 Binary files a/resources/live-preview.png and /dev/null differ diff --git a/resources/load_indent_cfg.png b/resources/load_indent_cfg.png deleted file mode 100755 index b51c82d..0000000 Binary files a/resources/load_indent_cfg.png and /dev/null differ diff --git a/resources/preferences-system.png b/resources/preferences-system.png deleted file mode 100755 index cc91d65..0000000 Binary files a/resources/preferences-system.png and /dev/null differ diff --git a/resources/programicon.rc b/resources/programicon.rc deleted file mode 100755 index 03b1e8e..0000000 --- a/resources/programicon.rc +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "..\src\UiGuiVersion.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "windows.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Deutsch (Deutschland) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - #define PROGRAM_TITLE "UniversalIndentGUI Notepad++ Plugin" - #define INTERNALNAME "UiGUI NPP Plugin" - #define ORIGINALFILENAME "UniversalIndentGUI_NPP.dll" -#else - #define PROGRAM_TITLE "UniversalIndentGUI" - #define INTERNALNAME "UiGUI" - #define ORIGINALFILENAME "UniversalIndentGUI.exe" -#endif - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION RESOURCE_VERSION - PRODUCTVERSION RESOURCE_VERSION - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040704b0" - BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "Thomas Schweitzer\0" - VALUE "FileDescription", PROGRAM_TITLE "\0" - VALUE "FileVersion", RESOURCE_VERSION_STRING - VALUE "InternalName", INTERNALNAME "\0" - VALUE "LegalCopyright", "Copyright © Thomas Schweitzer 2012\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", ORIGINALFILENAME "\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", PROGRAM_TITLE "\0" - VALUE "ProductVersion", RESOURCE_VERSION_STRING - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x407, 1200 - END -END - -#endif // !_MAC - -#endif // #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON DISCARDABLE "universalIndentGUI.ico" diff --git a/resources/qt_logo.png b/resources/qt_logo.png deleted file mode 100755 index 332f2ad..0000000 Binary files a/resources/qt_logo.png and /dev/null differ diff --git a/resources/save_indent_cfg.png b/resources/save_indent_cfg.png deleted file mode 100755 index 2276121..0000000 Binary files a/resources/save_indent_cfg.png and /dev/null differ diff --git a/resources/shell.png b/resources/shell.png deleted file mode 100755 index da59c67..0000000 Binary files a/resources/shell.png and /dev/null differ diff --git a/resources/syntax-highlight.png b/resources/syntax-highlight.png deleted file mode 100755 index fb6e297..0000000 Binary files a/resources/syntax-highlight.png and /dev/null differ diff --git a/resources/system-log-out.png b/resources/system-log-out.png deleted file mode 100755 index 780411d..0000000 Binary files a/resources/system-log-out.png and /dev/null differ diff --git a/resources/system-software-update.png b/resources/system-software-update.png deleted file mode 100755 index 470b5d4..0000000 Binary files a/resources/system-software-update.png and /dev/null differ diff --git a/resources/tooltip.png b/resources/tooltip.png deleted file mode 100755 index e4cdb05..0000000 Binary files a/resources/tooltip.png and /dev/null differ diff --git a/resources/universalIndentGUI.ico b/resources/universalIndentGUI.ico deleted file mode 100755 index db25009..0000000 Binary files a/resources/universalIndentGUI.ico and /dev/null differ diff --git a/resources/universalIndentGUI.svg b/resources/universalIndentGUI.svg deleted file mode 100755 index 44532ee..0000000 --- a/resources/universalIndentGUI.svg +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/resources/universalIndentGUI_32x32.xpm b/resources/universalIndentGUI_32x32.xpm deleted file mode 100755 index fd01f5e..0000000 --- a/resources/universalIndentGUI_32x32.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * universalIndentGUI_32x32_xpm[] = { -"32 32 85 1", -" c None", -". c #DFDFDF", -"+ c #EEEEEE", -"@ c #DEDEDE", -"# c #F0F0F0", -"$ c #FFFFFF", -"% c #EFEFEF", -"& c #7878E4", -"* c #6565EE", -"= c #9191E7", -"- c #6C6CF0", -"; c #5555FF", -"> c #8888F0", -", c #E9F1E9", -"' c #DEEBDE", -") c #F8FAF8", -"! c #55D655", -"~ c #00D400", -"{ c #ADEAAD", -"] c #8080E5", -"^ c #6F6FEE", -"/ c #9898E8", -"( c #69DF69", -"_ c #24D324", -": c #FEFEFE", -"< c #AEEAAE", -"[ c #32D632", -"} c #FDFEFD", -"| c #84E084", -"1 c #CFF7CF", -"2 c #33DD33", -"3 c #75DE75", -"4 c #03D503", -"5 c #ABE8AB", -"6 c #C3F5C3", -"7 c #05D205", -"8 c #96E796", -"9 c #51D851", -"0 c #DDF4DD", -"a c #C8F2C8", -"b c #20CB20", -"c c #65D165", -"d c #0AD30A", -"e c #68DD68", -"f c #D9F3D9", -"g c #03D303", -"h c #4DD94D", -"i c #B5EBB5", -"j c #FCFDFC", -"k c #22D322", -"l c #83E283", -"m c #EAF6EA", -"n c #01D301", -"o c #44D844", -"p c #B6ECB6", -"q c #2ED52E", -"r c #BEEBBE", -"s c #D3F8D3", -"t c #44DF44", -"u c #80E180", -"v c #67DC67", -"w c #F9FCF9", -"x c #82DF82", -"y c #5CDB5C", -"z c #C4F2C4", -"A c #10C910", -"B c #5BCF5B", -"C c #1AD31A", -"D c #F3FAF3", -"E c #91E691", -"F c #15D215", -"G c #F6FBF6", -"H c #58DC58", -"I c #9DE89D", -"J c #9C9CF5", -"K c #8E8EFF", -"L c #AFAFF5", -"M c #D0F4D0", -"N c #BBF4BB", -"O c #EFFAEF", -"P c #6E6EE3", -"Q c #5A5AEE", -"R c #8989E5", -"S c #EDEDED", -"T c #DCDCDC", -".++++++++++++++++++++++++++++++@", -"#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$$$$$$$$$$&**************=$$%", -"#$$$$$$$$$$$$-;;;;;;;;;;;;;;>$$%", -"#$$$,')$$$$$$-;;;;;;;;;;;;;;>$$%", -"#$$$!~{$$$$$$]^^^^^^^^^^^^^^/$$%", -"#$$$!~($$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~_:$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~~<$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~~[}$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~~~|$$$$$$$$$12222222223$$%", -"#$$$!~~~45$$$$$$$$6~~~~~~~~~!$$%", -"#$$$!~~~~78$$$$$$$6~~~~~~~~~!$$%", -"#$$$!~~~~~~90$$$$$abbbbbbbbbc$$%", -"#$$$!~~~~~~~def$$$$$$$$$$$$$$$$%", -"#$$$!~~~~~~~~~ghij$$$$$$$$$$$$$%", -"#$$$!~~~~~~~~~~klm$$$$$$$$$$$$$%", -"#$$$!~~~~~~~nopj$$$$$$$$$$$$$$$%", -"#$$$!~~~~~~qr$$$$$stttttttttu$$%", -"#$$$!~~~~~vw$$$$$$6~~~~~~~~~!$$%", -"#$$$!~~~~x$$$$$$$$6~~~~~~~~~!$$%", -"#$$$!~~~y$$$$$$$$$zAAAAAAAAAB$$%", -"#$$$!~~CD$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~~E$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~FG$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~H$$$$$$$$$$$$$$$$$$$$$$$$%", -"#$$$!~I$$$$$$JKKKKKKKKKKKKKKL$$%", -"#$$$MNO$$$$$$-;;;;;;;;;;;;;;>$$%", -"#$$$$$$$$$$$$-;;;;;;;;;;;;;;>$$%", -"#$$$$$$$$$$$$PQQQQQQQQQQQQQQR$$%", -"#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%", -"@SSSSSSSSSSSSSSSSSSSSSSSSSSSSSST"}; diff --git a/resources/universalIndentGUI_512x512.png b/resources/universalIndentGUI_512x512.png deleted file mode 100755 index 9c6a0df..0000000 Binary files a/resources/universalIndentGUI_512x512.png and /dev/null differ diff --git a/resources/universalIndentGUI_64x64.png b/resources/universalIndentGUI_64x64.png deleted file mode 100755 index c251538..0000000 Binary files a/resources/universalIndentGUI_64x64.png and /dev/null differ diff --git a/resources/view-refresh.png b/resources/view-refresh.png deleted file mode 100755 index 606ea9e..0000000 Binary files a/resources/view-refresh.png and /dev/null differ diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp deleted file mode 100644 index 3cbdf4f..0000000 --- a/src/AboutDialog.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "AboutDialog.h" -#include "ui_AboutDialog.h" - -#include "UiGuiVersion.h" - -#include -#include -#include -#include -#include - -/*! - \class AboutDialog - \brief Displays a dialog window with information about UniversalIndentGUI -*/ - -/*! - \brief The constructor calls the setup function for the ui created by uic and adds - the GPL text to the text edit. - */ -AboutDialog::AboutDialog(TQWidget *parent, TQt::WindowFlags flags) : - TQDialog(parent, flags), _dialogForm(NULL), _timer(NULL) -{ - _dialogForm = new Ui::AboutDialog(); - _dialogForm->setupUi(this); - - _dialogForm->authorTextBrowser->setOpenExternalLinks(true); - _dialogForm->creditsTextBrowser->setOpenExternalLinks(true); - - TQString versionString = _dialogForm->versionTextBrowser->toHtml(); - versionString = - versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( - UiGuiVersion::getBuildDate()); - _dialogForm->versionTextBrowser->setHtml(versionString); - - _dialogForm->creditsTextBrowser->setHtml("" - "
 
" - "

Thanks go out to

" - "

Nelson Tai for Chinese translation, good ideas and always fast answers.


" - "

Sebastian Pipping for helping me bring UiGUI into the Debian repository and other good ideas.


" - "

Oleksandr for Ukrainian and Russian translation.


" - "

Erwan "leg" for French translation and the icon logo.


" - "

The Scintilla project for their great text editing component.


" - "

Riverbank for their Scintilla TQt wrapper TQScintilla.


" - "

The Artistic Style project.


" - "

The BCPP project.


" - "

The Cobol Beautifier project.


" - "

The CSSTidy project.


" - "

The Fortran 90 PPR project.


" - "

The GNU Indent project.


" - "

The GreatCode project.


" - "

The hindent project.


" - "

The HTB project.


" - "

The HTML Tidy project.


" - "

The JsDecoder project.


" - "

The JSPPP project.


" - "

The Perltidy project.


" - "

The PHP_Beautifier project.


" - "

The phpCB project.


" - "

The PHP Stylist project.


" - "

The pindent project.


" - "

The Pl/Sql tidy project.


" - "

The Ruby Beautifier project.


" - "

The Ruby Formatter project.


" - "

The Shell Indent project.


" - "

The Uncrustify project, specially Ben Gardner.


" - "

The VBSBeautifier project.


" - "

The XML Indent project.


" - "

Nirvash for the initial Japanese translation.


" - "

The Tango Project for their icons.


" - "

famfamfam for the flag icons.


" - "

Trolltech for their really great GUI framework .


" - "

My girlfriend (meanwhile also wife) for putting my head right and not sit all the time in front of my computer ;-)

" - ""); - - _scrollDirection = 1; - _scrollSpeed = 100; - _timer = new TQTimer(this); - connect(_timer, SIGNAL(timeout()), this, SLOT(scroll())); - connect(this, SIGNAL(accepted()), _timer, SLOT(stop())); -} - -/*! - \brief Catches language change events and retranslates all needed widgets. - */ -void AboutDialog::changeEvent(TQEvent *event) -{ - if (event->type() == TQEvent::LanguageChange) - { - _dialogForm->retranslateUi(this); - - TQString versionString = _dialogForm->versionTextBrowser->toHtml(); - versionString = - versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( - UiGuiVersion::getBuildDate()); - _dialogForm->versionTextBrowser->setHtml(versionString); - } - else - { - TQWidget::changeEvent(event); - } -} - -/*! - \brief Reimplements the dialog execution function to init the credits scroller. - */ -int AboutDialog::exec() -{ - //creditsTextBrowser->verticalScrollBar()->setValue(0); - _timer->start(_scrollSpeed); - return TQDialog::exec(); -} - -/*! - \brief This slot is called each _timer timeout to scroll the credits textbrowser. - Also changes the scroll direction and speed when reaching the start or end. - */ -void AboutDialog::scroll() -{ - TQScrollBar *scrollBar = _dialogForm->creditsTextBrowser->verticalScrollBar(); - scrollBar->setValue(scrollBar->value() + _scrollDirection); - - if (scrollBar->value() == scrollBar->maximum()) - { - // Toggle scroll direction and change scroll speed; - _scrollDirection = -1; - _scrollSpeed = 5; - _timer->stop(); - _timer->start(_scrollSpeed); - } - else if (scrollBar->value() == scrollBar->minimum()) - { - // Toggle scroll direction and change scroll speed; - _scrollDirection = 1; - _scrollSpeed = 100; - _timer->stop(); - _timer->start(_scrollSpeed); - } - - _dialogForm->creditsTextBrowser->update(); -} - -/*! - \brief Shows the about dialog and also starts the credits scroller. - */ -void AboutDialog::show() -{ - _timer->start(_scrollSpeed); - TQDialog::show(); -} diff --git a/src/AboutDialog.h b/src/AboutDialog.h deleted file mode 100644 index c849f7b..0000000 --- a/src/AboutDialog.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef ABOUTDIALOG_H -#define ABOUTDIALOG_H - -#include - -namespace Ui -{ - class AboutDialog; -} - - -class AboutDialog : public TQDialog -{ - Q_OBJECT - - public: - AboutDialog(TQWidget *parent = NULL, TQt::WindowFlags flags = 0); - - public slots: - int exec(); - void show(); - - private slots: - void scroll(); - - private: - void changeEvent(TQEvent *event); - - Ui::AboutDialog *_dialogForm; - int _scrollDirection; - int _scrollSpeed; - TQTimer *_timer; -}; - -#endif // ABOUTDIALOG_H diff --git a/src/AboutDialog.ui b/src/AboutDialog.ui deleted file mode 100755 index dbc2b8c..0000000 --- a/src/AboutDialog.ui +++ /dev/null @@ -1,218 +0,0 @@ - - - AboutDialog - - - - 0 - 0 - 588 - 512 - - - - - 0 - 0 - - - - - 588 - 333 - - - - About UniversalIndentGUI - - - - :/mainWindow/info.png:/mainWindow/info.png - - - - 0 - - - - - TQFrame#frame { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #FFFF60, stop:0.5 #D8C304, stop:1 #FFFF60 ); border: 2px solid #A89C57; border-radius: 4px;} - - - TQFrame::StyledPanel - - - - - - - 0 - 0 - - - - - 570 - 87 - - - - - 570 - 87 - - - - - - - :/aboutDialog/banner.png - - - - - - - - 0 - 0 - - - - - 16777215 - 25 - - - - TQTextBrowser{background-color:transparent} - - - TQFrame::NoFrame - - - TQt::ScrollBarAlwaysOff - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'sans-serif'; font-size:large;">Version %1 rev.%2, %3</span></p></body></html> - - - - - - - - 0 - 0 - - - - false - - - TQTextBrowser{background-color:transparent} - - - TQFrame::NoFrame - - - TQt::ScrollBarAlwaysOff - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">... is a cross platform compatible GUI for several code formatter, beautifier and indenter like GreatCode, AStyle (Artistic Styler), GNU Indent, BCPP and so on. Main feature is a live preview to directly see how the selected formatting option affects the source code.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;"><br />Written by : </span><a href="http://www.thomas-schweitzer.de"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">Thomas Schweitzer</span></a></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">Project Homepage : </span><a href="http://universalindent.sourceforge.net"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">http://universalindent.sourceforge.net</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">License: UniversalIndentGui is released under the GPL 2. For details read the included file LICENSE.GPL visit </span><a href="http://www.gnu.org/licenses/gpl.html"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/gpl.html</span></a><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">Credits:</span></p></body></html> - - - - - - - TQTextBrowser#creditsTextBrowser{border:2px solid rgba(0,0,0,10%); background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,0,80%), stop:0.1 rgba(0,0,0,15%), stop:0.9 rgba(0,0,0,15%), stop:1 rgba(0,0,0,80%) )} - - - TQFrame::NoFrame - - - TQt::ScrollBarAlwaysOff - - - - - - - - - TQt::Horizontal - - - - 131 - 31 - - - - - - - - TQPushButton#okButton { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #DCB28A, stop:0.5 #B8784B, stop:1 #DCB28A ); border: 2px solid #A89C57; border-radius: 4px;} TQPushButton:hover#okButton { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #B8784B, stop:0.5 #DCB28A, stop:1 #B8784B ); } TQPushButton:pressed#okButton{ border: 2px solid #D8CB75 } - - - OK - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - okButton - clicked() - AboutDialog - accept() - - - 278 - 253 - - - 96 - 254 - - - - - diff --git a/src/AboutDialogGraphicsView.cpp b/src/AboutDialogGraphicsView.cpp deleted file mode 100644 index 3c031f2..0000000 --- a/src/AboutDialogGraphicsView.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#include "AboutDialogGraphicsView.h" - -#include "AboutDialog.h" - -#include -#include -#include -#include -#include - -/*! - \class AboutDialogGraphicsView - \brief A container for the real \a AboutDialog. Makes the 3D animation possible. - - The 3D animation shall suggest the user, that he is looking at his desktop, while - this animation is done. Since this is not directly possible, \a AboutDialogGraphicsView - when shown starts in frameless fullscreen mode with a screenshot of the desktop as background. -*/ - -/*! - \brief The constructor initializes everything needed for the 3D animation. - */ -AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow) : - TQGraphicsView(parentWindow), _aboutDialog(NULL), _graphicsProxyWidget(NULL), - _parentWindow(NULL), _timeLine(NULL), _aboutDialogAsSplashScreen(NULL) -{ - _parentWindow = parentWindow; - setWindowFlags(TQt::SplashScreen); - -#ifdef Q_OS_LINUX - TQRect availableGeometry = TQApplication::desktop()->availableGeometry(); - TQRect newGeometry = TQRect(availableGeometry.x(), - availableGeometry.y(), availableGeometry.width(), availableGeometry.height()); -#else - TQRect newGeometry = TQRect(-1, -1, - TQApplication::desktop()->rect().width() + 2, - TQApplication::desktop()->rect().height() + 2); -#endif - setGeometry(newGeometry); - - _aboutDialog = aboutDialog; - - _windowTitleBarWidth = 0; - _windowPosOffset = 0; - - TQGraphicsScene *scene = new TQGraphicsScene(this); - setSceneRect(newGeometry); - _aboutDialogAsSplashScreen = new TQSplashScreen(this); - _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen); - _graphicsProxyWidget->setWindowFlags(TQt::ToolTip); - - setScene(scene); - setRenderHint(TQPainter::Antialiasing); - - setCacheMode(TQGraphicsView::CacheBackground); - setViewportUpdateMode(TQGraphicsView::BoundingRectViewportUpdate); - - connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide())); - - //setWindowOpacity(0.9); - - setVerticalScrollBarPolicy(TQt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(TQt::ScrollBarAlwaysOff); - setStyleSheet("AboutDialogGraphicsView { border: 0px; }"); - - _timeLine = new TQTimeLine(1000, this); - _timeLine->setFrameRange(270, 0); - //_timeLine->setUpdateInterval(10); - //_timeLine->setCurveShape(TQTimeLine::EaseInCurve); - connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int))); -} - -AboutDialogGraphicsView::~AboutDialogGraphicsView(void) -{ -} - -/*! - \brief Grabs a screenshot of the full desktop and shows that as background. Above that background the - AboutDialog 3D animation is shown. Also grabs the content of the AboutDialog itself. - */ -void AboutDialogGraphicsView::show() -{ - // Because on X11 system the window decoration is only available after a widget has been shown - // once, - // we can detect _windowTitleBarWidth here for the first time. - _windowTitleBarWidth = _parentWindow->geometry().y() - _parentWindow->y(); - // If the _windowTitleBarWidth could not be determined, try it a second way. Even the chances are - // low to get good results. - if (_windowTitleBarWidth == 0) - { - _windowTitleBarWidth = _parentWindow->frameGeometry().height() - - _parentWindow->geometry().height(); - } -#ifdef Q_OS_LINUX - if (_windowTitleBarWidth == 0) - { - //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a - // workaround for that specific case. - _windowPosOffset = 27; - _windowTitleBarWidth = 27; - } -#endif - TQPixmap originalPixmap = TQPixmap::grabWindow( - TQApplication::desktop()->winId(), - TQApplication::desktop()->availableGeometry().x(), - TQApplication::desktop()->availableGeometry().y(), geometry().width(), - geometry().height()); - TQBrush brush(originalPixmap); - TQTransform transform; - transform.translate(0, TQApplication::desktop()->availableGeometry().y()); - brush.setTransform(transform); - - setBackgroundBrush(brush); - - _aboutDialogAsSplashScreen->setPixmap(TQPixmap::grabWidget(_aboutDialog)); - _graphicsProxyWidget->setGeometry(_aboutDialog->geometry()); - _aboutDialog->hide(); - _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + - (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, - _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); - - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform().translate( - r.width() / 2, -_windowTitleBarWidth).rotate(270, TQt::XAxis) - //.rotate(90, TQt::YAxis) - //.rotate(5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - - _graphicsProxyWidget->show(); - //_aboutDialogAsSplashScreen->show(); - TQGraphicsView::show(); - - connect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); - _timeLine->setDirection(TQTimeLine::Forward); - _timeLine->start(); -} - -/*! - \brief Does the next calculation/transformation step. - */ -void AboutDialogGraphicsView::updateStep(int step) -{ - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform().translate( - r.width() / 2, -_windowTitleBarWidth).rotate(step, TQt::XAxis) - //.rotate(step, TQt::YAxis) - //.rotate(step * 5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - //update(); -} - -/*! - \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it. - */ -void AboutDialogGraphicsView::showAboutDialog() -{ - //hide(); - disconnect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); - _aboutDialog->move(int(_parentWindow->geometry().x() + - (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2), - _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); - _aboutDialog->exec(); -} - -/*! - \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation. - */ -void AboutDialogGraphicsView::hide() -{ - _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + - (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, - _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); - - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform().translate( - r.width() / 2, -_windowTitleBarWidth).rotate(0, TQt::XAxis) - //.rotate(90, TQt::YAxis) - //.rotate(5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - - _graphicsProxyWidget->show(); - //_aboutDialogAsSplashScreen->show(); - TQGraphicsView::show(); - - connect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); - _timeLine->setDirection(TQTimeLine::Backward); - _timeLine->start(); -} - -/*! - \brief This slot really hides this AboutDialog container. - */ -void AboutDialogGraphicsView::hideReally() -{ - disconnect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); - TQGraphicsView::hide(); - _parentWindow->activateWindow(); -} diff --git a/src/AboutDialogGraphicsView.h b/src/AboutDialogGraphicsView.h deleted file mode 100644 index 4554e36..0000000 --- a/src/AboutDialogGraphicsView.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -#ifndef ABOUTDIALOGGRAPHICSVIEW_H -#define ABOUTDIALOGGRAPHICSVIEW_H - -#include - -class AboutDialog; - -class TQTimeLine; -class TQSplashScreen; - - -class AboutDialogGraphicsView : public TQGraphicsView -{ - Q_OBJECT - - public: - AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow = NULL); - ~AboutDialogGraphicsView(void); - - public slots: - void show(); - void hide(); - - private slots: - void updateStep(int step); - void showAboutDialog(); - void hideReally(); - - private: - AboutDialog *_aboutDialog; - TQGraphicsProxyWidget *_graphicsProxyWidget; - TQWidget *_parentWindow; - TQTimeLine *_timeLine; - TQSplashScreen *_aboutDialogAsSplashScreen; - int _windowTitleBarWidth; - int _windowPosOffset; -}; - -#endif // ABOUTDIALOGGRAPHICSVIEW_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 253a779..a911d9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,9 +26,8 @@ link_directories( set( target universal-indent-gui-tqt ) set( ${target}_SRCS - main.cpp + MainWindowBase.ui MainWindow.cpp main.cpp UiGuiVersion.cpp - MainWindow.cpp ) tde_add_executable( ${target} AUTOMOC diff --git a/src/FindDialog.ui b/src/FindDialog.ui deleted file mode 100755 index 00cc527..0000000 --- a/src/FindDialog.ui +++ /dev/null @@ -1,121 +0,0 @@ - - - FindDialog - - - - 0 - 0 - 347 - 227 - - - - Find - - - - - - - 0 - 0 - - - - Find what: - - - - - - - true - - - - - - - - 0 - 0 - - - - Find options - - - - - - Match case - - - - - - - Match whole word - - - - - - - Search forward - - - true - - - - - - - Use Regular Expressions - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - TQLayout::SetMaximumSize - - - - - Find Next - - - - - - - Close - - - - - - - - - - diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp deleted file mode 100644 index b0378a8..0000000 --- a/src/IndentHandler.cpp +++ /dev/null @@ -1,2044 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "IndentHandler.h" - -#include "UiGuiSettings.h" -#include "UiGuiErrorMessage.h" -#include "TemplateBatchScript.h" -#include "UiGuiIniFileParser.h" -#include "SettingsPaths.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef Q_OS_WIN32 - #include -#endif - -// Avoid unused parameter warnings by this template -template -inline void UNUSED_PARAMETER_WARNING_AVOID(T) -{ -} - -//! \defgroup grp_Indenter All concerning handling of the indenter. - -/*! - \class IndentHandler - \ingroup grp_Indenter - \brief A widget for handling many indenters that are configured by an ini file. - - This is a widget that is used by the main window. It handles access to the - indenter config file and calls the chosen indenter to reformat the source text. - Calls the indenter each time a setting has been changed and informs - the main window about the reformatted source code. -*/ - - -/*! - \brief Constructor of the indent handler. - - By calling this constructor the indenter to be loaded, can be selected by setting - its \a indenterID, which is the number of found indenter ini files in alphabetic - order starting at index 0. - */ -IndentHandler::IndentHandler(int indenterID, TQWidget *mainWindow, TQWidget *parent) : - TQWidget(parent), _indenterSelectionCombobox(NULL), _indenterParameterHelpButton(NULL), - _toolBoxContainerLayout(NULL), _indenterParameterCategoriesToolBox(NULL), _indenterSettings( - NULL), _mainWindow(NULL), _errorMessageDialog(NULL), _menuIndenter(NULL), - _actionLoadIndenterConfigFile(NULL), _actionSaveIndenterConfigFile(NULL), - _actionCreateShellScript(NULL), _actionResetIndenterParameters(NULL), - _parameterChangedCallback(NULL), _windowClosedCallback(NULL) -{ - Q_ASSERT_X(indenterID >= 0, "IndentHandler", "the selected indenterID is < 0"); - - setObjectName(TQString::fromUtf8("indentHandler")); - - _mainWindow = mainWindow; - - initIndenterMenu(); - - connect(_actionLoadIndenterConfigFile, SIGNAL(triggered()), this, SLOT(openConfigFileDialog())); - connect(_actionSaveIndenterConfigFile, SIGNAL(triggered()), this, SLOT( - saveasIndentCfgFileDialog())); - connect(_actionCreateShellScript, SIGNAL(triggered()), this, - SLOT(createIndenterCallShellScript())); - connect(_actionResetIndenterParameters, SIGNAL(triggered()), this, - SLOT(resetIndenterParameter())); - - // define this widgets resize behavior - setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); - - // create vertical layout box, into which the toolbox will be added - _toolBoxContainerLayout = new TQVBoxLayout(this); - _toolBoxContainerLayout->setMargin(2); - - // Create horizontal layout for indenter selector and help button. - TQHBoxLayout *hboxLayout = new TQHBoxLayout(); - //hboxLayout->setMargin(2); - _toolBoxContainerLayout->addLayout(hboxLayout); - - // Create the indenter selection combo box. - _indenterSelectionCombobox = new TQComboBox(this); - _indenterSelectionCombobox->setSizeAdjustPolicy(TQComboBox::AdjustToMinimumContentsLengthWithIcon); - _indenterSelectionCombobox->setMinimumContentsLength(20); - connect(_indenterSelectionCombobox, SIGNAL(activated(int)), this, SLOT(setIndenter(int))); - UiGuiSettings::getInstance()->registerObjectProperty(_indenterSelectionCombobox, "currentIndex", - "selectedIndenter"); - hboxLayout->addWidget(_indenterSelectionCombobox); - - // Create the indenter parameter help button. - _indenterParameterHelpButton = new TQToolButton(this); - _indenterParameterHelpButton->setObjectName(TQString::fromUtf8("indenterParameterHelpButton")); - _indenterParameterHelpButton->setIcon(TQIcon(TQString::fromUtf8(":/mainWindow/help.png"))); - hboxLayout->addWidget(_indenterParameterHelpButton); - // Handle if the indenter parameter help button is pressed. - connect(_indenterParameterHelpButton, SIGNAL(clicked()), this, SLOT(showIndenterManual())); - - // create a toolbox and set its resize behavior - _indenterParameterCategoriesToolBox = new TQToolBox(this); - _indenterParameterCategoriesToolBox->setObjectName(TQString::fromUtf8( - "_indenterParameterCategoriesToolBox")); - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, - SLOT(updateDrawing())); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS - - //_indenterParameterCategoriesToolBox->setSizePolicy( TQSizePolicy::Expanding, - // TQSizePolicy::Expanding ); - //_indenterParameterCategoriesToolBox->setMaximumSize(TQSize(16777215, 16777215)); - // insert the toolbox into the vlayout - _toolBoxContainerLayout->addWidget(_indenterParameterCategoriesToolBox); - - _indenterExecutableCallString = ""; - _indenterExecutableSuffix = ""; - - _indenterDirctoryStr = SettingsPaths::getIndenterPath(); - _tempDirctoryStr = SettingsPaths::getTempPath(); - _settingsDirctoryStr = SettingsPaths::getSettingsPath(); - TQDir indenterDirctory = TQDir(_indenterDirctoryStr); - - if (_mainWindow != NULL) - { - _errorMessageDialog = new UiGuiErrorMessage(_mainWindow); - } - else - { - _errorMessageDialog = new UiGuiErrorMessage(this); - } - - _indenterIniFileList = indenterDirctory.entryList(TQStringList("uigui_*.ini")); - if (_indenterIniFileList.count() > 0) - { - // Take care if the selected indenterID is smaller or greater than the number of existing - // indenters - if (indenterID < 0) - { - indenterID = 0; - } - if (indenterID >= _indenterIniFileList.count()) - { - indenterID = _indenterIniFileList.count() - 1; - } - - // Reads and parses the by indenterID defined indent ini file and creates toolbox entries - readIndentIniFile(_indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID)); - - // Find out how the indenter can be executed. - createIndenterCallString(); - - // Load the users last settings made for this indenter. - loadConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg"); - - // Fill the indenter selection combo box with the list of available indenters. - if (!getAvailableIndenters().isEmpty()) - { - _indenterSelectionCombobox->addItems(getAvailableIndenters()); - _indenterSelectionCombobox->setCurrentIndex(indenterID); - connect(_indenterSelectionCombobox, SIGNAL(currentIndexChanged(int)), this, - SIGNAL(selectedIndenterIndexChanged(int))); - } - } - else - { - _errorMessageDialog->showMessage(tr("No indenter ini files"), - tr("There exists no indenter ini files in the directory \"") + - TQDir(_indenterDirctoryStr).absolutePath() + "\"."); - } - - retranslateUi(); -} - -/*! - \brief Implicitly writes the current indenter parameters to the indenters config file. - */ -IndentHandler::~IndentHandler() -{ - // Generate the parameter string that will be saved to the indenters config file. - TQString parameterString = getParameterString(); - if (!_indenterFileName.isEmpty()) - { - saveConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString); - } - - delete _errorMessageDialog; -} - -/*! - \brief Initializes the context menu used for some actions like saving the indenter config file. - */ -void IndentHandler::initIndenterMenu() -{ - if (_menuIndenter == NULL) - { - _actionLoadIndenterConfigFile = new TQAction(this); - _actionLoadIndenterConfigFile->setObjectName(TQString::fromUtf8("_actionLoadIndenterConfigFile")); - _actionLoadIndenterConfigFile->setIcon(TQIcon(TQString::fromUtf8( - ":/mainWindow/load_indent_cfg.png"))); - - _actionSaveIndenterConfigFile = new TQAction(this); - _actionSaveIndenterConfigFile->setObjectName(TQString::fromUtf8("_actionSaveIndenterConfigFile")); - _actionSaveIndenterConfigFile->setIcon(TQIcon(TQString::fromUtf8( - ":/mainWindow/save_indent_cfg.png"))); - - _actionCreateShellScript = new TQAction(this); - _actionCreateShellScript->setObjectName(TQString::fromUtf8("_actionCreateShellScript")); - _actionCreateShellScript->setIcon(TQIcon(TQString::fromUtf8(":/mainWindow/shell.png"))); - - _actionResetIndenterParameters = new TQAction(this); - _actionResetIndenterParameters->setObjectName(TQString::fromUtf8( - "_actionResetIndenterParameters")); - _actionResetIndenterParameters->setIcon(TQIcon(TQString::fromUtf8( - ":/mainWindow/view-refresh.png"))); - - _menuIndenter = new TQMenu(this); - _menuIndenter->setObjectName(TQString::fromUtf8("_menuIndenter")); - _menuIndenter->addAction(_actionLoadIndenterConfigFile); - _menuIndenter->addAction(_actionSaveIndenterConfigFile); - _menuIndenter->addAction(_actionCreateShellScript); - _menuIndenter->addAction(_actionResetIndenterParameters); - } -} - -/*! - \brief Returns the context menu used for some actions like saving the indenter config file. - */ -TQMenu* IndentHandler::getIndenterMenu() -{ - return _menuIndenter; -} - -/*! - \brief Returns the actions of the context menu used for some actions like saving the indenter config file. - */ -TQList IndentHandler::getIndenterMenuActions() -{ - TQList actionList; - actionList << _actionLoadIndenterConfigFile << _actionSaveIndenterConfigFile << - _actionCreateShellScript << _actionResetIndenterParameters; - return actionList; -} - -/*! - \brief Opens the context menu, used for some actions like saving the indenter config file, at the event position. - */ -void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) -{ - getIndenterMenu()->exec(event->globalPos()); -} - -/*! - \brief Creates the content for a shell script that can be used as a external tool call - to indent an as parameter defined file. - */ -TQString IndentHandler::generateShellScript(const TQString &configFilename) -{ - TQString indenterCompleteCallString; - TQString parameterInputFile; - TQString parameterOuputFile; - TQString parameterParameterFile; - TQString replaceInputFileCommand; - - // Define the placeholder for parameter variables either in batch or bash programming. -#if defined (Q_OS_WIN32) - TQString shellParameterPlaceholder = "%1"; -#else - TQString shellParameterPlaceholder = "$1"; -#endif - - parameterInputFile = " " + _inputFileParameter + "\"" + shellParameterPlaceholder + "\""; - - if (_outputFileParameter != "none" && _outputFileParameter != "stdout") - { - if (_outputFileName == _inputFileName) - { - parameterOuputFile = " " + _outputFileParameter + "\"" + shellParameterPlaceholder + "\""; - } - else - { - parameterOuputFile = " " + _outputFileParameter + _outputFileName + ".tmp"; - } - } - - // If the config file name is empty it is assumed that all parameters are sent via command line - // call - if (_globalConfigFilename.isEmpty()) - { - parameterParameterFile = " " + getParameterString(); - } - // else if needed add the parameter to the indenter call string where the config file can be - // found. - else if (_useCfgFileParameter != "none") - { - parameterParameterFile = " " + _useCfgFileParameter + "\"./" + configFilename + "\""; - } - - // Assemble indenter call string for parameters according to the set order. - if (_parameterOrder == "ipo") - { - indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile; - } - else if (_parameterOrder == "pio") - { - indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile; - } - else if (_parameterOrder == "poi") - { - indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile; - } - else - { - indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile; - } - - // Generate the indenter call string either for win32 or other systems. -#if defined (Q_OS_WIN32) - indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString; -#else - indenterCompleteCallString = "#!/bin/bash\n" + _indenterExecutableCallString + - indenterCompleteCallString; -#endif - - // If the indenter writes to stdout pipe the output into a file - if (_outputFileParameter == "stdout") - { - indenterCompleteCallString = indenterCompleteCallString + " >" + _outputFileName + ".tmp"; - } - - // If the output filename is not the same as the input filename copy the output over the input. - if (_outputFileName != _inputFileName) - { -#if defined (Q_OS_WIN32) - replaceInputFileCommand = "move /Y " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + - "\"\n"; -#else - replaceInputFileCommand = "mv " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + - "\"\n"; -#endif - } - -#if defined (Q_OS_WIN32) - TQString shellScript(TemplateBatchScript::getTemplateBatchScript()); - shellScript = shellScript.replace("__INDENTERCALLSTRING2__", - indenterCompleteCallString + "\n" + replaceInputFileCommand); - indenterCompleteCallString = indenterCompleteCallString.replace("%1", "%%G"); - replaceInputFileCommand = replaceInputFileCommand.replace("%1", "%%G"); - shellScript = shellScript.replace("__INDENTERCALLSTRING1__", - indenterCompleteCallString + "\n" + replaceInputFileCommand); -#else - TQString shellScript(TemplateBatchScript::getTemplateBatchScript()); - shellScript = shellScript.replace("__INDENTERCALLSTRING2__", - indenterCompleteCallString + "\n" + replaceInputFileCommand); - indenterCompleteCallString = indenterCompleteCallString.replace("$1", "$file2indent"); - replaceInputFileCommand = replaceInputFileCommand.replace("$1", "$file2indent"); - shellScript = shellScript.replace("__INDENTERCALLSTRING1__", - indenterCompleteCallString + "\n" + replaceInputFileCommand); -#endif - - return shellScript; -} - -/*! - \brief Format \a sourceCode by calling the indenter. - - The \a inputFileExtension has to be given as parameter so the called indenter - can identify the programming language if needed. - */ -TQString IndentHandler::callIndenter(TQString sourceCode, TQString inputFileExtension) -{ - if (_indenterExecutableSuffix == ".js") - { - return callJavaScriptIndenter(sourceCode); - } - else - { - return callExecutableIndenter(sourceCode, inputFileExtension); - } -} - -/*! - \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter. - - The \a inputFileExtension has to be given as parameter so the called indenter - can identify the programming language if needed. - */ -TQString IndentHandler::callJavaScriptIndenter(TQString sourceCode) -{ - TQScriptEngine engine; - - engine.globalObject().setProperty("unformattedCode", sourceCode); - - TQFile jsDecoderFile(_indenterExecutableCallString); - TQString jsDecoderCode; - if (jsDecoderFile.open(TQFile::ReadOnly)) - { - jsDecoderCode = jsDecoderFile.readAll(); - } - jsDecoderFile.close(); - - TQScriptValue value = engine.evaluate(jsDecoderCode); - return value.toString(); -} - -/*! - \brief Format \a sourceCode by calling the binary executable of the indenter. - - The \a inputFileExtension has to be given as parameter so the called indenter - can identify the programming language if needed. - */ -TQString IndentHandler::callExecutableIndenter(TQString sourceCode, TQString inputFileExtension) -{ - Q_ASSERT_X(!_inputFileName.isEmpty(), "callIndenter", "_inputFileName is empty"); - // Q_ASSERT_X( !_outputFileName.isEmpty(), "callIndenter", "_outputFileName is empty" ); - Q_ASSERT_X(!_indenterFileName.isEmpty(), "callIndenter", "_indenterFileName is empty"); - - if (_indenterFileName.isEmpty()) - { - return ""; - } - - TQString formattedSourceCode; - TQString indenterCompleteCallString; - TQString parameterInputFile; - TQString parameterOuputFile; - TQString parameterParameterFile; - TQProcess indentProcess; - TQString processReturnString; - - // Generate the parameter string that will be saved to the indenters config file - TQString parameterString = getParameterString(); - - if (!_globalConfigFilename.isEmpty()) - { - saveConfigFile(_tempDirctoryStr + "/" + _globalConfigFilename, parameterString); - } - - // Only add a dot to file extension if the string is not empty - if (!inputFileExtension.isEmpty()) - { - inputFileExtension = "." + inputFileExtension; - } - - // Delete any previously used input src file and create a new input src file. - TQFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); - TQFile inputSrcFile(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); - // Write the source code to the input file for the indenter - if (inputSrcFile.open(TQFile::ReadWrite | TQFile::Text)) - { - inputSrcFile.write(sourceCode.toUtf8()); - inputSrcFile.close(); - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Wrote to be indented source code to file " << - inputSrcFile.fileName(); - } - else - { - qCritical() << __LINE__ << " " << __FUNCTION__ << - ": Couldn't write to be indented source code to file " << inputSrcFile.fileName(); - } - - // Set the input file for the to be called indenter. - if (_inputFileParameter.trimmed() == "<" || _inputFileParameter == "stdin") - { - parameterInputFile = ""; - indentProcess.setStandardInputFile(inputSrcFile.fileName()); - } - else - { - parameterInputFile = " " + _inputFileParameter + _inputFileName + inputFileExtension; - } - - // Set the output file for the to be called indenter. - if (_outputFileParameter != "none" && _outputFileParameter != "stdout") - { - parameterOuputFile = " " + _outputFileParameter + _outputFileName + inputFileExtension; - } - -#ifdef Q_OS_WIN32 - // Paths may contain Unicode or other foreign characters. Windows commands line tools will - // receive als falsely encoded path string by TQProcess or they connot correctly handle - // the Unicode path on their own. - // Because of this the path gets converted to Windows short paths using the 8.3 notation. - - tqDebug() << __LINE__ << " " << __FUNCTION__ << - ": Temp dir before trying to convert it to short Windows path is" << _tempDirctoryStr; - - // At first convert the temp path to Windows like separators. - TQString tempDirctoryStrHelper = - TQDir::toNativeSeparators(_tempDirctoryStr).replace("\\", "\\\\"); - // Then convert the TQString to a WCHAR array and NULL terminate it. - WCHAR *tempDirctoryWindowsStr = new WCHAR[tempDirctoryStrHelper.length() + 1]; - tempDirctoryStrHelper.toWCharArray(tempDirctoryWindowsStr); - tempDirctoryWindowsStr[tempDirctoryStrHelper.length()] = (WCHAR)NULL; - - // Get the length of the resulting short path. - long length = 0; - TCHAR *buffer = NULL; - length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, NULL, 0); - - // If the short path could be retrieved, create a correct sized buffer, store the - // short path in it and convert all back to TQString. - if (length != 0) - { - #ifdef UNICODE - buffer = new WCHAR[length]; - length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length); - tempDirctoryStrHelper = TQString::fromWCharArray(buffer); - #else - buffer = new TCHAR[length]; - length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length); - tempDirctoryStrHelper = buffer; - #endif - _tempDirctoryStr = TQDir::fromNativeSeparators(tempDirctoryStrHelper).replace("//", "/"); - delete[] buffer; - - // Check whether the short path still contains some kind of non ascii characters. - if (_tempDirctoryStr.length() != _tempDirctoryStr.toAscii().length()) - { - tqWarning() << __LINE__ << " " << __FUNCTION__ << - ": Shortened path still contains non ascii characters. Could cause some indenters not to work properly!"; - } - } - else - { - tqWarning() << __LINE__ << " " << __FUNCTION__ << - ": Couldn't retrieve a short version of the temporary path!"; - } - - tqDebug() << __LINE__ << " " << __FUNCTION__ << - ": Temp dir after trying to convert it to short Windows path is " << _tempDirctoryStr; - - delete[] tempDirctoryWindowsStr; -#endif - - // If the config file name is empty it is assumed that all parameters are sent via command line - // call - if (_globalConfigFilename.isEmpty()) - { - parameterParameterFile = " " + parameterString; - } - // if needed add the parameter to the indenter call string where the config file can be found - else if (_useCfgFileParameter != "none") - { - parameterParameterFile = " " + _useCfgFileParameter + "\"" + _tempDirctoryStr + "/" + - _globalConfigFilename + "\""; - } - - // Assemble indenter call string for parameters according to the set order. - if (_parameterOrder == "ipo") - { - indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile; - } - else if (_parameterOrder == "pio") - { - indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile; - } - else if (_parameterOrder == "poi") - { - indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile; - } - else - { - indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile; - } - - // If no indenter executable call string could be created before, show an error message. - if (_indenterExecutableCallString.isEmpty()) - { - _errorMessageDialog->showMessage(tr("No indenter executable"), tr( - "There exists no indenter executable with the name \"%1\" in the directory \"%2\" nor in the global environment.").arg( - _indenterFileName).arg(_indenterDirctoryStr)); - return sourceCode; - } - - // Generate the indenter call string either for win32 or other systems. - indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString; - - // errors and standard outputs from the process call are merged together - //indentProcess.setReadChannelMode(TQProcess::MergedChannels); - - // Set the directory where the indenter will be executed for the process' environment as PWD. - TQStringList env = indentProcess.environment(); - env << "PWD=" + TQFileInfo(_tempDirctoryStr).absoluteFilePath(); - indentProcess.setEnvironment(env); - - // Set the directory for the indenter execution - indentProcess.setWorkingDirectory(TQFileInfo(_tempDirctoryStr).absoluteFilePath()); - - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Will call the indenter in the directory " << - indentProcess.workingDirectory() << " using this commandline call: " << - indenterCompleteCallString; - - indentProcess.start(indenterCompleteCallString); - - processReturnString = ""; - bool calledProcessSuccessfully = indentProcess.waitForFinished(10000); - // test if there was an error during starting the process of the indenter - if (!calledProcessSuccessfully) - { - processReturnString = ""; - processReturnString += tr("Returned error message: ") + indentProcess.errorString() + - "
"; - - switch (indentProcess.error()) - { - case TQProcess::FailedToStart: - { - processReturnString += tr("Reason could be: ") + - "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.
"; - break; - } - - case TQProcess::Crashed: - { - processReturnString += "The process crashed some time after starting successfully.
"; - break; - } - - case TQProcess::Timedout: - { - processReturnString += - "The called indenter did not response for over 10 seconds, so aborted its execution.
"; - break; - } - - case TQProcess::WriteError: - { - processReturnString += - "An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.
"; - break; - } - - case TQProcess::ReadError: - { - processReturnString += - "An error occurred when attempting to read from the process. For example, the process may not be running.
"; - break; - } - - case TQProcess::UnknownError: - { - processReturnString += - "An unknown error occurred. This is the default return value of error().
"; - break; - } - - default: - { - break; - } - } - processReturnString += tr("
Callstring was: ") + encodeToHTML( - indenterCompleteCallString); - processReturnString += tr("

Indenter output was:
") + "
" + "(STDOUT):" + - encodeToHTML(indentProcess.readAllStandardOutput()) + "
" + "(STDERR):" + - encodeToHTML(indentProcess.readAllStandardError()) + "
" + "
"; - tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; - TQApplication::restoreOverrideCursor(); - _errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString); - } - - // If the indenter returned an error code != 0 show its output. - if (indentProcess.exitCode() != 0) - { - TQString exitCode; - exitCode.setNum(indentProcess.exitCode()); - processReturnString = tr("Indenter returned with exit code: ") + exitCode + "
" + tr( - "Indent console output was: ") + "
" + "(STDOUT):" + encodeToHTML( - indentProcess.readAllStandardOutput()) + "
" + "(STDERR):" + encodeToHTML( - indentProcess.readAllStandardError()) + "
" + tr("
Callstring was: ") + - encodeToHTML(indenterCompleteCallString) + ""; - tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; - TQApplication::restoreOverrideCursor(); - _errorMessageDialog->showMessage(tr("Indenter returned error"), processReturnString); - } - - // Only get the formatted source code, if calling the indenter did succeed. - if (calledProcessSuccessfully) - { - // If the indenter results are written to stdout, read them from there... - if (indentProcess.exitCode() == 0 && _outputFileParameter == "stdout") - { - formattedSourceCode = indentProcess.readAllStandardOutput(); - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from StdOut."; - } - // ... else read the output file generated by the indenter call. - else - { - TQFile outSrcFile(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension); - if (outSrcFile.open(TQFile::ReadOnly | TQFile::Text)) - { - TQTextStream outSrcStrm(&outSrcFile); - outSrcStrm.setCodec(TQTextCodec::codecForName("UTF-8")); - formattedSourceCode = outSrcStrm.readAll(); - outSrcFile.close(); - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from file " << - outSrcFile.fileName(); - } - else - { - qCritical() << __LINE__ << " " << __FUNCTION__ << - ": Couldn't read indenter output from file " << outSrcFile.fileName(); - } - } - } - else - { - return sourceCode; - } - - // Delete the temporary input and output files. - TQFile::remove(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension); - TQFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); - - return formattedSourceCode; -} - -/*! - \brief Generates and returns a string with all parameters needed to call the indenter. - */ -TQString IndentHandler::getParameterString() -{ - TQString parameterString = ""; - - // generate parameter string for all boolean values - foreach(ParamBoolean pBoolean, _paramBooleans) - { - if (pBoolean.checkBox->isChecked()) - { - if (!pBoolean.trueString.isEmpty()) - { - parameterString += pBoolean.trueString + _cfgFileParameterEnding; - } - } - else - { - if (!pBoolean.falseString.isEmpty()) - { - parameterString += pBoolean.falseString + _cfgFileParameterEnding; - } - } - } - - // generate parameter string for all numeric values - foreach(ParamNumeric pNumeric, _paramNumerics) - { - if (pNumeric.valueEnabledChkBox->isChecked()) - { - parameterString += pNumeric.paramCallName + TQString::number(pNumeric.spinBox->value()) + - _cfgFileParameterEnding; - } - } - - // generate parameter string for all string values - foreach(ParamString pString, _paramStrings) - { - if (!pString.lineEdit->text().isEmpty() && pString.valueEnabledChkBox->isChecked()) - { - // Create parameter definition for each value devided by a | sign. - foreach(TQString paramValue, pString.lineEdit->text().split("|")) - { - parameterString += pString.paramCallName + paramValue + _cfgFileParameterEnding; - } - } - } - - // generate parameter string for all multiple choice values - foreach(ParamMultiple pMultiple, _paramMultiples) - { - if (pMultiple.valueEnabledChkBox->isChecked()) - { - parameterString += pMultiple.choicesStrings.at(pMultiple.comboBox->currentIndex()) + - _cfgFileParameterEnding; - } - } - - return parameterString; -} - -/*! - \brief Write settings for the indenter to a config file. - */ -void IndentHandler::saveConfigFile(TQString filePathName, TQString paramString) -{ - TQFile::remove(filePathName); - TQFile cfgFile(filePathName); - - cfgFile.open(TQFile::ReadWrite | TQFile::Text); - cfgFile.write(paramString.toAscii()); - cfgFile.close(); -} - -/*! - \brief Load the config file for the indenter and apply the settings made there. - */ -bool IndentHandler::loadConfigFile(TQString filePathName) -{ - TQFile cfgFile(filePathName); - int index; - int crPos; - int paramValue = 0; - TQString paramValueStr = ""; - TQString cfgFileData = ""; - - // If the to be loaded config file does not exist leave all values as they are and return false. - if (!cfgFile.exists()) - { - return false; - } - // else if the to be read config file exists, retrieve its whole content. - else - { - // Open the config file and read all data - cfgFile.open(TQFile::ReadOnly | TQFile::Text); - cfgFileData = cfgFile.readAll(); - cfgFile.close(); - } - - // Search for name of each boolean parameter and set its value if found. - foreach(ParamBoolean pBoolean, _paramBooleans) - { - // boolean value that will be assigned to the checkbox - bool paramValue = false; - - // first search for the longer parameter string - // the true parameter string is longer than the false string - if (pBoolean.trueString.length() > pBoolean.falseString.length()) - { - // search for the true string - index = cfgFileData.indexOf(pBoolean.trueString, 0, TQt::CaseInsensitive); - // if true string found set the parameter value to true - if (index != -1) - { - paramValue = true; - } - // if true string not found, search for false string - else - { - index = cfgFileData.indexOf(pBoolean.falseString, 0, TQt::CaseInsensitive); - // if false string found set the parameter value to false - if (index != -1) - { - paramValue = false; - } - // neither true nor false parameter found so use default value - else - { - paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); - } - } - } - // the false parameter string is longer than the true string - else - { - // search for the false string - index = cfgFileData.indexOf(pBoolean.falseString, 0, TQt::CaseInsensitive); - // if false string found set the parameter value to false - if (index != -1) - { - paramValue = false; - } - // if false string not found, search for true string - else - { - index = cfgFileData.indexOf(pBoolean.trueString, 0, TQt::CaseInsensitive); - // if true string found set the parameter value to true - if (index != -1) - { - paramValue = true; - } - // neither true nor false parameter found so use default value - else - { - paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); - } - } - } - pBoolean.checkBox->setChecked(paramValue); - } - - // Search for name of each numeric parameter and set the value found behind it. - foreach(ParamNumeric pNumeric, _paramNumerics) - { - index = cfgFileData.indexOf(pNumeric.paramCallName, 0, TQt::CaseInsensitive); - // parameter was found in config file - if (index != -1) - { - // set index after the parameter name, so in front of the number - index += pNumeric.paramCallName.length(); - - // Find the end of the parameter by searching for set config file parameter ending. Most of - // time this is a carriage return. - crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1); - - // get the number and convert it to int - TQString test = cfgFileData.mid(index, crPos - index); - paramValue = cfgFileData.mid(index, crPos - index).toInt(NULL); - - // disable the signal-slot connection. Otherwise signal is emmitted each time when value is - // set - TQObject::disconnect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, - SLOT(handleChangedIndenterSettings())); - pNumeric.spinBox->setValue(paramValue); - pNumeric.valueEnabledChkBox->setChecked(true); - TQObject::connect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, - SLOT(handleChangedIndenterSettings())); - } - // parameter was not found in config file - else - { - int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); - pNumeric.spinBox->setValue(defaultValue); - pNumeric.valueEnabledChkBox->setChecked(false); - } - } - - // Search for name of each string parameter and set it. - foreach(ParamString pString, _paramStrings) - { - paramValueStr = ""; - // The number of the found values for this parameter name. - int numberOfValues = 0; - index = cfgFileData.indexOf(pString.paramCallName, 0, TQt::CaseInsensitive); - // If parameter was found in config file - if (index != -1) - { - while (index != -1) - { - numberOfValues++; - - // Set index after the parameter name, so it points to the front of the string value. - index += pString.paramCallName.length(); - - // Find the end of the parameter by searching for set config file parameter ending. Most of - // time this is a carriage return. - crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1); - - // Get the string and remember it. - if (numberOfValues < 2) - { - paramValueStr = TQString(cfgFileData.mid(index, crPos - index)); - } - // If the same parameter has been set multiple times, concatenate the strings dvivided by a - // |. - else - { - paramValueStr = paramValueStr + "|" + TQString(cfgFileData.mid(index, crPos - index)); - } - - // Get next value for this setting, if one exists. - index = cfgFileData.indexOf(pString.paramCallName, crPos + 1, TQt::CaseInsensitive); - } - // Set the text for the line edit. - pString.lineEdit->setText(paramValueStr); - pString.valueEnabledChkBox->setChecked(true); - } - // Parameter was not found in config file - else - { - paramValueStr = _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); - pString.lineEdit->setText(paramValueStr); - pString.valueEnabledChkBox->setChecked(false); - } - } - - // search for name of each multiple choice parameter and set it - foreach(ParamMultiple pMultiple, _paramMultiples) - { - int i = 0; - index = -1; - - // search for all parameter names of the multiple choice list - // if one is found, set it and leave the while loop - while (i < pMultiple.choicesStrings.count() && index == -1) - { - index = cfgFileData.indexOf(pMultiple.choicesStrings.at(i), 0, TQt::CaseInsensitive); - if (index != -1) - { - pMultiple.comboBox->setCurrentIndex(i); - pMultiple.valueEnabledChkBox->setChecked(true); - } - i++; - } - - // parameter was not set in config file, so use default value - if (index == -1) - { - int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); - pMultiple.comboBox->setCurrentIndex(defaultValue); - pMultiple.valueEnabledChkBox->setChecked(false); - } - } - - return true; -} - -/*! - \brief Sets all indenter parameters to their default values defined in the ini file. - */ -void IndentHandler::resetToDefaultValues() -{ - // Search for name of each boolean parameter and set its value if found. - foreach(ParamBoolean pBoolean, _paramBooleans) - { - // Boolean value that will be assigned to the checkbox. - bool defaultValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); - pBoolean.checkBox->setChecked(defaultValue); - } - - // Search for name of each numeric parameter and set the value found behind it. - foreach(ParamNumeric pNumeric, _paramNumerics) - { - int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); - pNumeric.spinBox->setValue(defaultValue); - pNumeric.valueEnabledChkBox->setChecked(_indenterSettings->value( - pNumeric.paramName + "/Enabled").toBool()); - } - - // Search for name of each string parameter and set it. - foreach(ParamString pString, _paramStrings) - { - TQString defaultValue = - _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); - pString.lineEdit->setText(defaultValue); - pString.valueEnabledChkBox->setChecked(_indenterSettings->value( - pString.paramName + "/Enabled").toBool()); - } - - // Search for name of each multiple choice parameter and set it. - foreach(ParamMultiple pMultiple, _paramMultiples) - { - int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); - pMultiple.comboBox->setCurrentIndex(defaultValue); - pMultiple.valueEnabledChkBox->setChecked(_indenterSettings->value(pMultiple.paramName + - "/Enabled").toBool()); - } -} - -/*! - \brief Opens and parses the indenter ini file that is declared by \a iniFilePath. - */ -void IndentHandler::readIndentIniFile(TQString iniFilePath) -{ - Q_ASSERT_X(!iniFilePath.isEmpty(), "readIndentIniFile", "iniFilePath is empty"); - - // open the ini-file that contains all available indenter settings with their additional infos - _indenterSettings = new UiGuiIniFileParser(iniFilePath); - - TQStringList categories; - //TQString indenterGroupString = ""; - TQString paramToolTip = ""; - - // - // parse ini file indenter header - // - - _indenterName = _indenterSettings->value("header/indenterName").toString(); - _indenterFileName = _indenterSettings->value("header/indenterFileName").toString(); - _globalConfigFilename = _indenterSettings->value("header/configFilename").toString(); - _useCfgFileParameter = _indenterSettings->value("header/useCfgFileParameter").toString(); - _cfgFileParameterEnding = _indenterSettings->value("header/cfgFileParameterEnding").toString(); - if (_cfgFileParameterEnding == "cr") - { - _cfgFileParameterEnding = "\n"; - } - _indenterShowHelpParameter = _indenterSettings->value("header/showHelpParameter").toString(); - - if (_indenterFileName.isEmpty()) - { - _errorMessageDialog->showMessage(tr("Indenter ini file header error"), tr( - "The loaded indenter ini file \"%1\"has a faulty header. At least the indenters file name is not set.").arg( - iniFilePath)); - } - - // Read the parameter order. Possible values are (p=parameter[file] i=inputfile o=outputfile) - // pio, ipo, iop - _parameterOrder = _indenterSettings->value("header/parameterOrder", "pio").toString(); - _inputFileParameter = _indenterSettings->value("header/inputFileParameter").toString(); - _inputFileName = _indenterSettings->value("header/inputFileName").toString(); - _outputFileParameter = _indenterSettings->value("header/outputFileParameter").toString(); - _outputFileName = _indenterSettings->value("header/outputFileName").toString(); - _fileTypes = _indenterSettings->value("header/fileTypes").toString(); - _fileTypes.replace('|', " "); - - // read the categories names which are separated by "|" - TQString categoriesStr = _indenterSettings->value("header/categories").toString(); - categories = categoriesStr.split("|"); - // Assure that the category list is never empty. At least contain a "general" section. - if (categories.isEmpty()) - { - categories.append("General"); - } - - IndenterParameterCategoryPage categoryPage; - - // create a page for each category and store its references in a toolboxpage-array - foreach(TQString category, categories) - { - categoryPage.widget = new TQWidget(); - categoryPage.widget->setObjectName(category); - categoryPage.widget->setSizePolicy(TQSizePolicy::MinimumExpanding, - TQSizePolicy::MinimumExpanding); - categoryPage.vboxLayout = new TQVBoxLayout(categoryPage.widget); - categoryPage.vboxLayout->setSpacing(6); - categoryPage.vboxLayout->setMargin(9); - categoryPage.vboxLayout->setObjectName(category); - _indenterParameterCategoryPages.append(categoryPage); - _indenterParameterCategoriesToolBox->addItem(categoryPage.widget, category); - } - - // - // parse ini file indenter parameters - // - - // read all possible parameters written in brackets [] - _indenterParameters = _indenterSettings->childGroups(); - - // read each parameter to create the corresponding input field - foreach(TQString indenterParameter, _indenterParameters) - { - // if it is not the indent header definition read the parameter and add it to - // the corresponding category toolbox page - if (indenterParameter != "header") - { - // read to which category the parameter belongs - int category = _indenterSettings->value(indenterParameter + "/Category").toInt(); - // Assure that the category number is never greater than the available categories. - if (category > _indenterParameterCategoryPages.size() - 1) - { - category = _indenterParameterCategoryPages.size() - 1; - } - // read which type of input field the parameter needs - TQString editType = _indenterSettings->value(indenterParameter + "/EditorType").toString(); - - // edit type is numeric so create a spinbox with label - if (editType == "numeric") - { - // read the parameter name as it is used at the command line or in its config file - TQString parameterCallName = - _indenterSettings->value(indenterParameter + "/CallName").toString(); - - // create checkbox which enables or disables the parameter - TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); - chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); - chkBox->setToolTip( - "Enables/disables the parameter. If disabled the indenters default value will be used."); - chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); - int left, top, right, bottom; - chkBox->getContentsMargins(&left, &top, &right, &bottom); - chkBox->setContentsMargins(left, top, 0, bottom); - - // create the spinbox - TQSpinBox *spinBox = new TQSpinBox(_indenterParameterCategoryPages.at(category).widget); - paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); - spinBox->setToolTip(paramToolTip); - spinBox->setMaximumWidth(50); - spinBox->setMinimumWidth(50); - if (_mainWindow != NULL) - { - spinBox->installEventFilter(_mainWindow); - } - if (_indenterSettings->value(indenterParameter + "/MinVal").toString() != "") - { - spinBox->setMinimum(_indenterSettings->value(indenterParameter + "/MinVal").toInt()); - } - else - { - spinBox->setMinimum(0); - } - if (_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "") - { - spinBox->setMaximum(_indenterSettings->value(indenterParameter + "/MaxVal").toInt()); - } - else - { - spinBox->setMaximum(2000); - } - - // create the label - TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget); - label->setText(indenterParameter); - label->setBuddy(spinBox); - label->setToolTip(paramToolTip); - if (_mainWindow != NULL) - { - label->installEventFilter(_mainWindow); - } - - // put all into a layout and add it to the toolbox page - TQHBoxLayout *hboxLayout = new TQHBoxLayout(); - hboxLayout->addWidget(chkBox); - hboxLayout->addWidget(spinBox); - hboxLayout->addWidget(label); - _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); - - // remember parameter name and reference to its spinbox - ParamNumeric paramNumeric; - paramNumeric.paramName = indenterParameter; - paramNumeric.paramCallName = parameterCallName; - paramNumeric.spinBox = spinBox; - paramNumeric.label = label; - paramNumeric.valueEnabledChkBox = chkBox; - paramNumeric.spinBox->setValue(_indenterSettings->value(paramNumeric.paramName + - "/ValueDefault").toInt()); - _paramNumerics.append(paramNumeric); - - TQObject::connect(spinBox, SIGNAL(valueChanged(int)), this, - SLOT(handleChangedIndenterSettings())); - TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateDrawing())); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS - } - // edit type is boolean so create a checkbox - else if (editType == "boolean") - { - // create the checkbox, make its settings and add it to the toolbox page - TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); - chkBox->setText(indenterParameter); - paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); - chkBox->setToolTip(paramToolTip); - if (_mainWindow != NULL) - { - chkBox->installEventFilter(_mainWindow); - } - _indenterParameterCategoryPages.at(category).vboxLayout->addWidget(chkBox); - - // remember parameter name and reference to its checkbox - ParamBoolean paramBoolean; - paramBoolean.paramName = indenterParameter; - paramBoolean.checkBox = chkBox; - TQStringList trueFalseStrings = - _indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|"); - paramBoolean.trueString = trueFalseStrings.at(0); - paramBoolean.falseString = trueFalseStrings.at(1); - paramBoolean.checkBox->setChecked(_indenterSettings->value(paramBoolean.paramName + - "/ValueDefault").toBool()); - _paramBooleans.append(paramBoolean); - - TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); - } - // edit type is numeric so create a line edit with label - else if (editType == "string") - { - // read the parameter name as it is used at the command line or in its config file - TQString parameterCallName = - _indenterSettings->value(indenterParameter + "/CallName").toString(); - - // create check box which enables or disables the parameter - TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); - chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); - chkBox->setToolTip( - "Enables/disables the parameter. If disabled the indenters default value will be used."); - chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); - int left, top, right, bottom; - chkBox->getContentsMargins(&left, &top, &right, &bottom); - chkBox->setContentsMargins(left, top, 0, bottom); - - // create the line edit - TQLineEdit *lineEdit = new TQLineEdit(_indenterParameterCategoryPages.at(category).widget); - paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); - lineEdit->setToolTip(paramToolTip); - lineEdit->setMaximumWidth(50); - lineEdit->setMinimumWidth(50); - if (_mainWindow != NULL) - { - lineEdit->installEventFilter(_mainWindow); - } - - // create the label - TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget); - label->setText(indenterParameter); - label->setBuddy(lineEdit); - label->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Preferred); - label->setToolTip(paramToolTip); - if (_mainWindow != NULL) - { - label->installEventFilter(_mainWindow); - } - - // put all into a layout and add it to the toolbox page - TQHBoxLayout *hboxLayout = new TQHBoxLayout(); - hboxLayout->addWidget(chkBox); - hboxLayout->addWidget(lineEdit); - hboxLayout->addWidget(label); - _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); - - // remember parameter name and reference to its line edit - ParamString paramString; - paramString.paramName = indenterParameter; - paramString.paramCallName = parameterCallName; - paramString.lineEdit = lineEdit; - paramString.label = label; - paramString.valueEnabledChkBox = chkBox; - paramString.lineEdit->setText(_indenterSettings->value(paramString.paramName + - "/ValueDefault").toString()); - _paramStrings.append(paramString); - - TQObject::connect(lineEdit, SIGNAL(editingFinished()), this, - SLOT(handleChangedIndenterSettings())); - TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect(lineEdit, SIGNAL(textChanged(const TQString)), this, SLOT(updateDrawing())); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS - } - // edit type is multiple so create a combobox with label - else if (editType == "multiple") - { - // read the parameter name as it is used at the command line or in its config file - TQString parameterCallName = - _indenterSettings->value(indenterParameter + "/CallName").toString(); - - // create checkbox which enables or disables the parameter - TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); - chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); - chkBox->setToolTip( - "Enables/disables the parameter. If disabled the indenters default value will be used."); - chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); - int left, top, right, bottom; - chkBox->getContentsMargins(&left, &top, &right, &bottom); - chkBox->setContentsMargins(left, top, 0, bottom); - - // create the combo box - TQComboBox *comboBox = new TQComboBox(_indenterParameterCategoryPages.at( - category).widget); - TQStringList choicesStrings = - _indenterSettings->value(indenterParameter + "/Choices").toString().split("|"); - TQStringList choicesStringsReadable = _indenterSettings->value( - indenterParameter + "/ChoicesReadable").toString().split("|", TQString::SkipEmptyParts); - if (choicesStringsReadable.isEmpty()) - { - comboBox->addItems(choicesStrings); - } - else - { - comboBox->addItems(choicesStringsReadable); - } - paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); - comboBox->setToolTip(paramToolTip); - if (_mainWindow != NULL) - { - comboBox->installEventFilter(_mainWindow); - } - - // put all into a layout and add it to the toolbox page - TQHBoxLayout *hboxLayout = new TQHBoxLayout(); - hboxLayout->addWidget(chkBox); - hboxLayout->addWidget(comboBox); - _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); - - // remember parameter name and reference to its lineedit - ParamMultiple paramMultiple; - paramMultiple.paramName = indenterParameter; - paramMultiple.paramCallName = parameterCallName; - paramMultiple.comboBox = comboBox; - paramMultiple.choicesStrings = choicesStrings; - paramMultiple.choicesStringsReadable = choicesStringsReadable; - paramMultiple.valueEnabledChkBox = chkBox; - paramMultiple.comboBox->setCurrentIndex(_indenterSettings->value(paramMultiple.paramName + - "/ValueDefault").toInt()); - _paramMultiples.append(paramMultiple); - - TQObject::connect(comboBox, SIGNAL(activated(int)), this, - SLOT(handleChangedIndenterSettings())); - TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect(comboBox, SIGNAL(activated(int)), this, SLOT(updateDrawing())); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS - } - } - } - - // put a spacer at each page end - foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) - { - categoryPage.vboxLayout->addStretch(); - } -} - -/*! - \brief Searches and returns all indenters a configuration file is found for. - - Opens all uigui ini files found in the list \a _indenterIniFileList, opens each ini file - and reads the there defined real name of the indenter. These names are being returned as TQStringList. - */ -TQStringList IndentHandler::getAvailableIndenters() -{ - TQStringList indenterNamesList; - - // Loop for every existing uigui ini file - foreach(TQString indenterIniFile, _indenterIniFileList) - { - // Open the ini file and search for the indenter name - TQFile file(_indenterDirctoryStr + "/" + indenterIniFile); - if (file.open(TQIODevice::ReadOnly | TQIODevice::Text)) - { - int index = -1; - TQByteArray line; - // Search for the string "indenterName=" and get the following string until line end. - while (index == -1 && !file.atEnd()) - { - line = file.readLine(); - index = line.indexOf("indenterName=", 0); - } - - if (index == 0) - { - line = line.remove(0, 13); - indenterNamesList << line.trimmed(); - } - } - } - return indenterNamesList; -} - -/*! - \brief Deletes all elements in the toolbox and initializes the indenter selected by \a indenterID. - */ -void IndentHandler::setIndenter(int indenterID) -{ - TQApplication::setOverrideCursor(TQt::WaitCursor); - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - disconnect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, - SLOT(updateDrawing())); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS - - // Generate the parameter string that will be saved to the indenters config file. - TQString parameterString = getParameterString(); - if (!_indenterFileName.isEmpty()) - { - saveConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString); - } - - // Take care if the selected indenterID is smaller or greater than the number of existing - // indenters - if (indenterID < 0) - { - indenterID = 0; - } - if (indenterID >= _indenterIniFileList.count()) - { - indenterID = _indenterIniFileList.count() - 1; - } - - // remove all pages from the toolbox - for (int i = 0; i < _indenterParameterCategoriesToolBox->count(); i++) - { - _indenterParameterCategoriesToolBox->removeItem(i); - } - - // delete all toolbox pages and by this its children - foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) - { - delete categoryPage.widget; - } - - // empty all lists, which stored infos for the toolbox pages and its widgets - _indenterParameterCategoryPages.clear(); - _paramStrings.clear(); - _paramNumerics.clear(); - _paramBooleans.clear(); - _paramMultiples.clear(); - delete _indenterSettings; - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - TQWidget dummyWidget; - _indenterParameterCategoriesToolBox->addItem(&dummyWidget, "dummyText"); -#endif - - readIndentIniFile(_indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID)); - - // Find out how the indenter can be executed. - createIndenterCallString(); - - // Load the users last settings made for this indenter. - loadConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg"); - - handleChangedIndenterSettings(); - - TQApplication::restoreOverrideCursor(); - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, - SLOT(updateDrawing())); - _indenterParameterCategoriesToolBox->removeItem(_indenterParameterCategoriesToolBox->indexOf(& - dummyWidget)); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS -} - -/*! - \brief Returns a string containing by the indenter supported file types/extensions divided by a space. - */ -TQString IndentHandler::getPossibleIndenterFileExtensions() -{ - return _fileTypes; -} - -/*! - \brief Returns the path and filename of the current indenter config file. - */ -TQString IndentHandler::getIndenterCfgFile() -{ - TQFileInfo fileInfo(_indenterDirctoryStr + "/" + _globalConfigFilename); - return fileInfo.absoluteFilePath(); -} - -/*! - \brief Tries to create a call path string for the indenter executable. If successful returns true. - */ -bool IndentHandler::createIndenterCallString() -{ - TQProcess indentProcess; - - if (_indenterFileName.isEmpty()) - { - return false; - } - - // First try to call the indenter inside of the data dir, using some suffix - // ------------------------------------------------------------------------ - - // Set the directory for the indenter execution - indentProcess.setWorkingDirectory(TQFileInfo(_indenterDirctoryStr).absoluteFilePath()); - - foreach(TQString suffix, TQStringList() << "" << ".exe" << ".bat" << ".com" << ".sh") - { - _indenterExecutableSuffix = suffix; - _indenterExecutableCallString = TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + - _indenterFileName; - _indenterExecutableCallString += suffix; - - // Only try to call the indenter, if the file exists. - if (TQFile::exists(_indenterExecutableCallString)) - { - // Only try to call the indenter directly if it is no php file - if (TQFileInfo(_indenterExecutableCallString).suffix().toLower() != "php") - { - indentProcess.start( - "\"" + _indenterExecutableCallString + +"\" " + _indenterShowHelpParameter); - if (indentProcess.waitForFinished(2000)) - { - _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\""; - return true; - } - else if (indentProcess.error() == TQProcess::Timedout) - { - _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\""; - return true; - } - } - - // Test for needed interpreters - // ---------------------------- - // If the file could not be executed, try to find a shebang at its start or test if its a php - // file. - TQString interpreterName = ""; - TQFile indenterExecutable(_indenterExecutableCallString); - - // If indenter executable file has .php as suffix, use php as default interpreter - if (TQFileInfo(_indenterExecutableCallString).suffix().toLower() == "php") - { - interpreterName = "php -f"; - } - // Else try to open the file and read the shebang. - else if (indenterExecutable.open(TQFile::ReadOnly)) - { - // Read the first line of the file. - TQTextStream indenterExecutableContent(&indenterExecutable); - TQString firstLineOfIndenterExe = indenterExecutableContent.readLine(75); - indenterExecutable.close(); - - // If the initial shebang is found, read the named intepreter. e.g. perl - if (firstLineOfIndenterExe.startsWith("#!")) - { - // Get the rightmost word. by splitting the string into only full words. - interpreterName = firstLineOfIndenterExe.split("/").last(); - } - } - - // Try to call the interpreter, if it exists. - if (!interpreterName.isEmpty()) - { - _indenterExecutableCallString = interpreterName + " \"" + _indenterExecutableCallString + - "\""; - indentProcess.start(interpreterName + " -h"); - if (indentProcess.waitForFinished(2000)) - { - return true; - } - else if (indentProcess.error() == TQProcess::Timedout) - { - return true; - } - // now we know an interpreter is needed but it could not be called, so inform the user. - else - { - _errorMessageDialog->showMessage(tr("Interpreter needed"), tr( - "To use the selected indenter the program \"%1\" needs to be available in the global environment. You should add an entry to your path settings.").arg( - interpreterName)); - return true; - } - } - } - } - - // If unsuccessful try if the indenter executable is a JavaScript file - // ------------------------------------------------------------------- - _indenterExecutableSuffix = ".js"; - _indenterExecutableCallString = TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + - _indenterFileName; - _indenterExecutableCallString += _indenterExecutableSuffix; - if (TQFile::exists(_indenterExecutableCallString)) - { - return true; - } - - // If unsuccessful try to call the indenter global, using some suffix - // ------------------------------------------------------------------ - foreach(TQString suffix, TQStringList() << "" << ".exe" << ".bat" << ".com" << ".sh") - { - _indenterExecutableSuffix = suffix; - _indenterExecutableCallString = _indenterFileName + suffix; - indentProcess.start(_indenterExecutableCallString + " " + _indenterShowHelpParameter); - if (indentProcess.waitForFinished(2000)) - { - return true; - } - else if (indentProcess.error() == TQProcess::Timedout) - { - return true; - } - } - - // If even globally calling the indenter fails, try calling .com and .exe via wine - // ------------------------------------------------------------------------------- - _indenterExecutableCallString = "\"" + TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + - _indenterFileName; - - foreach(TQString suffix, TQStringList() << ".exe" << ".com") - { - _indenterExecutableSuffix = suffix; - if (TQFile::exists(_indenterDirctoryStr + "/" + _indenterFileName + suffix)) - { - TQProcess wineTestProcess; - wineTestProcess.start("wine --version"); - // if the process of wine was not callable assume that wine is not installed - if (!wineTestProcess.waitForFinished(2000)) - { - _errorMessageDialog->showMessage(tr("wine not installed"), tr( - "There exists only a win32 executable of the indenter and wine does not seem to be installed. Please install wine to be able to run the indenter.")); - _indenterExecutableCallString = ""; - return false; - } - else - { - _indenterExecutableCallString = "\"" + - TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/"; - _indenterExecutableCallString += _indenterFileName + suffix + "\""; - _indenterExecutableCallString = "wine " + _indenterExecutableCallString; - - return true; - } - } - } - - _indenterExecutableCallString = ""; - _indenterExecutableSuffix = ""; - return false; -} - -/*! - \brief Returns a string that points to where the indenters manual can be found. - */ -TQString IndentHandler::getManual() -{ - if (_indenterSettings != NULL) - { - return _indenterSettings->value("header/manual").toString(); - } - else - { - return ""; - } -} - -/*! - \brief This slot gets the reference to the indenters manual and opens it. - */ -void IndentHandler::showIndenterManual() -{ - TQString manualReference = getManual(); - TQDesktopServices::openUrl(manualReference); -} - -/*! - \brief Can be called to update all widgets text to the currently selected language. - */ -void IndentHandler::retranslateUi() -{ - _indenterSelectionCombobox->setToolTip(tr( - "

Shows the currently chosen indenters name and lets you choose other available indenters

")); - _indenterParameterHelpButton->setToolTip(tr( - "Brings you to the online manual of the currently selected indenter, where you can get further help on the possible parameters.")); - - _actionLoadIndenterConfigFile->setText(TQApplication::translate("IndentHandler", - "Load Indenter Config File", 0, TQApplication::UnicodeUTF8)); - _actionLoadIndenterConfigFile->setStatusTip(TQApplication::translate("IndentHandler", - "Opens a file dialog to load the original config file of the indenter.", 0, - TQApplication::UnicodeUTF8)); - _actionLoadIndenterConfigFile->setShortcut(TQApplication::translate("IndentHandler", "Alt+O", 0, - TQApplication::UnicodeUTF8)); - - _actionSaveIndenterConfigFile->setText(TQApplication::translate("IndentHandler", - "Save Indenter Config File", 0, TQApplication::UnicodeUTF8)); - _actionSaveIndenterConfigFile->setStatusTip(TQApplication::translate("IndentHandler", - "Opens a dialog to save the current indenter configuration to a file.", 0, - TQApplication::UnicodeUTF8)); - _actionSaveIndenterConfigFile->setShortcut(TQApplication::translate("IndentHandler", "Alt+S", 0, - TQApplication::UnicodeUTF8)); - - _actionCreateShellScript->setText(TQApplication::translate("IndentHandler", - "Create Indenter Call Shell Script", 0, TQApplication::UnicodeUTF8)); - _actionCreateShellScript->setToolTip(TQApplication::translate("IndentHandler", - "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", - 0, TQApplication::UnicodeUTF8)); - _actionCreateShellScript->setStatusTip(TQApplication::translate("IndentHandler", - "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", - 0, TQApplication::UnicodeUTF8)); - - _actionResetIndenterParameters->setText(TQApplication::translate("IndentHandler", - "Reset indenter parameters", 0, TQApplication::UnicodeUTF8)); - _actionResetIndenterParameters->setToolTip(TQApplication::translate("IndentHandler", - "Resets all indenter parameters to the default values.", 0, TQApplication::UnicodeUTF8)); - _actionResetIndenterParameters->setStatusTip(TQApplication::translate("IndentHandler", - "Resets all indenter parameters to the default values.", 0, TQApplication::UnicodeUTF8)); -} - -/*! - \brief Returns the name of the currently selected indenter. - */ -TQString IndentHandler::getCurrentIndenterName() -{ - TQString currentIndenterName = _indenterSelectionCombobox->currentText(); - - // Remove the supported programming languages from indenters name, which are set in braces. - if (currentIndenterName.indexOf("(") > 0) - { - // Using index-1 to also leave out the blank before the brace. - currentIndenterName = currentIndenterName.left(currentIndenterName.indexOf("(") - 1); - } - - return currentIndenterName; -} - -/*! - \brief Shows a file open dialog to open an existing config file for the currently selected indenter. - - If the file was successfully opened the indent handler is called to load the settings and update itself. -*/ -void IndentHandler::openConfigFileDialog() -{ - TQString configFilePath; - - configFilePath = TQFileDialog::getOpenFileName(NULL, tr( - "Choose indenter config file"), getIndenterCfgFile(), "All files (*.*)"); - - if (configFilePath != "") - { - // If the config file was loaded successfully, inform any who is interested about it. - if (loadConfigFile(configFilePath)) - { - handleChangedIndenterSettings(); - } - } -} - -/*! - \brief Calls the indenter config file save as dialog to save the config file under a chosen name. - - If the file already exists and it should be overwritten, a warning is shown before. -*/ -void IndentHandler::saveasIndentCfgFileDialog() -{ - TQString fileExtensions = tr("All files") + " (*.*)"; - - //TQString openedSourceFileContent = openFileDialog( tr("Choose source code file"), "./", - // fileExtensions ); - TQString fileName = TQFileDialog::getSaveFileName(this, tr( - "Save indent config file"), getIndenterCfgFile(), fileExtensions); - - if (fileName != "") - { - TQFile::remove(fileName); - TQFile outCfgFile(fileName); - outCfgFile.open(TQFile::ReadWrite | TQFile::Text); - outCfgFile.write(getParameterString().toAscii()); - outCfgFile.close(); - } -} - -/*! - \brief Invokes the indenter to create a shell script. - - Lets the indenter create a shell script for calling the indenter out of any - other application and open a save dialog for saving the shell script. -*/ -void IndentHandler::createIndenterCallShellScript() -{ - TQString shellScriptExtension; -#if defined (Q_OS_WIN32) - shellScriptExtension = "bat"; -#else - shellScriptExtension = "sh"; -#endif - - TQString fileExtensions = tr("Shell Script") + " (*." + shellScriptExtension + ");;" + tr( - "All files") + " (*.*)"; - - TQString currentIndenterName = getCurrentIndenterName(); - currentIndenterName = currentIndenterName.replace(" ", "_"); - - TQString shellScriptFileName = TQFileDialog::getSaveFileName(this, tr( - "Save shell script"), "call_" + currentIndenterName + "." + shellScriptExtension, - fileExtensions); - - // Saving has been canceled if the filename is empty - if (shellScriptFileName.isEmpty()) - { - return; - } - - // Delete any old file, write the new contents and set executable permissions. - TQFile::remove(shellScriptFileName); - TQFile outSrcFile(shellScriptFileName); - if (outSrcFile.open(TQFile::ReadWrite | TQFile::Text)) - { - TQString shellScriptConfigFilename = TQFileInfo(shellScriptFileName).baseName() + "." + - TQFileInfo(_globalConfigFilename).suffix(); - - // Get the content of the shell/batch script. - TQString indenterCallShellScript = generateShellScript(shellScriptConfigFilename); - - // Replace placeholder for script name in script template. - indenterCallShellScript = indenterCallShellScript.replace("__INDENTERCALLSTRINGSCRIPTNAME__", TQFileInfo( - shellScriptFileName).fileName()); - - outSrcFile.write(indenterCallShellScript.toAscii()); -#if !defined (Q_OS_WIN32) - // For none Windows systems set the files executable flag - outSrcFile.setPermissions( - outSrcFile.permissions() | TQFile::ExeOwner | TQFile::ExeUser | TQFile::ExeGroup); -#endif - outSrcFile.close(); - - // Save the indenter config file to the same directory, where the shell srcipt was saved to, - // because the script will reference it there via "./". - if (!_globalConfigFilename.isEmpty()) - { - saveConfigFile(TQFileInfo( - shellScriptFileName).path() + "/" + shellScriptConfigFilename, - getParameterString()); - } - } -} - -/*! - \brief Resets all parameters to the indenters default values as they are specified in the uigui ini file - but asks the user whether to do it really. - */ -void IndentHandler::resetIndenterParameter() -{ - int messageBoxAnswer = TQMessageBox::question(this, tr("Really reset parameters?"), tr( - "Do you really want to reset the indenter parameters to the default values?"), - TQMessageBox::Yes | TQMessageBox::Abort); - if (messageBoxAnswer == TQMessageBox::Yes) - { - resetToDefaultValues(); - } -} - -/*! - \brief Catch some events and let some other be handled by the super class. - - Is needed for use as Notepad++ plugin. - */ -bool IndentHandler::event(TQEvent *event) -{ - if (event->type() == TQEvent::WindowActivate) - { - event->accept(); - return true; - } - else if (event->type() == TQEvent::WindowDeactivate) - { - event->accept(); - return true; - } - else - { - event->ignore(); - return TQWidget::event(event); - } -} - -/*! - \brief Sets the function pointer \a _parameterChangedCallback to the given callback - function \a paramChangedCallback. - - Is needed for use as Notepad++ plugin. - */ -void IndentHandler::setParameterChangedCallback(void (*paramChangedCallback)(void)) -{ - _parameterChangedCallback = paramChangedCallback; -} - -/*! - \brief Emits the \a indenterSettingsChanged signal and if set executes the \a _parameterChangedCallback function. - - Is needed for use as Notepad++ plugin. - */ -void IndentHandler::handleChangedIndenterSettings() -{ - emit(indenterSettingsChanged()); - - if (_parameterChangedCallback != NULL) - { - _parameterChangedCallback(); - } -} - -/*! - \brief Sets a callback function that shall be called, when the this indenter parameter window gets closed. - - Is needed for use as Notepad++ plugin. - */ -void IndentHandler::setWindowClosedCallback(void (*winClosedCallback)(void)) -{ - _windowClosedCallback = winClosedCallback; -} - -/*! - \brief Is called on this indenter parameter window close and if set calls the function \a _windowClosedCallback. - - Is needed for use as Notepad++ plugin. - */ -void IndentHandler::closeEvent(TQCloseEvent *event) -{ - if (_windowClosedCallback != NULL) - { - _windowClosedCallback(); - } - event->accept(); -} - -/*! - \brief Returns the id (list index) of the currently selected indenter. - */ -int IndentHandler::getIndenterId() -{ - return _indenterSelectionCombobox->currentIndex(); -} - -void IndentHandler::updateDrawing() -{ -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - if (isVisible()) - { - TQRect savedGeometry = geometry(); - setGeometry(savedGeometry.adjusted(0, 0, 0, 1)); - repaint(); - setGeometry(savedGeometry); - } -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS -} - -void IndentHandler::wheelEvent(TQWheelEvent *event) -{ - UNUSED_PARAMETER_WARNING_AVOID(event); -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - TQWidget::wheelEvent(event); - updateDrawing(); -#endif // UNIVERSALINDENTGUI_NPP_EXPORTS -} - -/*! - \brief Converts characters < > and & in the \a text to HTML codes < > and &. - */ - -//TODO: This function should go into a string helper/tool class/file. -TQString IndentHandler::encodeToHTML(const TQString &text) -{ - TQString htmlText = text; - htmlText.replace("&", "&"); - htmlText.replace("<", "<"); - htmlText.replace(">", ">"); - htmlText.replace('"', """); - htmlText.replace("'", "'"); - htmlText.replace("^", "ˆ"); - htmlText.replace("~", "˜"); - htmlText.replace("€", "€"); - htmlText.replace("©", "©"); - return htmlText; -} diff --git a/src/IndentHandler.h b/src/IndentHandler.h deleted file mode 100644 index f576518..0000000 --- a/src/IndentHandler.h +++ /dev/null @@ -1,195 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef INDENTHANDLER_H -#define INDENTHANDLER_H - -#include - -class UiGuiErrorMessage; -class UiGuiIniFileParser; - -class TQMenu; -class TQVBoxLayout; -class TQLabel; -class TQSpinBox; -class TQComboBox; -class TQCheckBox; -class TQLineEdit; -class TQToolButton; -class TQToolBox; - - -class IndentHandler : public TQWidget -{ - Q_OBJECT - - public: - IndentHandler(int indenterID, TQWidget *mainWindow = NULL, TQWidget *parent = NULL); - ~IndentHandler(); - - TQString generateShellScript(const TQString &configFilename); - TQString callIndenter(TQString sourceCode, TQString inputFileExtension); - bool loadConfigFile(TQString filePathName); - void resetToDefaultValues(); - TQStringList getAvailableIndenters(); - TQString getPossibleIndenterFileExtensions(); - TQString getParameterString(); - TQString getIndenterCfgFile(); - TQString getManual(); - void retranslateUi(); - TQString getCurrentIndenterName(); - TQMenu* getIndenterMenu(); - TQList getIndenterMenuActions(); - void contextMenuEvent(TQContextMenuEvent *event); - void setParameterChangedCallback(void (*paramChangedCallback)(void)); - void setWindowClosedCallback(void (*winClosedCallback)(void)); - int getIndenterId(); - - signals: - void indenterSettingsChanged(); - void selectedIndenterIndexChanged(int index); - - protected: - bool event(TQEvent *event); - void closeEvent(TQCloseEvent *event); - void wheelEvent(TQWheelEvent *event); - - private slots: - void setIndenter(int indenterID); - void showIndenterManual(); - void openConfigFileDialog(); - void saveasIndentCfgFileDialog(); - void createIndenterCallShellScript(); - void resetIndenterParameter(); - void handleChangedIndenterSettings(); - void updateDrawing(); - - private: - TQString callExecutableIndenter(TQString sourceCode, TQString inputFileExtension); - TQString callJavaScriptIndenter(TQString sourceCode); - void saveConfigFile(TQString filePathName, TQString parameterString); - void readIndentIniFile(TQString iniFilePath); - bool createIndenterCallString(); - void initIndenterMenu(); - - //! Holds a reference to all created pages of the parameter categories toolbox and the pages - // boxlayout - struct IndenterParameterCategoryPage - { - TQWidget *widget; - TQVBoxLayout *vboxLayout; - }; - - TQVector _indenterParameterCategoryPages; - - //! Holds a reference to all checkboxes needed for boolean parameter setting and the parameters - // name - struct ParamBoolean - { - TQString paramName; - TQString trueString; - TQString falseString; - TQCheckBox *checkBox; - }; - - TQVector _paramBooleans; - - //! Holds a reference to all line edits needed for parameter setting and the parameters name - struct ParamString - { - TQString paramName; - TQString paramCallName; - TQCheckBox *valueEnabledChkBox; - TQLineEdit *lineEdit; - TQLabel *label; - }; - - TQVector _paramStrings; - - //! Hold a reference to all spin boxes needed for parameter setting and the parameters name - struct ParamNumeric - { - TQString paramName; - TQString paramCallName; - TQCheckBox *valueEnabledChkBox; - TQSpinBox *spinBox; - TQLabel *label; - }; - - TQVector _paramNumerics; - - //! Hold a reference to all combo boxes needed for parameter setting and the parameters name - struct ParamMultiple - { - TQString paramName; - TQString paramCallName; - TQCheckBox *valueEnabledChkBox; - TQComboBox *comboBox; - TQStringList choicesStrings; - TQStringList choicesStringsReadable; - }; - - TQVector _paramMultiples; - - TQComboBox *_indenterSelectionCombobox; - TQToolButton *_indenterParameterHelpButton; - //! Vertical layout box, into which the toolbox will be added - TQVBoxLayout *_toolBoxContainerLayout; - TQToolBox *_indenterParameterCategoriesToolBox; - UiGuiIniFileParser *_indenterSettings; - TQStringList _indenterParameters; - //! The indenters name in a descriptive form - TQString _indenterName; - //! The indenters file name (w/o extension), that is being called - TQString _indenterFileName; - TQString _indenterDirctoryStr; - TQString _tempDirctoryStr; - TQString _settingsDirctoryStr; - TQStringList _indenterIniFileList; - TQString _parameterOrder; - TQString _globalConfigFilename; - TQString _cfgFileParameterEnding; - TQString _inputFileParameter; - TQString _inputFileName; - TQString _outputFileParameter; - TQString _outputFileName; - TQString _fileTypes; - TQString _useCfgFileParameter; - TQString _indenterShowHelpParameter; - TQWidget *_mainWindow; - UiGuiErrorMessage *_errorMessageDialog; - TQString _indenterExecutableCallString; - TQString _indenterExecutableSuffix; - - TQMenu *_menuIndenter; - TQAction *_actionLoadIndenterConfigFile; - TQAction *_actionSaveIndenterConfigFile; - TQAction *_actionCreateShellScript; - TQAction *_actionResetIndenterParameters; - //! Needed for the NPP plugin. - void (*_parameterChangedCallback)(void); - //! Needed for the NPP plugin. - void (*_windowClosedCallback)(void); - - //TODO: This function should go into a string helper/tool class/file. - TQString encodeToHTML(const TQString &text); -}; - -#endif // INDENTHANDLER_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 1aa68a3..242797d 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -17,10 +17,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "config.h" #include "MainWindow.h" -///-- #include "ui_MainWindow.h" -///-- -///-- #include "UiGuiVersion.h" +#include "UiGuiVersion.h" + ///-- #include "debugging/TSLogger.h" ///-- #include "SettingsPaths.h" ///-- @@ -33,25 +33,28 @@ ///-- #include "IndentHandler.h" ///-- #include "UpdateCheckDialog.h" ///-- -///-- #include -///-- #include -///-- #include -///-- #include +#include +#include +#include +///-- #include +///-- #include +///-- #include +///-- #include ///-- #include -///-- #include -///-- #include +///-- #include +///-- #include ///-- #include -///-- #include -///-- #include +///-- #include +///-- #include ///-- #include ///-- #include -///-- #include -///-- #include -///-- #include -///-- #include +///-- #include +///-- #include +///-- #include +///-- #include ///-- #include -///-- #include -///-- #include +///-- #include +///-- #include ///-- #include ///-- ///-- #include @@ -75,7 +78,7 @@ \brief Constructs the main window. */ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : - TQMainWindow(parent) + MainWindowBase(parent) ///- , _mainWindowForm(NULL), _qSciSourceCodeEditor(NULL), _settings(NULL), ///- _highlighter(NULL), _textEditVScrollBar(NULL), _aboutDialog(NULL), _aboutDialogGraphicsView( ///- NULL), _settingsDialog(NULL), _encodingActionGroup(NULL), _saveEncodedActionGroup(NULL), @@ -93,7 +96,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- initApplicationLanguage(); ///-- ///-- // Creates the main window and initializes it. -///-- initMainWindow(); + initMainWindow(); ///-- ///-- // Create toolbar and insert it into the main window. ///-- initToolBar(); @@ -116,12 +119,11 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _aboutDialog = new AboutDialog(this, TQt::SplashScreen); ///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(_aboutDialog, this); ///-- connect(_toolBarWidget->pbAbout, SIGNAL(clicked()), this, SLOT(showAboutDialog())); -///-- connect(_mainWindowForm->actionAbout_UniversalIndentGUI, SIGNAL(triggered()), this, -///-- SLOT(showAboutDialog())); + connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog())); ///-- ///-- // Generate settings dialog box ///-- _settingsDialog = new UiGuiSettingsDialog(this, _settings); -///-- connect(_mainWindowForm->actionShowSettings, SIGNAL(triggered()), _settingsDialog, +///-- connect(actionShowSettings, SIGNAL(activated()), _settingsDialog, ///-- SLOT(showDialog())); ///-- ///-- // If a file that should be opened on start has been handed over to the constructor exists, load @@ -153,12 +155,37 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- /*! ///-- \brief Initializes the main window by creating the main gui and make some _settings. ///-- */ -///-- void MainWindow::initMainWindow() -///-- { -///-- // Generate gui as it is build in the file "mainwindow.ui" -///-- _mainWindowForm = new Ui::MainWindowUi(); -///-- _mainWindowForm->setupUi(this); -///-- +void MainWindow::initMainWindow() +{ + // Setup icons + TQString ICONS_PATH(APP_ICONS_PATH); + // Application icon + setIcon(TQPixmap(ICONS_PATH + "universalIndentGUI_64x64.png")); + // Menu icons + // - File menu + actionOpenSourceFile->setIconSet(TQPixmap(ICONS_PATH + "document-open.png")); + actionMenuRecentlyOpenedFiles->setIconSet(TQPixmap(ICONS_PATH + "document-open.png")); + actionClearRecentlyOpenedList->setIconSet(TQPixmap(ICONS_PATH + "edit-clear.png")); + actionMenuEncoding->setIconSet(TQPixmap(ICONS_PATH + "document-open.png")); + actionSaveSourceFile->setIconSet(TQPixmap(ICONS_PATH + "document-save.png")); + actionSaveSourceFileAs->setIconSet(TQPixmap(ICONS_PATH + "document-save-as.png")); + actionMenuSaveEncoded->setIconSet(TQPixmap(ICONS_PATH + "document-save-as.png")); + actionMenuExport->setIconSet(TQPixmap(ICONS_PATH + "exporthtml.png")); + actionExportPDF->setIconSet(TQPixmap(ICONS_PATH + "exportpdf.png")); + actionExportHTML->setIconSet(TQPixmap(ICONS_PATH + "exporthtml.png")); + actionExit->setIconSet(TQPixmap(ICONS_PATH + "system-log-out.png")); + // - Setting menu + actionLiveIndentPreview->setIconSet(TQPixmap(ICONS_PATH + "live-preview.png")); + actionEnableSyntaxHighlighting->setIconSet(TQPixmap(ICONS_PATH + "syntax-highlight.png")); + actionIndenterParameterTooltipsEnabled->setIconSet(TQPixmap(ICONS_PATH + "tooltip.png")); + actionShowSettings->setIconSet(TQPixmap(ICONS_PATH + "preferences-system.png")); + // - Help menu + actionShowLog->setIconSet(TQPixmap(ICONS_PATH + "document-properties.png")); + actionAboutUniversalIndentGUITQt->setIconSet(TQPixmap(ICONS_PATH + "info.png")); + // Menu ids + _actionClearRecentlyOpenedListId = popupMenuRecentlyOpenedFiles->idAt( + popupMenuRecentlyOpenedFiles->count() - 1); + ///-- // Handle last opened window size ///-- // ------------------------------ ///-- bool maximized = _settings->getValueByName("maximized").toBool(); @@ -194,39 +221,36 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _updateCheckDialog = new UpdateCheckDialog(_settings, this); ///-- ///-- // Register the load last file setting in the menu to the _settings object. -///-- _settings->registerObjectProperty(_mainWindowForm->loadLastOpenedFileOnStartupAction, "checked", +///-- _settings->registerObjectProperty(actionLoadLastOpenedFileOnStartup, "checked", ///-- "loadLastSourceCodeFileOnStartup"); ///-- ///-- // Tell the TQScintilla editor if it has to show white space. -///-- connect(_mainWindowForm->whiteSpaceIsVisibleAction, SIGNAL(toggled(bool)), this, +///-- connect(_mainWindowForm->actionWhiteSpaceIsVisible, SIGNAL(acivated(bool)), this, ///-- SLOT(setWhiteSpaceVisibility(bool))); ///-- // Register the white space setting in the menu to the _settings object. -///-- _settings->registerObjectProperty(_mainWindowForm->whiteSpaceIsVisibleAction, "checked", +///-- _settings->registerObjectProperty(actionWhiteSpaceIsVisible, "checked", ///-- "whiteSpaceIsVisible"); ///-- ///-- // Connect the remaining menu items. -///-- connect(_mainWindowForm->actionOpen_Source_File, SIGNAL(triggered()), this, -///-- SLOT(openSourceFileDialog())); -///-- connect(_mainWindowForm->actionSave_Source_File_As, SIGNAL(triggered()), this, -///-- SLOT(saveasSourceFileDialog())); -///-- connect(_mainWindowForm->actionSave_Source_File, SIGNAL(triggered()), this, -///-- SLOT(saveSourceFile())); -///-- connect(_mainWindowForm->actionExportPDF, SIGNAL(triggered()), this, SLOT(exportToPDF())); -///-- connect(_mainWindowForm->actionExportHTML, SIGNAL(triggered()), this, SLOT(exportToHTML())); + connect(actionOpenSourceFile, SIGNAL(activated()), this, SLOT(openSourceFileDialog())); + connect(actionSaveSourceFile, SIGNAL(activated()), this, SLOT(saveSourceFile())); + connect(actionSaveSourceFileAs, SIGNAL(activated()), this, SLOT(saveasSourceFileDialog())); + connect(actionExportPDF, SIGNAL(activated()), this, SLOT(exportToPDF())); + connect(actionExportHTML, SIGNAL(activated()), this, SLOT(exportToHTML())); ///-- connect(_mainWindowForm->actionCheck_for_update, SIGNAL(triggered()), _updateCheckDialog, ///-- SLOT(checkForUpdateAndShowDialog())); -///-- connect(_mainWindowForm->actionShowLog, SIGNAL(triggered()), +///-- connect(actionShowLog, SIGNAL(activated()), ///-- debugging::TSLogger::getInstance(), SLOT(show())); ///-- -///-- // Init the menu for selecting one of the recently opened files. -///-- updateRecentlyOpenedList(); -///-- connect(_mainWindowForm->menuRecently_Opened_Files, SIGNAL(triggered(TQAction*)), this, -///-- SLOT(openFileFromRecentlyOpenedList(TQAction*))); + // Init the menu for selecting one of the recently opened files. + updateRecentlyOpenedList(); + connect(popupMenuRecentlyOpenedFiles, SIGNAL(activated(int)), + this, SLOT(openFileFromRecentlyOpenedList(int))); ///-- //connect( _settings, SIGNAL(recentlyOpenedListSize(int)), this, SLOT(updateRecentlyOpenedList()) ///-- // ); ///-- _settings->registerObjectSlot(this, "updateRecentlyOpenedList()", "recentlyOpenedListSize"); -///-- } -///-- +} + ///-- /*! ///-- \brief Creates and inits the tool bar. It is added to the main window. ///-- */ @@ -249,8 +273,8 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- connect(_toolBarWidget->cbLivePreview, SIGNAL(toggled(bool)), this, ///-- SLOT(previewTurnedOnOff(bool))); ///-- connect(_toolBarWidget->cbLivePreview, SIGNAL(toggled( -///-- bool)), _mainWindowForm->actionLive_Indent_Preview, SLOT(setChecked(bool))); -///-- connect(_mainWindowForm->actionLive_Indent_Preview, SIGNAL(toggled( +///-- bool)), actionLiveIndentPreview, SLOT(setChecked(bool))); +///-- connect(actionLiveIndentPreview, SIGNAL(toggled( ///-- bool)), _toolBarWidget->cbLivePreview, SLOT(setChecked(bool))); ///-- } ///-- @@ -323,11 +347,11 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _highlighter = new UiGuiHighlighter(_qSciSourceCodeEditor); ///-- ///-- // Connect the syntax highlighting setting in the menu to the turnHighlightOnOff function. -///-- connect(_mainWindowForm->enableSyntaxHighlightingAction, SIGNAL(toggled(bool)), this, +///-- connect(actionEnableSyntaxHighlighting, SIGNAL(activated(bool)), this, ///-- SLOT(turnHighlightOnOff(bool))); ///-- ///-- // Register the syntax highlighting setting in the menu to the _settings object. -///-- _settings->registerObjectProperty(_mainWindowForm->enableSyntaxHighlightingAction, "checked", +///-- _settings->registerObjectProperty(actionEnableSyntaxHighlighting, "checked", ///-- "SyntaxHighlightingEnabled"); ///-- } ///-- @@ -421,7 +445,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _previewToggled = true; ///-- ///-- // Handle if indenter parameter tool tips are enabled -///-- _settings->registerObjectProperty(_mainWindowForm->indenterParameterTooltipsEnabledAction, +///-- _settings->registerObjectProperty(actionIndenterParameterTooltipsEnabled, ///-- "checked", "indenterParameterTooltipsEnabled"); ///-- ///-- // Add the indenters context menu to the mainwindows menu. @@ -459,14 +483,13 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- } ///-- return fileContent; ///-- } -///-- -///-- /*! -///-- \brief Calls the source file open dialog to load a source file for the formatting preview. -///-- -///-- If the file was successfully loaded the indenter will be called to generate the formatted source code. -///-- */ -///-- void MainWindow::openSourceFileDialog(TQString fileName) -///-- { + +/*! + \brief Calls the source file open dialog to load a source file for the formatting preview. + If the file was successfully loaded the indenter will be called to generate the formatted source code. + */ +void MainWindow::openSourceFileDialog(TQString fileName) +{ ///-- // If the source code file is changed and the shown dialog for saving the file ///-- // is canceled, also stop opening another source file. ///-- if (!maybeSave()) @@ -509,15 +532,14 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _qSciSourceCodeEditor->setModified(false); ///-- setWindowModified(false); ///-- } -///-- } -///-- -///-- /*! -///-- \brief Calls the source file save as dialog to save a source file under a chosen name. -///-- -///-- If the file already exists and it should be overwritten, a warning is shown before. -///-- */ -///-- bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction) -///-- { +} + +/*! + \brief Calls the source file save as dialog to save a source file under a chosen name. + If the file already exists and it should be overwritten, a warning is shown before. + */ +bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction) +{ ///-- TQString encoding; ///-- TQString fileExtensions = tr("Supported by indenter") + " (" + ///-- _indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)"; @@ -561,17 +583,16 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- setWindowModified(false); ///-- ///-- updateWindowTitle(); -///-- return true; -///-- } -///-- -///-- /*! -///-- \brief Saves the currently shown source code to the last save or opened source file. -///-- -///-- If no source file has been opened, because only the static example has been loaded, -///-- the save as file dialog will be shown. -///-- */ -///-- bool MainWindow::saveSourceFile() -///-- { + return true; +} + +/*! + \brief Saves the currently shown source code to the last save or opened source file. + If no source file has been opened, because only the static example has been loaded, + the save as file dialog will be shown. + */ +bool MainWindow::saveSourceFile() +{ ///-- if (_currentSourceFile.isEmpty()) ///-- { ///-- return saveasSourceFileDialog(); @@ -593,9 +614,9 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _qSciSourceCodeEditor->setModified(false); ///-- setWindowModified(false); ///-- } -///-- return true; -///-- } -///-- + return true; +} + ///-- /*! ///-- \brief Shows a file open dialog. ///-- @@ -946,12 +967,12 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- this->setWindowTitle("UniversalIndentGUI " + TQString( ///-- PROGRAM_VERSION_STRING) + " [*]" + _currentSourceFile); ///-- } -///-- -///-- /*! -///-- \brief Opens a dialog to save the current source code as a PDF document. -///-- */ -///-- void MainWindow::exportToPDF() -///-- { + +/*! + \brief Opens a dialog to save the current source code as a PDF document. + */ +void MainWindow::exportToPDF() +{ ///-- TQString fileExtensions = tr("PDF Document") + " (*.pdf)"; ///-- ///-- TQString fileName = _currentSourceFile; @@ -969,13 +990,13 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- printer.setOutputFileName(fileName); ///-- printer.printRange(_qSciSourceCodeEditor); ///-- } -///-- } -///-- -///-- /*! -///-- \brief Opens a dialog to save the current source code as a HTML document. -///-- */ -///-- void MainWindow::exportToHTML() -///-- { +} + +/*! + \brief Opens a dialog to save the current source code as a HTML document. + */ +void MainWindow::exportToHTML() +{ ///-- TQString fileExtensions = tr("HTML Document") + " (*.html)"; ///-- ///-- TQString fileName = _currentSourceFile; @@ -1002,8 +1023,8 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- outSrcFile.write(sourceCodeAsHTML.toAscii()); ///-- outSrcFile.close(); ///-- } -///-- } -///-- +} + ///-- /*! ///-- \brief Loads the last opened file if this option is enabled in the _settings. ///-- @@ -1107,7 +1128,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- { ///-- if (event->type() == TQEvent::ToolTip) ///-- { -///-- if (_mainWindowForm->indenterParameterTooltipsEnabledAction->isChecked()) +///-- if (actionIndenterParameterTooltipsEnabled->isOn()) ///-- { ///-- return TQMainWindow::eventFilter(obj, event); ///-- } @@ -1220,11 +1241,11 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- encodingName); ///-- } ///-- -///-- _mainWindowForm->encodingMenu->addActions(_encodingActionGroup->actions()); +///-- _mainWindowForm->popupMenuEncoding->addActions(_encodingActionGroup->actions()); ///-- connect(_encodingActionGroup, SIGNAL(triggered(TQAction*)), this, ///-- SLOT(encodingChanged(TQAction*))); ///-- -///-- _mainWindowForm->saveEncodedMenu->addActions(_saveEncodedActionGroup->actions()); +///-- _mainWindowForm->popupMenuSaveEncoded->addActions(_saveEncodedActionGroup->actions()); ///-- connect(_saveEncodedActionGroup, SIGNAL(triggered(TQAction*)), this, ///-- SLOT(saveAsOtherEncoding(TQAction*))); ///-- } @@ -1301,9 +1322,9 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- highlighterAction->setStatusTip(tr("Set the syntax highlightning to ") + highlighterName); ///-- highlighterAction->setCheckable(true); ///-- } -///-- _mainWindowForm->highlighterMenu->addActions(_highlighterActionGroup->actions()); -///-- _mainWindowForm->menuSettings->insertMenu(_mainWindowForm->indenterParameterTooltipsEnabledAction, -///-- _mainWindowForm->highlighterMenu); +///-- _mainWindowForm->popupMenuHighlighter->addActions(_highlighterActionGroup->actions()); +///-- _mainWindowForm->menuSettings->insertMenu(actionIndenterParameterTooltipsEnabled, +///-- _mainWindowForm->popupMenuHighlighter); ///-- ///-- connect(_highlighterActionGroup, SIGNAL(triggered(TQAction*)), _highlighter, ///-- SLOT(setHighlighterByAction(TQAction*))); @@ -1378,7 +1399,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- } ///-- ///-- // Translate the _highlighter menu. -///-- TQList actionList = _mainWindowForm->highlighterMenu->actions(); +///-- TQList actionList = _mainWindowForm->popupMenuHighlighter->actions(); ///-- i = 0; ///-- foreach(TQString highlighterName, _highlighter->getAvailableHighlighters()) ///-- { @@ -1397,17 +1418,16 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- TQWidget::changeEvent(event); ///-- } ///-- } -///-- -///-- /*! -///-- \brief Updates the list of recently opened files. -///-- -///-- Therefore the currently open file is set at the lists first position -///-- regarding the in the _settings set maximum list length. Overheads of the -///-- list will be cut off. The new list will be updated to the _settings and -///-- the recently opened menu will be updated too. -///-- */ -///-- void MainWindow::updateRecentlyOpenedList() -///-- { + +/*! + \brief Updates the list of recently opened files. + Therefore the currently open file is set at the lists first position + regarding the in the _settings set maximum list length. Overheads of the + list will be cut off. The new list will be updated to the _settings and + the recently opened menu will be updated too. + */ +void MainWindow::updateRecentlyOpenedList() +{ ///-- TQString fileName; ///-- TQString filePath; ///-- TQStringList recentlyOpenedList = @@ -1484,22 +1504,22 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- // Write the new recently opened list to the _settings. ///-- _settings->setValueByName("lastSourceCodeFile", recentlyOpenedList.join("|")); ///-- -///-- // Enable or disable "actionClear_Recently_Opened_List" if list is [not] emtpy +///-- // Enable or disable "actionClearRecentlyOpenedList" if list is [not] emtpy ///-- if (recentlyOpenedList.isEmpty()) ///-- { -///-- _mainWindowForm->actionClear_Recently_Opened_List->setEnabled(false); +///-- _mainWindowForm->actionClearRecentlyOpenedList->setEnabled(false); ///-- } ///-- else ///-- { -///-- _mainWindowForm->actionClear_Recently_Opened_List->setEnabled(true); +///-- _mainWindowForm->actionClearRecentlyOpenedList->setEnabled(true); ///-- } -///-- } -///-- -///-- /*! -///-- \brief This slot empties the list of recently opened files. -///-- */ -///-- void MainWindow::clearRecentlyOpenedList() -///-- { +} + +/*! + \brief This slot empties the list of recently opened files. + */ +void MainWindow::clearRecentlyOpenedList() +{ ///-- TQStringList recentlyOpenedList = ///-- _settings->getValueByName("lastSourceCodeFile").toString().split("|"); ///-- TQList recentlyOpenedActionList = @@ -1515,24 +1535,24 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- // Write the new recently opened list to the _settings. ///-- _settings->setValueByName("lastSourceCodeFile", recentlyOpenedList.join("|")); ///-- -///-- // Disable "actionClear_Recently_Opened_List" -///-- _mainWindowForm->actionClear_Recently_Opened_List->setEnabled(false); -///-- } -///-- -///-- /*! -///-- \brief This slot is called if an entry from the list of recently opened files is -///-- being selected. -///-- */ -///-- void MainWindow::openFileFromRecentlyOpenedList(TQAction *recentlyOpenedAction) -///-- { -///-- // If the selected action from the recently opened list menu is the clear action -///-- // call the slot to clear the list and then leave. -///-- if (recentlyOpenedAction == _mainWindowForm->actionClear_Recently_Opened_List) -///-- { -///-- clearRecentlyOpenedList(); -///-- return; -///-- } -///-- +///-- // Disable "actionClearRecentlyOpenedList" +///-- _mainWindowForm->actionClearRecentlyOpenedList->setEnabled(false); +} + +/*! + \brief This slot is called if an entry from the list of recently opened files is + being selected. + */ +void MainWindow::openFileFromRecentlyOpenedList(int recentlyOpenedActionId) +{ + // If the selected action from the recently opened list menu is the clear action + // call the slot to clear the list and then leave. + if (recentlyOpenedActionId == _actionClearRecentlyOpenedListId) + { + clearRecentlyOpenedList(); + return; + } + ///-- TQString fileName = recentlyOpenedAction->text(); ///-- int indexOfSelectedFile = _mainWindowForm->menuRecently_Opened_Files->actions().indexOf( ///-- recentlyOpenedAction); @@ -1558,8 +1578,8 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- // any of these actions in updateRecentlyOpenedList() causes an error. ///-- TQTimer::singleShot(0, this, SLOT(updateRecentlyOpenedList())); ///-- } -///-- } -///-- +} + ///-- /*! ///-- \brief If the dragged in object contains urls/paths to a file, accept the drag. ///-- */ @@ -1584,19 +1604,19 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- ///-- event->acceptProposedAction(); ///-- } -///-- -///-- /*! -///-- \brief If the dropped in object contains urls/paths to a file, open that file. -///-- */ -///-- void MainWindow::showAboutDialog() -///-- { + +/*! + \brief Show the About dialog. +*/ +void MainWindow::showAboutDialog() +{ ///-- //TQPixmap originalPixmap = TQPixmap::grabWindow(TQApplication::desktop()->screen()->winId()); ///-- //tqDebug("in main pixmap width %d, numScreens = %d", originalPixmap.size().width(), ///-- // TQApplication::desktop()->availableGeometry().width()); ///-- //_aboutDialogGraphicsView->setScreenshotPixmap( originalPixmap ); ///-- _aboutDialogGraphicsView->show(); -///-- } -///-- +} + ///-- /*! ///-- \brief Sets the label in the status bar to show the \a line and \a column number. ///-- */ @@ -1604,3 +1624,5 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- { ///-- _textEditLineColumnInfoLabel->setText(tr("Line %1, Column %2").arg(line + 1).arg(column + 1)); ///-- } + +#include "MainWindow.moc" diff --git a/src/MainWindow.h b/src/MainWindow.h index acb399a..e0d9320 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -20,7 +20,8 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include +#include "MainWindowBase.h" +#include "ntqobjectdefs.h" /// #include "UiGuiSettings.h" /// @@ -33,7 +34,6 @@ /// namespace Ui /// { /// class ToolBarWidget; -/// class MainWindowUi; /// } /// /// class TQLabel; @@ -44,9 +44,9 @@ /// class QsciScintilla; -class MainWindow : public TQMainWindow +class MainWindow : public MainWindowBase { -///--Q_OBJECT + TQ_OBJECT public: //! Constructor @@ -61,11 +61,11 @@ class MainWindow : public TQMainWindow ///-- void closeEvent(TQCloseEvent *event); ///-- bool eventFilter(TQObject *obj, TQEvent *event); ///-- -///-- private slots: -///-- void openSourceFileDialog(TQString fileName = ""); -///-- bool saveasSourceFileDialog(TQAction *chosenEncodingAction = NULL); + private slots: + void openSourceFileDialog(TQString fileName = ""); + bool saveSourceFile(); + bool saveasSourceFileDialog(TQAction *chosenEncodingAction = NULL); ///-- void saveAsOtherEncoding(TQAction *chosenEncodingAction); -///-- bool saveSourceFile(); ///-- void callIndenter(); ///-- void updateSourceView(); ///-- void turnHighlightOnOff(bool turnOn); @@ -74,20 +74,18 @@ class MainWindow : public TQMainWindow ///-- void sourceCodeChangedSlot(); ///-- void indentSettingsChangedSlot(); ///-- void previewTurnedOnOff(bool turnOn); -///-- void exportToPDF(); -///-- void exportToHTML(); + void exportToPDF(); + void exportToHTML(); ///-- void languageChanged(int languageIndex); ///-- void encodingChanged(TQAction *encodingAction); ///-- void numberOfLinesChanged(); -///-- void updateRecentlyOpenedList(); -///-- void openFileFromRecentlyOpenedList(TQAction *recentlyOpenedAction); -///-- void clearRecentlyOpenedList(); -///-- void showAboutDialog(); + void updateRecentlyOpenedList(); + void openFileFromRecentlyOpenedList(int recentlyOpenedActionId); + void clearRecentlyOpenedList(); + void showAboutDialog(); ///-- void setStatusBarCursorPosInfo(int line, int column); ///-- -///-- private: -///-- Ui::MainWindowUi *_mainWindowForm; -///-- + private: ///-- TQString loadFile(TQString filePath); ///-- TQString openFileDialog(TQString dialogHeaderStr, TQString startPath, TQString fileMaskStr); ///-- void updateWindowTitle(); @@ -97,7 +95,7 @@ class MainWindow : public TQMainWindow ///-- void createEncodingMenu(); ///-- void createHighlighterMenu(); ///-- bool initApplicationLanguage(); -///-- void initMainWindow(); + void initMainWindow(); ///-- void initToolBar(); ///-- void initTextEditor(); ///-- void initSyntaxHighlighter(); @@ -118,6 +116,7 @@ class MainWindow : public TQMainWindow ///-- AboutDialog *_aboutDialog; ///-- AboutDialogGraphicsView *_aboutDialogGraphicsView; ///-- UiGuiSettingsDialog *_settingsDialog; + int _actionClearRecentlyOpenedListId; ///-- int _textEditLastScrollPos; ///-- int _currentIndenterID; ///-- bool _loadLastSourceCodeFileOnStartup; diff --git a/src/MainWindow.ui b/src/MainWindow.ui deleted file mode 100755 index cc73e47..0000000 --- a/src/MainWindow.ui +++ /dev/null @@ -1,488 +0,0 @@ - - - Thomas_-_S - MainWindowUi - - - - 0 - 0 - 949 - 633 - - - - UniversalIndentGUI - - - - :/mainWindow/universalIndentGUI.svg:/mainWindow/universalIndentGUI.svg - - - - - 6 - - - 0 - - - - - 0 - - - 2 - - - - - - - - - - 0 - 0 - 949 - 21 - - - - - Indenter - - - - - File - - - - Export - - - - - - - Recently Opened Files - - - - - - - Reopen File with other Encoding - - - - - Save Source File As with other Encoding - - - - - - - - - - - - - - - - Settings - - - - Set Syntax Highlighter - - - - - - - - - - - - - Help - - - - - - - - - - - - - - - 0 - 0 - - - - TQDockWidget::DockWidgetFloatable|TQDockWidget::DockWidgetMovable - - - TQt::LeftDockWidgetArea|TQt::RightDockWidgetArea - - - Indenter Settings - - - 1 - - - - - 6 - - - 0 - - - - - 0 - - - 0 - - - - - - - - - TQt::PreventContextMenu - - - Main Toolbar - - - TQt::Horizontal - - - - 16 - 16 - - - - TQt::ToolButtonTextBesideIcon - - - TopToolBarArea - - - false - - - - - - :/mainWindow/document-open.png:/mainWindow/document-open.png - - - Open Source File - - - Opens a dialog for selecting a source code file. - - - Ctrl+O - - - - - - :/mainWindow/document-save.png:/mainWindow/document-save.png - - - Save Source File - - - Saves the currently shown source code to the last opened or saved source file. - - - Ctrl+S - - - - - - :/mainWindow/document-save-as.png:/mainWindow/document-save-as.png - - - Save Source File As... - - - Save Source File As... - - - Save Source File As... - - - Opens a file dialog to save the currently shown source code. - - - Ctrl+Shift+S - - - - - - :/mainWindow/info.png:/mainWindow/info.png - - - About UniversalIndentGUI - - - Shows info about UniversalIndentGUI. - - - - - - :/mainWindow/system-log-out.png:/mainWindow/system-log-out.png - - - Exit - - - Quits the UniversalIndentGUI. - - - Ctrl+Q - - - - - - :/mainWindow/exportpdf.png:/mainWindow/exportpdf.png - - - PDF - - - Export the currently visible source code as PDF document - - - - - - :/mainWindow/exporthtml.png:/mainWindow/exporthtml.png - - - HTML - - - Export the currently visible source code as HTML document - - - - - true - - - true - - - - :/mainWindow/tooltip.png:/mainWindow/tooltip.png - - - Parameter Tooltips - - - If checked, tool tips will show up if the mouse cursor remains over an indenter parameter for a while. - - - DONOTTRANSLATE:indenterParameterTooltipsEnabled - - - - - true - - - - :/mainWindow/live-preview.png:/mainWindow/live-preview.png - - - Live Indent Preview - - - Ctrl+L - - - false - - - - - true - - - true - - - - :/mainWindow/syntax-highlight.png:/mainWindow/syntax-highlight.png - - - Syntax Highlighting - - - Syntax Highlighting - - - Enables or disables syntax highlighting for the source code. - - - By enabling special key words of the source code are highlighted. - - - Ctrl+H - - - DONOTTRANSLATE:SyntaxHighlightingEnabled - - - - - true - - - White Space Visible - - - White Space Visible - - - Set white space visible - - - Enables or disables diplaying of white space characters in the editor. - - - false - - - DONOTTRANSLATE:whiteSpaceIsVisible - - - - - true - - - true - - - Auto Open Last File - - - Auto open last source file on startup - - - If selected opens last source code file on startup - - - false - - - DONOTTRANSLATE:loadLastSourceCodeFileOnStartup - - - - - - :/mainWindow/preferences-system.png:/mainWindow/preferences-system.png - - - Settings - - - Settings - - - Opens the settings dialog - - - Opens the settings dialog, to set language etc. - - - - - - :/mainWindow/system-software-update.png:/mainWindow/system-software-update.png - - - Check for update - - - Checks online whether a new version of UniversalIndentGUI is available. - - - Checks online whether a new version of UniversalIndentGUI is available. - - - - - - :/mainWindow/edit-clear.png:/mainWindow/edit-clear.png - - - Clear Recently Opened List - - - - - - :/mainWindow/document-properties.png:/mainWindow/document-properties.png - - - Show Log - - - Displays logging information. - - - Displays logging info about the currently running UiGUI application. - - - - - - - - - actionExit - triggered() - MainWindowUi - close() - - - -1 - -1 - - - 399 - 299 - - - - - diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui new file mode 100755 index 0000000..56256f0 --- /dev/null +++ b/src/MainWindowBase.ui @@ -0,0 +1,383 @@ + + Thomas_-_S + MainWindowBase + + + MainWindowBase + + + + 0 + 0 + 949 + 633 + + + + UniversalIndentGUI (TQt) + + + + centralWidget + + + 6 + + + 0 + + + + + + menuBar + + + + 0 + 0 + 949 + 21 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + actionOpenSourceFile + + + Open Source File + + + Opens a dialog for selecting a source code file. + + + Ctrl+O + + + + + actionMenuRecentlyOpenedFiles + + + Recently Opened Files + + + Open a recently used file. + + + + + actionClearRecentlyOpenedList + + + Clear Recently Opened List + + + Clears the list of recently open files. + + + + + actionMenuEncoding + + + Reopen File with other Encoding + + + Reopen the current file using a specified encoding. + + + + + actionSaveSourceFile + + + Save Source File + + + Saves the currently shown source code to the last opened or saved source file. + + + Ctrl+S + + + + + actionSaveSourceFileAs + + + Save Source File As... + + + Opens a file dialog to save the currently shown source code. + + + Ctrl+Shift+S + + + + + actionMenuSaveEncoded + + + Save Source File As with other Encoding + + + Save the current source file using a specified encoding. + + + + + actionMenuExport + + + Export + + + Export the currently visible source + + + + + actionExportHTML + + + HTML + + + Export the currently visible source code as HTML document + + + + + actionExportPDF + + + PDF + + + Export the currently visible source code as PDF document + + + + + actionExit + + + Exit + + + Quits the UniversalIndentGUI. + + + Ctrl+Q + + + + + actionLiveIndentPreview + + + true + + + Live Indent Preview + + + Ctrl+L + + + false + + + + + actionEnableSyntaxHighlighting + + + true + + + true + + + Syntax Highlighting + + + By enabling this, special keywords of the source code are highlighted. + + + Ctrl+H + + + + + actionWhiteSpaceIsVisible + + + true + + + White Space Visible + + + Set white space visible + + + Enables or disables diplaying of white space characters in the editor. + + + false + + + + + actionMenuHighlighter + + + Set Syntax Highlighter + + + Set the syntax highlighter to use + + + + + actionIndenterParameterTooltipsEnabled + + + true + + + true + + + Parameter Tooltips + + + If checked, tooltips will show up if the mouse cursor remains over an indenter parameter for a while. + + + + + actionLoadLastOpenedFileOnStartup + + + true + + + true + + + Auto Open Last File + + + Auto open last source file on startup + + + If selected opens last source code file on startup + + + false + + + + + actionShowSettings + + + Settings + + + Opens the settings dialog + + + Opens the settings dialog, to set language etc. + + + + + actionShowLog + + + Show Log + + + Displays logging information. + + + Displays logging info about the currently running UiGUI application. + + + + + actionAboutUniversalIndentGUITQt + + + About UniversalIndentGUI TQt + + + Shows info about UniversalIndentGUI TQt. + + + + + + actionExit + activated() + MainWindowBase + close() + + + -1 + -1 + + + 399 + 299 + + + + + diff --git a/src/SettingsPaths.cpp b/src/SettingsPaths.cpp deleted file mode 100644 index a8016f7..0000000 --- a/src/SettingsPaths.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "SettingsPaths.h" - -#include -#include -#include -#include -#include -#include - -#include - -//! \defgroup grp_Settings All concerning applications settings. - -/*! - \class SettingsPaths - \ingroup grp_Settings - \brief SettingsPaths is a pure static functions class from which info about the - paths needed for settings can be retrieved. -*/ - -bool SettingsPaths::_alreadyInitialized = false; -TQString SettingsPaths::_applicationBinaryPath = ""; -TQString SettingsPaths::_settingsPath = ""; -TQString SettingsPaths::_globalFilesPath = ""; -TQString SettingsPaths::_indenterPath = ""; -TQString SettingsPaths::_tempPath = ""; -bool SettingsPaths::_portableMode = false; - -/*! - \brief Initializes all available information about the paths. - - Mainly during this init it is detected whether to start in portable mode or not. This is - done by testing whether the directory "config" is in the same directory as this - applications executable file. - In portable mode all data is ONLY written to subdirectories of the applications executable file. - Means also that the directory "indenters" has to be there. - In not portable mode (multiuser mode) only users home directory is used for writing config data. - */ -void SettingsPaths::init() -{ - _alreadyInitialized = true; - - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths."; - - // Get the applications binary path, with respect to MacOSXs use of the .app folder. - _applicationBinaryPath = TQCoreApplication::applicationDirPath(); - // Remove any trailing slashes - while (_applicationBinaryPath.right(1) == "/") - { - _applicationBinaryPath.chop(1); - } - -#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - _applicationBinaryPath += "/plugins/uigui"; -#endif - -#ifdef Q_OS_MAC - // Because on Mac universal binaries are used, the binary path is not equal - // to the applications (.app) path. So get the .apps path here. - int indexOfDotApp = _applicationBinaryPath.indexOf(".app"); - if (indexOfDotApp != -1) - { - // Cut off after the dot of ".app". - _applicationBinaryPath = _applicationBinaryPath.left(indexOfDotApp - 1); - // Cut off after the first slash that was in front of ".app" (normally this is the word - // "UniversalIndentGUI") - _applicationBinaryPath = _applicationBinaryPath.left(_applicationBinaryPath.lastIndexOf("/")); - } -#endif - - // If the "config" directory is a subdir of the applications binary path, use this one (portable - // mode) - _settingsPath = _applicationBinaryPath + "/config"; - if (TQFile::exists(_settingsPath)) - { - _portableMode = true; - TQDir dirCreator; - _globalFilesPath = _applicationBinaryPath; - _indenterPath = _applicationBinaryPath + "/indenters"; - dirCreator.mkpath(_settingsPath); - _tempPath = _applicationBinaryPath + "/temp"; - //TODO: If the portable drive has write protection, use local temp path and clean it up on exit. - dirCreator.mkpath(_tempPath); - } - // ... otherwise use the system specific global application data path. - else - { - _portableMode = false; - TQDir dirCreator; -#ifdef Q_OS_WIN - // Get the local users application settings directory. - // Remove any trailing slashes. - _settingsPath = TQDir::fromNativeSeparators(qgetenv("APPDATA")); - while (_settingsPath.right(1) == "/") - { - _settingsPath.chop(1); - } - _settingsPath = _settingsPath + "/UniversalIndentGUI"; - - // On windows systems the directories "indenters", "translations" are subdirs of the - // _applicationBinaryPath. - _globalFilesPath = _applicationBinaryPath; -#else - // Remove any trailing slashes. - _settingsPath = TQDir::homePath(); - while (_settingsPath.right(1) == "/") - { - _settingsPath.chop(1); - } - _settingsPath = _settingsPath + "/.universalindentgui"; - _globalFilesPath = "/usr/share/universalindentgui"; -#endif - dirCreator.mkpath(_settingsPath); - // If a highlighter config file does not exist in the users home config dir - // copy the default config file over there. - if (!TQFile::exists(_settingsPath + "/UiGuiSyntaxHighlightConfig.ini")) - { - TQFile::copy(_globalFilesPath + "/config/UiGuiSyntaxHighlightConfig.ini", - _settingsPath + "/UiGuiSyntaxHighlightConfig.ini"); - } - _indenterPath = _globalFilesPath + "/indenters"; - - // On different systems it may be that "TQDir::tempPath()" ends with a "/" or not. So check - // this. - // Remove any trailing slashes. - _tempPath = TQDir::tempPath(); - while (_tempPath.right(1) == "/") - { - _tempPath.chop(1); - } - _tempPath = _tempPath + "/UniversalIndentGUI"; - -#if defined (Q_OS_WIN32) - dirCreator.mkpath(_tempPath); -#else - // On Unix based systems create a random temporary directory for security - // reasons. Otherwise an evil human being could create a symbolic link - // to an important existing file which gets overwritten when UiGUI writes - // into this normally temporary but linked file. - char *pathTemplate = new char[_tempPath.length() + 8]; - TQByteArray pathTemplateTQBA = TQString(_tempPath + "-XXXXXX").toAscii(); - delete[] pathTemplate; - pathTemplate = pathTemplateTQBA.data(); - pathTemplate = mkdtemp(pathTemplate); - _tempPath = pathTemplate; -#endif - } - - tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \ - "
  • _applicationBinaryPath=" << - _applicationBinaryPath << "
  • _settingsPath=" << _settingsPath << - "
  • _globalFilesPath=" << _globalFilesPath << "
  • _indenterPath=" << - _indenterPath << "
  • _tempPath=" << _tempPath << - "
  • Running in portable mode=" << _portableMode << "
"; -} - -/*! - \brief Returns the path of the applications executable. - */ -const TQString SettingsPaths::getApplicationBinaryPath() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _applicationBinaryPath; -} - -/*! - \brief Returns the path where all settings are being/should be written to. - */ -const TQString SettingsPaths::getSettingsPath() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _settingsPath; -} - -/*! - \brief Returns the path where the files concerning all users reside. For example translations. - */ -const TQString SettingsPaths::getGlobalFilesPath() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _globalFilesPath; -} - -/*! - \brief Returns the path where the indenter executables reside. - */ -const TQString SettingsPaths::getIndenterPath() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _indenterPath; -} - -/*! - \brief Returns the path where the where all temporary data should be written to. - */ -const TQString SettingsPaths::getTempPath() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _tempPath; -} - -/*! - \brief Returns true if portable mode shall be used. - */ -bool SettingsPaths::getPortableMode() -{ - if (!_alreadyInitialized) - { - SettingsPaths::init(); - } - return _portableMode; -} - -/*! - \brief Completely deletes the created temporary directory with all of its content. - */ -void SettingsPaths::cleanAndRemoveTempDir() -{ - TQDirIterator dirIterator(_tempPath, TQDirIterator::Subdirectories); - TQStack directoryStack; - bool noErrorsOccurred = true; - - while (dirIterator.hasNext()) - { - TQString currentDirOrFile = dirIterator.next(); - // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow - // fails. - dirIterator.fileInfo(); - - if (!currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && - dirIterator.fileName() != "..") - { - // There is a path on the stack but the current path doesn't start with that path. - // So we changed into another parent directory and the one on the stack can be deleted - // since it must be empty. - if (!directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top())) - { - TQString dirToBeRemoved = directoryStack.pop(); - bool couldRemoveDir = TQDir(dirToBeRemoved).rmdir(dirToBeRemoved); - noErrorsOccurred &= couldRemoveDir; - if (couldRemoveDir == false) - { - tqWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << - dirToBeRemoved; - } - //tqDebug() << "Removing Dir " << directoryStack.pop(); - } - - // If the iterator currently points to a directory push it onto the stack. - if (dirIterator.fileInfo().isDir()) - { - directoryStack.push(currentDirOrFile); - //tqDebug() << "Pushing onto Stack " << currentDirOrFile; - } - // otherwise it must be a file, so delete it. - else - { - bool couldRemoveFile = TQFile::remove(currentDirOrFile); - noErrorsOccurred &= couldRemoveFile; - if (couldRemoveFile == false) - { - tqWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << - currentDirOrFile; - } - //tqDebug() << "Removing File " << currentDirOrFile; - } - } - } - noErrorsOccurred &= TQDir(_tempPath).rmdir(_tempPath); - if (noErrorsOccurred == false) - { - tqWarning() << __LINE__ << " " << __FUNCTION__ << - "While cleaning up the temp dir an error occurred."; - } -} diff --git a/src/SettingsPaths.h b/src/SettingsPaths.h deleted file mode 100644 index 92d1d52..0000000 --- a/src/SettingsPaths.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef SETTINGSPATHS_H -#define SETTINGSPATHS_H - -class TQString; - - -class SettingsPaths -{ - public: - static void init(); - static const TQString getApplicationBinaryPath(); - static const TQString getSettingsPath(); - static const TQString getGlobalFilesPath(); - static const TQString getIndenterPath(); - static const TQString getTempPath(); - static bool getPortableMode(); - static void cleanAndRemoveTempDir(); - - private: - SettingsPaths(); - - static bool _alreadyInitialized; - static TQString _applicationBinaryPath; - static TQString _settingsPath; - static TQString _globalFilesPath; - static TQString _indenterPath; - static TQString _tempPath; - static bool _portableMode; -}; - -#endif // SETTINGSPATHS_H diff --git a/src/TemplateBatchScript.cpp b/src/TemplateBatchScript.cpp deleted file mode 100644 index 0650cb4..0000000 --- a/src/TemplateBatchScript.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "TemplateBatchScript.h" - -// Need to include TQObject here so that platform specific defines like Q_OS_WIN32 are set. -#include - -/*! - \brief The only and static function of this class returns a batch or shell script - as string that can be used to call an indenter with the current settings from - the command line. - - The returned string contains some placeholders where the indenter name needs to - be filled in. The placeholders are "__INDENTERCALLSTRING1__" that should be replaced - by the indenter call string that indents a complete directory. - "__INDENTERCALLSTRING2__" the call string for indenting only one file. - And "__INDENTERCALLSTRINGSCRIPTNAME__" which is only the shown name of the indenter. - */ -const char* TemplateBatchScript::getTemplateBatchScript() -{ - static const char *templateBatchScript = -#if defined (Q_OS_WIN32) - "@echo off\n" - "\n" - "IF (%1)==() GOTO error\n" - "dir /b /ad %1 >nul 2>nul && GOTO indentDir\n" - "IF NOT EXIST %1 GOTO error\n" - "goto indentFile\n" - "\n" - ":indentDir\n" - "set searchdir=%1\n" - "\n" - "IF (%2)==() GOTO assignDefaultSuffix\n" - "set filesuffix=%2\n" - "\n" - "GOTO run\n" - "\n" - ":assignDefaultSuffix\n" - "::echo !!!!DEFAULT SUFFIX!!!\n" - "set filesuffix=*\n" - "\n" - ":run\n" - "FOR /F \"tokens=*\" %%G IN ('DIR /B /S %searchdir%\\*.%filesuffix%') DO (\n" - "echo Indenting file \"%%G\"\n" - "__INDENTERCALLSTRING1__\n" - ")\n" - "GOTO ende\n" - "\n" - ":indentFile\n" - "echo Indenting one file %1\n" - "__INDENTERCALLSTRING2__\n" - "\n" - "GOTO ende\n" - "\n" - ":error\n" - "echo .\n" - "echo ERROR: As parameter given directory or file does not exist!\n" - "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\n" - "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\n" - "echo Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\n" - "echo .\n" - "\n" - ":ende\n"; - -#else - - "#!/bin/sh \n" - "\n" - "if [ ! -n \"$1\" ]; then\n" - "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" - "echo \"Syntax is: recurse.sh filename\"\n" - "echo \"Example: recurse.sh temp cpp\"\n" - "exit 1\n" - "fi\n" - "\n" - "if [ -d \"$1\" ]; then\n" - "#echo \"Dir ${1} exists\"\n" - "if [ -n \"$2\" ]; then\n" - "filesuffix=$2\n" - "else\n" - "filesuffix=\"*\"\n" - "fi\n" - "\n" - "#echo \"Filtering files using suffix ${filesuffix}\"\n" - "\n" - "file_list=`find ${1} -name \"*.${filesuffix}\" -type f`\n" - "for file2indent in $file_list\n" - "do \n" - "echo \"Indenting file $file2indent\"\n" - "__INDENTERCALLSTRING1__\n" - "done\n" - "else\n" - "if [ -f \"$1\" ]; then\n" - "echo \"Indenting one file $1\"\n" - "__INDENTERCALLSTRING2__\n" - "else\n" - "echo \"ERROR: As parameter given directory or file does not exist!\"\n" - "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\"\n" - "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\"\n" - "echo \"Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\"\n" - "exit 1\n" - "fi\n" - "fi\n"; -#endif // #if defined(Q_OS_WIN32) - return templateBatchScript; -} - -/* Here comes the original batch script without the c++ markup -@echo off - -IF (%1)==() GOTO error -dir /b /ad %1 >nul 2>nul && GOTO indentDir -IF NOT EXIST %1 GOTO error -goto indentFile - -:indentDir -set searchdir=%1 - -IF (%2)==() GOTO assignDefaultSuffix -set filesuffix=%2 - -GOTO run - -:assignDefaultSuffix -::echo !!!!DEFAULT SUFFIX!!! -set filesuffix=* - -:run -FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO ( - echo Indenting file "%%G" - ::call call_CSSTidy.bat "%%G" - "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" "%%G" --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css - move /Y indentoutput.css "%%G" -) -GOTO ende - -:indentFile -echo Indenting one file %1 -"C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" %1 --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css -move /Y indentoutput.css %1 - -GOTO ende - -:error -echo . -echo ERROR: As parameter given directory or file does not exist! -echo Syntax is: recurse.bat dirname filesuffix -echo Syntax is: recurse.bat filename -echo Example: recurse.bat temp cpp -echo . - -:ende - -*/ diff --git a/src/TemplateBatchScript.h b/src/TemplateBatchScript.h deleted file mode 100644 index 6384ff0..0000000 --- a/src/TemplateBatchScript.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef TEMPLATEBATCHSCRIPT_H -#define TEMPLATEBATCHSCRIPT_H - -class TemplateBatchScript -{ - private: - TemplateBatchScript(); - - public: - static const char* getTemplateBatchScript(); -}; - -#endif // TEMPLATEBATCHSCRIPT_H diff --git a/src/ToolBarWidget.ui b/src/ToolBarWidget.ui deleted file mode 100755 index 8665cac..0000000 --- a/src/ToolBarWidget.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - ToolBarWidget - - - - 0 - 0 - 773 - 34 - - - - Form - - - - 6 - - - 0 - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Opens a dialog for selecting a source code file.</span></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">This file will be used to show what the indent tool changes.</p></body></html> - - - Open Source File - - - - :/mainWindow/document-open.png:/mainWindow/document-open.png - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Turns the preview of the reformatted source code on and off.</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">In other words it switches between formatted and nonformatted code. (Ctrl+L)</p></body></html> - - - Live Indent Preview - - - - :/mainWindow/live-preview.png:/mainWindow/live-preview.png - - - Ctrl+L - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Enables and disables the highlightning of the source</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">code shown below. (Still needs some performance improvements) (Ctrl+H)</p></body></html> - - - Syntax Highlight - - - - :/mainWindow/syntax-highlight.png:/mainWindow/syntax-highlight.png - - - Ctrl+H - - - true - - - DONOTTRANSLATE:SyntaxHighlightingEnabled - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Shows info about UniversalIndentGUI</p></body></html> - - - About - - - - :/mainWindow/info.png:/mainWindow/info.png - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Quits the UniversalIndentGUI</p></body></html> - - - Exit - - - - :/mainWindow/system-log-out.png:/mainWindow/system-log-out.png - - - - - - - - - - diff --git a/src/UiGuiErrorMessage.cpp b/src/UiGuiErrorMessage.cpp deleted file mode 100644 index 67e8e0c..0000000 --- a/src/UiGuiErrorMessage.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiErrorMessage.h" - -#include - -/*! - \class UiGuiErrorMessage - \ingroup grp_Dialogs - \brief UiGuiErrorMessage is a child of TQErrorMessage. But TQErrorMessages - "Do not show again" didn't work with my strings, so this is my own, working - implementation of it. -*/ - - -/*! - \brief Initializes the dialog. - - Retrieves the object pointer to the \a _showAgainCheckBox check box, sets the dialogs - modality and for a working translation sets the check box text. - */ -UiGuiErrorMessage::UiGuiErrorMessage(TQWidget *parent) : - TQErrorMessage(parent) -{ - _showAgainCheckBox = findChild(); - setWindowModality(TQt::ApplicationModal); - _showAgainCheckBox->setText(tr("Show this message again")); -} - -/*! - \brief Just a lazy nothin doin destructive destructor. - */ -UiGuiErrorMessage::~UiGuiErrorMessage(void) -{ -} - -/*! - \brief Shows an error \a message in a dialog box with \a title. - - The shown \a message is added to a list, if not already in there. If it is - already in that list and "Show this message again" is not checked, that - message will not be shown. - */ -void UiGuiErrorMessage::showMessage(const TQString &title, const TQString &message) -{ - bool showAgain = true; - - if (_showAgainCheckBox != 0) - { - showAgain = _showAgainCheckBox->isChecked(); - } - - setWindowTitle(title); - - if (!_errorMessageList.contains(message)) - { - _errorMessageList << message; - if (_showAgainCheckBox != 0) - { - _showAgainCheckBox->setChecked(true); - } - TQErrorMessage::showMessage(message); - } - else if (showAgain) - { - TQErrorMessage::showMessage(message); - } -} - -/*! - \brief For convinience, for showing a dialog box with the default title "UniversalIndentGUI". - */ -void UiGuiErrorMessage::showMessage(const TQString &message) -{ - showMessage("UniversalIndentGUI", message); -} diff --git a/src/UiGuiErrorMessage.h b/src/UiGuiErrorMessage.h deleted file mode 100644 index 0ad9f70..0000000 --- a/src/UiGuiErrorMessage.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIERRORMESSAGE_H -#define UIGUIERRORMESSAGE_H - -#include - -class TQCheckBox; - - -class UiGuiErrorMessage : public TQErrorMessage -{ - Q_OBJECT - - public: - UiGuiErrorMessage(TQWidget *parent = 0); - ~UiGuiErrorMessage(void); - - void showMessage(const TQString &message); - void showMessage(const TQString &title, const TQString &message); - - private: - TQCheckBox *_showAgainCheckBox; - TQStringList _errorMessageList; -}; - -#endif // UIGUIERRORMESSAGE_H diff --git a/src/UiGuiHighlighter.cpp b/src/UiGuiHighlighter.cpp deleted file mode 100644 index 7ee13e8..0000000 --- a/src/UiGuiHighlighter.cpp +++ /dev/null @@ -1,604 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiHighlighter.h" - -#include "SettingsPaths.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (TQSCINTILLA_VERSION >= 0x020300) - #include - #include -#endif -#include -#include -#include -#include -#include -#include -#if (TQSCINTILLA_VERSION >= 0x020300) - #include -#endif -#include -#if (TQSCINTILLA_VERSION >= 0x020300) - #include -#endif -#include -#include -#include -#include -#if (TQSCINTILLA_VERSION >= 0x020400) - #include -#endif -#include -#if (TQSCINTILLA_VERSION >= 0x020300) - #include -#endif -#include -#if (TQSCINTILLA_VERSION >= 0x020400) - #include -#endif -#include -#if (TQSCINTILLA_VERSION >= 0x020300) - #include - #include -#endif - -//! \defgroup grp_EditorComponent All concerning editor widget. - -/*! - \class UiGuiHighlighter - \ingroup grp_EditorComponent - \brief UiGuiHighlighter used for selecting the syntax highlighter/lexer for the QsciScintilla component. -*/ - -/*! - \brief The constructor initializes some regular expressions and keywords to identify cpp tokens - */ -UiGuiHighlighter::UiGuiHighlighter(QsciScintilla *parent) : - TQObject(parent) -{ - _qsciEditorParent = parent; - - // Create the highlighter _settings object from the UiGuiSyntaxHighlightConfig.ini file. - _settings = new TQSettings( - SettingsPaths::getSettingsPath() + "/UiGuiSyntaxHighlightConfig.ini", TQSettings::IniFormat, - this); - - _highlightningIsOn = true; - - _mapHighlighternameToExtension["Bash"] = TQStringList() << "sh"; - _mapHighlighternameToExtension["Batch"] = TQStringList() << "bat"; - _mapHighlighternameToExtension["CMake"] = TQStringList() << "cmake"; - _mapHighlighternameToExtension["C++"] = TQStringList() << "c" << "h" << "cpp" << "hpp" << - "cxx" << "hxx"; - _mapHighlighternameToExtension["C#"] = TQStringList() << "cs"; - _mapHighlighternameToExtension["CSS"] = TQStringList() << "css"; - _mapHighlighternameToExtension["D"] = TQStringList() << "d"; - _mapHighlighternameToExtension["Diff"] = TQStringList() << "diff"; -#if (TQSCINTILLA_VERSION >= 0x020300) - _mapHighlighternameToExtension["Fortran"] = TQStringList() << "f" << "for" << "f90"; - _mapHighlighternameToExtension["Fortran77"] = TQStringList() << "f77"; -#endif - _mapHighlighternameToExtension["HTML"] = TQStringList() << "html" << "htm"; - _mapHighlighternameToExtension["IDL"] = TQStringList() << "idl"; - _mapHighlighternameToExtension["Java"] = TQStringList() << "java"; - _mapHighlighternameToExtension["JavaScript"] = TQStringList() << "js"; - _mapHighlighternameToExtension["LUA"] = TQStringList() << "lua"; - _mapHighlighternameToExtension["Makefile"] = TQStringList() << "makefile"; -#if (TQSCINTILLA_VERSION >= 0x020300) - _mapHighlighternameToExtension["Pascal"] = TQStringList() << "pas"; -#endif - _mapHighlighternameToExtension["Perl"] = TQStringList() << "perl" << "pl" << "pm"; - _mapHighlighternameToExtension["PHP"] = TQStringList() << "php"; -#if (TQSCINTILLA_VERSION >= 0x020300) - _mapHighlighternameToExtension["PostScript"] = TQStringList() << "ps" << "eps" << "pdf" << "ai" << - "fh"; -#endif - _mapHighlighternameToExtension["POV"] = TQStringList() << "pov"; - _mapHighlighternameToExtension["Ini"] = TQStringList() << "ini"; - _mapHighlighternameToExtension["Python"] = TQStringList() << "py"; - _mapHighlighternameToExtension["Ruby"] = TQStringList() << "rub" << "rb"; -#if (TQSCINTILLA_VERSION >= 0x020400) - _mapHighlighternameToExtension["Spice"] = TQStringList() << "cir"; -#endif - _mapHighlighternameToExtension["SQL"] = TQStringList() << "sql"; -#if (TQSCINTILLA_VERSION >= 0x020300) - _mapHighlighternameToExtension["TCL"] = TQStringList() << "tcl"; -#endif - _mapHighlighternameToExtension["TeX"] = TQStringList() << "tex"; -#if (TQSCINTILLA_VERSION >= 0x020400) - _mapHighlighternameToExtension["Verilog"] = TQStringList() << "v" << "vh"; -#endif - _mapHighlighternameToExtension["VHDL"] = TQStringList() << "vhdl"; - _mapHighlighternameToExtension["XML"] = TQStringList() << "xml"; -#if (TQSCINTILLA_VERSION >= 0x020300) - _mapHighlighternameToExtension["YAML"] = TQStringList() << "yaml"; -#endif - - _lexer = NULL; - - // This code is only for testing. - /* - foreach(TQStringList extensionList, _mapHighlighternameToExtension.values() ) { - setLexerForExtension( extensionList.at(0) ); - } - */ - - // Set default highlighter to C++ highlighter. - setLexerForExtension("cpp"); -} - -/*! - \brief Returns the available highlighters as TQStringList. - */ -TQStringList UiGuiHighlighter::getAvailableHighlighters() -{ - return _mapHighlighternameToExtension.keys(); -} - -/*! - \brief This slot handles signals coming from selecting another syntax highlighter. - */ -void UiGuiHighlighter::setHighlighterByAction(TQAction *highlighterAction) -{ - TQString highlighterName = highlighterAction->text(); - setLexerForExtension(_mapHighlighternameToExtension[highlighterName].first()); - //TODO: This is really no nice way. How do it better? - // Need to do this "text update" to update the syntax highlighting. Otherwise highlighting is - // wrong. - int scrollPos = _qsciEditorParent->verticalScrollBar()->value(); - _qsciEditorParent->setText(_qsciEditorParent->text()); - _qsciEditorParent->verticalScrollBar()->setValue(scrollPos); -} - -/*! - \brief Turns the syntax parser on. -*/ -void UiGuiHighlighter::turnHighlightOn() -{ - _highlightningIsOn = true; - _qsciEditorParent->setLexer(_lexer); - readCurrentSettings(""); -} - -/*! - \brief Turns the syntax parser off. -*/ -void UiGuiHighlighter::turnHighlightOff() -{ - _highlightningIsOn = false; - _qsciEditorParent->setLexer(); -#if defined (Q_OS_WIN) || defined (Q_OS_MAC) - _qsciEditorParent->setFont(TQFont("Courier", 10, TQFont::Normal)); - _qsciEditorParent->setMarginsFont(TQFont("Courier", 10, TQFont::Normal)); -#else - _qsciEditorParent->setFont(TQFont("Monospace", 10, TQFont::Normal)); - _qsciEditorParent->setMarginsFont(TQFont("Monospace", 10, TQFont::Normal)); -#endif -} - -/*! - \brief Read the settings for the current lexer from the settings file. - */ - -//TODO: Refactor this function so that the coding style and variable names suit better. -bool UiGuiHighlighter::readCurrentSettings(const char *prefix) -{ - bool ok, flag, rc = true; - int num; - TQString key; - - // Reset lists containing fonts and colors for each style - _fontForStyles.clear(); - _colorForStyles.clear(); - - // Read the styles. - for (int i = 0; i < 128; ++i) - { - // Ignore invalid styles. - if (_lexer->description(i).isEmpty()) - { - continue; - } - - key.sprintf("%s/%s/style%d/", prefix, _lexer->language(), i); - key.replace("+", "p"); - - // Read the foreground color. - ok = _settings->contains(key + "color"); - num = _settings->value(key + "color", 0).toInt(); - - if (ok) - { - setColor(TQColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i); - } - else - { - rc = false; - } - - // Read the end-of-line fill. - ok = _settings->contains(key + "eolfill"); - flag = _settings->value(key + "eolfill", false).toBool(); - - if (ok) - { - _lexer->setEolFill(flag, i); - } - else - { - rc = false; - } - - // Read the font - TQStringList fdesc; - - ok = _settings->contains(key + "font"); - fdesc = _settings->value(key + "font").toStringList(); - - if (ok && fdesc.count() == 5) - { - TQFont f; - -#if defined (Q_OS_WIN) || defined (Q_OS_MAC) - f.setFamily(fdesc[0]); -#else - if (fdesc[0].contains("courier", TQt::CaseInsensitive)) - { - f.setFamily("Monospace"); - } - else - { - f.setFamily(fdesc[0]); - } -#endif - f.setPointSize(fdesc[1].toInt()); - f.setBold(fdesc[2].toInt()); - f.setItalic(fdesc[3].toInt()); - f.setUnderline(fdesc[4].toInt()); - - setFont(f, i); - } - else - { - rc = false; - } - - // Read the background color. - ok = _settings->contains(key + "paper"); - num = _settings->value(key + "paper", 0).toInt(); - - if (ok) - { - _lexer->setPaper(TQColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i); - } - else - { - rc = false; - } - } - - // Read the properties. - key.sprintf("%s/%s/properties/", prefix, _lexer->language()); - - _lexer->refreshProperties(); - - return rc; -} - -/*! - \brief Write the settings for the current lexer to the settings file. - */ -void UiGuiHighlighter::writeCurrentSettings(const char *prefix) -{ - TQString key; - - // Write the styles. - for (int i = 0; i < 128; ++i) - { - // Ignore invalid styles. - if (_lexer->description(i).isEmpty()) - { - continue; - } - - int num; - TQColor c; - - key.sprintf("%s/%s/style%d/", prefix, _lexer->language(), i); - key.replace("+", "p"); - - // Write style name - _settings->setValue(key + "", _lexer->description(i)); - - // Write the foreground color. - if (_colorForStyles.contains(i)) - { - c = _colorForStyles[i]; - } - else - { - c = _lexer->color(i); - } - num = (c.red() << 16) | (c.green() << 8) | c.blue(); - - _settings->setValue(key + "color", num); - - // Write the end-of-line fill. - _settings->setValue(key + "eolfill", _lexer->eolFill(i)); - - // Write the font - TQStringList fdesc; - TQString fmt("%1"); - TQFont f; - - if (_fontForStyles.contains(i)) - { - f = _fontForStyles[i]; - } - else - { - f = _lexer->font(i); - } - - fdesc += f.family(); - fdesc += fmt.arg(f.pointSize()); - - // The casts are for Borland. - fdesc += fmt.arg((int)f.bold()); - fdesc += fmt.arg((int)f.italic()); - fdesc += fmt.arg((int)f.underline()); - - _settings->setValue(key + "font", fdesc); - - // Write the background color. - c = _lexer->paper(i); - num = (c.red() << 16) | (c.green() << 8) | c.blue(); - - _settings->setValue(key + "paper", num); - } -} - -/*! - \brief Sets the \a color for the given \a style. - */ -void UiGuiHighlighter::setColor(const TQColor &color, int style) -{ - _colorForStyles[style] = color; - _lexer->setColor(color, style); -} - -/*! - \brief Sets the \a font for the given \a style. - */ -void UiGuiHighlighter::setFont(const TQFont &font, int style) -{ - _fontForStyles[style] = font; - _lexer->setFont(font, style); -} - -/*! - \brief Sets the to be used lexer by giving his name. - */ -void UiGuiHighlighter::setLexerByName(TQString lexerName) -{ - setLexerForExtension(_mapHighlighternameToExtension[lexerName].first()); -} - -/*! - \brief Sets the proper highlighter / lexer for the given file \a extension. Returns the index of the used lexer in the list. - */ -int UiGuiHighlighter::setLexerForExtension(TQString extension) -{ - int indexOfHighlighter = 0; - extension = extension.toLower(); - - if (_lexer != NULL) - { - writeCurrentSettings(""); - delete _lexer; - } - - if (extension == "cpp" || extension == "hpp" || extension == "c" || extension == "h" || - extension == "cxx" || extension == "hxx") - { - _lexer = new QsciLexerCPP(); - } - else if (extension == "sh") - { - _lexer = new QsciLexerBash(); - } - else if (extension == "bat") - { - _lexer = new QsciLexerBatch(); - } - else if (extension == "cmake") - { - _lexer = new QsciLexerCMake(); - } - else if (extension == "cs") - { - _lexer = new QsciLexerCSharp(); - } - else if (extension == "css") - { - _lexer = new QsciLexerCSS(); - } - else if (extension == "d") - { - _lexer = new QsciLexerD(); - } - else if (extension == "diff") - { - _lexer = new QsciLexerDiff(); - } -#if (TQSCINTILLA_VERSION >= 0x020300) - else if (extension == "f" || extension == "for" || extension == "f90") - { - _lexer = new QsciLexerFortran(); - } - else if (extension == "f77") - { - _lexer = new QsciLexerFortran77(); - } -#endif - else if (extension == "html" || extension == "htm") - { - _lexer = new QsciLexerHTML(); - } - else if (extension == "idl") - { - _lexer = new QsciLexerIDL(); - } - else if (extension == "java") - { - _lexer = new QsciLexerJava(); - } - else if (extension == "js") - { - _lexer = new QsciLexerJavaScript(); - } - else if (extension == "lua") - { - _lexer = new QsciLexerLua(); - } - else if (extension == "makefile") - { - _lexer = new QsciLexerMakefile(); - } -#if (TQSCINTILLA_VERSION >= 0x020300) - else if (extension == "pas") - { - _lexer = new QsciLexerPascal(); - } -#endif - else if (extension == "perl" || extension == "pl" || extension == "pm") - { - _lexer = new QsciLexerPerl(); - } - else if (extension == "php") - { - _lexer = new QsciLexerHTML(); - } -#if (TQSCINTILLA_VERSION >= 0x020300) - else if (extension == "ps" || extension == "eps" || extension == "pdf" || extension == "ai" || - extension == "fh") - { - _lexer = new QsciLexerPostScript(); - } -#endif - else if (extension == "pov") - { - _lexer = new QsciLexerPOV(); - } - else if (extension == "ini") - { - _lexer = new QsciLexerProperties(); - } - else if (extension == "py") - { - _lexer = new QsciLexerPython(); - } - else if (extension == "rub" || extension == "rb") - { - _lexer = new QsciLexerRuby(); - } -#if (TQSCINTILLA_VERSION >= 0x020400) - else if (extension == "spice?") - { - _lexer = new QsciLexerSpice(); - } -#endif - else if (extension == "sql") - { - _lexer = new QsciLexerSQL(); - } -#if (TQSCINTILLA_VERSION >= 0x020300) - else if (extension == "tcl") - { - _lexer = new QsciLexerTCL(); - } -#endif - else if (extension == "tex") - { - _lexer = new QsciLexerTeX(); - } -#if (TQSCINTILLA_VERSION >= 0x020400) - else if (extension == "vlog?") - { - _lexer = new QsciLexerVerilog(); - } -#endif - else if (extension == "vhdl") - { - _lexer = new QsciLexerVHDL(); - } - else if (extension == "xml") - { -#if (TQSCINTILLA_VERSION >= 0x020300) - _lexer = new QsciLexerXML(); -#else - _lexer = new QsciLexerHTML(); -#endif - } -#if (TQSCINTILLA_VERSION >= 0x020300) - else if (extension == "yaml") - { - _lexer = new QsciLexerYAML(); - } -#endif - else - { - _lexer = new QsciLexerCPP(); - extension = "cpp"; - } - - // Find the index of the selected _lexer. - indexOfHighlighter = 0; - while (!_mapHighlighternameToExtension.values().at(indexOfHighlighter).contains(extension)) - { - indexOfHighlighter++; - } - - // Set the _lexer for the TQScintilla widget. - if (_highlightningIsOn) - { - _qsciEditorParent->setLexer(_lexer); - } - - // Read the _settings for the _lexer properties from file. - readCurrentSettings(""); - - return indexOfHighlighter; -} diff --git a/src/UiGuiHighlighter.h b/src/UiGuiHighlighter.h deleted file mode 100644 index ad50849..0000000 --- a/src/UiGuiHighlighter.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIHIGHLIGHTER_H -#define UIGUIHIGHLIGHTER_H - -#include -#include -#include -#include - -class TQAction; -class TQSettings; - -class QsciScintilla; -class QsciLexer; - - -class UiGuiHighlighter : public TQObject -{ - Q_OBJECT - - public: - UiGuiHighlighter(QsciScintilla *parent); - - void turnHighlightOff(); - void turnHighlightOn(); - - bool readCurrentSettings(const char *prefix); - void writeCurrentSettings(const char *prefix); - TQStringList getAvailableHighlighters(); - - public slots: - //! The foreground color for style number \a style is set to \a color. If - //! \a style is -1 then the color is set for all styles. - void setColor(const TQColor &color, int style = -1); - - //! The font for style number \a style is set to \a font. If \a style is - //! -1 then the font is set for all styles. - void setFont(const TQFont &font, int style = -1); - - //! Sets the lexer that is responsible for the given \a extension. - int setLexerForExtension(TQString extension); - - void setLexerByName(TQString lexerName); - - void setHighlighterByAction(TQAction *highlighterAction); - - private: - bool _highlightningIsOn; - QsciScintilla *_qsciEditorParent; - TQMap _fontForStyles; - TQMap _colorForStyles; - QsciLexer *_lexer; - TQSettings *_settings; - TQMap _mapHighlighternameToExtension; -}; - -#endif // UIGUIHIGHLIGHTER_H diff --git a/src/UiGuiIndentServer.cpp b/src/UiGuiIndentServer.cpp deleted file mode 100644 index 91c5ec7..0000000 --- a/src/UiGuiIndentServer.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiIndentServer.h" - -#include -#include -#include -#include - -//! \defgroup grp_Server All concerning the server component. - -/*! - \class UiGuiIndentServer - \ingroup grp_Server - \brief UiGuiIndentServer is in such an early state, that even the communication - protocol isn't completely planned. So this class lacks documentation until - I really know where all this will lead to. - - The plan however is to have a server that receives commands for selecting an - indenter and perhaps load some by the user predefined indenter config file. Then - the client can send a text to it and will receive it formatted. - The idea behind that is to make UiGUIs use as plugin or whatever more flexible. - So the plugin is developed for Eclipse for example and it takes the client role, - making it possible to use UiGUI from within Eclipse. Choosing a network protocol - makes everything platform and programming language independent, so it doesn't - matter for which application the plugin/client is developed. -*/ - -UiGuiIndentServer::UiGuiIndentServer(void) : - TQObject() -{ - _tcpServer = NULL; - _currentClientConnection = NULL; - _readyForHandleRequest = false; -} - -UiGuiIndentServer::~UiGuiIndentServer(void) -{ -} - -void UiGuiIndentServer::startServer() -{ - if (_tcpServer == NULL) - { - _tcpServer = new TQTcpServer(this); - } - - if (!_tcpServer->isListening()) - { - if (!_tcpServer->listen(TQHostAddress::Any, tquint16(84484))) - { - TQMessageBox::critical(NULL, tr("UiGUI Server"), - tr("Unable to start the server: %1.").arg(_tcpServer->errorString())); - return; - } - } - - connect(_tcpServer, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); - _readyForHandleRequest = true; - _blockSize = 0; -} - -void UiGuiIndentServer::stopServer() -{ - if (_tcpServer != NULL) - { - _tcpServer->close(); - delete _tcpServer; - _tcpServer = NULL; - } - _currentClientConnection = NULL; - _readyForHandleRequest = false; -} - -void UiGuiIndentServer::handleNewConnection() -{ - TQTcpSocket *clientConnection = _tcpServer->nextPendingConnection(); - connect(clientConnection, SIGNAL(disconnected()), clientConnection, SLOT(deleteLater())); - - connect(clientConnection, SIGNAL(readyRead()), this, SLOT(handleReceivedData())); -} - -void UiGuiIndentServer::handleReceivedData() -{ - if (!_readyForHandleRequest) - { - return; - } - - _currentClientConnection = qobject_cast(sender()); - TQString receivedData = ""; - - if (_currentClientConnection != NULL) - { - TQDataStream in(_currentClientConnection); - in.setVersion(TQDataStream::TQt_4_0); - - if (_blockSize == 0) - { - if (_currentClientConnection->bytesAvailable() < (int)sizeof(tquint32)) - { - return; - } - - in >> _blockSize; - } - - if (_currentClientConnection->bytesAvailable() < _blockSize) - { - return; - } - - TQString receivedMessage; - in >> receivedMessage; - - _blockSize = 0; - - tqDebug() << "receivedMessage: " << receivedMessage; - - if (receivedMessage == "ts") - { - sendMessage("Toll"); - } - else - { - sendMessage("irgendwas"); - } - } -} - -void UiGuiIndentServer::sendMessage(const TQString &message) -{ - _readyForHandleRequest = false; - - _dataToSend = ""; - TQDataStream out(&_dataToSend, TQIODevice::WriteOnly); - out.setVersion(TQDataStream::TQt_4_0); - out << (tquint32)0; - out << message; - out.device()->seek(0); - out << (tquint32)(_dataToSend.size() - sizeof(tquint32)); - - connect(_currentClientConnection, SIGNAL(bytesWritten(qint64)), this, - SLOT(checkIfReadyForHandleRequest())); - _currentClientConnection->write(_dataToSend); -} - -void UiGuiIndentServer::checkIfReadyForHandleRequest() -{ - if (_currentClientConnection->bytesToWrite() == 0) - { - TQString dataToSendStr = _dataToSend.right(_dataToSend.size() - sizeof(tquint32)); - tqDebug() << "checkIfReadyForHandleRequest _dataToSend was: " << dataToSendStr; - disconnect(_currentClientConnection, SIGNAL(bytesWritten(qint64)), this, - SLOT(checkIfReadyForHandleRequest())); - _readyForHandleRequest = true; - } -} diff --git a/src/UiGuiIndentServer.h b/src/UiGuiIndentServer.h deleted file mode 100644 index 0a8f069..0000000 --- a/src/UiGuiIndentServer.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIINDENTSERVER_H -#define UIGUIINDENTSERVER_H - -#include - -class TQTcpServer; -class TQTcpSocket; - - -class UiGuiIndentServer : public TQObject -{ - Q_OBJECT - - public: - UiGuiIndentServer(void); - ~UiGuiIndentServer(void); - - public slots: - void startServer(); - void stopServer(); - - private slots: - void handleNewConnection(); - void handleReceivedData(); - void sendMessage(const TQString &message); - void checkIfReadyForHandleRequest(); - - private: - TQTcpServer *_tcpServer; - TQByteArray _dataToSend; - bool _readyForHandleRequest; - TQTcpSocket *_currentClientConnection; - tquint32 _blockSize; -}; - -#endif // UIGUIINDENTSERVER_H diff --git a/src/UiGuiIniFileParser.cpp b/src/UiGuiIniFileParser.cpp deleted file mode 100644 index e690139..0000000 --- a/src/UiGuiIniFileParser.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiIniFileParser.h" - -#include -#include -#include -#include - -//! \defgroup grp_Settings All concerning applications settings. - -/*! - \class UiGuiIniFileParser - \ingroup grp_Settings - \brief UiGuiIniFileParser is a simple ini file format parser. - - These ini files need to have key-value pairs in the style - "keyname=keyvalue". Groups can be defined by writing the groupname - in the style [groupname] before some key-value pairs. - - The reason why I use my own class instead of TQSettings is mainly, that - TQSettings always internally sorts the groups alphabetically and also - rewrites a settings file sorted. Very annoying for me. -*/ - -/*! - \brief Init and empty all needed lists and strings. - */ -UiGuiIniFileParser::UiGuiIniFileParser(void) -{ - init(); -} - -/*! - \brief Directly loads and parses the file with name \a iniFileName. - */ -UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName) -{ - init(); - _iniFileName = iniFileName; - parseIniFile(); -} - -void UiGuiIniFileParser::init() -{ - _sections.clear(); - _keyValueMap.clear(); - _iniFileName = ""; -} - -UiGuiIniFileParser::~UiGuiIniFileParser(void) -{ -} - -/*! - \brief Returns the group/section names in the same order as they occurr in the ini file as TQStringList. - */ -TQStringList UiGuiIniFileParser::childGroups() -{ - TQStringList sectionsStringList; - - for (unsigned int i = 0; i < _sections.size(); i++) - { - sectionsStringList << _sections[i]; - } - - return sectionsStringList; -} - -/*! - \brief Returns the value of the defined \a keyName as TQVariant. - - The \a keyName is assembled by a section name, a slash and the key name itself. - For example if you wish to access the value of the following setting: - [NiceSection]
niceKeyName=2
you would have to call - value("NiceSection/niceKeyName"). - */ -TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue) -{ - return _keyValueMap.value(keyName, defaultValue); -} - -/*! - \brief Parses the ini file and stores the key value pairs in the internal vectors \a keys and \a values. - */ -void UiGuiIniFileParser::parseIniFile() -{ - TQFile iniFile(_iniFileName); - - if (iniFile.open(TQFile::ReadOnly)) - { - // Clear the vectors holding the keys and values. - _sections.clear(); - _keyValueMap.clear(); - - TQTextStream iniFileStream(&iniFile); - TQString line; - TQString currentSectionName = ""; - TQString keyName = ""; - TQString valueAsString = ""; - - while (!iniFileStream.atEnd()) - { - line = iniFileStream.readLine().trimmed(); - - // Test if the read line is a section name and if so remeber it. - if (line.startsWith("[") && line.endsWith("]")) - { - currentSectionName = line.remove(0, 1); - currentSectionName.chop(1); - - // Store the section name. - _sections.push_back(currentSectionName); - } - // Otherwise test whether the line has a assign char - else if (line.contains("=")) - { - int indexOfFirstAssign = line.indexOf("="); - keyName = line.left(indexOfFirstAssign); - - if (!keyName.isEmpty()) - { - valueAsString = line.remove(0, indexOfFirstAssign + 1); - // Remove any existing double quotes from the value. - if (valueAsString.startsWith("\"") && valueAsString.endsWith("\"")) - { - valueAsString = valueAsString.remove(0, 1); - valueAsString.chop(1); - } - - // Prepend an eventually section name to the key name. - if (!currentSectionName.isEmpty()) - { - keyName = currentSectionName + "/" + keyName; - } - - // Store the key and value in the map. - _keyValueMap.insert(keyName, valueAsString); - } - } - } - } -} diff --git a/src/UiGuiIniFileParser.h b/src/UiGuiIniFileParser.h deleted file mode 100644 index 0aebb09..0000000 --- a/src/UiGuiIniFileParser.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIINIFILEPARSER_H -#define UIGUIINIFILEPARSER_H - -#include -#include - -#include - -class TQStringList; -class TQVariant; - - -class UiGuiIniFileParser -{ - public: - UiGuiIniFileParser(void); - UiGuiIniFileParser(const TQString &iniFileName); - ~UiGuiIniFileParser(void); - - TQVariant value(const TQString &keyName, const TQString &defaultValue = ""); - TQStringList childGroups(); - - protected: - void init(); - - private: - void parseIniFile(); - - TQString _iniFileName; - std::vector _sections; - TQMap _keyValueMap; -}; - -#endif // UIGUIINIFILEPARSER_H diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp deleted file mode 100644 index 11cc4c2..0000000 --- a/src/UiGuiSettings.cpp +++ /dev/null @@ -1,933 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#include "UiGuiSettings.h" - -#include "SettingsPaths.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//! \defgroup grp_Settings All concerning the settings. - -/*! - \class UiGuiSettings - \ingroup grp_Settings - \brief Handles the settings of the program. Reads them on startup and saves them on exit. - Is a singleton class and can only be accessed via getInstance(). -*/ - -// Inits the single class instance pointer. -TQWeakPointer UiGuiSettings::_instance; - - -/*! - \brief The constructor for the settings. -*/ -UiGuiSettings::UiGuiSettings() : - TQObject() -{ - // Create the main application settings object from the UniversalIndentGUI.ini file. - _qsettings = new TQSettings( - SettingsPaths::getSettingsPath() + "/UniversalIndentGUI.ini", TQSettings::IniFormat, this); - - _indenterDirctoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters"; - readAvailableTranslations(); - initSettings(); -} - -/*! - \brief Returns the instance of the settings class. If no instance exists, ONE will be created. - */ -TQSharedPointer UiGuiSettings::getInstance() -{ - TQSharedPointer sharedInstance = _instance.toStrongRef(); - if (sharedInstance.isNull()) - { - // Create the settings object, which loads all UiGui settings from a file. - sharedInstance = TQSharedPointer(new UiGuiSettings()); - _instance = sharedInstance.toWeakRef(); - } - - return sharedInstance; -} - -/*! - \brief The destructor saves the settings to a file. - */ -UiGuiSettings::~UiGuiSettings() -{ - // Convert the language setting from an integer index to a string. - int index = _qsettings->value("UniversalIndentGUI/language", 0).toInt(); - if (index < 0 || index >= _availableTranslations.size()) - { - index = 0; - } - - _qsettings->setValue("UniversalIndentGUI/language", _availableTranslations.at(index)); -} - -/*! - \brief Scans the translations directory for available translation files and - stores them in the TQList \a _availableTranslations. - */ -void UiGuiSettings::readAvailableTranslations() -{ - TQString languageShort; - TQStringList languageFileList; - - // English is the default language. A translation file does not exist but to have a menu entry, - // added here. - languageFileList << "universalindent_en.qm"; - - // Find all translation files in the "translations" directory. - TQDir translationDirectory = TQDir(SettingsPaths::getGlobalFilesPath() + "/translations"); - languageFileList << translationDirectory.entryList(TQStringList("universalindent_*.qm")); - - // Loop for each found translation file - foreach(languageShort, languageFileList) - { - // Remove the leading string "universalindent_" from the filename. - languageShort.remove(0, 16); - // Remove trailing file extension ".qm". - languageShort.chop(3); - - _availableTranslations.append(languageShort); - } -} - -/*! - \brief Returns a list of the mnemonics of the available translations. - */ -TQStringList UiGuiSettings::getAvailableTranslations() -{ - return _availableTranslations; -} - -/*! - \brief Returns the value of the by \a settingsName defined setting as TQVariant. - - If the named setting does not exist, 0 is being returned. -*/ -TQVariant UiGuiSettings::getValueByName(TQString settingName) -{ - return _qsettings->value("UniversalIndentGUI/" + settingName); -} - -/*! - \brief Loads the settings for the main application. - - Settings are for example last selected indenter, last loaded source code file and so on. -*/ -bool UiGuiSettings::initSettings() -{ - // Read the version string saved in the settings file. - _qsettings->setValue("UniversalIndentGUI/version", - _qsettings->value("UniversalIndentGUI/version", "")); - - // Read windows last size and position from the settings file. - _qsettings->setValue("UniversalIndentGUI/maximized", - _qsettings->value("UniversalIndentGUI/maximized", false)); - _qsettings->setValue("UniversalIndentGUI/position", - _qsettings->value("UniversalIndentGUI/position", TQPoint(50, 50))); - _qsettings->setValue("UniversalIndentGUI/size", - _qsettings->value("UniversalIndentGUI/size", TQSize(800, 600))); - - // Read last selected encoding for the opened source code file. - _qsettings->setValue("UniversalIndentGUI/encoding", - _qsettings->value("UniversalIndentGUI/encoding", "UTF-8")); - - // Read maximum length of list for recently opened files. - _qsettings->setValue("UniversalIndentGUI/recentlyOpenedListSize", - _qsettings->value("UniversalIndentGUI/recentlyOpenedListSize", 5)); - - // Read if last opened source code file should be loaded on startup. - _qsettings->setValue("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", - _qsettings->value("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", true)); - - // Read last opened source code file from the settings file. - _qsettings->setValue("UniversalIndentGUI/lastSourceCodeFile", - _qsettings->value("UniversalIndentGUI/lastSourceCodeFile", - _indenterDirctoryStr + "/example.cpp")); - - // Read last selected indenter from the settings file. - int selectedIndenter = _qsettings->value("UniversalIndentGUI/selectedIndenter", 0).toInt(); - if (selectedIndenter < 0) - { - selectedIndenter = 0; - } - _qsettings->setValue("UniversalIndentGUI/selectedIndenter", selectedIndenter); - - // Read if syntax highlighting is enabled. - _qsettings->setValue("UniversalIndentGUI/SyntaxHighlightingEnabled", - _qsettings->value("UniversalIndentGUI/SyntaxHighlightingEnabled", true)); - - // Read if white space characters should be displayed. - _qsettings->setValue("UniversalIndentGUI/whiteSpaceIsVisible", - _qsettings->value("UniversalIndentGUI/whiteSpaceIsVisible", false)); - - // Read if indenter parameter tool tips are enabled. - _qsettings->setValue("UniversalIndentGUI/indenterParameterTooltipsEnabled", - _qsettings->value("UniversalIndentGUI/indenterParameterTooltipsEnabled", true)); - - // Read the tab width from the settings file. - _qsettings->setValue("UniversalIndentGUI/tabWidth", - _qsettings->value("UniversalIndentGUI/tabWidth", 4)); - - // Read the last selected language and stores the index it has in the list of available - // translations. - _qsettings->setValue("UniversalIndentGUI/language", - _availableTranslations.indexOf(_qsettings->value("UniversalIndentGUI/language", - "").toString())); - - // Read the update check settings from the settings file. - _qsettings->setValue("UniversalIndentGUI/CheckForUpdate", - _qsettings->value("UniversalIndentGUI/CheckForUpdate", false)); - _qsettings->setValue("UniversalIndentGUI/LastUpdateCheck", - _qsettings->value("UniversalIndentGUI/LastUpdateCheck", TQDate(1900, 1, 1))); - - // Read the main window state. - _qsettings->setValue("UniversalIndentGUI/MainWindowState", - _qsettings->value("UniversalIndentGUI/MainWindowState", TQByteArray())); - - return true; -} - -/*! - \brief Register the by \a propertyName defined property of \a obj to be connected to the setting defined by \a settingName. - - The \a propertyName must be one of those that are listed in the TQt "Properties" documentation section of a TQt Object. - All further needed info is retrieved via the \a obj's MetaObject, like the to the property bound signal. - */ -bool UiGuiSettings::registerObjectProperty(TQObject *obj, const TQString &propertyName, - const TQString &settingName) -{ - const TQMetaObject *metaObject = obj->metaObject(); - bool connectSuccess = false; - - // Connect to the objects destroyed signal, so that it will be correctly unregistered. - connectSuccess = - connect(obj, SIGNAL(destroyed(TQObject*)), this, - SLOT(unregisterObjectProperty(TQObject*))); - - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (connectSuccess && indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - - // Connect to the property's value changed signal. - if (mProp.hasNotifySignal()) - { - TQMetaMethod signal = mProp.notifySignal(); - //TQString teststr = qPrintable(SIGNAL() + TQString(signal.signature())); - // The command "SIGNAL() + TQString(signal.signature())" assembles the signal methods - // signature to a valid TQt SIGNAL. - connectSuccess = - connect(obj, qPrintable(SIGNAL() + TQString(signal.signature())), this, - SLOT(handleObjectPropertyChange())); - } - - if (connectSuccess) - { - _registeredObjectProperties[obj] = TQStringList() << propertyName << settingName; - } - else - { - //TODO: Write a debug warning to the log. - disconnect(obj, SIGNAL(destroyed(TQObject*)), this, - SLOT(unregisterObjectProperty(TQObject*))); - return false; - } - - // If setting already exists, set the objects property to the setting value. - if (_qsettings->contains("UniversalIndentGUI/" + settingName)) - { - mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); - } - // Otherwise add the setting and set it to the value of the objects property. - else - { - _qsettings->setValue("UniversalIndentGUI/" + settingName, mProp.read(obj)); - } - } - else - { - //TODO: Write a debug warning to the log. - disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectProperty(TQObject*))); - return false; - } - - return true; -} - -/*! - \brief Searches the child TQObjects of \a obj for a property name and setting name definition within - their custom properties and registers this property name to that setting name if both were found. - - The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", - where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and - "connectedSettingName" is the name of a setting here within UiGuiSettings. If the mentioned setting - name doesn't exist, it will be created. - - Returns true, if all found property and setting definitions could be successfully registered. - Returns false, if any of those registrations fails. - */ -bool UiGuiSettings::registerObjectPropertyRecursive(TQObject *obj) -{ - return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::registerObjectProperty); -} - -/*! - \brief Assigns the by \a settingName defined setting value to the by \a propertyName defined property of \a obj. - - Returns true, if the value could be assigned, otherwise returns false, which is the case if settingName doesn't exist - within the settings or if the mentioned propertyName wasn't found for the \a obj. - */ -bool UiGuiSettings::setObjectPropertyToSettingValue(TQObject *obj, const TQString &propertyName, - const TQString &settingName) -{ - const TQMetaObject *metaObject = obj->metaObject(); - - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - - // If setting already exists, set the objects property to the setting value. - if (_qsettings->contains("UniversalIndentGUI/" + settingName)) - { - mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); - } - // The setting didn't exist so return that setting the objects property failed. - else - { - //TODO: Write a debug warning to the log. - return false; - } - } - else - { - //TODO: Write a debug warning to the log. - return false; - } - - return true; -} - -/*! - \brief Searches the child TQObjects of \a obj for a property name and setting name definition within - their custom properties and sets each property to settings value. - - The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", - where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and - "connectedSettingName" is the name of a setting here within UiGuiSettings. - - Returns true, if all found property and setting definitions could be successfully registered. - Returns false, if any of those registrations fails. - */ -bool UiGuiSettings::setObjectPropertyToSettingValueRecursive(TQObject *obj) -{ - return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setObjectPropertyToSettingValue); -} - -/*! - \brief Assigns the by \a propertyName defined property's value of \a obj to the by \a settingName defined setting. - - If the \a settingName didn't exist yet, it will be created. - - Returns true, if the value could be assigned, otherwise returns false, which is the case if the mentioned - propertyName wasn't found for the \a obj. - */ -bool UiGuiSettings::setSettingToObjectPropertyValue(TQObject *obj, const TQString &propertyName, - const TQString &settingName) -{ - const TQMetaObject *metaObject = obj->metaObject(); - - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - - setValueByName(settingName, mProp.read(obj)); - } - else - { - //TODO: Write a debug warning to the log. - return false; - } - - return true; -} - -/*! - \brief Searches the child TQObjects of \a obj for a property name and setting name definition within - their custom properties and sets each setting to the property value. - - The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", - where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and - "connectedSettingName" is the name of a setting here within UiGuiSettings. If the settingName - didn't exist yet, it will be created. - - Returns true, if all found property and setting definitions could be successfully registered. - Returns false, if any of those registrations fails. - */ -bool UiGuiSettings::setSettingToObjectPropertyValueRecursive(TQObject *obj) -{ - return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setSettingToObjectPropertyValue); -} - -/*! - \brief Iterates over all \a objs child TQObjects and checks whether they have the custom properties - "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the \a callBackFunc - with both. - */ -bool UiGuiSettings::checkCustomPropertiesAndCallFunction(TQObject *obj, bool (UiGuiSettings::*callBackFunc)( - TQObject *obj, const TQString &propertyName, - const TQString &settingName)) -{ - bool success = true; - - // Find all widgets that have PropertyName and SettingName defined in their style sheet. - TQList allObjects = obj->findChildren(); - foreach(TQObject * object, allObjects) - { - TQString propertyName = object->property("connectedPropertyName").toString(); - TQString settingName = object->property("connectedSettingName").toString(); - - // If property and setting name were found, register that widget with the settings. - if (!propertyName.isEmpty() && !settingName.isEmpty()) - { - success &= (this->*callBackFunc)(object, propertyName, settingName); - } - } - - return success; -} - -/*! - \brief The with a certain property registered \a obj gets unregistered. - */ -void UiGuiSettings::unregisterObjectProperty(TQObject *obj) -{ - if (_registeredObjectProperties.contains(obj)) - { - const TQMetaObject *metaObject = obj->metaObject(); - TQString propertyName = _registeredObjectProperties[obj].first(); - TQString settingName = _registeredObjectProperties[obj].last(); - - bool connectSuccess = false; - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - - // Disconnect to the property's value changed signal. - if (mProp.hasNotifySignal()) - { - TQMetaMethod signal = mProp.notifySignal(); - // The command "SIGNAL() + TQString(signal.signature())" assembles the signal methods - // signature to a valid TQt SIGNAL. - connectSuccess = disconnect(obj, qPrintable(SIGNAL() + TQString( - signal.signature())), this, SLOT(handleObjectPropertyChange())); - } - } - _registeredObjectProperties.remove(obj); - } -} - -/*! - \brief Registers a slot form the \a obj by its \a slotName to be invoked, if the by \a settingName defined - setting changes. - - The registered slot may have no parameters or exactly one. If it accepts one parameter, whenever the setting - \a settingName changes the slot gets tried to be invoked with the settings value as parameter. This only works, - if the slot parameter is of the same type as the setting. - */ -bool UiGuiSettings::registerObjectSlot(TQObject *obj, const TQString &slotName, - const TQString &settingName) -{ - const TQMetaObject *metaObject = obj->metaObject(); - - bool connectSuccess = false; - // Connect to the objects destroyed signal, so that it will be correctly unregistered. - connectSuccess = - connect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); - - TQString normalizedSlotName = TQMetaObject::normalizedSignature(qPrintable(slotName)); - int indexOfMethod = metaObject->indexOfMethod(qPrintable(normalizedSlotName)); - if (connectSuccess && indexOfMethod > -1) - { - TQMetaMethod mMethod = metaObject->method(indexOfMethod); - //TQMetaMethod::Access access = mMethod.access(); - //TQMetaMethod::MethodType methType = mMethod.methodType(); - - // Since the method can at maximum be invoked with the setting value as argument, - // only methods taking max one argument are allowed. - if (mMethod.parameterTypes().size() <= 1) - { - _registeredObjectSlots.insert(obj, TQStringList() << normalizedSlotName << settingName); - } - else - { - //TODO: Write a debug warning to the log. - disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); - return false; - } - } - else - { - //TODO: Write a debug warning to the log. - disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); - return false; - } - - return true; -} - -/*! - \brief If \a obj, \a slotName and \a settingName are given, that certain connection is unregistered. - If only \a obj is given, all to this object registered slot-setting connections are unregistered. - */ -void UiGuiSettings::unregisterObjectSlot(TQObject *obj, const TQString &slotName, - const TQString &settingName) -{ - //const TQMetaObject *metaObject = obj->metaObject(); - TQString normalizedSlotName = TQMetaObject::normalizedSignature(qPrintable(slotName)); - TQMutableMapIterator it(_registeredObjectSlots); - while (it.hasNext()) - { - it.next(); - if (it.key() == obj && slotName.isEmpty() && settingName.isEmpty()) - { - it.remove(); - } - else if (it.key() == obj && it.value().first() == slotName && it.value().last() == settingName) - { - it.remove(); - } - } -} - -/*! - \brief This private slot gets invoked whenever a registered objects property changes - and distributes the new value to all other to the same settingName registered objects. - */ -void UiGuiSettings::handleObjectPropertyChange() -{ - TQObject *obj = TQObject::sender(); - TQString className = obj->metaObject()->className(); - const TQMetaObject *metaObject = obj->metaObject(); - TQString propertyName = _registeredObjectProperties[obj].first(); - TQString settingName = _registeredObjectProperties[obj].last(); - - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - setValueByName(settingName, mProp.read(obj)); - } -} - -/*! - \brief Sets the setting defined by \a settingName to \a value. - - When setting a changed value, all to this settingName registered objects get - the changed value set too. - If the \a settingName didn't exist yet, it will be created. - */ -void UiGuiSettings::setValueByName(const TQString &settingName, const TQVariant &value) -{ - // Do the updating only, if the setting was really changed. - if (_qsettings->value("UniversalIndentGUI/" + settingName) != value) - { - _qsettings->setValue("UniversalIndentGUI/" + settingName, value); - - // Set the new value for all registered object properties for settingName. - for (TQMap::ConstIterator it = _registeredObjectProperties.begin(); - it != _registeredObjectProperties.end(); ++it) - { - if (it.value().last() == settingName) - { - TQObject *obj = it.key(); - const TQMetaObject *metaObject = obj->metaObject(); - TQString propertyName = it.value().first(); - - int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); - if (indexOfProp > -1) - { - TQMetaProperty mProp = metaObject->property(indexOfProp); - mProp.write(obj, value); - } - } - } - - // Invoke all registered object methods for settingName. - for (TQMap::ConstIterator it = _registeredObjectSlots.begin(); - it != _registeredObjectSlots.end(); ++it) - { - if (it.value().last() == settingName) - { - TQObject *obj = it.key(); - const TQMetaObject *metaObject = obj->metaObject(); - TQString slotName = it.value().first(); - - int indexOfMethod = metaObject->indexOfMethod(qPrintable(slotName)); - if (indexOfMethod > -1) - { - TQMetaMethod mMethod = metaObject->method(indexOfMethod); - //TQMetaMethod::Access access = mMethod.access(); - //TQMetaMethod::MethodType methType = mMethod.methodType(); - - bool success = false; - - // Handle registered slots taking one parameter. - if (mMethod.parameterTypes().size() == 1) - { - if (mMethod.parameterTypes().first() == value.typeName()) - { - success = invokeMethodWithValue(obj, mMethod, value); - } - } - // Handle registered slots taking zero parameters. - else - { - success = mMethod.invoke(obj, TQt::DirectConnection); - } - - if (success == false) - { - // TODO: Write a warning to the log if no success. - } - } - } - } - } -} - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if TQT_VERSION >= 0x040600 - #include - #include -#endif - -bool UiGuiSettings::invokeMethodWithValue(TQObject *obj, TQMetaMethod mMethod, TQVariant value) -{ - switch (value.type()) - { - case TQVariant::BitArray: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBitArray, value.toBitArray())); - } - - case TQVariant::Bitmap: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBitmap, value.value())); - } - - case TQVariant::Bool: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(bool, value.toBool())); - } - - case TQVariant::Brush: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBrush, value.value())); - } - - case TQVariant::ByteArray: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQByteArray, value.toByteArray())); - } - - case TQVariant::Char: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQChar, value.toChar())); - } - - case TQVariant::Color: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQColor, value.value())); - } - - case TQVariant::Cursor: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQCursor, value.value())); - } - - case TQVariant::Date: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQDate, value.toDate())); - } - - case TQVariant::DateTime: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQDateTime, value.toDateTime())); - } - - case TQVariant::Double: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(double, value.toDouble())); - } - - case TQVariant::Font: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQFont, value.value())); - } - - case TQVariant::Hash: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantHash, value.toHash())); - } - - case TQVariant::Icon: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQIcon, value.value())); - } - - case TQVariant::Image: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQImage, value.value())); - } - - case TQVariant::Int: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(int, value.toInt())); - } - - case TQVariant::KeySequence: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQKeySequence, - value.value())); - } - - case TQVariant::Line: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLine, value.toLine())); - } - - case TQVariant::LineF: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLineF, value.toLineF())); - } - - case TQVariant::List: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantList, value.toList())); - } - - case TQVariant::Locale: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLocale, value.toLocale())); - } - - case TQVariant::LongLong: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(qlonglong, value.toLongLong())); - } - - case TQVariant::Map: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantMap, value.toMap())); - } - - case TQVariant::Matrix: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQMatrix, value.value())); - } - - case TQVariant::Transform: - { - return mMethod.invoke(obj, TQt::DirectConnection, - Q_ARG(TQTransform, value.value())); - } - -#if TQT_VERSION >= 0x040600 - case TQVariant::Matrix4x4: - { - return mMethod.invoke(obj, TQt::DirectConnection, - Q_ARG(TQMatrix4x4, value.value())); - } - -#endif - case TQVariant::Palette: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPalette, value.value())); - } - - case TQVariant::Pen: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPen, value.value())); - } - - case TQVariant::Pixmap: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPixmap, value.value())); - } - - case TQVariant::Point: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPoint, value.toPoint())); - } - - // case TQVariant::PointArray : - // return Q_ARG(TQPointArray, value.value()) ); - case TQVariant::PointF: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPointF, value.toPointF())); - } - - case TQVariant::Polygon: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPolygon, value.value())); - } - -#if TQT_VERSION >= 0x040600 - case TQVariant::Quaternion: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQQuaternion, - value.value())); - } - -#endif - case TQVariant::Rect: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRect, value.toRect())); - } - - case TQVariant::RectF: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRectF, value.toRectF())); - } - - case TQVariant::RegExp: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRegExp, value.toRegExp())); - } - - case TQVariant::Region: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRegion, value.value())); - } - - case TQVariant::Size: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSize, value.toSize())); - } - - case TQVariant::SizeF: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSizeF, value.toSizeF())); - } - - case TQVariant::SizePolicy: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSizePolicy, - value.value())); - } - - case TQVariant::String: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQString, value.toString())); - } - - case TQVariant::StringList: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQStringList, value.toStringList())); - } - - case TQVariant::TextFormat: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTextFormat, - value.value())); - } - - case TQVariant::TextLength: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTextLength, - value.value())); - } - - case TQVariant::Time: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTime, value.toTime())); - } - - case TQVariant::UInt: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(uint, value.toUInt())); - } - - case TQVariant::ULongLong: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(qulonglong, value.toULongLong())); - } - - case TQVariant::Url: - { - return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQUrl, value.toUrl())); - } - -#if TQT_VERSION >= 0x040600 - case TQVariant::Vector2D: - { - return mMethod.invoke(obj, TQt::DirectConnection, - Q_ARG(TQVector2D, value.value())); - } - - case TQVariant::Vector3D: - { - return mMethod.invoke(obj, TQt::DirectConnection, - Q_ARG(TQVector3D, value.value())); - } - - case TQVariant::Vector4D: - { - return mMethod.invoke(obj, TQt::DirectConnection, - Q_ARG(TQVector4D, value.value())); - } - -#endif - default: - { - return false; - } - } -} diff --git a/src/UiGuiSettings.h b/src/UiGuiSettings.h deleted file mode 100644 index 14376ad..0000000 --- a/src/UiGuiSettings.h +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#ifndef UIGUISETTINGS_H -#define UIGUISETTINGS_H - -#include -#include -#include -#include - -class TQSettings; - - -class UiGuiSettings : public TQObject -{ - Q_OBJECT - - private: - UiGuiSettings(); - - static TQWeakPointer _instance; - - public: - static TQSharedPointer getInstance(); - - ~UiGuiSettings(); - - bool registerObjectProperty(TQObject *obj, const TQString &propertyName, - const TQString &settingName); - bool registerObjectPropertyRecursive(TQObject *obj); - bool setObjectPropertyToSettingValue(TQObject *obj, const TQString &propertyName, - const TQString &settingName); - bool setObjectPropertyToSettingValueRecursive(TQObject *obj); - bool setSettingToObjectPropertyValue(TQObject *obj, const TQString &propertyName, - const TQString &settingName); - bool setSettingToObjectPropertyValueRecursive(TQObject *obj); - bool registerObjectSlot(TQObject *obj, const TQString &slotName, - const TQString &settingName); - TQVariant getValueByName(TQString settingName); - TQStringList getAvailableTranslations(); - - public slots: - void setValueByName(const TQString &settingName, const TQVariant &value); - void unregisterObjectProperty(TQObject *obj); - void unregisterObjectSlot(TQObject *obj, const TQString &slotName = "", - const TQString &settingName = ""); - - protected: - bool initSettings(); - bool invokeMethodWithValue(TQObject *obj, TQMetaMethod mMethod, TQVariant value); - - bool checkCustomPropertiesAndCallFunction(TQObject * obj, - bool (UiGuiSettings::*callBackFunc)(TQObject *obj, const TQString &propertyName, - const TQString &settingName)); - - private slots: - void handleObjectPropertyChange(); - - private: - void readAvailableTranslations(); - - //! Stores the mnemonics of the available translations. - TQStringList _availableTranslations; - - //! The settings file. - TQSettings *_qsettings; - - //! Maps an TQObject to a string list containing the property name and the associated setting - // name. - TQMap _registeredObjectProperties; - - //! Maps TQObjects to a string list containing the method name and the associated setting name. - TQMultiMap _registeredObjectSlots; - - TQString _indenterDirctoryStr; -}; - -#endif // UIGUISETTINGS_H diff --git a/src/UiGuiSettingsDialog.cpp b/src/UiGuiSettingsDialog.cpp deleted file mode 100644 index 8bfe0e5..0000000 --- a/src/UiGuiSettingsDialog.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#include "UiGuiSettingsDialog.h" -#include "ui_UiGuiSettingsDialog.h" - -#include "UiGuiSettings.h" - -/*! - \class UiGuiSettingsDialog - \ingroup grp_Settings - \brief Displays a dialog window with settings for UniversalIndentGUI -*/ - -/*! - \brief The constructor calls the setup function for the ui created by uic. -*/ -UiGuiSettingsDialog::UiGuiSettingsDialog(TQWidget *parent, - TQSharedPointer settings) : - TQDialog(parent) -{ - // Remember pointer to the UiGuiSettings object. - _settings = settings; - - // Init the user interface created by the UIC. - _settingsDialogForm = new Ui::SettingsDialog(); - _settingsDialogForm->setupUi(this); - - //TODO: This call has to be removed when the properties for the highlighters can be set - // with the settings dialog. - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( - "(Will be implemented soon)" + - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); - - // Connect the accepted signal to own function, to write values back to the UiGuiSettings object. - connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings())); - - // Init the language selection combobox. - initTranslationSelection(); -} - -/*! - \brief By calling this function the combobox for selecting the application language will - be initialized. - - Also the translation itself will be reinitialized. - */ -void UiGuiSettingsDialog::initTranslationSelection() -{ - // First empty the combo box. - _settingsDialogForm->languageSelectionComboBox->clear(); - - // Now add an entry into the box for every language short. - foreach(TQString languageShort, _settings->getAvailableTranslations()) - { - // Identify the language mnemonic and set the full name. - if (languageShort == "en") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("English")); - } - else if (languageShort == "fr") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("French")); - } - else if (languageShort == "de") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("German")); - } - else if (languageShort == "zh_TW") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Chinese (Taiwan)")); - } - else if (languageShort == "ja") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Japanese")); - } - else if (languageShort == "ru") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Russian")); - } - else if (languageShort == "uk") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Ukrainian")); - } - else - { - _settingsDialogForm->languageSelectionComboBox->addItem(tr( - "Unknown language mnemonic ") + languageShort); - } - } -} - -/*! - \brief Displays the dialog by calling the dialogs exec function. - - Before it gets all the values needed from the UiGuiSettings object. - */ -int UiGuiSettingsDialog::showDialog() -{ - // Init all settings dialog objects with values from settings. - _settings->setObjectPropertyToSettingValueRecursive(this); - - // Execute the dialog. - return exec(); -} - -/*! - \brief This slot is called when the dialog box is closed by pressing the Ok button. - - Writes all settings to the UiGuiSettings object. - */ -void UiGuiSettingsDialog::writeWidgetValuesToSettings() -{ - // Write settings dialog object values to settings. - _settings->setSettingToObjectPropertyValueRecursive(this); -} - -/*! - \brief Catches language change events and retranslates all needed widgets. - */ -void UiGuiSettingsDialog::changeEvent(TQEvent *event) -{ - if (event->type() == TQEvent::LanguageChange) - { - _settingsDialogForm->retranslateUi(this); - // If this is not explicit set here, TQt < 4.3.0 does not translate the buttons. - _settingsDialogForm->buttonBox->setStandardButtons( - TQDialogButtonBox::Cancel | TQDialogButtonBox::NoButton | TQDialogButtonBox::Ok); - - //TODO: This has to be removed when the properties for the highlighters can be set. - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( - "(Will be implemented soon)" + - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); - - TQStringList languageShortList = _settings->getAvailableTranslations(); - - // Now retranslate every entry in the language selection box. - for (int i = 0; i < languageShortList.size(); i++) - { - TQString languageShort = languageShortList.at(i); - - // Identify the language mnemonic and set the full name. - if (languageShort == "en") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("English")); - } - else if (languageShort == "fr") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("French")); - } - else if (languageShort == "de") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("German")); - } - else if (languageShort == "zh_TW") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Chinese (Taiwan)")); - } - else if (languageShort == "ja") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Japanese")); - } - else if (languageShort == "ru") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Russian")); - } - else if (languageShort == "uk") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Ukrainian")); - } - else - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, - tr("Unknown language mnemonic ") + languageShort); - } - } - } - else - { - TQWidget::changeEvent(event); - } -} diff --git a/src/UiGuiSettingsDialog.h b/src/UiGuiSettingsDialog.h deleted file mode 100644 index 8dc9543..0000000 --- a/src/UiGuiSettingsDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#ifndef UIGUISETTINGSDIALOG_H -#define UIGUISETTINGSDIALOG_H - -#include - -#include "UiGuiSettings.h" - -namespace Ui -{ - class SettingsDialog; -} - - -class UiGuiSettingsDialog : public TQDialog -{ - Q_OBJECT - - public: - UiGuiSettingsDialog(TQWidget *parent, TQSharedPointer settings); - - public slots: - int showDialog(); - - private slots: - void writeWidgetValuesToSettings(); - - private: - Ui::SettingsDialog *_settingsDialogForm; - - void changeEvent(TQEvent *event); - void initTranslationSelection(); - - TQSharedPointer _settings; -}; - -#endif // UIGUISETTINGSDIALOG_H diff --git a/src/UiGuiSettingsDialog.ui b/src/UiGuiSettingsDialog.ui deleted file mode 100755 index 2f96561..0000000 --- a/src/UiGuiSettingsDialog.ui +++ /dev/null @@ -1,625 +0,0 @@ - - - SettingsDialog - - - TQt::ApplicationModal - - - - 0 - 0 - 503 - 336 - - - - Settings - - - - :/mainWindow/preferences-system.png:/mainWindow/preferences-system.png - - - - - - 0 - - - - - :/settingsDialog/applications-system.png:/settingsDialog/applications-system.png - - - Common - - - - - - - - Displays all available translations for UniversalIndentGui and lets you choose one. - - - Application language - - - languageSelectionComboBox - - - - - - - - 0 - 0 - - - - Displays all available translations for UniversalIndentGui and lets you choose one. - - - language - - - currentIndex - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - If selected opens the source code file on startup that was opened last time. - - - Automatically open last file on startup - - - loadLastSourceCodeFileOnStartup - - - checked - - - - - - - If checked, tool tips will show up if the mouse cursor remains over an indenter parameter for a while. - - - Enable Parameter Tooltips - - - indenterParameterTooltipsEnabled - - - checked - - - - - - - - - Sets how many files should be remembered in the list of recently opened files. - - - Number of files in recently opened list - - - - - - - - 0 - 0 - - - - Sets how many files should be remembered in the list of recently opened files. - - - 1 - - - 30 - - - 1 - - - recentlyOpenedListSize - - - value - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - :/settingsDialog/accessories-text-editor.png:/settingsDialog/accessories-text-editor.png - - - Editor - - - - - - Enables or disables displaying of white space characters in the editor. - - - Display white space character (tabs, spaces, etc.) - - - whiteSpaceIsVisible - - - checked - - - - - - - - - Sets width in single spaces used for tabs - - - Defines how many spaces should be displayed in the editor for one tab. - - - Displayed width of tabs - - - - - - - - 0 - 0 - - - - Defines how many spaces should be displayed in the editor for one tab character. - - - 1 - - - 99 - - - 1 - - - tabWidth - - - value - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - :/mainWindow/system-software-update.png:/mainWindow/system-software-update.png - - - Network - - - - - - Checks whether a new version of UniversalIndentGUI exists on program start, but only once a day. - - - Check online for update on program start - - - CheckForUpdate - - - checked - - - - - - - - - - - - - If checked, the made proxy settings will be applied for all network connections. Type of the used proxy is SOCKS5. - - - Enable proxy - - - ProxyEnabled - - - checked - - - - - - - false - - - - - - Host name: - - - proxyHostNameLineEdit - - - - - - - Host name of the to be used proxy. E.g.: proxy.example.com - - - ProxyHostName - - - text - - - - - - - Port: - - - proxyPortSpinBox - - - - - - - Port number to connect to the before named proxy. - - - TQt::AlignRight|TQt::AlignTrailing|TQt::AlignVCenter - - - TQAbstractSpinBox::NoButtons - - - 99999 - - - ProxyPort - - - text - - - - - - - User name: - - - proxyUserNameLineEdit - - - - - - - If the proxy needs authentification, enter the login name here. - - - ProxyUserName - - - text - - - - - - - Password: - - - proxyPasswordLineEdit - - - - - - - If the proxy needs authentification, enter the password here. - - - TQLineEdit::Password - - - ProxyPassword - - - text - - - - - - - - - - - - - - - :/settingsDialog/syntax-highlight.png:/settingsDialog/syntax-highlight.png - - - Syntax Highlighting - - - - - - By enabling special key words of the source code are highlighted. - - - Enable syntax highlighting - - - SyntaxHighlightingEnabled - - - checked - - - - - - - false - - - Lets you make settings for all properties of the available syntax highlighters, like font and color. - - - Highlighter settings - - - - - - -1 - - - - - - - -1 - - - - - - - - - Set the font for the current selected highlighter property. - - - Set Font - - - - - - - Set the color for the current selected highlighter property. - - - Set Color - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - - - TQt::Horizontal - - - TQDialogButtonBox::Cancel|TQDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - SettingsDialog - accept() - - - 250 - 316 - - - 153 - 236 - - - - - buttonBox - rejected() - SettingsDialog - reject() - - - 327 - 316 - - - 282 - 236 - - - - - enableProxyCheckBox - toggled(bool) - widget - setEnabled(bool) - - - 73 - 68 - - - 76 - 95 - - - - - diff --git a/src/UiGuiSystemInfo.cpp b/src/UiGuiSystemInfo.cpp deleted file mode 100644 index 5456519..0000000 --- a/src/UiGuiSystemInfo.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiSystemInfo.h" - -#include -#include -#include -#include - -UiGuiSystemInfo::UiGuiSystemInfo() -{ -} - -/*! - \brief Returns the operating system UiGUI is currently running on as one string. - - The String contains name and version of the os. E.g. Linux Ubuntu 9.04. - */ -TQString UiGuiSystemInfo::getOperatingSystem() -{ - TQString operatingSystemString = ""; - -#if defined (Q_WS_WIN) - switch (TQSysInfo::WindowsVersion) - { - case TQSysInfo::WV_32s: - { - operatingSystemString = "Windows 3.1 with Win 32s"; - break; - } - - case TQSysInfo::WV_95: - { - operatingSystemString = "Windows 95"; - break; - } - - case TQSysInfo::WV_98: - { - operatingSystemString = "Windows 98"; - break; - } - - case TQSysInfo::WV_Me: - { - operatingSystemString = "Windows Me"; - break; - } - - case TQSysInfo::WV_NT: - { - operatingSystemString = "Windows NT (operating system version 4.0)"; - break; - } - - case TQSysInfo::WV_2000: - { - operatingSystemString = "Windows 2000 (operating system version 5.0)"; - break; - } - - case TQSysInfo::WV_XP: - { - operatingSystemString = "Windows XP (operating system version 5.1)"; - break; - } - - case TQSysInfo::WV_2003: - { - operatingSystemString = - "Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)"; - break; - } - - case TQSysInfo::WV_VISTA: - { - operatingSystemString = "Windows Vista, Windows Server 2008 (operating system version 6.0)"; - break; - } - - case TQSysInfo::WV_WINDOWS7: - { - operatingSystemString = "Windows 7 (operating system version 6.1)"; - break; - } - - case TQSysInfo::WV_CE: - { - operatingSystemString = "Windows CE"; - break; - } - - case TQSysInfo::WV_CENET: - { - operatingSystemString = "Windows CE .NET"; - break; - } - - case TQSysInfo::WV_CE_5: - { - operatingSystemString = "Windows CE 5.x"; - break; - } - - case TQSysInfo::WV_CE_6: - { - operatingSystemString = "Windows CE 6.x"; - break; - } - - default: - { - operatingSystemString = "Unknown Windows operating system."; - break; - } - } -#elif defined (Q_WS_MAC) - switch (TQSysInfo::MacintoshVersion) - { - case TQSysInfo::MV_9: - { - operatingSystemString = "Mac OS 9 (unsupported)"; - break; - } - - case TQSysInfo::MV_10_0: - { - operatingSystemString = "Mac OS X 10.0 Cheetah (unsupported)"; - break; - } - - case TQSysInfo::MV_10_1: - { - operatingSystemString = "Mac OS X 10.1 Puma (unsupported)"; - break; - } - - case TQSysInfo::MV_10_2: - { - operatingSystemString = "Mac OS X 10.2 Jaguar (unsupported)"; - break; - } - - case TQSysInfo::MV_10_3: - { - operatingSystemString = "Mac OS X 10.3 Panther"; - break; - } - - case TQSysInfo::MV_10_4: - { - operatingSystemString = "Mac OS X 10.4 Tiger"; - break; - } - - case TQSysInfo::MV_10_5: - { - operatingSystemString = "Mac OS X 10.5 Leopard"; - break; - } - - case TQSysInfo::MV_10_6: - { - operatingSystemString = "Mac OS X 10.6 Snow Leopard"; - break; - } - - case TQSysInfo::MV_Unknown: - { - operatingSystemString = "An unknown and currently unsupported platform"; - break; - } - - default: - { - operatingSystemString = "Unknown Mac operating system."; - break; - } - } -#else - //TODO: Detect Unix, Linux etc. distro as described on - // http://www.novell.com/coolsolutions/feature/11251.html - operatingSystemString = "Linux"; - TQProcess process; - - process.start("uname -s"); - bool result = process.waitForFinished(1000); - TQString os = process.readAllStandardOutput().trimmed(); - - process.start("uname -r"); - result = process.waitForFinished(1000); - TQString rev = process.readAllStandardOutput().trimmed(); - - process.start("uname -m"); - result = process.waitForFinished(1000); - TQString mach = process.readAllStandardOutput().trimmed(); - - if (os == "SunOS") - { - os = "Solaris"; - - process.start("uname -p"); - result = process.waitForFinished(1000); - TQString arch = process.readAllStandardOutput().trimmed(); - - process.start("uname -v"); - result = process.waitForFinished(1000); - TQString timestamp = process.readAllStandardOutput().trimmed(); - - operatingSystemString = os + " " + rev + " (" + arch + " " + timestamp + ")"; - } - else if (os == "AIX") - { - process.start("oslevel -r"); - result = process.waitForFinished(1000); - TQString oslevel = process.readAllStandardOutput().trimmed(); - - operatingSystemString = os + "oslevel " + oslevel; - } - else if (os == "Linux") - { - TQString dist; - TQString pseudoname; - TQString kernel = rev; - - if (TQFile::exists("/etc/redhat-release")) - { - dist = "RedHat"; - - process.start("sh -c \"cat /etc/redhat-release | sed s/.*\\(// | sed s/\\)//\""); - result = process.waitForFinished(1000); - pseudoname = process.readAllStandardOutput().trimmed(); - - process.start("sh -c \"cat /etc/redhat-release | sed s/.*release\\ // | sed s/\\ .*//\""); - result = process.waitForFinished(1000); - rev = process.readAllStandardOutput().trimmed(); - } - else if (TQFile::exists("/etc/SUSE-release")) - { - process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' '| sed s/VERSION.*//\""); - result = process.waitForFinished(1000); - dist = process.readAllStandardOutput().trimmed(); - - process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' ' | sed s/.*=\\ //\""); - result = process.waitForFinished(1000); - rev = process.readAllStandardOutput().trimmed(); - } - else if (TQFile::exists("/etc/mandrake-release")) - { - dist = "Mandrake"; - - process.start("sh -c \"cat /etc/mandrake-release | sed s/.*\\(// | sed s/\\)//\""); - result = process.waitForFinished(1000); - pseudoname = process.readAllStandardOutput().trimmed(); - - process.start("sh -c \"cat /etc/mandrake-release | sed s/.*release\\ // | sed s/\\ .*//\""); - result = process.waitForFinished(1000); - rev = process.readAllStandardOutput().trimmed(); - } - else if (TQFile::exists("/etc/lsb-release")) - { - dist = "Ubuntu"; - - TQString processCall = - "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_RELEASE=// | sed s/\\ .*//\""; - process.start(processCall); - result = process.waitForFinished(1000); - rev = process.readAllStandardOutput().trimmed(); - TQString errorStr = process.readAllStandardError(); - - process.start( - "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_CODENAME=// | sed s/\\ .*//\""); - result = process.waitForFinished(1000); - pseudoname = process.readAllStandardOutput().trimmed(); - } - else if (TQFile::exists("/etc/debian_version")) - { - dist = "Debian"; - - process.start("cat /etc/debian_version"); - result = process.waitForFinished(1000); - dist += process.readAllStandardOutput().trimmed(); - - rev = ""; - } - - if (TQFile::exists("/etc/UnitedLinux-release")) - { - process.start("sh -c \"cat /etc/UnitedLinux-release | tr '\\n' ' ' | sed s/VERSION.*//\""); - result = process.waitForFinished(1000); - dist += process.readAllStandardOutput().trimmed(); - } - - operatingSystemString = os + " " + dist + " " + rev + " (" + pseudoname + " " + kernel + " " + - mach + ")"; - } -#endif - - return operatingSystemString; -} diff --git a/src/UiGuiSystemInfo.h b/src/UiGuiSystemInfo.h deleted file mode 100644 index 4d6405d..0000000 --- a/src/UiGuiSystemInfo.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUISYSTEMINFO_H -#define UIGUISYSTEMINFO_H - -class TQString; - - -class UiGuiSystemInfo -{ - public: - static TQString getOperatingSystem(); - - private: - UiGuiSystemInfo(); -}; - -#endif // UIGUISYSTEMINFO_H diff --git a/src/UpdateCheckDialog.cpp b/src/UpdateCheckDialog.cpp deleted file mode 100644 index 5c9b1e3..0000000 --- a/src/UpdateCheckDialog.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UpdateCheckDialog.h" -#include "ui_UpdateCheckDialog.h" - -#include "UiGuiSettings.h" -#include "UiGuiVersion.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*! - \class UpdateCheckDialog - \ingroup grp_MainWindow - \brief UpdateCheckDialog is a dialog widget that contains functions - for online checking for a new version of UniversalIndentGUI. -*/ - -/*! - \brief Initializes member variables and stores the version of UiGui and a pointer to the _settings object. - */ -UpdateCheckDialog::UpdateCheckDialog(TQSharedPointer settings, TQWidget *parent) : - TQDialog(parent), _manualUpdateRequested(false), _currentNetworkReply(NULL), - _roleOfClickedButton(TQDialogButtonBox::InvalidRole) -{ - _updateCheckDialogForm = new Ui::UpdateCheckDialog(); - _updateCheckDialogForm->setupUi(this); - - // Create object for _networkAccessManager request and connect it with the request return handler. - _networkAccessManager = new TQNetworkAccessManager(this); - connect(_networkAccessManager, SIGNAL(finished(TQNetworkReply*)), this, - SLOT(checkResultsOfFetchedPadXMLFile(TQNetworkReply*))); - - // Create a timer object used for the progress bar. - _updateCheckProgressTimer = new TQTimer(this); - _updateCheckProgressTimer->setInterval(5); - connect(_updateCheckProgressTimer, SIGNAL(timeout()), this, SLOT(updateUpdateCheckProgressBar())); - _updateCheckProgressCounter = 0; - - // Connect the dialogs buttonbox with a button click handler. - connect(_updateCheckDialogForm->buttonBox, SIGNAL(clicked(TQAbstractButton*)), this, - SLOT(handleUpdateCheckDialogButtonClicked(TQAbstractButton*))); - - settings->registerObjectSlot(this, "initProxySettings()", "ProxyEnabled"); - settings->registerObjectSlot(this, "initProxySettings()", "ProxyHostName"); - settings->registerObjectSlot(this, "initProxySettings()", "ProxyPort"); - settings->registerObjectSlot(this, "initProxySettings()", "ProxyUserName"); - settings->registerObjectSlot(this, "initProxySettings()", "ProxyPassword"); - - _settings = settings; - - initProxySettings(); - - // This dialog is always modal. - setModal(true); -} - -/*! - \brief On destroy cancels any currently running network request. - */ -UpdateCheckDialog::~UpdateCheckDialog() -{ - disconnect(_networkAccessManager, SIGNAL(finished(TQNetworkReply*)), this, - SLOT(checkResultsOfFetchedPadXMLFile(TQNetworkReply*))); - if (_currentNetworkReply != NULL) - { - _currentNetworkReply->abort(); - } -} - -/*! - \brief This slot should be called, if an update check is manually invoked. - - In difference to the automatic update check, during manual update check request - a modal progress indicator dialog will be shown. - */ -void UpdateCheckDialog::checkForUpdateAndShowDialog() -{ - _manualUpdateRequested = true; - getPadXMLFile(); - showCheckingForUpdateDialog(); -} - -/*! - \brief This slot should be called, if an update check is automatically invoked. - - An automatic invoked update check should run in background, so the user - gets not interrupted by a dialog box. - */ -void UpdateCheckDialog::checkForUpdate() -{ - _manualUpdateRequested = false; - getPadXMLFile(); -} - -/*! - \brief This function tries to download the UniversalIndentGui pad file from the SourceForge server. - */ -void UpdateCheckDialog::getPadXMLFile() -{ - //_networkAccessManager->setHost("universalindent.sourceforge.net"); - //_networkAccessManager->get("/universalindentgui_pad.xml"); - _currentNetworkReply = _networkAccessManager->get(TQNetworkRequest(TQUrl( - "http://universalindent.sourceforge.net/universalindentgui_pad.xml"))); -} - -/*! - \brief This slot is called after the update check has returned, either by successfully - retrieving the pad file, or on any kind of network error. - - Shows a message if check was successful or not. Offers the user to go to the - download page if a newer version exists. In case of an error during update - check, a message box with the error will be displayed. - */ -void UpdateCheckDialog::checkResultsOfFetchedPadXMLFile(TQNetworkReply *networkReply) -{ - Q_ASSERT(_currentNetworkReply == networkReply); - - // Stop the progress bar timer. - _updateCheckProgressTimer->stop(); - - if (networkReply->error() == TQNetworkReply::NoError) - { - // Try to find the version string. - TQString returnedString = networkReply->readAll(); - int leftPosition = returnedString.indexOf(""); - int rightPosition = returnedString.indexOf(""); - - // If the version string could be found in the returned string, show an update dialog and set - // last update check date. - if (leftPosition != -1 && rightPosition != -1) - { - // Get the pure version string from returned string. - returnedString = returnedString.mid(leftPosition + 17, rightPosition - (leftPosition + 17)); - - // Create integer values from the version strings. - int versionOnServerInt = convertVersionStringToNumber(returnedString); - int currentVersionInt = convertVersionStringToNumber(PROGRAM_VERSION_STRING); - - // Only show update dialog, if the current version number is lower than the one received from - // the server. - if (versionOnServerInt > currentVersionInt && currentVersionInt >= 0 && - versionOnServerInt >= 0) - { - // Show message box whether to download the new version. - showNewVersionAvailableDialog(returnedString); - - // If yes clicked, open the download url in the default browser. - if (_roleOfClickedButton == TQDialogButtonBox::YesRole) - { - TQDesktopServices::openUrl(TQUrl( - "_networkAccessManager://sourceforge.net/project/showfiles.php?group_id=167482")); - } - } - else if (_manualUpdateRequested) - { - showNoNewVersionAvailableDialog(); - } - // Set last update check date. - _settings->setValueByName("LastUpdateCheck", TQDate::currentDate()); - } - // In the returned string, the version string could not be found. - else - { - TQMessageBox::warning(this, tr("Update check error"), tr( - "There was an error while trying to check for an update! The retrieved file did not contain expected content.")); - } - } - // If there was some error while trying to retrieve the update info from server and not cancel was - // pressed. - else if (_roleOfClickedButton != TQDialogButtonBox::RejectRole) - { - TQMessageBox::warning(this, tr("Update check error"), - tr("There was an error while trying to check for an update! Error was : %1").arg( - networkReply->errorString())); - hide(); - } - _manualUpdateRequested = false; - networkReply->deleteLater(); - _currentNetworkReply = NULL; -} - -/*! - \brief Displays the progress bar during update check. - - For displaying activity during update check, a timer is started to - updated the progress bar. The user can press a cancel button to - stop the update check. - */ -void UpdateCheckDialog::showCheckingForUpdateDialog() -{ - // Reset the progress bar. - _updateCheckProgressCounter = 0; - _updateCheckDialogForm->progressBar->setValue(_updateCheckProgressCounter); - _updateCheckDialogForm->progressBar->setInvertedAppearance(false); - - _updateCheckProgressTimer->start(); - _updateCheckDialogForm->progressBar->show(); - setWindowTitle(tr("Checking for update...")); - _updateCheckDialogForm->label->setText(tr("Checking whether a newer version is available")); - _updateCheckDialogForm->buttonBox->setStandardButtons(TQDialogButtonBox::Cancel); - show(); -} - -/*! - \brief Displays the dialog with info about the new available version. - */ -void UpdateCheckDialog::showNewVersionAvailableDialog(TQString newVersion) -{ - _updateCheckDialogForm->progressBar->hide(); - setWindowTitle(tr("Update available")); - _updateCheckDialogForm->label->setText(tr( - "A newer version of UniversalIndentGUI is available.\nYour version is %1. New version is %2.\nDo you want to go to the download website?").arg( - PROGRAM_VERSION_STRING).arg(newVersion)); - _updateCheckDialogForm->buttonBox->setStandardButtons( - TQDialogButtonBox::No | TQDialogButtonBox::NoButton | TQDialogButtonBox::Yes); - exec(); -} - -/*! - \brief Displays the dialog, that no new version is available. - */ -void UpdateCheckDialog::showNoNewVersionAvailableDialog() -{ - _updateCheckDialogForm->progressBar->hide(); - setWindowTitle(tr("No new update available")); - _updateCheckDialogForm->label->setText(tr( - "You already have the latest version of UniversalIndentGUI.")); - _updateCheckDialogForm->buttonBox->setStandardButtons(TQDialogButtonBox::Ok); - exec(); -} - -/*! - \brief This slot is called, when a button in the dialog is clicked. - - If the clicked button was the cancel button, the user wants to cancel - the update check. So the _networkAccessManager request is aborted and the timer for the - progress bar animation is stopped. - - In any case if a button is clicked, the dialog box will be closed. - */ -void UpdateCheckDialog::handleUpdateCheckDialogButtonClicked(TQAbstractButton *clickedButton) -{ - _roleOfClickedButton = _updateCheckDialogForm->buttonBox->buttonRole(clickedButton); - - if (_roleOfClickedButton == TQDialogButtonBox::RejectRole) - { - // Abort the _networkAccessManager request. - _currentNetworkReply->abort(); - // Stop the progress bar timer. - _updateCheckProgressTimer->stop(); - } - - accept(); -} - -/*! - \brief This slot is responsible for the animation of the update check progress bar. - */ -void UpdateCheckDialog::updateUpdateCheckProgressBar() -{ - // Depending on the progress bar direction, decrease or increase the progressbar value. - if (_updateCheckDialogForm->progressBar->invertedAppearance()) - { - _updateCheckProgressCounter--; - } - else - { - _updateCheckProgressCounter++; - } - - // If the progress bar reaches 0 or 100 as value, swap the animation direction. - if (_updateCheckProgressCounter == 0 || _updateCheckProgressCounter == 100) - { - _updateCheckDialogForm->progressBar->setInvertedAppearance( - !_updateCheckDialogForm->progressBar->invertedAppearance()); - } - - // Update the progress bar value. - _updateCheckDialogForm->progressBar->setValue(_updateCheckProgressCounter); -} - -/*! - \brief Converts the as string given version \a versionString to an integer number. - - The \a versionString must have the format x.x.x where each x represents a number - of a maximum of 999. If the input format is wrong, -1 will be returned.The first - number will be multiplied by 1000000 the second by 1000 and then all three will - be summarized. - - Thus for example 12.5.170 will result in 12005170. - */ -int UpdateCheckDialog::convertVersionStringToNumber(TQString versionString) -{ - int versionInteger = 0; - int pos = 0; - - TQRegExp regEx("\\d{1,3}.\\d{1,3}.\\d{1,3}"); - TQRegExpValidator validator(regEx, NULL); - - if (validator.validate(versionString, pos) == TQValidator::Acceptable) - { - TQStringList versionNumberStringList = versionString.split("."); - versionInteger = versionNumberStringList.at(0).toInt() * 1000000; - versionInteger += versionNumberStringList.at(1).toInt() * 1000; - versionInteger += versionNumberStringList.at(2).toInt(); - } - else - { - versionInteger = -1; - } - - return versionInteger; -} - -void UpdateCheckDialog::initProxySettings() -{ - if (_settings->getValueByName("ProxyEnabled") == true) - { - TQString proxyHostName = _settings->getValueByName("ProxyHostName").toString(); - int proxyPort = _settings->getValueByName("ProxyPort").toInt(); - TQString proxyUserName = _settings->getValueByName("ProxyUserName").toString(); - TQString proxyPassword = _settings->getValueByName("ProxyPassword").toString(); - _networkAccessManager->setProxy(TQNetworkProxy(TQNetworkProxy::Socks5Proxy, proxyHostName, - proxyPort, proxyUserName, proxyPassword)); - } - else - { - _networkAccessManager->setProxy(TQNetworkProxy()); - } -} diff --git a/src/UpdateCheckDialog.h b/src/UpdateCheckDialog.h deleted file mode 100644 index 6f1116b..0000000 --- a/src/UpdateCheckDialog.h +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UPDATECHECKDIALOG_H -#define UPDATECHECKDIALOG_H - -#include -#include - -class UiGuiSettings; -namespace Ui -{ - class UpdateCheckDialog; -} - -class TQTimer; -class TQDesktopServices; -class TQNetworkAccessManager; -class TQNetworkReply; - - -class UpdateCheckDialog : public TQDialog -{ - Q_OBJECT - - public: - UpdateCheckDialog(TQSharedPointer settings, TQWidget *parent = NULL); - ~UpdateCheckDialog(); - - public slots: - void checkForUpdateAndShowDialog(); - void checkForUpdate(); - - private slots: - void checkResultsOfFetchedPadXMLFile(TQNetworkReply *networkReply); - void handleUpdateCheckDialogButtonClicked(TQAbstractButton *clickedButton); - void updateUpdateCheckProgressBar(); - void initProxySettings(); - - private: - Ui::UpdateCheckDialog *_updateCheckDialogForm; - - void getPadXMLFile(); - void showCheckingForUpdateDialog(); - void showNewVersionAvailableDialog(TQString newVersion); - void showNoNewVersionAvailableDialog(); - int convertVersionStringToNumber(TQString versionString); - - TQSharedPointer _settings; - bool _manualUpdateRequested; - TQNetworkAccessManager *_networkAccessManager; - TQNetworkReply *_currentNetworkReply; - TQDialogButtonBox::ButtonRole _roleOfClickedButton; - TQTimer *_updateCheckProgressTimer; - int _updateCheckProgressCounter; -}; - -#endif // UPDATECHECKDIALOG_H diff --git a/src/UpdateCheckDialog.ui b/src/UpdateCheckDialog.ui deleted file mode 100755 index ebfc8bb..0000000 --- a/src/UpdateCheckDialog.ui +++ /dev/null @@ -1,51 +0,0 @@ - - - UpdateCheckDialog - - - TQt::WindowModal - - - - 0 - 0 - 323 - 108 - - - - Checking for update... - - - - - - Checking whether a newer version is available - - - - - - - 0 - - - false - - - - - - - TQDialogButtonBox::Cancel - - - true - - - - - - - - diff --git a/src/__TODO/AboutDialog.cpp b/src/__TODO/AboutDialog.cpp new file mode 100644 index 0000000..3cbdf4f --- /dev/null +++ b/src/__TODO/AboutDialog.cpp @@ -0,0 +1,169 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "AboutDialog.h" +#include "ui_AboutDialog.h" + +#include "UiGuiVersion.h" + +#include +#include +#include +#include +#include + +/*! + \class AboutDialog + \brief Displays a dialog window with information about UniversalIndentGUI +*/ + +/*! + \brief The constructor calls the setup function for the ui created by uic and adds + the GPL text to the text edit. + */ +AboutDialog::AboutDialog(TQWidget *parent, TQt::WindowFlags flags) : + TQDialog(parent, flags), _dialogForm(NULL), _timer(NULL) +{ + _dialogForm = new Ui::AboutDialog(); + _dialogForm->setupUi(this); + + _dialogForm->authorTextBrowser->setOpenExternalLinks(true); + _dialogForm->creditsTextBrowser->setOpenExternalLinks(true); + + TQString versionString = _dialogForm->versionTextBrowser->toHtml(); + versionString = + versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( + UiGuiVersion::getBuildDate()); + _dialogForm->versionTextBrowser->setHtml(versionString); + + _dialogForm->creditsTextBrowser->setHtml("" + "
 
" + "

Thanks go out to

" + "

Nelson Tai for Chinese translation, good ideas and always fast answers.


" + "

Sebastian Pipping for helping me bring UiGUI into the Debian repository and other good ideas.


" + "

Oleksandr for Ukrainian and Russian translation.


" + "

Erwan "leg" for French translation and the icon logo.


" + "

The Scintilla project for their great text editing component.


" + "

Riverbank for their Scintilla TQt wrapper TQScintilla.


" + "

The Artistic Style project.


" + "

The BCPP project.


" + "

The Cobol Beautifier project.


" + "

The CSSTidy project.


" + "

The Fortran 90 PPR project.


" + "

The GNU Indent project.


" + "

The GreatCode project.


" + "

The hindent project.


" + "

The HTB project.


" + "

The HTML Tidy project.


" + "

The JsDecoder project.


" + "

The JSPPP project.


" + "

The Perltidy project.


" + "

The PHP_Beautifier project.


" + "

The phpCB project.


" + "

The PHP Stylist project.


" + "

The pindent project.


" + "

The Pl/Sql tidy project.


" + "

The Ruby Beautifier project.


" + "

The Ruby Formatter project.


" + "

The Shell Indent project.


" + "

The Uncrustify project, specially Ben Gardner.


" + "

The VBSBeautifier project.


" + "

The XML Indent project.


" + "

Nirvash for the initial Japanese translation.


" + "

The Tango Project for their icons.


" + "

famfamfam for the flag icons.


" + "

Trolltech for their really great GUI framework .


" + "

My girlfriend (meanwhile also wife) for putting my head right and not sit all the time in front of my computer ;-)

" + ""); + + _scrollDirection = 1; + _scrollSpeed = 100; + _timer = new TQTimer(this); + connect(_timer, SIGNAL(timeout()), this, SLOT(scroll())); + connect(this, SIGNAL(accepted()), _timer, SLOT(stop())); +} + +/*! + \brief Catches language change events and retranslates all needed widgets. + */ +void AboutDialog::changeEvent(TQEvent *event) +{ + if (event->type() == TQEvent::LanguageChange) + { + _dialogForm->retranslateUi(this); + + TQString versionString = _dialogForm->versionTextBrowser->toHtml(); + versionString = + versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg( + UiGuiVersion::getBuildDate()); + _dialogForm->versionTextBrowser->setHtml(versionString); + } + else + { + TQWidget::changeEvent(event); + } +} + +/*! + \brief Reimplements the dialog execution function to init the credits scroller. + */ +int AboutDialog::exec() +{ + //creditsTextBrowser->verticalScrollBar()->setValue(0); + _timer->start(_scrollSpeed); + return TQDialog::exec(); +} + +/*! + \brief This slot is called each _timer timeout to scroll the credits textbrowser. + Also changes the scroll direction and speed when reaching the start or end. + */ +void AboutDialog::scroll() +{ + TQScrollBar *scrollBar = _dialogForm->creditsTextBrowser->verticalScrollBar(); + scrollBar->setValue(scrollBar->value() + _scrollDirection); + + if (scrollBar->value() == scrollBar->maximum()) + { + // Toggle scroll direction and change scroll speed; + _scrollDirection = -1; + _scrollSpeed = 5; + _timer->stop(); + _timer->start(_scrollSpeed); + } + else if (scrollBar->value() == scrollBar->minimum()) + { + // Toggle scroll direction and change scroll speed; + _scrollDirection = 1; + _scrollSpeed = 100; + _timer->stop(); + _timer->start(_scrollSpeed); + } + + _dialogForm->creditsTextBrowser->update(); +} + +/*! + \brief Shows the about dialog and also starts the credits scroller. + */ +void AboutDialog::show() +{ + _timer->start(_scrollSpeed); + TQDialog::show(); +} diff --git a/src/__TODO/AboutDialog.h b/src/__TODO/AboutDialog.h new file mode 100644 index 0000000..c849f7b --- /dev/null +++ b/src/__TODO/AboutDialog.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui +{ + class AboutDialog; +} + + +class AboutDialog : public TQDialog +{ + Q_OBJECT + + public: + AboutDialog(TQWidget *parent = NULL, TQt::WindowFlags flags = 0); + + public slots: + int exec(); + void show(); + + private slots: + void scroll(); + + private: + void changeEvent(TQEvent *event); + + Ui::AboutDialog *_dialogForm; + int _scrollDirection; + int _scrollSpeed; + TQTimer *_timer; +}; + +#endif // ABOUTDIALOG_H diff --git a/src/__TODO/AboutDialog.ui b/src/__TODO/AboutDialog.ui new file mode 100755 index 0000000..dbc2b8c --- /dev/null +++ b/src/__TODO/AboutDialog.ui @@ -0,0 +1,218 @@ + + + AboutDialog + + + + 0 + 0 + 588 + 512 + + + + + 0 + 0 + + + + + 588 + 333 + + + + About UniversalIndentGUI + + + + :/mainWindow/info.png:/mainWindow/info.png + + + + 0 + + + + + TQFrame#frame { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #FFFF60, stop:0.5 #D8C304, stop:1 #FFFF60 ); border: 2px solid #A89C57; border-radius: 4px;} + + + TQFrame::StyledPanel + + + + + + + 0 + 0 + + + + + 570 + 87 + + + + + 570 + 87 + + + + + + + :/aboutDialog/banner.png + + + + + + + + 0 + 0 + + + + + 16777215 + 25 + + + + TQTextBrowser{background-color:transparent} + + + TQFrame::NoFrame + + + TQt::ScrollBarAlwaysOff + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'sans-serif'; font-size:large;">Version %1 rev.%2, %3</span></p></body></html> + + + + + + + + 0 + 0 + + + + false + + + TQTextBrowser{background-color:transparent} + + + TQFrame::NoFrame + + + TQt::ScrollBarAlwaysOff + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">... is a cross platform compatible GUI for several code formatter, beautifier and indenter like GreatCode, AStyle (Artistic Styler), GNU Indent, BCPP and so on. Main feature is a live preview to directly see how the selected formatting option affects the source code.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;"><br />Written by : </span><a href="http://www.thomas-schweitzer.de"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">Thomas Schweitzer</span></a></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">Project Homepage : </span><a href="http://universalindent.sourceforge.net"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">http://universalindent.sourceforge.net</span></a></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">License: UniversalIndentGui is released under the GPL 2. For details read the included file LICENSE.GPL visit </span><a href="http://www.gnu.org/licenses/gpl.html"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium; text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/gpl.html</span></a><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Trebuchet MS,Helvetica,sans-serif'; font-size:medium;">Credits:</span></p></body></html> + + + + + + + TQTextBrowser#creditsTextBrowser{border:2px solid rgba(0,0,0,10%); background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,0,80%), stop:0.1 rgba(0,0,0,15%), stop:0.9 rgba(0,0,0,15%), stop:1 rgba(0,0,0,80%) )} + + + TQFrame::NoFrame + + + TQt::ScrollBarAlwaysOff + + + + + + + + + TQt::Horizontal + + + + 131 + 31 + + + + + + + + TQPushButton#okButton { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #DCB28A, stop:0.5 #B8784B, stop:1 #DCB28A ); border: 2px solid #A89C57; border-radius: 4px;} TQPushButton:hover#okButton { background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1, stop:0 #B8784B, stop:0.5 #DCB28A, stop:1 #B8784B ); } TQPushButton:pressed#okButton{ border: 2px solid #D8CB75 } + + + OK + + + + + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + okButton + clicked() + AboutDialog + accept() + + + 278 + 253 + + + 96 + 254 + + + + + diff --git a/src/__TODO/AboutDialogGraphicsView.cpp b/src/__TODO/AboutDialogGraphicsView.cpp new file mode 100644 index 0000000..3c031f2 --- /dev/null +++ b/src/__TODO/AboutDialogGraphicsView.cpp @@ -0,0 +1,220 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#include "AboutDialogGraphicsView.h" + +#include "AboutDialog.h" + +#include +#include +#include +#include +#include + +/*! + \class AboutDialogGraphicsView + \brief A container for the real \a AboutDialog. Makes the 3D animation possible. + + The 3D animation shall suggest the user, that he is looking at his desktop, while + this animation is done. Since this is not directly possible, \a AboutDialogGraphicsView + when shown starts in frameless fullscreen mode with a screenshot of the desktop as background. +*/ + +/*! + \brief The constructor initializes everything needed for the 3D animation. + */ +AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow) : + TQGraphicsView(parentWindow), _aboutDialog(NULL), _graphicsProxyWidget(NULL), + _parentWindow(NULL), _timeLine(NULL), _aboutDialogAsSplashScreen(NULL) +{ + _parentWindow = parentWindow; + setWindowFlags(TQt::SplashScreen); + +#ifdef Q_OS_LINUX + TQRect availableGeometry = TQApplication::desktop()->availableGeometry(); + TQRect newGeometry = TQRect(availableGeometry.x(), + availableGeometry.y(), availableGeometry.width(), availableGeometry.height()); +#else + TQRect newGeometry = TQRect(-1, -1, + TQApplication::desktop()->rect().width() + 2, + TQApplication::desktop()->rect().height() + 2); +#endif + setGeometry(newGeometry); + + _aboutDialog = aboutDialog; + + _windowTitleBarWidth = 0; + _windowPosOffset = 0; + + TQGraphicsScene *scene = new TQGraphicsScene(this); + setSceneRect(newGeometry); + _aboutDialogAsSplashScreen = new TQSplashScreen(this); + _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen); + _graphicsProxyWidget->setWindowFlags(TQt::ToolTip); + + setScene(scene); + setRenderHint(TQPainter::Antialiasing); + + setCacheMode(TQGraphicsView::CacheBackground); + setViewportUpdateMode(TQGraphicsView::BoundingRectViewportUpdate); + + connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide())); + + //setWindowOpacity(0.9); + + setVerticalScrollBarPolicy(TQt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(TQt::ScrollBarAlwaysOff); + setStyleSheet("AboutDialogGraphicsView { border: 0px; }"); + + _timeLine = new TQTimeLine(1000, this); + _timeLine->setFrameRange(270, 0); + //_timeLine->setUpdateInterval(10); + //_timeLine->setCurveShape(TQTimeLine::EaseInCurve); + connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int))); +} + +AboutDialogGraphicsView::~AboutDialogGraphicsView(void) +{ +} + +/*! + \brief Grabs a screenshot of the full desktop and shows that as background. Above that background the + AboutDialog 3D animation is shown. Also grabs the content of the AboutDialog itself. + */ +void AboutDialogGraphicsView::show() +{ + // Because on X11 system the window decoration is only available after a widget has been shown + // once, + // we can detect _windowTitleBarWidth here for the first time. + _windowTitleBarWidth = _parentWindow->geometry().y() - _parentWindow->y(); + // If the _windowTitleBarWidth could not be determined, try it a second way. Even the chances are + // low to get good results. + if (_windowTitleBarWidth == 0) + { + _windowTitleBarWidth = _parentWindow->frameGeometry().height() - + _parentWindow->geometry().height(); + } +#ifdef Q_OS_LINUX + if (_windowTitleBarWidth == 0) + { + //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a + // workaround for that specific case. + _windowPosOffset = 27; + _windowTitleBarWidth = 27; + } +#endif + TQPixmap originalPixmap = TQPixmap::grabWindow( + TQApplication::desktop()->winId(), + TQApplication::desktop()->availableGeometry().x(), + TQApplication::desktop()->availableGeometry().y(), geometry().width(), + geometry().height()); + TQBrush brush(originalPixmap); + TQTransform transform; + transform.translate(0, TQApplication::desktop()->availableGeometry().y()); + brush.setTransform(transform); + + setBackgroundBrush(brush); + + _aboutDialogAsSplashScreen->setPixmap(TQPixmap::grabWidget(_aboutDialog)); + _graphicsProxyWidget->setGeometry(_aboutDialog->geometry()); + _aboutDialog->hide(); + _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(270, TQt::XAxis) + //.rotate(90, TQt::YAxis) + //.rotate(5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + + _graphicsProxyWidget->show(); + //_aboutDialogAsSplashScreen->show(); + TQGraphicsView::show(); + + connect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); + _timeLine->setDirection(TQTimeLine::Forward); + _timeLine->start(); +} + +/*! + \brief Does the next calculation/transformation step. + */ +void AboutDialogGraphicsView::updateStep(int step) +{ + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(step, TQt::XAxis) + //.rotate(step, TQt::YAxis) + //.rotate(step * 5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + //update(); +} + +/*! + \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it. + */ +void AboutDialogGraphicsView::showAboutDialog() +{ + //hide(); + disconnect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); + _aboutDialog->move(int(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2), + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + _aboutDialog->exec(); +} + +/*! + \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation. + */ +void AboutDialogGraphicsView::hide() +{ + _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(0, TQt::XAxis) + //.rotate(90, TQt::YAxis) + //.rotate(5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + + _graphicsProxyWidget->show(); + //_aboutDialogAsSplashScreen->show(); + TQGraphicsView::show(); + + connect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); + _timeLine->setDirection(TQTimeLine::Backward); + _timeLine->start(); +} + +/*! + \brief This slot really hides this AboutDialog container. + */ +void AboutDialogGraphicsView::hideReally() +{ + disconnect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); + TQGraphicsView::hide(); + _parentWindow->activateWindow(); +} diff --git a/src/__TODO/AboutDialogGraphicsView.h b/src/__TODO/AboutDialogGraphicsView.h new file mode 100644 index 0000000..4554e36 --- /dev/null +++ b/src/__TODO/AboutDialogGraphicsView.h @@ -0,0 +1,57 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#ifndef ABOUTDIALOGGRAPHICSVIEW_H +#define ABOUTDIALOGGRAPHICSVIEW_H + +#include + +class AboutDialog; + +class TQTimeLine; +class TQSplashScreen; + + +class AboutDialogGraphicsView : public TQGraphicsView +{ + Q_OBJECT + + public: + AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow = NULL); + ~AboutDialogGraphicsView(void); + + public slots: + void show(); + void hide(); + + private slots: + void updateStep(int step); + void showAboutDialog(); + void hideReally(); + + private: + AboutDialog *_aboutDialog; + TQGraphicsProxyWidget *_graphicsProxyWidget; + TQWidget *_parentWindow; + TQTimeLine *_timeLine; + TQSplashScreen *_aboutDialogAsSplashScreen; + int _windowTitleBarWidth; + int _windowPosOffset; +}; + +#endif // ABOUTDIALOGGRAPHICSVIEW_H diff --git a/src/__TODO/FindDialog.ui b/src/__TODO/FindDialog.ui new file mode 100755 index 0000000..00cc527 --- /dev/null +++ b/src/__TODO/FindDialog.ui @@ -0,0 +1,121 @@ + + + FindDialog + + + + 0 + 0 + 347 + 227 + + + + Find + + + + + + + 0 + 0 + + + + Find what: + + + + + + + true + + + + + + + + 0 + 0 + + + + Find options + + + + + + Match case + + + + + + + Match whole word + + + + + + + Search forward + + + true + + + + + + + Use Regular Expressions + + + + + + + + + + TQt::Vertical + + + + 20 + 40 + + + + + + + + TQLayout::SetMaximumSize + + + + + Find Next + + + + + + + Close + + + + + + + + + + diff --git a/src/__TODO/IndentHandler.cpp b/src/__TODO/IndentHandler.cpp new file mode 100644 index 0000000..b0378a8 --- /dev/null +++ b/src/__TODO/IndentHandler.cpp @@ -0,0 +1,2044 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "IndentHandler.h" + +#include "UiGuiSettings.h" +#include "UiGuiErrorMessage.h" +#include "TemplateBatchScript.h" +#include "UiGuiIniFileParser.h" +#include "SettingsPaths.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_WIN32 + #include +#endif + +// Avoid unused parameter warnings by this template +template +inline void UNUSED_PARAMETER_WARNING_AVOID(T) +{ +} + +//! \defgroup grp_Indenter All concerning handling of the indenter. + +/*! + \class IndentHandler + \ingroup grp_Indenter + \brief A widget for handling many indenters that are configured by an ini file. + + This is a widget that is used by the main window. It handles access to the + indenter config file and calls the chosen indenter to reformat the source text. + Calls the indenter each time a setting has been changed and informs + the main window about the reformatted source code. +*/ + + +/*! + \brief Constructor of the indent handler. + + By calling this constructor the indenter to be loaded, can be selected by setting + its \a indenterID, which is the number of found indenter ini files in alphabetic + order starting at index 0. + */ +IndentHandler::IndentHandler(int indenterID, TQWidget *mainWindow, TQWidget *parent) : + TQWidget(parent), _indenterSelectionCombobox(NULL), _indenterParameterHelpButton(NULL), + _toolBoxContainerLayout(NULL), _indenterParameterCategoriesToolBox(NULL), _indenterSettings( + NULL), _mainWindow(NULL), _errorMessageDialog(NULL), _menuIndenter(NULL), + _actionLoadIndenterConfigFile(NULL), _actionSaveIndenterConfigFile(NULL), + _actionCreateShellScript(NULL), _actionResetIndenterParameters(NULL), + _parameterChangedCallback(NULL), _windowClosedCallback(NULL) +{ + Q_ASSERT_X(indenterID >= 0, "IndentHandler", "the selected indenterID is < 0"); + + setObjectName(TQString::fromUtf8("indentHandler")); + + _mainWindow = mainWindow; + + initIndenterMenu(); + + connect(_actionLoadIndenterConfigFile, SIGNAL(triggered()), this, SLOT(openConfigFileDialog())); + connect(_actionSaveIndenterConfigFile, SIGNAL(triggered()), this, SLOT( + saveasIndentCfgFileDialog())); + connect(_actionCreateShellScript, SIGNAL(triggered()), this, + SLOT(createIndenterCallShellScript())); + connect(_actionResetIndenterParameters, SIGNAL(triggered()), this, + SLOT(resetIndenterParameter())); + + // define this widgets resize behavior + setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); + + // create vertical layout box, into which the toolbox will be added + _toolBoxContainerLayout = new TQVBoxLayout(this); + _toolBoxContainerLayout->setMargin(2); + + // Create horizontal layout for indenter selector and help button. + TQHBoxLayout *hboxLayout = new TQHBoxLayout(); + //hboxLayout->setMargin(2); + _toolBoxContainerLayout->addLayout(hboxLayout); + + // Create the indenter selection combo box. + _indenterSelectionCombobox = new TQComboBox(this); + _indenterSelectionCombobox->setSizeAdjustPolicy(TQComboBox::AdjustToMinimumContentsLengthWithIcon); + _indenterSelectionCombobox->setMinimumContentsLength(20); + connect(_indenterSelectionCombobox, SIGNAL(activated(int)), this, SLOT(setIndenter(int))); + UiGuiSettings::getInstance()->registerObjectProperty(_indenterSelectionCombobox, "currentIndex", + "selectedIndenter"); + hboxLayout->addWidget(_indenterSelectionCombobox); + + // Create the indenter parameter help button. + _indenterParameterHelpButton = new TQToolButton(this); + _indenterParameterHelpButton->setObjectName(TQString::fromUtf8("indenterParameterHelpButton")); + _indenterParameterHelpButton->setIcon(TQIcon(TQString::fromUtf8(":/mainWindow/help.png"))); + hboxLayout->addWidget(_indenterParameterHelpButton); + // Handle if the indenter parameter help button is pressed. + connect(_indenterParameterHelpButton, SIGNAL(clicked()), this, SLOT(showIndenterManual())); + + // create a toolbox and set its resize behavior + _indenterParameterCategoriesToolBox = new TQToolBox(this); + _indenterParameterCategoriesToolBox->setObjectName(TQString::fromUtf8( + "_indenterParameterCategoriesToolBox")); + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, + SLOT(updateDrawing())); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS + + //_indenterParameterCategoriesToolBox->setSizePolicy( TQSizePolicy::Expanding, + // TQSizePolicy::Expanding ); + //_indenterParameterCategoriesToolBox->setMaximumSize(TQSize(16777215, 16777215)); + // insert the toolbox into the vlayout + _toolBoxContainerLayout->addWidget(_indenterParameterCategoriesToolBox); + + _indenterExecutableCallString = ""; + _indenterExecutableSuffix = ""; + + _indenterDirctoryStr = SettingsPaths::getIndenterPath(); + _tempDirctoryStr = SettingsPaths::getTempPath(); + _settingsDirctoryStr = SettingsPaths::getSettingsPath(); + TQDir indenterDirctory = TQDir(_indenterDirctoryStr); + + if (_mainWindow != NULL) + { + _errorMessageDialog = new UiGuiErrorMessage(_mainWindow); + } + else + { + _errorMessageDialog = new UiGuiErrorMessage(this); + } + + _indenterIniFileList = indenterDirctory.entryList(TQStringList("uigui_*.ini")); + if (_indenterIniFileList.count() > 0) + { + // Take care if the selected indenterID is smaller or greater than the number of existing + // indenters + if (indenterID < 0) + { + indenterID = 0; + } + if (indenterID >= _indenterIniFileList.count()) + { + indenterID = _indenterIniFileList.count() - 1; + } + + // Reads and parses the by indenterID defined indent ini file and creates toolbox entries + readIndentIniFile(_indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID)); + + // Find out how the indenter can be executed. + createIndenterCallString(); + + // Load the users last settings made for this indenter. + loadConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg"); + + // Fill the indenter selection combo box with the list of available indenters. + if (!getAvailableIndenters().isEmpty()) + { + _indenterSelectionCombobox->addItems(getAvailableIndenters()); + _indenterSelectionCombobox->setCurrentIndex(indenterID); + connect(_indenterSelectionCombobox, SIGNAL(currentIndexChanged(int)), this, + SIGNAL(selectedIndenterIndexChanged(int))); + } + } + else + { + _errorMessageDialog->showMessage(tr("No indenter ini files"), + tr("There exists no indenter ini files in the directory \"") + + TQDir(_indenterDirctoryStr).absolutePath() + "\"."); + } + + retranslateUi(); +} + +/*! + \brief Implicitly writes the current indenter parameters to the indenters config file. + */ +IndentHandler::~IndentHandler() +{ + // Generate the parameter string that will be saved to the indenters config file. + TQString parameterString = getParameterString(); + if (!_indenterFileName.isEmpty()) + { + saveConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString); + } + + delete _errorMessageDialog; +} + +/*! + \brief Initializes the context menu used for some actions like saving the indenter config file. + */ +void IndentHandler::initIndenterMenu() +{ + if (_menuIndenter == NULL) + { + _actionLoadIndenterConfigFile = new TQAction(this); + _actionLoadIndenterConfigFile->setObjectName(TQString::fromUtf8("_actionLoadIndenterConfigFile")); + _actionLoadIndenterConfigFile->setIcon(TQIcon(TQString::fromUtf8( + ":/mainWindow/load_indent_cfg.png"))); + + _actionSaveIndenterConfigFile = new TQAction(this); + _actionSaveIndenterConfigFile->setObjectName(TQString::fromUtf8("_actionSaveIndenterConfigFile")); + _actionSaveIndenterConfigFile->setIcon(TQIcon(TQString::fromUtf8( + ":/mainWindow/save_indent_cfg.png"))); + + _actionCreateShellScript = new TQAction(this); + _actionCreateShellScript->setObjectName(TQString::fromUtf8("_actionCreateShellScript")); + _actionCreateShellScript->setIcon(TQIcon(TQString::fromUtf8(":/mainWindow/shell.png"))); + + _actionResetIndenterParameters = new TQAction(this); + _actionResetIndenterParameters->setObjectName(TQString::fromUtf8( + "_actionResetIndenterParameters")); + _actionResetIndenterParameters->setIcon(TQIcon(TQString::fromUtf8( + ":/mainWindow/view-refresh.png"))); + + _menuIndenter = new TQMenu(this); + _menuIndenter->setObjectName(TQString::fromUtf8("_menuIndenter")); + _menuIndenter->addAction(_actionLoadIndenterConfigFile); + _menuIndenter->addAction(_actionSaveIndenterConfigFile); + _menuIndenter->addAction(_actionCreateShellScript); + _menuIndenter->addAction(_actionResetIndenterParameters); + } +} + +/*! + \brief Returns the context menu used for some actions like saving the indenter config file. + */ +TQMenu* IndentHandler::getIndenterMenu() +{ + return _menuIndenter; +} + +/*! + \brief Returns the actions of the context menu used for some actions like saving the indenter config file. + */ +TQList IndentHandler::getIndenterMenuActions() +{ + TQList actionList; + actionList << _actionLoadIndenterConfigFile << _actionSaveIndenterConfigFile << + _actionCreateShellScript << _actionResetIndenterParameters; + return actionList; +} + +/*! + \brief Opens the context menu, used for some actions like saving the indenter config file, at the event position. + */ +void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) +{ + getIndenterMenu()->exec(event->globalPos()); +} + +/*! + \brief Creates the content for a shell script that can be used as a external tool call + to indent an as parameter defined file. + */ +TQString IndentHandler::generateShellScript(const TQString &configFilename) +{ + TQString indenterCompleteCallString; + TQString parameterInputFile; + TQString parameterOuputFile; + TQString parameterParameterFile; + TQString replaceInputFileCommand; + + // Define the placeholder for parameter variables either in batch or bash programming. +#if defined (Q_OS_WIN32) + TQString shellParameterPlaceholder = "%1"; +#else + TQString shellParameterPlaceholder = "$1"; +#endif + + parameterInputFile = " " + _inputFileParameter + "\"" + shellParameterPlaceholder + "\""; + + if (_outputFileParameter != "none" && _outputFileParameter != "stdout") + { + if (_outputFileName == _inputFileName) + { + parameterOuputFile = " " + _outputFileParameter + "\"" + shellParameterPlaceholder + "\""; + } + else + { + parameterOuputFile = " " + _outputFileParameter + _outputFileName + ".tmp"; + } + } + + // If the config file name is empty it is assumed that all parameters are sent via command line + // call + if (_globalConfigFilename.isEmpty()) + { + parameterParameterFile = " " + getParameterString(); + } + // else if needed add the parameter to the indenter call string where the config file can be + // found. + else if (_useCfgFileParameter != "none") + { + parameterParameterFile = " " + _useCfgFileParameter + "\"./" + configFilename + "\""; + } + + // Assemble indenter call string for parameters according to the set order. + if (_parameterOrder == "ipo") + { + indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile; + } + else if (_parameterOrder == "pio") + { + indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile; + } + else if (_parameterOrder == "poi") + { + indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile; + } + else + { + indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile; + } + + // Generate the indenter call string either for win32 or other systems. +#if defined (Q_OS_WIN32) + indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString; +#else + indenterCompleteCallString = "#!/bin/bash\n" + _indenterExecutableCallString + + indenterCompleteCallString; +#endif + + // If the indenter writes to stdout pipe the output into a file + if (_outputFileParameter == "stdout") + { + indenterCompleteCallString = indenterCompleteCallString + " >" + _outputFileName + ".tmp"; + } + + // If the output filename is not the same as the input filename copy the output over the input. + if (_outputFileName != _inputFileName) + { +#if defined (Q_OS_WIN32) + replaceInputFileCommand = "move /Y " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + + "\"\n"; +#else + replaceInputFileCommand = "mv " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + + "\"\n"; +#endif + } + +#if defined (Q_OS_WIN32) + TQString shellScript(TemplateBatchScript::getTemplateBatchScript()); + shellScript = shellScript.replace("__INDENTERCALLSTRING2__", + indenterCompleteCallString + "\n" + replaceInputFileCommand); + indenterCompleteCallString = indenterCompleteCallString.replace("%1", "%%G"); + replaceInputFileCommand = replaceInputFileCommand.replace("%1", "%%G"); + shellScript = shellScript.replace("__INDENTERCALLSTRING1__", + indenterCompleteCallString + "\n" + replaceInputFileCommand); +#else + TQString shellScript(TemplateBatchScript::getTemplateBatchScript()); + shellScript = shellScript.replace("__INDENTERCALLSTRING2__", + indenterCompleteCallString + "\n" + replaceInputFileCommand); + indenterCompleteCallString = indenterCompleteCallString.replace("$1", "$file2indent"); + replaceInputFileCommand = replaceInputFileCommand.replace("$1", "$file2indent"); + shellScript = shellScript.replace("__INDENTERCALLSTRING1__", + indenterCompleteCallString + "\n" + replaceInputFileCommand); +#endif + + return shellScript; +} + +/*! + \brief Format \a sourceCode by calling the indenter. + + The \a inputFileExtension has to be given as parameter so the called indenter + can identify the programming language if needed. + */ +TQString IndentHandler::callIndenter(TQString sourceCode, TQString inputFileExtension) +{ + if (_indenterExecutableSuffix == ".js") + { + return callJavaScriptIndenter(sourceCode); + } + else + { + return callExecutableIndenter(sourceCode, inputFileExtension); + } +} + +/*! + \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter. + + The \a inputFileExtension has to be given as parameter so the called indenter + can identify the programming language if needed. + */ +TQString IndentHandler::callJavaScriptIndenter(TQString sourceCode) +{ + TQScriptEngine engine; + + engine.globalObject().setProperty("unformattedCode", sourceCode); + + TQFile jsDecoderFile(_indenterExecutableCallString); + TQString jsDecoderCode; + if (jsDecoderFile.open(TQFile::ReadOnly)) + { + jsDecoderCode = jsDecoderFile.readAll(); + } + jsDecoderFile.close(); + + TQScriptValue value = engine.evaluate(jsDecoderCode); + return value.toString(); +} + +/*! + \brief Format \a sourceCode by calling the binary executable of the indenter. + + The \a inputFileExtension has to be given as parameter so the called indenter + can identify the programming language if needed. + */ +TQString IndentHandler::callExecutableIndenter(TQString sourceCode, TQString inputFileExtension) +{ + Q_ASSERT_X(!_inputFileName.isEmpty(), "callIndenter", "_inputFileName is empty"); + // Q_ASSERT_X( !_outputFileName.isEmpty(), "callIndenter", "_outputFileName is empty" ); + Q_ASSERT_X(!_indenterFileName.isEmpty(), "callIndenter", "_indenterFileName is empty"); + + if (_indenterFileName.isEmpty()) + { + return ""; + } + + TQString formattedSourceCode; + TQString indenterCompleteCallString; + TQString parameterInputFile; + TQString parameterOuputFile; + TQString parameterParameterFile; + TQProcess indentProcess; + TQString processReturnString; + + // Generate the parameter string that will be saved to the indenters config file + TQString parameterString = getParameterString(); + + if (!_globalConfigFilename.isEmpty()) + { + saveConfigFile(_tempDirctoryStr + "/" + _globalConfigFilename, parameterString); + } + + // Only add a dot to file extension if the string is not empty + if (!inputFileExtension.isEmpty()) + { + inputFileExtension = "." + inputFileExtension; + } + + // Delete any previously used input src file and create a new input src file. + TQFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); + TQFile inputSrcFile(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); + // Write the source code to the input file for the indenter + if (inputSrcFile.open(TQFile::ReadWrite | TQFile::Text)) + { + inputSrcFile.write(sourceCode.toUtf8()); + inputSrcFile.close(); + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Wrote to be indented source code to file " << + inputSrcFile.fileName(); + } + else + { + qCritical() << __LINE__ << " " << __FUNCTION__ << + ": Couldn't write to be indented source code to file " << inputSrcFile.fileName(); + } + + // Set the input file for the to be called indenter. + if (_inputFileParameter.trimmed() == "<" || _inputFileParameter == "stdin") + { + parameterInputFile = ""; + indentProcess.setStandardInputFile(inputSrcFile.fileName()); + } + else + { + parameterInputFile = " " + _inputFileParameter + _inputFileName + inputFileExtension; + } + + // Set the output file for the to be called indenter. + if (_outputFileParameter != "none" && _outputFileParameter != "stdout") + { + parameterOuputFile = " " + _outputFileParameter + _outputFileName + inputFileExtension; + } + +#ifdef Q_OS_WIN32 + // Paths may contain Unicode or other foreign characters. Windows commands line tools will + // receive als falsely encoded path string by TQProcess or they connot correctly handle + // the Unicode path on their own. + // Because of this the path gets converted to Windows short paths using the 8.3 notation. + + tqDebug() << __LINE__ << " " << __FUNCTION__ << + ": Temp dir before trying to convert it to short Windows path is" << _tempDirctoryStr; + + // At first convert the temp path to Windows like separators. + TQString tempDirctoryStrHelper = + TQDir::toNativeSeparators(_tempDirctoryStr).replace("\\", "\\\\"); + // Then convert the TQString to a WCHAR array and NULL terminate it. + WCHAR *tempDirctoryWindowsStr = new WCHAR[tempDirctoryStrHelper.length() + 1]; + tempDirctoryStrHelper.toWCharArray(tempDirctoryWindowsStr); + tempDirctoryWindowsStr[tempDirctoryStrHelper.length()] = (WCHAR)NULL; + + // Get the length of the resulting short path. + long length = 0; + TCHAR *buffer = NULL; + length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, NULL, 0); + + // If the short path could be retrieved, create a correct sized buffer, store the + // short path in it and convert all back to TQString. + if (length != 0) + { + #ifdef UNICODE + buffer = new WCHAR[length]; + length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length); + tempDirctoryStrHelper = TQString::fromWCharArray(buffer); + #else + buffer = new TCHAR[length]; + length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length); + tempDirctoryStrHelper = buffer; + #endif + _tempDirctoryStr = TQDir::fromNativeSeparators(tempDirctoryStrHelper).replace("//", "/"); + delete[] buffer; + + // Check whether the short path still contains some kind of non ascii characters. + if (_tempDirctoryStr.length() != _tempDirctoryStr.toAscii().length()) + { + tqWarning() << __LINE__ << " " << __FUNCTION__ << + ": Shortened path still contains non ascii characters. Could cause some indenters not to work properly!"; + } + } + else + { + tqWarning() << __LINE__ << " " << __FUNCTION__ << + ": Couldn't retrieve a short version of the temporary path!"; + } + + tqDebug() << __LINE__ << " " << __FUNCTION__ << + ": Temp dir after trying to convert it to short Windows path is " << _tempDirctoryStr; + + delete[] tempDirctoryWindowsStr; +#endif + + // If the config file name is empty it is assumed that all parameters are sent via command line + // call + if (_globalConfigFilename.isEmpty()) + { + parameterParameterFile = " " + parameterString; + } + // if needed add the parameter to the indenter call string where the config file can be found + else if (_useCfgFileParameter != "none") + { + parameterParameterFile = " " + _useCfgFileParameter + "\"" + _tempDirctoryStr + "/" + + _globalConfigFilename + "\""; + } + + // Assemble indenter call string for parameters according to the set order. + if (_parameterOrder == "ipo") + { + indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile; + } + else if (_parameterOrder == "pio") + { + indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile; + } + else if (_parameterOrder == "poi") + { + indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile; + } + else + { + indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile; + } + + // If no indenter executable call string could be created before, show an error message. + if (_indenterExecutableCallString.isEmpty()) + { + _errorMessageDialog->showMessage(tr("No indenter executable"), tr( + "There exists no indenter executable with the name \"%1\" in the directory \"%2\" nor in the global environment.").arg( + _indenterFileName).arg(_indenterDirctoryStr)); + return sourceCode; + } + + // Generate the indenter call string either for win32 or other systems. + indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString; + + // errors and standard outputs from the process call are merged together + //indentProcess.setReadChannelMode(TQProcess::MergedChannels); + + // Set the directory where the indenter will be executed for the process' environment as PWD. + TQStringList env = indentProcess.environment(); + env << "PWD=" + TQFileInfo(_tempDirctoryStr).absoluteFilePath(); + indentProcess.setEnvironment(env); + + // Set the directory for the indenter execution + indentProcess.setWorkingDirectory(TQFileInfo(_tempDirctoryStr).absoluteFilePath()); + + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Will call the indenter in the directory " << + indentProcess.workingDirectory() << " using this commandline call: " << + indenterCompleteCallString; + + indentProcess.start(indenterCompleteCallString); + + processReturnString = ""; + bool calledProcessSuccessfully = indentProcess.waitForFinished(10000); + // test if there was an error during starting the process of the indenter + if (!calledProcessSuccessfully) + { + processReturnString = ""; + processReturnString += tr("Returned error message: ") + indentProcess.errorString() + + "
"; + + switch (indentProcess.error()) + { + case TQProcess::FailedToStart: + { + processReturnString += tr("Reason could be: ") + + "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.
"; + break; + } + + case TQProcess::Crashed: + { + processReturnString += "The process crashed some time after starting successfully.
"; + break; + } + + case TQProcess::Timedout: + { + processReturnString += + "The called indenter did not response for over 10 seconds, so aborted its execution.
"; + break; + } + + case TQProcess::WriteError: + { + processReturnString += + "An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.
"; + break; + } + + case TQProcess::ReadError: + { + processReturnString += + "An error occurred when attempting to read from the process. For example, the process may not be running.
"; + break; + } + + case TQProcess::UnknownError: + { + processReturnString += + "An unknown error occurred. This is the default return value of error().
"; + break; + } + + default: + { + break; + } + } + processReturnString += tr("
Callstring was: ") + encodeToHTML( + indenterCompleteCallString); + processReturnString += tr("

Indenter output was:
") + "
" + "(STDOUT):" + + encodeToHTML(indentProcess.readAllStandardOutput()) + "
" + "(STDERR):" + + encodeToHTML(indentProcess.readAllStandardError()) + "
" + "
"; + tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; + TQApplication::restoreOverrideCursor(); + _errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString); + } + + // If the indenter returned an error code != 0 show its output. + if (indentProcess.exitCode() != 0) + { + TQString exitCode; + exitCode.setNum(indentProcess.exitCode()); + processReturnString = tr("Indenter returned with exit code: ") + exitCode + "
" + tr( + "Indent console output was: ") + "
" + "(STDOUT):" + encodeToHTML( + indentProcess.readAllStandardOutput()) + "
" + "(STDERR):" + encodeToHTML( + indentProcess.readAllStandardError()) + "
" + tr("
Callstring was: ") + + encodeToHTML(indenterCompleteCallString) + ""; + tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; + TQApplication::restoreOverrideCursor(); + _errorMessageDialog->showMessage(tr("Indenter returned error"), processReturnString); + } + + // Only get the formatted source code, if calling the indenter did succeed. + if (calledProcessSuccessfully) + { + // If the indenter results are written to stdout, read them from there... + if (indentProcess.exitCode() == 0 && _outputFileParameter == "stdout") + { + formattedSourceCode = indentProcess.readAllStandardOutput(); + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from StdOut."; + } + // ... else read the output file generated by the indenter call. + else + { + TQFile outSrcFile(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension); + if (outSrcFile.open(TQFile::ReadOnly | TQFile::Text)) + { + TQTextStream outSrcStrm(&outSrcFile); + outSrcStrm.setCodec(TQTextCodec::codecForName("UTF-8")); + formattedSourceCode = outSrcStrm.readAll(); + outSrcFile.close(); + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from file " << + outSrcFile.fileName(); + } + else + { + qCritical() << __LINE__ << " " << __FUNCTION__ << + ": Couldn't read indenter output from file " << outSrcFile.fileName(); + } + } + } + else + { + return sourceCode; + } + + // Delete the temporary input and output files. + TQFile::remove(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension); + TQFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension); + + return formattedSourceCode; +} + +/*! + \brief Generates and returns a string with all parameters needed to call the indenter. + */ +TQString IndentHandler::getParameterString() +{ + TQString parameterString = ""; + + // generate parameter string for all boolean values + foreach(ParamBoolean pBoolean, _paramBooleans) + { + if (pBoolean.checkBox->isChecked()) + { + if (!pBoolean.trueString.isEmpty()) + { + parameterString += pBoolean.trueString + _cfgFileParameterEnding; + } + } + else + { + if (!pBoolean.falseString.isEmpty()) + { + parameterString += pBoolean.falseString + _cfgFileParameterEnding; + } + } + } + + // generate parameter string for all numeric values + foreach(ParamNumeric pNumeric, _paramNumerics) + { + if (pNumeric.valueEnabledChkBox->isChecked()) + { + parameterString += pNumeric.paramCallName + TQString::number(pNumeric.spinBox->value()) + + _cfgFileParameterEnding; + } + } + + // generate parameter string for all string values + foreach(ParamString pString, _paramStrings) + { + if (!pString.lineEdit->text().isEmpty() && pString.valueEnabledChkBox->isChecked()) + { + // Create parameter definition for each value devided by a | sign. + foreach(TQString paramValue, pString.lineEdit->text().split("|")) + { + parameterString += pString.paramCallName + paramValue + _cfgFileParameterEnding; + } + } + } + + // generate parameter string for all multiple choice values + foreach(ParamMultiple pMultiple, _paramMultiples) + { + if (pMultiple.valueEnabledChkBox->isChecked()) + { + parameterString += pMultiple.choicesStrings.at(pMultiple.comboBox->currentIndex()) + + _cfgFileParameterEnding; + } + } + + return parameterString; +} + +/*! + \brief Write settings for the indenter to a config file. + */ +void IndentHandler::saveConfigFile(TQString filePathName, TQString paramString) +{ + TQFile::remove(filePathName); + TQFile cfgFile(filePathName); + + cfgFile.open(TQFile::ReadWrite | TQFile::Text); + cfgFile.write(paramString.toAscii()); + cfgFile.close(); +} + +/*! + \brief Load the config file for the indenter and apply the settings made there. + */ +bool IndentHandler::loadConfigFile(TQString filePathName) +{ + TQFile cfgFile(filePathName); + int index; + int crPos; + int paramValue = 0; + TQString paramValueStr = ""; + TQString cfgFileData = ""; + + // If the to be loaded config file does not exist leave all values as they are and return false. + if (!cfgFile.exists()) + { + return false; + } + // else if the to be read config file exists, retrieve its whole content. + else + { + // Open the config file and read all data + cfgFile.open(TQFile::ReadOnly | TQFile::Text); + cfgFileData = cfgFile.readAll(); + cfgFile.close(); + } + + // Search for name of each boolean parameter and set its value if found. + foreach(ParamBoolean pBoolean, _paramBooleans) + { + // boolean value that will be assigned to the checkbox + bool paramValue = false; + + // first search for the longer parameter string + // the true parameter string is longer than the false string + if (pBoolean.trueString.length() > pBoolean.falseString.length()) + { + // search for the true string + index = cfgFileData.indexOf(pBoolean.trueString, 0, TQt::CaseInsensitive); + // if true string found set the parameter value to true + if (index != -1) + { + paramValue = true; + } + // if true string not found, search for false string + else + { + index = cfgFileData.indexOf(pBoolean.falseString, 0, TQt::CaseInsensitive); + // if false string found set the parameter value to false + if (index != -1) + { + paramValue = false; + } + // neither true nor false parameter found so use default value + else + { + paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); + } + } + } + // the false parameter string is longer than the true string + else + { + // search for the false string + index = cfgFileData.indexOf(pBoolean.falseString, 0, TQt::CaseInsensitive); + // if false string found set the parameter value to false + if (index != -1) + { + paramValue = false; + } + // if false string not found, search for true string + else + { + index = cfgFileData.indexOf(pBoolean.trueString, 0, TQt::CaseInsensitive); + // if true string found set the parameter value to true + if (index != -1) + { + paramValue = true; + } + // neither true nor false parameter found so use default value + else + { + paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); + } + } + } + pBoolean.checkBox->setChecked(paramValue); + } + + // Search for name of each numeric parameter and set the value found behind it. + foreach(ParamNumeric pNumeric, _paramNumerics) + { + index = cfgFileData.indexOf(pNumeric.paramCallName, 0, TQt::CaseInsensitive); + // parameter was found in config file + if (index != -1) + { + // set index after the parameter name, so in front of the number + index += pNumeric.paramCallName.length(); + + // Find the end of the parameter by searching for set config file parameter ending. Most of + // time this is a carriage return. + crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1); + + // get the number and convert it to int + TQString test = cfgFileData.mid(index, crPos - index); + paramValue = cfgFileData.mid(index, crPos - index).toInt(NULL); + + // disable the signal-slot connection. Otherwise signal is emmitted each time when value is + // set + TQObject::disconnect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, + SLOT(handleChangedIndenterSettings())); + pNumeric.spinBox->setValue(paramValue); + pNumeric.valueEnabledChkBox->setChecked(true); + TQObject::connect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, + SLOT(handleChangedIndenterSettings())); + } + // parameter was not found in config file + else + { + int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); + pNumeric.spinBox->setValue(defaultValue); + pNumeric.valueEnabledChkBox->setChecked(false); + } + } + + // Search for name of each string parameter and set it. + foreach(ParamString pString, _paramStrings) + { + paramValueStr = ""; + // The number of the found values for this parameter name. + int numberOfValues = 0; + index = cfgFileData.indexOf(pString.paramCallName, 0, TQt::CaseInsensitive); + // If parameter was found in config file + if (index != -1) + { + while (index != -1) + { + numberOfValues++; + + // Set index after the parameter name, so it points to the front of the string value. + index += pString.paramCallName.length(); + + // Find the end of the parameter by searching for set config file parameter ending. Most of + // time this is a carriage return. + crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1); + + // Get the string and remember it. + if (numberOfValues < 2) + { + paramValueStr = TQString(cfgFileData.mid(index, crPos - index)); + } + // If the same parameter has been set multiple times, concatenate the strings dvivided by a + // |. + else + { + paramValueStr = paramValueStr + "|" + TQString(cfgFileData.mid(index, crPos - index)); + } + + // Get next value for this setting, if one exists. + index = cfgFileData.indexOf(pString.paramCallName, crPos + 1, TQt::CaseInsensitive); + } + // Set the text for the line edit. + pString.lineEdit->setText(paramValueStr); + pString.valueEnabledChkBox->setChecked(true); + } + // Parameter was not found in config file + else + { + paramValueStr = _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); + pString.lineEdit->setText(paramValueStr); + pString.valueEnabledChkBox->setChecked(false); + } + } + + // search for name of each multiple choice parameter and set it + foreach(ParamMultiple pMultiple, _paramMultiples) + { + int i = 0; + index = -1; + + // search for all parameter names of the multiple choice list + // if one is found, set it and leave the while loop + while (i < pMultiple.choicesStrings.count() && index == -1) + { + index = cfgFileData.indexOf(pMultiple.choicesStrings.at(i), 0, TQt::CaseInsensitive); + if (index != -1) + { + pMultiple.comboBox->setCurrentIndex(i); + pMultiple.valueEnabledChkBox->setChecked(true); + } + i++; + } + + // parameter was not set in config file, so use default value + if (index == -1) + { + int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); + pMultiple.comboBox->setCurrentIndex(defaultValue); + pMultiple.valueEnabledChkBox->setChecked(false); + } + } + + return true; +} + +/*! + \brief Sets all indenter parameters to their default values defined in the ini file. + */ +void IndentHandler::resetToDefaultValues() +{ + // Search for name of each boolean parameter and set its value if found. + foreach(ParamBoolean pBoolean, _paramBooleans) + { + // Boolean value that will be assigned to the checkbox. + bool defaultValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); + pBoolean.checkBox->setChecked(defaultValue); + } + + // Search for name of each numeric parameter and set the value found behind it. + foreach(ParamNumeric pNumeric, _paramNumerics) + { + int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); + pNumeric.spinBox->setValue(defaultValue); + pNumeric.valueEnabledChkBox->setChecked(_indenterSettings->value( + pNumeric.paramName + "/Enabled").toBool()); + } + + // Search for name of each string parameter and set it. + foreach(ParamString pString, _paramStrings) + { + TQString defaultValue = + _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); + pString.lineEdit->setText(defaultValue); + pString.valueEnabledChkBox->setChecked(_indenterSettings->value( + pString.paramName + "/Enabled").toBool()); + } + + // Search for name of each multiple choice parameter and set it. + foreach(ParamMultiple pMultiple, _paramMultiples) + { + int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); + pMultiple.comboBox->setCurrentIndex(defaultValue); + pMultiple.valueEnabledChkBox->setChecked(_indenterSettings->value(pMultiple.paramName + + "/Enabled").toBool()); + } +} + +/*! + \brief Opens and parses the indenter ini file that is declared by \a iniFilePath. + */ +void IndentHandler::readIndentIniFile(TQString iniFilePath) +{ + Q_ASSERT_X(!iniFilePath.isEmpty(), "readIndentIniFile", "iniFilePath is empty"); + + // open the ini-file that contains all available indenter settings with their additional infos + _indenterSettings = new UiGuiIniFileParser(iniFilePath); + + TQStringList categories; + //TQString indenterGroupString = ""; + TQString paramToolTip = ""; + + // + // parse ini file indenter header + // + + _indenterName = _indenterSettings->value("header/indenterName").toString(); + _indenterFileName = _indenterSettings->value("header/indenterFileName").toString(); + _globalConfigFilename = _indenterSettings->value("header/configFilename").toString(); + _useCfgFileParameter = _indenterSettings->value("header/useCfgFileParameter").toString(); + _cfgFileParameterEnding = _indenterSettings->value("header/cfgFileParameterEnding").toString(); + if (_cfgFileParameterEnding == "cr") + { + _cfgFileParameterEnding = "\n"; + } + _indenterShowHelpParameter = _indenterSettings->value("header/showHelpParameter").toString(); + + if (_indenterFileName.isEmpty()) + { + _errorMessageDialog->showMessage(tr("Indenter ini file header error"), tr( + "The loaded indenter ini file \"%1\"has a faulty header. At least the indenters file name is not set.").arg( + iniFilePath)); + } + + // Read the parameter order. Possible values are (p=parameter[file] i=inputfile o=outputfile) + // pio, ipo, iop + _parameterOrder = _indenterSettings->value("header/parameterOrder", "pio").toString(); + _inputFileParameter = _indenterSettings->value("header/inputFileParameter").toString(); + _inputFileName = _indenterSettings->value("header/inputFileName").toString(); + _outputFileParameter = _indenterSettings->value("header/outputFileParameter").toString(); + _outputFileName = _indenterSettings->value("header/outputFileName").toString(); + _fileTypes = _indenterSettings->value("header/fileTypes").toString(); + _fileTypes.replace('|', " "); + + // read the categories names which are separated by "|" + TQString categoriesStr = _indenterSettings->value("header/categories").toString(); + categories = categoriesStr.split("|"); + // Assure that the category list is never empty. At least contain a "general" section. + if (categories.isEmpty()) + { + categories.append("General"); + } + + IndenterParameterCategoryPage categoryPage; + + // create a page for each category and store its references in a toolboxpage-array + foreach(TQString category, categories) + { + categoryPage.widget = new TQWidget(); + categoryPage.widget->setObjectName(category); + categoryPage.widget->setSizePolicy(TQSizePolicy::MinimumExpanding, + TQSizePolicy::MinimumExpanding); + categoryPage.vboxLayout = new TQVBoxLayout(categoryPage.widget); + categoryPage.vboxLayout->setSpacing(6); + categoryPage.vboxLayout->setMargin(9); + categoryPage.vboxLayout->setObjectName(category); + _indenterParameterCategoryPages.append(categoryPage); + _indenterParameterCategoriesToolBox->addItem(categoryPage.widget, category); + } + + // + // parse ini file indenter parameters + // + + // read all possible parameters written in brackets [] + _indenterParameters = _indenterSettings->childGroups(); + + // read each parameter to create the corresponding input field + foreach(TQString indenterParameter, _indenterParameters) + { + // if it is not the indent header definition read the parameter and add it to + // the corresponding category toolbox page + if (indenterParameter != "header") + { + // read to which category the parameter belongs + int category = _indenterSettings->value(indenterParameter + "/Category").toInt(); + // Assure that the category number is never greater than the available categories. + if (category > _indenterParameterCategoryPages.size() - 1) + { + category = _indenterParameterCategoryPages.size() - 1; + } + // read which type of input field the parameter needs + TQString editType = _indenterSettings->value(indenterParameter + "/EditorType").toString(); + + // edit type is numeric so create a spinbox with label + if (editType == "numeric") + { + // read the parameter name as it is used at the command line or in its config file + TQString parameterCallName = + _indenterSettings->value(indenterParameter + "/CallName").toString(); + + // create checkbox which enables or disables the parameter + TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); + chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); + chkBox->setToolTip( + "Enables/disables the parameter. If disabled the indenters default value will be used."); + chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); + int left, top, right, bottom; + chkBox->getContentsMargins(&left, &top, &right, &bottom); + chkBox->setContentsMargins(left, top, 0, bottom); + + // create the spinbox + TQSpinBox *spinBox = new TQSpinBox(_indenterParameterCategoryPages.at(category).widget); + paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); + spinBox->setToolTip(paramToolTip); + spinBox->setMaximumWidth(50); + spinBox->setMinimumWidth(50); + if (_mainWindow != NULL) + { + spinBox->installEventFilter(_mainWindow); + } + if (_indenterSettings->value(indenterParameter + "/MinVal").toString() != "") + { + spinBox->setMinimum(_indenterSettings->value(indenterParameter + "/MinVal").toInt()); + } + else + { + spinBox->setMinimum(0); + } + if (_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "") + { + spinBox->setMaximum(_indenterSettings->value(indenterParameter + "/MaxVal").toInt()); + } + else + { + spinBox->setMaximum(2000); + } + + // create the label + TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget); + label->setText(indenterParameter); + label->setBuddy(spinBox); + label->setToolTip(paramToolTip); + if (_mainWindow != NULL) + { + label->installEventFilter(_mainWindow); + } + + // put all into a layout and add it to the toolbox page + TQHBoxLayout *hboxLayout = new TQHBoxLayout(); + hboxLayout->addWidget(chkBox); + hboxLayout->addWidget(spinBox); + hboxLayout->addWidget(label); + _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); + + // remember parameter name and reference to its spinbox + ParamNumeric paramNumeric; + paramNumeric.paramName = indenterParameter; + paramNumeric.paramCallName = parameterCallName; + paramNumeric.spinBox = spinBox; + paramNumeric.label = label; + paramNumeric.valueEnabledChkBox = chkBox; + paramNumeric.spinBox->setValue(_indenterSettings->value(paramNumeric.paramName + + "/ValueDefault").toInt()); + _paramNumerics.append(paramNumeric); + + TQObject::connect(spinBox, SIGNAL(valueChanged(int)), this, + SLOT(handleChangedIndenterSettings())); + TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateDrawing())); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS + } + // edit type is boolean so create a checkbox + else if (editType == "boolean") + { + // create the checkbox, make its settings and add it to the toolbox page + TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); + chkBox->setText(indenterParameter); + paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); + chkBox->setToolTip(paramToolTip); + if (_mainWindow != NULL) + { + chkBox->installEventFilter(_mainWindow); + } + _indenterParameterCategoryPages.at(category).vboxLayout->addWidget(chkBox); + + // remember parameter name and reference to its checkbox + ParamBoolean paramBoolean; + paramBoolean.paramName = indenterParameter; + paramBoolean.checkBox = chkBox; + TQStringList trueFalseStrings = + _indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|"); + paramBoolean.trueString = trueFalseStrings.at(0); + paramBoolean.falseString = trueFalseStrings.at(1); + paramBoolean.checkBox->setChecked(_indenterSettings->value(paramBoolean.paramName + + "/ValueDefault").toBool()); + _paramBooleans.append(paramBoolean); + + TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); + } + // edit type is numeric so create a line edit with label + else if (editType == "string") + { + // read the parameter name as it is used at the command line or in its config file + TQString parameterCallName = + _indenterSettings->value(indenterParameter + "/CallName").toString(); + + // create check box which enables or disables the parameter + TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); + chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); + chkBox->setToolTip( + "Enables/disables the parameter. If disabled the indenters default value will be used."); + chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); + int left, top, right, bottom; + chkBox->getContentsMargins(&left, &top, &right, &bottom); + chkBox->setContentsMargins(left, top, 0, bottom); + + // create the line edit + TQLineEdit *lineEdit = new TQLineEdit(_indenterParameterCategoryPages.at(category).widget); + paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); + lineEdit->setToolTip(paramToolTip); + lineEdit->setMaximumWidth(50); + lineEdit->setMinimumWidth(50); + if (_mainWindow != NULL) + { + lineEdit->installEventFilter(_mainWindow); + } + + // create the label + TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget); + label->setText(indenterParameter); + label->setBuddy(lineEdit); + label->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Preferred); + label->setToolTip(paramToolTip); + if (_mainWindow != NULL) + { + label->installEventFilter(_mainWindow); + } + + // put all into a layout and add it to the toolbox page + TQHBoxLayout *hboxLayout = new TQHBoxLayout(); + hboxLayout->addWidget(chkBox); + hboxLayout->addWidget(lineEdit); + hboxLayout->addWidget(label); + _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); + + // remember parameter name and reference to its line edit + ParamString paramString; + paramString.paramName = indenterParameter; + paramString.paramCallName = parameterCallName; + paramString.lineEdit = lineEdit; + paramString.label = label; + paramString.valueEnabledChkBox = chkBox; + paramString.lineEdit->setText(_indenterSettings->value(paramString.paramName + + "/ValueDefault").toString()); + _paramStrings.append(paramString); + + TQObject::connect(lineEdit, SIGNAL(editingFinished()), this, + SLOT(handleChangedIndenterSettings())); + TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect(lineEdit, SIGNAL(textChanged(const TQString)), this, SLOT(updateDrawing())); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS + } + // edit type is multiple so create a combobox with label + else if (editType == "multiple") + { + // read the parameter name as it is used at the command line or in its config file + TQString parameterCallName = + _indenterSettings->value(indenterParameter + "/CallName").toString(); + + // create checkbox which enables or disables the parameter + TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); + chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); + chkBox->setToolTip( + "Enables/disables the parameter. If disabled the indenters default value will be used."); + chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); + int left, top, right, bottom; + chkBox->getContentsMargins(&left, &top, &right, &bottom); + chkBox->setContentsMargins(left, top, 0, bottom); + + // create the combo box + TQComboBox *comboBox = new TQComboBox(_indenterParameterCategoryPages.at( + category).widget); + TQStringList choicesStrings = + _indenterSettings->value(indenterParameter + "/Choices").toString().split("|"); + TQStringList choicesStringsReadable = _indenterSettings->value( + indenterParameter + "/ChoicesReadable").toString().split("|", TQString::SkipEmptyParts); + if (choicesStringsReadable.isEmpty()) + { + comboBox->addItems(choicesStrings); + } + else + { + comboBox->addItems(choicesStringsReadable); + } + paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); + comboBox->setToolTip(paramToolTip); + if (_mainWindow != NULL) + { + comboBox->installEventFilter(_mainWindow); + } + + // put all into a layout and add it to the toolbox page + TQHBoxLayout *hboxLayout = new TQHBoxLayout(); + hboxLayout->addWidget(chkBox); + hboxLayout->addWidget(comboBox); + _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout); + + // remember parameter name and reference to its lineedit + ParamMultiple paramMultiple; + paramMultiple.paramName = indenterParameter; + paramMultiple.paramCallName = parameterCallName; + paramMultiple.comboBox = comboBox; + paramMultiple.choicesStrings = choicesStrings; + paramMultiple.choicesStringsReadable = choicesStringsReadable; + paramMultiple.valueEnabledChkBox = chkBox; + paramMultiple.comboBox->setCurrentIndex(_indenterSettings->value(paramMultiple.paramName + + "/ValueDefault").toInt()); + _paramMultiples.append(paramMultiple); + + TQObject::connect(comboBox, SIGNAL(activated(int)), this, + SLOT(handleChangedIndenterSettings())); + TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect(comboBox, SIGNAL(activated(int)), this, SLOT(updateDrawing())); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS + } + } + } + + // put a spacer at each page end + foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) + { + categoryPage.vboxLayout->addStretch(); + } +} + +/*! + \brief Searches and returns all indenters a configuration file is found for. + + Opens all uigui ini files found in the list \a _indenterIniFileList, opens each ini file + and reads the there defined real name of the indenter. These names are being returned as TQStringList. + */ +TQStringList IndentHandler::getAvailableIndenters() +{ + TQStringList indenterNamesList; + + // Loop for every existing uigui ini file + foreach(TQString indenterIniFile, _indenterIniFileList) + { + // Open the ini file and search for the indenter name + TQFile file(_indenterDirctoryStr + "/" + indenterIniFile); + if (file.open(TQIODevice::ReadOnly | TQIODevice::Text)) + { + int index = -1; + TQByteArray line; + // Search for the string "indenterName=" and get the following string until line end. + while (index == -1 && !file.atEnd()) + { + line = file.readLine(); + index = line.indexOf("indenterName=", 0); + } + + if (index == 0) + { + line = line.remove(0, 13); + indenterNamesList << line.trimmed(); + } + } + } + return indenterNamesList; +} + +/*! + \brief Deletes all elements in the toolbox and initializes the indenter selected by \a indenterID. + */ +void IndentHandler::setIndenter(int indenterID) +{ + TQApplication::setOverrideCursor(TQt::WaitCursor); + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + disconnect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, + SLOT(updateDrawing())); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS + + // Generate the parameter string that will be saved to the indenters config file. + TQString parameterString = getParameterString(); + if (!_indenterFileName.isEmpty()) + { + saveConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString); + } + + // Take care if the selected indenterID is smaller or greater than the number of existing + // indenters + if (indenterID < 0) + { + indenterID = 0; + } + if (indenterID >= _indenterIniFileList.count()) + { + indenterID = _indenterIniFileList.count() - 1; + } + + // remove all pages from the toolbox + for (int i = 0; i < _indenterParameterCategoriesToolBox->count(); i++) + { + _indenterParameterCategoriesToolBox->removeItem(i); + } + + // delete all toolbox pages and by this its children + foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) + { + delete categoryPage.widget; + } + + // empty all lists, which stored infos for the toolbox pages and its widgets + _indenterParameterCategoryPages.clear(); + _paramStrings.clear(); + _paramNumerics.clear(); + _paramBooleans.clear(); + _paramMultiples.clear(); + delete _indenterSettings; + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + TQWidget dummyWidget; + _indenterParameterCategoriesToolBox->addItem(&dummyWidget, "dummyText"); +#endif + + readIndentIniFile(_indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID)); + + // Find out how the indenter can be executed. + createIndenterCallString(); + + // Load the users last settings made for this indenter. + loadConfigFile(_settingsDirctoryStr + "/" + _indenterFileName + ".cfg"); + + handleChangedIndenterSettings(); + + TQApplication::restoreOverrideCursor(); + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect(_indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, + SLOT(updateDrawing())); + _indenterParameterCategoriesToolBox->removeItem(_indenterParameterCategoriesToolBox->indexOf(& + dummyWidget)); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS +} + +/*! + \brief Returns a string containing by the indenter supported file types/extensions divided by a space. + */ +TQString IndentHandler::getPossibleIndenterFileExtensions() +{ + return _fileTypes; +} + +/*! + \brief Returns the path and filename of the current indenter config file. + */ +TQString IndentHandler::getIndenterCfgFile() +{ + TQFileInfo fileInfo(_indenterDirctoryStr + "/" + _globalConfigFilename); + return fileInfo.absoluteFilePath(); +} + +/*! + \brief Tries to create a call path string for the indenter executable. If successful returns true. + */ +bool IndentHandler::createIndenterCallString() +{ + TQProcess indentProcess; + + if (_indenterFileName.isEmpty()) + { + return false; + } + + // First try to call the indenter inside of the data dir, using some suffix + // ------------------------------------------------------------------------ + + // Set the directory for the indenter execution + indentProcess.setWorkingDirectory(TQFileInfo(_indenterDirctoryStr).absoluteFilePath()); + + foreach(TQString suffix, TQStringList() << "" << ".exe" << ".bat" << ".com" << ".sh") + { + _indenterExecutableSuffix = suffix; + _indenterExecutableCallString = TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + + _indenterFileName; + _indenterExecutableCallString += suffix; + + // Only try to call the indenter, if the file exists. + if (TQFile::exists(_indenterExecutableCallString)) + { + // Only try to call the indenter directly if it is no php file + if (TQFileInfo(_indenterExecutableCallString).suffix().toLower() != "php") + { + indentProcess.start( + "\"" + _indenterExecutableCallString + +"\" " + _indenterShowHelpParameter); + if (indentProcess.waitForFinished(2000)) + { + _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\""; + return true; + } + else if (indentProcess.error() == TQProcess::Timedout) + { + _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\""; + return true; + } + } + + // Test for needed interpreters + // ---------------------------- + // If the file could not be executed, try to find a shebang at its start or test if its a php + // file. + TQString interpreterName = ""; + TQFile indenterExecutable(_indenterExecutableCallString); + + // If indenter executable file has .php as suffix, use php as default interpreter + if (TQFileInfo(_indenterExecutableCallString).suffix().toLower() == "php") + { + interpreterName = "php -f"; + } + // Else try to open the file and read the shebang. + else if (indenterExecutable.open(TQFile::ReadOnly)) + { + // Read the first line of the file. + TQTextStream indenterExecutableContent(&indenterExecutable); + TQString firstLineOfIndenterExe = indenterExecutableContent.readLine(75); + indenterExecutable.close(); + + // If the initial shebang is found, read the named intepreter. e.g. perl + if (firstLineOfIndenterExe.startsWith("#!")) + { + // Get the rightmost word. by splitting the string into only full words. + interpreterName = firstLineOfIndenterExe.split("/").last(); + } + } + + // Try to call the interpreter, if it exists. + if (!interpreterName.isEmpty()) + { + _indenterExecutableCallString = interpreterName + " \"" + _indenterExecutableCallString + + "\""; + indentProcess.start(interpreterName + " -h"); + if (indentProcess.waitForFinished(2000)) + { + return true; + } + else if (indentProcess.error() == TQProcess::Timedout) + { + return true; + } + // now we know an interpreter is needed but it could not be called, so inform the user. + else + { + _errorMessageDialog->showMessage(tr("Interpreter needed"), tr( + "To use the selected indenter the program \"%1\" needs to be available in the global environment. You should add an entry to your path settings.").arg( + interpreterName)); + return true; + } + } + } + } + + // If unsuccessful try if the indenter executable is a JavaScript file + // ------------------------------------------------------------------- + _indenterExecutableSuffix = ".js"; + _indenterExecutableCallString = TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + + _indenterFileName; + _indenterExecutableCallString += _indenterExecutableSuffix; + if (TQFile::exists(_indenterExecutableCallString)) + { + return true; + } + + // If unsuccessful try to call the indenter global, using some suffix + // ------------------------------------------------------------------ + foreach(TQString suffix, TQStringList() << "" << ".exe" << ".bat" << ".com" << ".sh") + { + _indenterExecutableSuffix = suffix; + _indenterExecutableCallString = _indenterFileName + suffix; + indentProcess.start(_indenterExecutableCallString + " " + _indenterShowHelpParameter); + if (indentProcess.waitForFinished(2000)) + { + return true; + } + else if (indentProcess.error() == TQProcess::Timedout) + { + return true; + } + } + + // If even globally calling the indenter fails, try calling .com and .exe via wine + // ------------------------------------------------------------------------------- + _indenterExecutableCallString = "\"" + TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + + _indenterFileName; + + foreach(TQString suffix, TQStringList() << ".exe" << ".com") + { + _indenterExecutableSuffix = suffix; + if (TQFile::exists(_indenterDirctoryStr + "/" + _indenterFileName + suffix)) + { + TQProcess wineTestProcess; + wineTestProcess.start("wine --version"); + // if the process of wine was not callable assume that wine is not installed + if (!wineTestProcess.waitForFinished(2000)) + { + _errorMessageDialog->showMessage(tr("wine not installed"), tr( + "There exists only a win32 executable of the indenter and wine does not seem to be installed. Please install wine to be able to run the indenter.")); + _indenterExecutableCallString = ""; + return false; + } + else + { + _indenterExecutableCallString = "\"" + + TQFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/"; + _indenterExecutableCallString += _indenterFileName + suffix + "\""; + _indenterExecutableCallString = "wine " + _indenterExecutableCallString; + + return true; + } + } + } + + _indenterExecutableCallString = ""; + _indenterExecutableSuffix = ""; + return false; +} + +/*! + \brief Returns a string that points to where the indenters manual can be found. + */ +TQString IndentHandler::getManual() +{ + if (_indenterSettings != NULL) + { + return _indenterSettings->value("header/manual").toString(); + } + else + { + return ""; + } +} + +/*! + \brief This slot gets the reference to the indenters manual and opens it. + */ +void IndentHandler::showIndenterManual() +{ + TQString manualReference = getManual(); + TQDesktopServices::openUrl(manualReference); +} + +/*! + \brief Can be called to update all widgets text to the currently selected language. + */ +void IndentHandler::retranslateUi() +{ + _indenterSelectionCombobox->setToolTip(tr( + "

Shows the currently chosen indenters name and lets you choose other available indenters

")); + _indenterParameterHelpButton->setToolTip(tr( + "Brings you to the online manual of the currently selected indenter, where you can get further help on the possible parameters.")); + + _actionLoadIndenterConfigFile->setText(TQApplication::translate("IndentHandler", + "Load Indenter Config File", 0, TQApplication::UnicodeUTF8)); + _actionLoadIndenterConfigFile->setStatusTip(TQApplication::translate("IndentHandler", + "Opens a file dialog to load the original config file of the indenter.", 0, + TQApplication::UnicodeUTF8)); + _actionLoadIndenterConfigFile->setShortcut(TQApplication::translate("IndentHandler", "Alt+O", 0, + TQApplication::UnicodeUTF8)); + + _actionSaveIndenterConfigFile->setText(TQApplication::translate("IndentHandler", + "Save Indenter Config File", 0, TQApplication::UnicodeUTF8)); + _actionSaveIndenterConfigFile->setStatusTip(TQApplication::translate("IndentHandler", + "Opens a dialog to save the current indenter configuration to a file.", 0, + TQApplication::UnicodeUTF8)); + _actionSaveIndenterConfigFile->setShortcut(TQApplication::translate("IndentHandler", "Alt+S", 0, + TQApplication::UnicodeUTF8)); + + _actionCreateShellScript->setText(TQApplication::translate("IndentHandler", + "Create Indenter Call Shell Script", 0, TQApplication::UnicodeUTF8)); + _actionCreateShellScript->setToolTip(TQApplication::translate("IndentHandler", + "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", + 0, TQApplication::UnicodeUTF8)); + _actionCreateShellScript->setStatusTip(TQApplication::translate("IndentHandler", + "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", + 0, TQApplication::UnicodeUTF8)); + + _actionResetIndenterParameters->setText(TQApplication::translate("IndentHandler", + "Reset indenter parameters", 0, TQApplication::UnicodeUTF8)); + _actionResetIndenterParameters->setToolTip(TQApplication::translate("IndentHandler", + "Resets all indenter parameters to the default values.", 0, TQApplication::UnicodeUTF8)); + _actionResetIndenterParameters->setStatusTip(TQApplication::translate("IndentHandler", + "Resets all indenter parameters to the default values.", 0, TQApplication::UnicodeUTF8)); +} + +/*! + \brief Returns the name of the currently selected indenter. + */ +TQString IndentHandler::getCurrentIndenterName() +{ + TQString currentIndenterName = _indenterSelectionCombobox->currentText(); + + // Remove the supported programming languages from indenters name, which are set in braces. + if (currentIndenterName.indexOf("(") > 0) + { + // Using index-1 to also leave out the blank before the brace. + currentIndenterName = currentIndenterName.left(currentIndenterName.indexOf("(") - 1); + } + + return currentIndenterName; +} + +/*! + \brief Shows a file open dialog to open an existing config file for the currently selected indenter. + + If the file was successfully opened the indent handler is called to load the settings and update itself. +*/ +void IndentHandler::openConfigFileDialog() +{ + TQString configFilePath; + + configFilePath = TQFileDialog::getOpenFileName(NULL, tr( + "Choose indenter config file"), getIndenterCfgFile(), "All files (*.*)"); + + if (configFilePath != "") + { + // If the config file was loaded successfully, inform any who is interested about it. + if (loadConfigFile(configFilePath)) + { + handleChangedIndenterSettings(); + } + } +} + +/*! + \brief Calls the indenter config file save as dialog to save the config file under a chosen name. + + If the file already exists and it should be overwritten, a warning is shown before. +*/ +void IndentHandler::saveasIndentCfgFileDialog() +{ + TQString fileExtensions = tr("All files") + " (*.*)"; + + //TQString openedSourceFileContent = openFileDialog( tr("Choose source code file"), "./", + // fileExtensions ); + TQString fileName = TQFileDialog::getSaveFileName(this, tr( + "Save indent config file"), getIndenterCfgFile(), fileExtensions); + + if (fileName != "") + { + TQFile::remove(fileName); + TQFile outCfgFile(fileName); + outCfgFile.open(TQFile::ReadWrite | TQFile::Text); + outCfgFile.write(getParameterString().toAscii()); + outCfgFile.close(); + } +} + +/*! + \brief Invokes the indenter to create a shell script. + + Lets the indenter create a shell script for calling the indenter out of any + other application and open a save dialog for saving the shell script. +*/ +void IndentHandler::createIndenterCallShellScript() +{ + TQString shellScriptExtension; +#if defined (Q_OS_WIN32) + shellScriptExtension = "bat"; +#else + shellScriptExtension = "sh"; +#endif + + TQString fileExtensions = tr("Shell Script") + " (*." + shellScriptExtension + ");;" + tr( + "All files") + " (*.*)"; + + TQString currentIndenterName = getCurrentIndenterName(); + currentIndenterName = currentIndenterName.replace(" ", "_"); + + TQString shellScriptFileName = TQFileDialog::getSaveFileName(this, tr( + "Save shell script"), "call_" + currentIndenterName + "." + shellScriptExtension, + fileExtensions); + + // Saving has been canceled if the filename is empty + if (shellScriptFileName.isEmpty()) + { + return; + } + + // Delete any old file, write the new contents and set executable permissions. + TQFile::remove(shellScriptFileName); + TQFile outSrcFile(shellScriptFileName); + if (outSrcFile.open(TQFile::ReadWrite | TQFile::Text)) + { + TQString shellScriptConfigFilename = TQFileInfo(shellScriptFileName).baseName() + "." + + TQFileInfo(_globalConfigFilename).suffix(); + + // Get the content of the shell/batch script. + TQString indenterCallShellScript = generateShellScript(shellScriptConfigFilename); + + // Replace placeholder for script name in script template. + indenterCallShellScript = indenterCallShellScript.replace("__INDENTERCALLSTRINGSCRIPTNAME__", TQFileInfo( + shellScriptFileName).fileName()); + + outSrcFile.write(indenterCallShellScript.toAscii()); +#if !defined (Q_OS_WIN32) + // For none Windows systems set the files executable flag + outSrcFile.setPermissions( + outSrcFile.permissions() | TQFile::ExeOwner | TQFile::ExeUser | TQFile::ExeGroup); +#endif + outSrcFile.close(); + + // Save the indenter config file to the same directory, where the shell srcipt was saved to, + // because the script will reference it there via "./". + if (!_globalConfigFilename.isEmpty()) + { + saveConfigFile(TQFileInfo( + shellScriptFileName).path() + "/" + shellScriptConfigFilename, + getParameterString()); + } + } +} + +/*! + \brief Resets all parameters to the indenters default values as they are specified in the uigui ini file + but asks the user whether to do it really. + */ +void IndentHandler::resetIndenterParameter() +{ + int messageBoxAnswer = TQMessageBox::question(this, tr("Really reset parameters?"), tr( + "Do you really want to reset the indenter parameters to the default values?"), + TQMessageBox::Yes | TQMessageBox::Abort); + if (messageBoxAnswer == TQMessageBox::Yes) + { + resetToDefaultValues(); + } +} + +/*! + \brief Catch some events and let some other be handled by the super class. + + Is needed for use as Notepad++ plugin. + */ +bool IndentHandler::event(TQEvent *event) +{ + if (event->type() == TQEvent::WindowActivate) + { + event->accept(); + return true; + } + else if (event->type() == TQEvent::WindowDeactivate) + { + event->accept(); + return true; + } + else + { + event->ignore(); + return TQWidget::event(event); + } +} + +/*! + \brief Sets the function pointer \a _parameterChangedCallback to the given callback + function \a paramChangedCallback. + + Is needed for use as Notepad++ plugin. + */ +void IndentHandler::setParameterChangedCallback(void (*paramChangedCallback)(void)) +{ + _parameterChangedCallback = paramChangedCallback; +} + +/*! + \brief Emits the \a indenterSettingsChanged signal and if set executes the \a _parameterChangedCallback function. + + Is needed for use as Notepad++ plugin. + */ +void IndentHandler::handleChangedIndenterSettings() +{ + emit(indenterSettingsChanged()); + + if (_parameterChangedCallback != NULL) + { + _parameterChangedCallback(); + } +} + +/*! + \brief Sets a callback function that shall be called, when the this indenter parameter window gets closed. + + Is needed for use as Notepad++ plugin. + */ +void IndentHandler::setWindowClosedCallback(void (*winClosedCallback)(void)) +{ + _windowClosedCallback = winClosedCallback; +} + +/*! + \brief Is called on this indenter parameter window close and if set calls the function \a _windowClosedCallback. + + Is needed for use as Notepad++ plugin. + */ +void IndentHandler::closeEvent(TQCloseEvent *event) +{ + if (_windowClosedCallback != NULL) + { + _windowClosedCallback(); + } + event->accept(); +} + +/*! + \brief Returns the id (list index) of the currently selected indenter. + */ +int IndentHandler::getIndenterId() +{ + return _indenterSelectionCombobox->currentIndex(); +} + +void IndentHandler::updateDrawing() +{ +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + if (isVisible()) + { + TQRect savedGeometry = geometry(); + setGeometry(savedGeometry.adjusted(0, 0, 0, 1)); + repaint(); + setGeometry(savedGeometry); + } +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS +} + +void IndentHandler::wheelEvent(TQWheelEvent *event) +{ + UNUSED_PARAMETER_WARNING_AVOID(event); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + TQWidget::wheelEvent(event); + updateDrawing(); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS +} + +/*! + \brief Converts characters < > and & in the \a text to HTML codes < > and &. + */ + +//TODO: This function should go into a string helper/tool class/file. +TQString IndentHandler::encodeToHTML(const TQString &text) +{ + TQString htmlText = text; + htmlText.replace("&", "&"); + htmlText.replace("<", "<"); + htmlText.replace(">", ">"); + htmlText.replace('"', """); + htmlText.replace("'", "'"); + htmlText.replace("^", "ˆ"); + htmlText.replace("~", "˜"); + htmlText.replace("€", "€"); + htmlText.replace("©", "©"); + return htmlText; +} diff --git a/src/__TODO/IndentHandler.h b/src/__TODO/IndentHandler.h new file mode 100644 index 0000000..f576518 --- /dev/null +++ b/src/__TODO/IndentHandler.h @@ -0,0 +1,195 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef INDENTHANDLER_H +#define INDENTHANDLER_H + +#include + +class UiGuiErrorMessage; +class UiGuiIniFileParser; + +class TQMenu; +class TQVBoxLayout; +class TQLabel; +class TQSpinBox; +class TQComboBox; +class TQCheckBox; +class TQLineEdit; +class TQToolButton; +class TQToolBox; + + +class IndentHandler : public TQWidget +{ + Q_OBJECT + + public: + IndentHandler(int indenterID, TQWidget *mainWindow = NULL, TQWidget *parent = NULL); + ~IndentHandler(); + + TQString generateShellScript(const TQString &configFilename); + TQString callIndenter(TQString sourceCode, TQString inputFileExtension); + bool loadConfigFile(TQString filePathName); + void resetToDefaultValues(); + TQStringList getAvailableIndenters(); + TQString getPossibleIndenterFileExtensions(); + TQString getParameterString(); + TQString getIndenterCfgFile(); + TQString getManual(); + void retranslateUi(); + TQString getCurrentIndenterName(); + TQMenu* getIndenterMenu(); + TQList getIndenterMenuActions(); + void contextMenuEvent(TQContextMenuEvent *event); + void setParameterChangedCallback(void (*paramChangedCallback)(void)); + void setWindowClosedCallback(void (*winClosedCallback)(void)); + int getIndenterId(); + + signals: + void indenterSettingsChanged(); + void selectedIndenterIndexChanged(int index); + + protected: + bool event(TQEvent *event); + void closeEvent(TQCloseEvent *event); + void wheelEvent(TQWheelEvent *event); + + private slots: + void setIndenter(int indenterID); + void showIndenterManual(); + void openConfigFileDialog(); + void saveasIndentCfgFileDialog(); + void createIndenterCallShellScript(); + void resetIndenterParameter(); + void handleChangedIndenterSettings(); + void updateDrawing(); + + private: + TQString callExecutableIndenter(TQString sourceCode, TQString inputFileExtension); + TQString callJavaScriptIndenter(TQString sourceCode); + void saveConfigFile(TQString filePathName, TQString parameterString); + void readIndentIniFile(TQString iniFilePath); + bool createIndenterCallString(); + void initIndenterMenu(); + + //! Holds a reference to all created pages of the parameter categories toolbox and the pages + // boxlayout + struct IndenterParameterCategoryPage + { + TQWidget *widget; + TQVBoxLayout *vboxLayout; + }; + + TQVector _indenterParameterCategoryPages; + + //! Holds a reference to all checkboxes needed for boolean parameter setting and the parameters + // name + struct ParamBoolean + { + TQString paramName; + TQString trueString; + TQString falseString; + TQCheckBox *checkBox; + }; + + TQVector _paramBooleans; + + //! Holds a reference to all line edits needed for parameter setting and the parameters name + struct ParamString + { + TQString paramName; + TQString paramCallName; + TQCheckBox *valueEnabledChkBox; + TQLineEdit *lineEdit; + TQLabel *label; + }; + + TQVector _paramStrings; + + //! Hold a reference to all spin boxes needed for parameter setting and the parameters name + struct ParamNumeric + { + TQString paramName; + TQString paramCallName; + TQCheckBox *valueEnabledChkBox; + TQSpinBox *spinBox; + TQLabel *label; + }; + + TQVector _paramNumerics; + + //! Hold a reference to all combo boxes needed for parameter setting and the parameters name + struct ParamMultiple + { + TQString paramName; + TQString paramCallName; + TQCheckBox *valueEnabledChkBox; + TQComboBox *comboBox; + TQStringList choicesStrings; + TQStringList choicesStringsReadable; + }; + + TQVector _paramMultiples; + + TQComboBox *_indenterSelectionCombobox; + TQToolButton *_indenterParameterHelpButton; + //! Vertical layout box, into which the toolbox will be added + TQVBoxLayout *_toolBoxContainerLayout; + TQToolBox *_indenterParameterCategoriesToolBox; + UiGuiIniFileParser *_indenterSettings; + TQStringList _indenterParameters; + //! The indenters name in a descriptive form + TQString _indenterName; + //! The indenters file name (w/o extension), that is being called + TQString _indenterFileName; + TQString _indenterDirctoryStr; + TQString _tempDirctoryStr; + TQString _settingsDirctoryStr; + TQStringList _indenterIniFileList; + TQString _parameterOrder; + TQString _globalConfigFilename; + TQString _cfgFileParameterEnding; + TQString _inputFileParameter; + TQString _inputFileName; + TQString _outputFileParameter; + TQString _outputFileName; + TQString _fileTypes; + TQString _useCfgFileParameter; + TQString _indenterShowHelpParameter; + TQWidget *_mainWindow; + UiGuiErrorMessage *_errorMessageDialog; + TQString _indenterExecutableCallString; + TQString _indenterExecutableSuffix; + + TQMenu *_menuIndenter; + TQAction *_actionLoadIndenterConfigFile; + TQAction *_actionSaveIndenterConfigFile; + TQAction *_actionCreateShellScript; + TQAction *_actionResetIndenterParameters; + //! Needed for the NPP plugin. + void (*_parameterChangedCallback)(void); + //! Needed for the NPP plugin. + void (*_windowClosedCallback)(void); + + //TODO: This function should go into a string helper/tool class/file. + TQString encodeToHTML(const TQString &text); +}; + +#endif // INDENTHANDLER_H diff --git a/src/__TODO/MainWindow.ui b/src/__TODO/MainWindow.ui new file mode 100755 index 0000000..6377823 --- /dev/null +++ b/src/__TODO/MainWindow.ui @@ -0,0 +1,157 @@ + + Thomas_-_S + MainWindowUi + + + MainWindowUi + + + + + 6 + + + 0 + + + + + 0 + + + 2 + + + + + + + + + + 0 + 0 + + + + TQDockWidget::DockWidgetFloatable|TQDockWidget::DockWidgetMovable + + + TQt::LeftDockWidgetArea|TQt::RightDockWidgetArea + + + Indenter Settings + + + 1 + + + + + 6 + + + 0 + + + + + 0 + + + 0 + + + + + + + + + TQt::PreventContextMenu + + + Main Toolbar + + + TQt::Horizontal + + + + 16 + 16 + + + + TQt::ToolButtonTextBesideIcon + + + TopToolBarArea + + + false + + + + + + + + :/mainWindow/document-save-as.png:/mainWindow/document-save-as.png + + + Save Source File As... + + + Save Source File As... + + + Save Source File As... + + + Opens a file dialog to save the currently shown source code. + + + Ctrl+Shift+S + + + + + + :/mainWindow/system-software-update.png:/mainWindow/system-software-update.png + + + Check for update + + + Checks online whether a new version of UniversalIndentGUI is available. + + + Checks online whether a new version of UniversalIndentGUI is available. + + + + + + + + + + + actionExit + triggered() + MainWindowUi + close() + + + -1 + -1 + + + 399 + 299 + + + + + diff --git a/src/__TODO/SettingsPaths.cpp b/src/__TODO/SettingsPaths.cpp new file mode 100644 index 0000000..a8016f7 --- /dev/null +++ b/src/__TODO/SettingsPaths.cpp @@ -0,0 +1,309 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "SettingsPaths.h" + +#include +#include +#include +#include +#include +#include + +#include + +//! \defgroup grp_Settings All concerning applications settings. + +/*! + \class SettingsPaths + \ingroup grp_Settings + \brief SettingsPaths is a pure static functions class from which info about the + paths needed for settings can be retrieved. +*/ + +bool SettingsPaths::_alreadyInitialized = false; +TQString SettingsPaths::_applicationBinaryPath = ""; +TQString SettingsPaths::_settingsPath = ""; +TQString SettingsPaths::_globalFilesPath = ""; +TQString SettingsPaths::_indenterPath = ""; +TQString SettingsPaths::_tempPath = ""; +bool SettingsPaths::_portableMode = false; + +/*! + \brief Initializes all available information about the paths. + + Mainly during this init it is detected whether to start in portable mode or not. This is + done by testing whether the directory "config" is in the same directory as this + applications executable file. + In portable mode all data is ONLY written to subdirectories of the applications executable file. + Means also that the directory "indenters" has to be there. + In not portable mode (multiuser mode) only users home directory is used for writing config data. + */ +void SettingsPaths::init() +{ + _alreadyInitialized = true; + + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths."; + + // Get the applications binary path, with respect to MacOSXs use of the .app folder. + _applicationBinaryPath = TQCoreApplication::applicationDirPath(); + // Remove any trailing slashes + while (_applicationBinaryPath.right(1) == "/") + { + _applicationBinaryPath.chop(1); + } + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + _applicationBinaryPath += "/plugins/uigui"; +#endif + +#ifdef Q_OS_MAC + // Because on Mac universal binaries are used, the binary path is not equal + // to the applications (.app) path. So get the .apps path here. + int indexOfDotApp = _applicationBinaryPath.indexOf(".app"); + if (indexOfDotApp != -1) + { + // Cut off after the dot of ".app". + _applicationBinaryPath = _applicationBinaryPath.left(indexOfDotApp - 1); + // Cut off after the first slash that was in front of ".app" (normally this is the word + // "UniversalIndentGUI") + _applicationBinaryPath = _applicationBinaryPath.left(_applicationBinaryPath.lastIndexOf("/")); + } +#endif + + // If the "config" directory is a subdir of the applications binary path, use this one (portable + // mode) + _settingsPath = _applicationBinaryPath + "/config"; + if (TQFile::exists(_settingsPath)) + { + _portableMode = true; + TQDir dirCreator; + _globalFilesPath = _applicationBinaryPath; + _indenterPath = _applicationBinaryPath + "/indenters"; + dirCreator.mkpath(_settingsPath); + _tempPath = _applicationBinaryPath + "/temp"; + //TODO: If the portable drive has write protection, use local temp path and clean it up on exit. + dirCreator.mkpath(_tempPath); + } + // ... otherwise use the system specific global application data path. + else + { + _portableMode = false; + TQDir dirCreator; +#ifdef Q_OS_WIN + // Get the local users application settings directory. + // Remove any trailing slashes. + _settingsPath = TQDir::fromNativeSeparators(qgetenv("APPDATA")); + while (_settingsPath.right(1) == "/") + { + _settingsPath.chop(1); + } + _settingsPath = _settingsPath + "/UniversalIndentGUI"; + + // On windows systems the directories "indenters", "translations" are subdirs of the + // _applicationBinaryPath. + _globalFilesPath = _applicationBinaryPath; +#else + // Remove any trailing slashes. + _settingsPath = TQDir::homePath(); + while (_settingsPath.right(1) == "/") + { + _settingsPath.chop(1); + } + _settingsPath = _settingsPath + "/.universalindentgui"; + _globalFilesPath = "/usr/share/universalindentgui"; +#endif + dirCreator.mkpath(_settingsPath); + // If a highlighter config file does not exist in the users home config dir + // copy the default config file over there. + if (!TQFile::exists(_settingsPath + "/UiGuiSyntaxHighlightConfig.ini")) + { + TQFile::copy(_globalFilesPath + "/config/UiGuiSyntaxHighlightConfig.ini", + _settingsPath + "/UiGuiSyntaxHighlightConfig.ini"); + } + _indenterPath = _globalFilesPath + "/indenters"; + + // On different systems it may be that "TQDir::tempPath()" ends with a "/" or not. So check + // this. + // Remove any trailing slashes. + _tempPath = TQDir::tempPath(); + while (_tempPath.right(1) == "/") + { + _tempPath.chop(1); + } + _tempPath = _tempPath + "/UniversalIndentGUI"; + +#if defined (Q_OS_WIN32) + dirCreator.mkpath(_tempPath); +#else + // On Unix based systems create a random temporary directory for security + // reasons. Otherwise an evil human being could create a symbolic link + // to an important existing file which gets overwritten when UiGUI writes + // into this normally temporary but linked file. + char *pathTemplate = new char[_tempPath.length() + 8]; + TQByteArray pathTemplateTQBA = TQString(_tempPath + "-XXXXXX").toAscii(); + delete[] pathTemplate; + pathTemplate = pathTemplateTQBA.data(); + pathTemplate = mkdtemp(pathTemplate); + _tempPath = pathTemplate; +#endif + } + + tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \ + "
  • _applicationBinaryPath=" << + _applicationBinaryPath << "
  • _settingsPath=" << _settingsPath << + "
  • _globalFilesPath=" << _globalFilesPath << "
  • _indenterPath=" << + _indenterPath << "
  • _tempPath=" << _tempPath << + "
  • Running in portable mode=" << _portableMode << "
"; +} + +/*! + \brief Returns the path of the applications executable. + */ +const TQString SettingsPaths::getApplicationBinaryPath() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _applicationBinaryPath; +} + +/*! + \brief Returns the path where all settings are being/should be written to. + */ +const TQString SettingsPaths::getSettingsPath() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _settingsPath; +} + +/*! + \brief Returns the path where the files concerning all users reside. For example translations. + */ +const TQString SettingsPaths::getGlobalFilesPath() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _globalFilesPath; +} + +/*! + \brief Returns the path where the indenter executables reside. + */ +const TQString SettingsPaths::getIndenterPath() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _indenterPath; +} + +/*! + \brief Returns the path where the where all temporary data should be written to. + */ +const TQString SettingsPaths::getTempPath() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _tempPath; +} + +/*! + \brief Returns true if portable mode shall be used. + */ +bool SettingsPaths::getPortableMode() +{ + if (!_alreadyInitialized) + { + SettingsPaths::init(); + } + return _portableMode; +} + +/*! + \brief Completely deletes the created temporary directory with all of its content. + */ +void SettingsPaths::cleanAndRemoveTempDir() +{ + TQDirIterator dirIterator(_tempPath, TQDirIterator::Subdirectories); + TQStack directoryStack; + bool noErrorsOccurred = true; + + while (dirIterator.hasNext()) + { + TQString currentDirOrFile = dirIterator.next(); + // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow + // fails. + dirIterator.fileInfo(); + + if (!currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && + dirIterator.fileName() != "..") + { + // There is a path on the stack but the current path doesn't start with that path. + // So we changed into another parent directory and the one on the stack can be deleted + // since it must be empty. + if (!directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top())) + { + TQString dirToBeRemoved = directoryStack.pop(); + bool couldRemoveDir = TQDir(dirToBeRemoved).rmdir(dirToBeRemoved); + noErrorsOccurred &= couldRemoveDir; + if (couldRemoveDir == false) + { + tqWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << + dirToBeRemoved; + } + //tqDebug() << "Removing Dir " << directoryStack.pop(); + } + + // If the iterator currently points to a directory push it onto the stack. + if (dirIterator.fileInfo().isDir()) + { + directoryStack.push(currentDirOrFile); + //tqDebug() << "Pushing onto Stack " << currentDirOrFile; + } + // otherwise it must be a file, so delete it. + else + { + bool couldRemoveFile = TQFile::remove(currentDirOrFile); + noErrorsOccurred &= couldRemoveFile; + if (couldRemoveFile == false) + { + tqWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << + currentDirOrFile; + } + //tqDebug() << "Removing File " << currentDirOrFile; + } + } + } + noErrorsOccurred &= TQDir(_tempPath).rmdir(_tempPath); + if (noErrorsOccurred == false) + { + tqWarning() << __LINE__ << " " << __FUNCTION__ << + "While cleaning up the temp dir an error occurred."; + } +} diff --git a/src/__TODO/SettingsPaths.h b/src/__TODO/SettingsPaths.h new file mode 100644 index 0000000..92d1d52 --- /dev/null +++ b/src/__TODO/SettingsPaths.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef SETTINGSPATHS_H +#define SETTINGSPATHS_H + +class TQString; + + +class SettingsPaths +{ + public: + static void init(); + static const TQString getApplicationBinaryPath(); + static const TQString getSettingsPath(); + static const TQString getGlobalFilesPath(); + static const TQString getIndenterPath(); + static const TQString getTempPath(); + static bool getPortableMode(); + static void cleanAndRemoveTempDir(); + + private: + SettingsPaths(); + + static bool _alreadyInitialized; + static TQString _applicationBinaryPath; + static TQString _settingsPath; + static TQString _globalFilesPath; + static TQString _indenterPath; + static TQString _tempPath; + static bool _portableMode; +}; + +#endif // SETTINGSPATHS_H diff --git a/src/__TODO/TemplateBatchScript.cpp b/src/__TODO/TemplateBatchScript.cpp new file mode 100644 index 0000000..0650cb4 --- /dev/null +++ b/src/__TODO/TemplateBatchScript.cpp @@ -0,0 +1,171 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "TemplateBatchScript.h" + +// Need to include TQObject here so that platform specific defines like Q_OS_WIN32 are set. +#include + +/*! + \brief The only and static function of this class returns a batch or shell script + as string that can be used to call an indenter with the current settings from + the command line. + + The returned string contains some placeholders where the indenter name needs to + be filled in. The placeholders are "__INDENTERCALLSTRING1__" that should be replaced + by the indenter call string that indents a complete directory. + "__INDENTERCALLSTRING2__" the call string for indenting only one file. + And "__INDENTERCALLSTRINGSCRIPTNAME__" which is only the shown name of the indenter. + */ +const char* TemplateBatchScript::getTemplateBatchScript() +{ + static const char *templateBatchScript = +#if defined (Q_OS_WIN32) + "@echo off\n" + "\n" + "IF (%1)==() GOTO error\n" + "dir /b /ad %1 >nul 2>nul && GOTO indentDir\n" + "IF NOT EXIST %1 GOTO error\n" + "goto indentFile\n" + "\n" + ":indentDir\n" + "set searchdir=%1\n" + "\n" + "IF (%2)==() GOTO assignDefaultSuffix\n" + "set filesuffix=%2\n" + "\n" + "GOTO run\n" + "\n" + ":assignDefaultSuffix\n" + "::echo !!!!DEFAULT SUFFIX!!!\n" + "set filesuffix=*\n" + "\n" + ":run\n" + "FOR /F \"tokens=*\" %%G IN ('DIR /B /S %searchdir%\\*.%filesuffix%') DO (\n" + "echo Indenting file \"%%G\"\n" + "__INDENTERCALLSTRING1__\n" + ")\n" + "GOTO ende\n" + "\n" + ":indentFile\n" + "echo Indenting one file %1\n" + "__INDENTERCALLSTRING2__\n" + "\n" + "GOTO ende\n" + "\n" + ":error\n" + "echo .\n" + "echo ERROR: As parameter given directory or file does not exist!\n" + "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\n" + "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\n" + "echo Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\n" + "echo .\n" + "\n" + ":ende\n"; + +#else + + "#!/bin/sh \n" + "\n" + "if [ ! -n \"$1\" ]; then\n" + "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" + "echo \"Syntax is: recurse.sh filename\"\n" + "echo \"Example: recurse.sh temp cpp\"\n" + "exit 1\n" + "fi\n" + "\n" + "if [ -d \"$1\" ]; then\n" + "#echo \"Dir ${1} exists\"\n" + "if [ -n \"$2\" ]; then\n" + "filesuffix=$2\n" + "else\n" + "filesuffix=\"*\"\n" + "fi\n" + "\n" + "#echo \"Filtering files using suffix ${filesuffix}\"\n" + "\n" + "file_list=`find ${1} -name \"*.${filesuffix}\" -type f`\n" + "for file2indent in $file_list\n" + "do \n" + "echo \"Indenting file $file2indent\"\n" + "__INDENTERCALLSTRING1__\n" + "done\n" + "else\n" + "if [ -f \"$1\" ]; then\n" + "echo \"Indenting one file $1\"\n" + "__INDENTERCALLSTRING2__\n" + "else\n" + "echo \"ERROR: As parameter given directory or file does not exist!\"\n" + "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\"\n" + "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\"\n" + "echo \"Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\"\n" + "exit 1\n" + "fi\n" + "fi\n"; +#endif // #if defined(Q_OS_WIN32) + return templateBatchScript; +} + +/* Here comes the original batch script without the c++ markup +@echo off + +IF (%1)==() GOTO error +dir /b /ad %1 >nul 2>nul && GOTO indentDir +IF NOT EXIST %1 GOTO error +goto indentFile + +:indentDir +set searchdir=%1 + +IF (%2)==() GOTO assignDefaultSuffix +set filesuffix=%2 + +GOTO run + +:assignDefaultSuffix +::echo !!!!DEFAULT SUFFIX!!! +set filesuffix=* + +:run +FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO ( + echo Indenting file "%%G" + ::call call_CSSTidy.bat "%%G" + "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" "%%G" --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css + move /Y indentoutput.css "%%G" +) +GOTO ende + +:indentFile +echo Indenting one file %1 +"C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" %1 --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css +move /Y indentoutput.css %1 + +GOTO ende + +:error +echo . +echo ERROR: As parameter given directory or file does not exist! +echo Syntax is: recurse.bat dirname filesuffix +echo Syntax is: recurse.bat filename +echo Example: recurse.bat temp cpp +echo . + +:ende + +*/ diff --git a/src/__TODO/TemplateBatchScript.h b/src/__TODO/TemplateBatchScript.h new file mode 100644 index 0000000..6384ff0 --- /dev/null +++ b/src/__TODO/TemplateBatchScript.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef TEMPLATEBATCHSCRIPT_H +#define TEMPLATEBATCHSCRIPT_H + +class TemplateBatchScript +{ + private: + TemplateBatchScript(); + + public: + static const char* getTemplateBatchScript(); +}; + +#endif // TEMPLATEBATCHSCRIPT_H diff --git a/src/__TODO/ToolBarWidget.ui b/src/__TODO/ToolBarWidget.ui new file mode 100755 index 0000000..8665cac --- /dev/null +++ b/src/__TODO/ToolBarWidget.ui @@ -0,0 +1,124 @@ + + + ToolBarWidget + + + + 0 + 0 + 773 + 34 + + + + Form + + + + 6 + + + 0 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Opens a dialog for selecting a source code file.</span></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">This file will be used to show what the indent tool changes.</p></body></html> + + + Open Source File + + + + :/mainWindow/document-open.png:/mainWindow/document-open.png + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Turns the preview of the reformatted source code on and off.</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">In other words it switches between formatted and nonformatted code. (Ctrl+L)</p></body></html> + + + Live Indent Preview + + + + :/mainWindow/live-preview.png:/mainWindow/live-preview.png + + + Ctrl+L + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Enables and disables the highlightning of the source</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">code shown below. (Still needs some performance improvements) (Ctrl+H)</p></body></html> + + + Syntax Highlight + + + + :/mainWindow/syntax-highlight.png:/mainWindow/syntax-highlight.png + + + Ctrl+H + + + true + + + DONOTTRANSLATE:SyntaxHighlightingEnabled + + + + + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Shows info about UniversalIndentGUI</p></body></html> + + + About + + + + :/mainWindow/info.png:/mainWindow/info.png + + + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Quits the UniversalIndentGUI</p></body></html> + + + Exit + + + + :/mainWindow/system-log-out.png:/mainWindow/system-log-out.png + + + + + + + + + + diff --git a/src/__TODO/UiGuiErrorMessage.cpp b/src/__TODO/UiGuiErrorMessage.cpp new file mode 100644 index 0000000..67e8e0c --- /dev/null +++ b/src/__TODO/UiGuiErrorMessage.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UiGuiErrorMessage.h" + +#include + +/*! + \class UiGuiErrorMessage + \ingroup grp_Dialogs + \brief UiGuiErrorMessage is a child of TQErrorMessage. But TQErrorMessages + "Do not show again" didn't work with my strings, so this is my own, working + implementation of it. +*/ + + +/*! + \brief Initializes the dialog. + + Retrieves the object pointer to the \a _showAgainCheckBox check box, sets the dialogs + modality and for a working translation sets the check box text. + */ +UiGuiErrorMessage::UiGuiErrorMessage(TQWidget *parent) : + TQErrorMessage(parent) +{ + _showAgainCheckBox = findChild(); + setWindowModality(TQt::ApplicationModal); + _showAgainCheckBox->setText(tr("Show this message again")); +} + +/*! + \brief Just a lazy nothin doin destructive destructor. + */ +UiGuiErrorMessage::~UiGuiErrorMessage(void) +{ +} + +/*! + \brief Shows an error \a message in a dialog box with \a title. + + The shown \a message is added to a list, if not already in there. If it is + already in that list and "Show this message again" is not checked, that + message will not be shown. + */ +void UiGuiErrorMessage::showMessage(const TQString &title, const TQString &message) +{ + bool showAgain = true; + + if (_showAgainCheckBox != 0) + { + showAgain = _showAgainCheckBox->isChecked(); + } + + setWindowTitle(title); + + if (!_errorMessageList.contains(message)) + { + _errorMessageList << message; + if (_showAgainCheckBox != 0) + { + _showAgainCheckBox->setChecked(true); + } + TQErrorMessage::showMessage(message); + } + else if (showAgain) + { + TQErrorMessage::showMessage(message); + } +} + +/*! + \brief For convinience, for showing a dialog box with the default title "UniversalIndentGUI". + */ +void UiGuiErrorMessage::showMessage(const TQString &message) +{ + showMessage("UniversalIndentGUI", message); +} diff --git a/src/__TODO/UiGuiErrorMessage.h b/src/__TODO/UiGuiErrorMessage.h new file mode 100644 index 0000000..0ad9f70 --- /dev/null +++ b/src/__TODO/UiGuiErrorMessage.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UIGUIERRORMESSAGE_H +#define UIGUIERRORMESSAGE_H + +#include + +class TQCheckBox; + + +class UiGuiErrorMessage : public TQErrorMessage +{ + Q_OBJECT + + public: + UiGuiErrorMessage(TQWidget *parent = 0); + ~UiGuiErrorMessage(void); + + void showMessage(const TQString &message); + void showMessage(const TQString &title, const TQString &message); + + private: + TQCheckBox *_showAgainCheckBox; + TQStringList _errorMessageList; +}; + +#endif // UIGUIERRORMESSAGE_H diff --git a/src/__TODO/UiGuiHighlighter.cpp b/src/__TODO/UiGuiHighlighter.cpp new file mode 100644 index 0000000..7ee13e8 --- /dev/null +++ b/src/__TODO/UiGuiHighlighter.cpp @@ -0,0 +1,604 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UiGuiHighlighter.h" + +#include "SettingsPaths.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (TQSCINTILLA_VERSION >= 0x020300) + #include + #include +#endif +#include +#include +#include +#include +#include +#include +#if (TQSCINTILLA_VERSION >= 0x020300) + #include +#endif +#include +#if (TQSCINTILLA_VERSION >= 0x020300) + #include +#endif +#include +#include +#include +#include +#if (TQSCINTILLA_VERSION >= 0x020400) + #include +#endif +#include +#if (TQSCINTILLA_VERSION >= 0x020300) + #include +#endif +#include +#if (TQSCINTILLA_VERSION >= 0x020400) + #include +#endif +#include +#if (TQSCINTILLA_VERSION >= 0x020300) + #include + #include +#endif + +//! \defgroup grp_EditorComponent All concerning editor widget. + +/*! + \class UiGuiHighlighter + \ingroup grp_EditorComponent + \brief UiGuiHighlighter used for selecting the syntax highlighter/lexer for the QsciScintilla component. +*/ + +/*! + \brief The constructor initializes some regular expressions and keywords to identify cpp tokens + */ +UiGuiHighlighter::UiGuiHighlighter(QsciScintilla *parent) : + TQObject(parent) +{ + _qsciEditorParent = parent; + + // Create the highlighter _settings object from the UiGuiSyntaxHighlightConfig.ini file. + _settings = new TQSettings( + SettingsPaths::getSettingsPath() + "/UiGuiSyntaxHighlightConfig.ini", TQSettings::IniFormat, + this); + + _highlightningIsOn = true; + + _mapHighlighternameToExtension["Bash"] = TQStringList() << "sh"; + _mapHighlighternameToExtension["Batch"] = TQStringList() << "bat"; + _mapHighlighternameToExtension["CMake"] = TQStringList() << "cmake"; + _mapHighlighternameToExtension["C++"] = TQStringList() << "c" << "h" << "cpp" << "hpp" << + "cxx" << "hxx"; + _mapHighlighternameToExtension["C#"] = TQStringList() << "cs"; + _mapHighlighternameToExtension["CSS"] = TQStringList() << "css"; + _mapHighlighternameToExtension["D"] = TQStringList() << "d"; + _mapHighlighternameToExtension["Diff"] = TQStringList() << "diff"; +#if (TQSCINTILLA_VERSION >= 0x020300) + _mapHighlighternameToExtension["Fortran"] = TQStringList() << "f" << "for" << "f90"; + _mapHighlighternameToExtension["Fortran77"] = TQStringList() << "f77"; +#endif + _mapHighlighternameToExtension["HTML"] = TQStringList() << "html" << "htm"; + _mapHighlighternameToExtension["IDL"] = TQStringList() << "idl"; + _mapHighlighternameToExtension["Java"] = TQStringList() << "java"; + _mapHighlighternameToExtension["JavaScript"] = TQStringList() << "js"; + _mapHighlighternameToExtension["LUA"] = TQStringList() << "lua"; + _mapHighlighternameToExtension["Makefile"] = TQStringList() << "makefile"; +#if (TQSCINTILLA_VERSION >= 0x020300) + _mapHighlighternameToExtension["Pascal"] = TQStringList() << "pas"; +#endif + _mapHighlighternameToExtension["Perl"] = TQStringList() << "perl" << "pl" << "pm"; + _mapHighlighternameToExtension["PHP"] = TQStringList() << "php"; +#if (TQSCINTILLA_VERSION >= 0x020300) + _mapHighlighternameToExtension["PostScript"] = TQStringList() << "ps" << "eps" << "pdf" << "ai" << + "fh"; +#endif + _mapHighlighternameToExtension["POV"] = TQStringList() << "pov"; + _mapHighlighternameToExtension["Ini"] = TQStringList() << "ini"; + _mapHighlighternameToExtension["Python"] = TQStringList() << "py"; + _mapHighlighternameToExtension["Ruby"] = TQStringList() << "rub" << "rb"; +#if (TQSCINTILLA_VERSION >= 0x020400) + _mapHighlighternameToExtension["Spice"] = TQStringList() << "cir"; +#endif + _mapHighlighternameToExtension["SQL"] = TQStringList() << "sql"; +#if (TQSCINTILLA_VERSION >= 0x020300) + _mapHighlighternameToExtension["TCL"] = TQStringList() << "tcl"; +#endif + _mapHighlighternameToExtension["TeX"] = TQStringList() << "tex"; +#if (TQSCINTILLA_VERSION >= 0x020400) + _mapHighlighternameToExtension["Verilog"] = TQStringList() << "v" << "vh"; +#endif + _mapHighlighternameToExtension["VHDL"] = TQStringList() << "vhdl"; + _mapHighlighternameToExtension["XML"] = TQStringList() << "xml"; +#if (TQSCINTILLA_VERSION >= 0x020300) + _mapHighlighternameToExtension["YAML"] = TQStringList() << "yaml"; +#endif + + _lexer = NULL; + + // This code is only for testing. + /* + foreach(TQStringList extensionList, _mapHighlighternameToExtension.values() ) { + setLexerForExtension( extensionList.at(0) ); + } + */ + + // Set default highlighter to C++ highlighter. + setLexerForExtension("cpp"); +} + +/*! + \brief Returns the available highlighters as TQStringList. + */ +TQStringList UiGuiHighlighter::getAvailableHighlighters() +{ + return _mapHighlighternameToExtension.keys(); +} + +/*! + \brief This slot handles signals coming from selecting another syntax highlighter. + */ +void UiGuiHighlighter::setHighlighterByAction(TQAction *highlighterAction) +{ + TQString highlighterName = highlighterAction->text(); + setLexerForExtension(_mapHighlighternameToExtension[highlighterName].first()); + //TODO: This is really no nice way. How do it better? + // Need to do this "text update" to update the syntax highlighting. Otherwise highlighting is + // wrong. + int scrollPos = _qsciEditorParent->verticalScrollBar()->value(); + _qsciEditorParent->setText(_qsciEditorParent->text()); + _qsciEditorParent->verticalScrollBar()->setValue(scrollPos); +} + +/*! + \brief Turns the syntax parser on. +*/ +void UiGuiHighlighter::turnHighlightOn() +{ + _highlightningIsOn = true; + _qsciEditorParent->setLexer(_lexer); + readCurrentSettings(""); +} + +/*! + \brief Turns the syntax parser off. +*/ +void UiGuiHighlighter::turnHighlightOff() +{ + _highlightningIsOn = false; + _qsciEditorParent->setLexer(); +#if defined (Q_OS_WIN) || defined (Q_OS_MAC) + _qsciEditorParent->setFont(TQFont("Courier", 10, TQFont::Normal)); + _qsciEditorParent->setMarginsFont(TQFont("Courier", 10, TQFont::Normal)); +#else + _qsciEditorParent->setFont(TQFont("Monospace", 10, TQFont::Normal)); + _qsciEditorParent->setMarginsFont(TQFont("Monospace", 10, TQFont::Normal)); +#endif +} + +/*! + \brief Read the settings for the current lexer from the settings file. + */ + +//TODO: Refactor this function so that the coding style and variable names suit better. +bool UiGuiHighlighter::readCurrentSettings(const char *prefix) +{ + bool ok, flag, rc = true; + int num; + TQString key; + + // Reset lists containing fonts and colors for each style + _fontForStyles.clear(); + _colorForStyles.clear(); + + // Read the styles. + for (int i = 0; i < 128; ++i) + { + // Ignore invalid styles. + if (_lexer->description(i).isEmpty()) + { + continue; + } + + key.sprintf("%s/%s/style%d/", prefix, _lexer->language(), i); + key.replace("+", "p"); + + // Read the foreground color. + ok = _settings->contains(key + "color"); + num = _settings->value(key + "color", 0).toInt(); + + if (ok) + { + setColor(TQColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i); + } + else + { + rc = false; + } + + // Read the end-of-line fill. + ok = _settings->contains(key + "eolfill"); + flag = _settings->value(key + "eolfill", false).toBool(); + + if (ok) + { + _lexer->setEolFill(flag, i); + } + else + { + rc = false; + } + + // Read the font + TQStringList fdesc; + + ok = _settings->contains(key + "font"); + fdesc = _settings->value(key + "font").toStringList(); + + if (ok && fdesc.count() == 5) + { + TQFont f; + +#if defined (Q_OS_WIN) || defined (Q_OS_MAC) + f.setFamily(fdesc[0]); +#else + if (fdesc[0].contains("courier", TQt::CaseInsensitive)) + { + f.setFamily("Monospace"); + } + else + { + f.setFamily(fdesc[0]); + } +#endif + f.setPointSize(fdesc[1].toInt()); + f.setBold(fdesc[2].toInt()); + f.setItalic(fdesc[3].toInt()); + f.setUnderline(fdesc[4].toInt()); + + setFont(f, i); + } + else + { + rc = false; + } + + // Read the background color. + ok = _settings->contains(key + "paper"); + num = _settings->value(key + "paper", 0).toInt(); + + if (ok) + { + _lexer->setPaper(TQColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i); + } + else + { + rc = false; + } + } + + // Read the properties. + key.sprintf("%s/%s/properties/", prefix, _lexer->language()); + + _lexer->refreshProperties(); + + return rc; +} + +/*! + \brief Write the settings for the current lexer to the settings file. + */ +void UiGuiHighlighter::writeCurrentSettings(const char *prefix) +{ + TQString key; + + // Write the styles. + for (int i = 0; i < 128; ++i) + { + // Ignore invalid styles. + if (_lexer->description(i).isEmpty()) + { + continue; + } + + int num; + TQColor c; + + key.sprintf("%s/%s/style%d/", prefix, _lexer->language(), i); + key.replace("+", "p"); + + // Write style name + _settings->setValue(key + "", _lexer->description(i)); + + // Write the foreground color. + if (_colorForStyles.contains(i)) + { + c = _colorForStyles[i]; + } + else + { + c = _lexer->color(i); + } + num = (c.red() << 16) | (c.green() << 8) | c.blue(); + + _settings->setValue(key + "color", num); + + // Write the end-of-line fill. + _settings->setValue(key + "eolfill", _lexer->eolFill(i)); + + // Write the font + TQStringList fdesc; + TQString fmt("%1"); + TQFont f; + + if (_fontForStyles.contains(i)) + { + f = _fontForStyles[i]; + } + else + { + f = _lexer->font(i); + } + + fdesc += f.family(); + fdesc += fmt.arg(f.pointSize()); + + // The casts are for Borland. + fdesc += fmt.arg((int)f.bold()); + fdesc += fmt.arg((int)f.italic()); + fdesc += fmt.arg((int)f.underline()); + + _settings->setValue(key + "font", fdesc); + + // Write the background color. + c = _lexer->paper(i); + num = (c.red() << 16) | (c.green() << 8) | c.blue(); + + _settings->setValue(key + "paper", num); + } +} + +/*! + \brief Sets the \a color for the given \a style. + */ +void UiGuiHighlighter::setColor(const TQColor &color, int style) +{ + _colorForStyles[style] = color; + _lexer->setColor(color, style); +} + +/*! + \brief Sets the \a font for the given \a style. + */ +void UiGuiHighlighter::setFont(const TQFont &font, int style) +{ + _fontForStyles[style] = font; + _lexer->setFont(font, style); +} + +/*! + \brief Sets the to be used lexer by giving his name. + */ +void UiGuiHighlighter::setLexerByName(TQString lexerName) +{ + setLexerForExtension(_mapHighlighternameToExtension[lexerName].first()); +} + +/*! + \brief Sets the proper highlighter / lexer for the given file \a extension. Returns the index of the used lexer in the list. + */ +int UiGuiHighlighter::setLexerForExtension(TQString extension) +{ + int indexOfHighlighter = 0; + extension = extension.toLower(); + + if (_lexer != NULL) + { + writeCurrentSettings(""); + delete _lexer; + } + + if (extension == "cpp" || extension == "hpp" || extension == "c" || extension == "h" || + extension == "cxx" || extension == "hxx") + { + _lexer = new QsciLexerCPP(); + } + else if (extension == "sh") + { + _lexer = new QsciLexerBash(); + } + else if (extension == "bat") + { + _lexer = new QsciLexerBatch(); + } + else if (extension == "cmake") + { + _lexer = new QsciLexerCMake(); + } + else if (extension == "cs") + { + _lexer = new QsciLexerCSharp(); + } + else if (extension == "css") + { + _lexer = new QsciLexerCSS(); + } + else if (extension == "d") + { + _lexer = new QsciLexerD(); + } + else if (extension == "diff") + { + _lexer = new QsciLexerDiff(); + } +#if (TQSCINTILLA_VERSION >= 0x020300) + else if (extension == "f" || extension == "for" || extension == "f90") + { + _lexer = new QsciLexerFortran(); + } + else if (extension == "f77") + { + _lexer = new QsciLexerFortran77(); + } +#endif + else if (extension == "html" || extension == "htm") + { + _lexer = new QsciLexerHTML(); + } + else if (extension == "idl") + { + _lexer = new QsciLexerIDL(); + } + else if (extension == "java") + { + _lexer = new QsciLexerJava(); + } + else if (extension == "js") + { + _lexer = new QsciLexerJavaScript(); + } + else if (extension == "lua") + { + _lexer = new QsciLexerLua(); + } + else if (extension == "makefile") + { + _lexer = new QsciLexerMakefile(); + } +#if (TQSCINTILLA_VERSION >= 0x020300) + else if (extension == "pas") + { + _lexer = new QsciLexerPascal(); + } +#endif + else if (extension == "perl" || extension == "pl" || extension == "pm") + { + _lexer = new QsciLexerPerl(); + } + else if (extension == "php") + { + _lexer = new QsciLexerHTML(); + } +#if (TQSCINTILLA_VERSION >= 0x020300) + else if (extension == "ps" || extension == "eps" || extension == "pdf" || extension == "ai" || + extension == "fh") + { + _lexer = new QsciLexerPostScript(); + } +#endif + else if (extension == "pov") + { + _lexer = new QsciLexerPOV(); + } + else if (extension == "ini") + { + _lexer = new QsciLexerProperties(); + } + else if (extension == "py") + { + _lexer = new QsciLexerPython(); + } + else if (extension == "rub" || extension == "rb") + { + _lexer = new QsciLexerRuby(); + } +#if (TQSCINTILLA_VERSION >= 0x020400) + else if (extension == "spice?") + { + _lexer = new QsciLexerSpice(); + } +#endif + else if (extension == "sql") + { + _lexer = new QsciLexerSQL(); + } +#if (TQSCINTILLA_VERSION >= 0x020300) + else if (extension == "tcl") + { + _lexer = new QsciLexerTCL(); + } +#endif + else if (extension == "tex") + { + _lexer = new QsciLexerTeX(); + } +#if (TQSCINTILLA_VERSION >= 0x020400) + else if (extension == "vlog?") + { + _lexer = new QsciLexerVerilog(); + } +#endif + else if (extension == "vhdl") + { + _lexer = new QsciLexerVHDL(); + } + else if (extension == "xml") + { +#if (TQSCINTILLA_VERSION >= 0x020300) + _lexer = new QsciLexerXML(); +#else + _lexer = new QsciLexerHTML(); +#endif + } +#if (TQSCINTILLA_VERSION >= 0x020300) + else if (extension == "yaml") + { + _lexer = new QsciLexerYAML(); + } +#endif + else + { + _lexer = new QsciLexerCPP(); + extension = "cpp"; + } + + // Find the index of the selected _lexer. + indexOfHighlighter = 0; + while (!_mapHighlighternameToExtension.values().at(indexOfHighlighter).contains(extension)) + { + indexOfHighlighter++; + } + + // Set the _lexer for the TQScintilla widget. + if (_highlightningIsOn) + { + _qsciEditorParent->setLexer(_lexer); + } + + // Read the _settings for the _lexer properties from file. + readCurrentSettings(""); + + return indexOfHighlighter; +} diff --git a/src/__TODO/UiGuiHighlighter.h b/src/__TODO/UiGuiHighlighter.h new file mode 100644 index 0000000..ad50849 --- /dev/null +++ b/src/__TODO/UiGuiHighlighter.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UIGUIHIGHLIGHTER_H +#define UIGUIHIGHLIGHTER_H + +#include +#include +#include +#include + +class TQAction; +class TQSettings; + +class QsciScintilla; +class QsciLexer; + + +class UiGuiHighlighter : public TQObject +{ + Q_OBJECT + + public: + UiGuiHighlighter(QsciScintilla *parent); + + void turnHighlightOff(); + void turnHighlightOn(); + + bool readCurrentSettings(const char *prefix); + void writeCurrentSettings(const char *prefix); + TQStringList getAvailableHighlighters(); + + public slots: + //! The foreground color for style number \a style is set to \a color. If + //! \a style is -1 then the color is set for all styles. + void setColor(const TQColor &color, int style = -1); + + //! The font for style number \a style is set to \a font. If \a style is + //! -1 then the font is set for all styles. + void setFont(const TQFont &font, int style = -1); + + //! Sets the lexer that is responsible for the given \a extension. + int setLexerForExtension(TQString extension); + + void setLexerByName(TQString lexerName); + + void setHighlighterByAction(TQAction *highlighterAction); + + private: + bool _highlightningIsOn; + QsciScintilla *_qsciEditorParent; + TQMap _fontForStyles; + TQMap _colorForStyles; + QsciLexer *_lexer; + TQSettings *_settings; + TQMap _mapHighlighternameToExtension; +}; + +#endif // UIGUIHIGHLIGHTER_H diff --git a/src/__TODO/UiGuiIndentServer.cpp b/src/__TODO/UiGuiIndentServer.cpp new file mode 100644 index 0000000..91c5ec7 --- /dev/null +++ b/src/__TODO/UiGuiIndentServer.cpp @@ -0,0 +1,175 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UiGuiIndentServer.h" + +#include +#include +#include +#include + +//! \defgroup grp_Server All concerning the server component. + +/*! + \class UiGuiIndentServer + \ingroup grp_Server + \brief UiGuiIndentServer is in such an early state, that even the communication + protocol isn't completely planned. So this class lacks documentation until + I really know where all this will lead to. + + The plan however is to have a server that receives commands for selecting an + indenter and perhaps load some by the user predefined indenter config file. Then + the client can send a text to it and will receive it formatted. + The idea behind that is to make UiGUIs use as plugin or whatever more flexible. + So the plugin is developed for Eclipse for example and it takes the client role, + making it possible to use UiGUI from within Eclipse. Choosing a network protocol + makes everything platform and programming language independent, so it doesn't + matter for which application the plugin/client is developed. +*/ + +UiGuiIndentServer::UiGuiIndentServer(void) : + TQObject() +{ + _tcpServer = NULL; + _currentClientConnection = NULL; + _readyForHandleRequest = false; +} + +UiGuiIndentServer::~UiGuiIndentServer(void) +{ +} + +void UiGuiIndentServer::startServer() +{ + if (_tcpServer == NULL) + { + _tcpServer = new TQTcpServer(this); + } + + if (!_tcpServer->isListening()) + { + if (!_tcpServer->listen(TQHostAddress::Any, tquint16(84484))) + { + TQMessageBox::critical(NULL, tr("UiGUI Server"), + tr("Unable to start the server: %1.").arg(_tcpServer->errorString())); + return; + } + } + + connect(_tcpServer, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); + _readyForHandleRequest = true; + _blockSize = 0; +} + +void UiGuiIndentServer::stopServer() +{ + if (_tcpServer != NULL) + { + _tcpServer->close(); + delete _tcpServer; + _tcpServer = NULL; + } + _currentClientConnection = NULL; + _readyForHandleRequest = false; +} + +void UiGuiIndentServer::handleNewConnection() +{ + TQTcpSocket *clientConnection = _tcpServer->nextPendingConnection(); + connect(clientConnection, SIGNAL(disconnected()), clientConnection, SLOT(deleteLater())); + + connect(clientConnection, SIGNAL(readyRead()), this, SLOT(handleReceivedData())); +} + +void UiGuiIndentServer::handleReceivedData() +{ + if (!_readyForHandleRequest) + { + return; + } + + _currentClientConnection = qobject_cast(sender()); + TQString receivedData = ""; + + if (_currentClientConnection != NULL) + { + TQDataStream in(_currentClientConnection); + in.setVersion(TQDataStream::TQt_4_0); + + if (_blockSize == 0) + { + if (_currentClientConnection->bytesAvailable() < (int)sizeof(tquint32)) + { + return; + } + + in >> _blockSize; + } + + if (_currentClientConnection->bytesAvailable() < _blockSize) + { + return; + } + + TQString receivedMessage; + in >> receivedMessage; + + _blockSize = 0; + + tqDebug() << "receivedMessage: " << receivedMessage; + + if (receivedMessage == "ts") + { + sendMessage("Toll"); + } + else + { + sendMessage("irgendwas"); + } + } +} + +void UiGuiIndentServer::sendMessage(const TQString &message) +{ + _readyForHandleRequest = false; + + _dataToSend = ""; + TQDataStream out(&_dataToSend, TQIODevice::WriteOnly); + out.setVersion(TQDataStream::TQt_4_0); + out << (tquint32)0; + out << message; + out.device()->seek(0); + out << (tquint32)(_dataToSend.size() - sizeof(tquint32)); + + connect(_currentClientConnection, SIGNAL(bytesWritten(qint64)), this, + SLOT(checkIfReadyForHandleRequest())); + _currentClientConnection->write(_dataToSend); +} + +void UiGuiIndentServer::checkIfReadyForHandleRequest() +{ + if (_currentClientConnection->bytesToWrite() == 0) + { + TQString dataToSendStr = _dataToSend.right(_dataToSend.size() - sizeof(tquint32)); + tqDebug() << "checkIfReadyForHandleRequest _dataToSend was: " << dataToSendStr; + disconnect(_currentClientConnection, SIGNAL(bytesWritten(qint64)), this, + SLOT(checkIfReadyForHandleRequest())); + _readyForHandleRequest = true; + } +} diff --git a/src/__TODO/UiGuiIndentServer.h b/src/__TODO/UiGuiIndentServer.h new file mode 100644 index 0000000..3f8c996 --- /dev/null +++ b/src/__TODO/UiGuiIndentServer.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UIGUIINDENTSERVER_H +#define UIGUIINDENTSERVER_H + +#include + +class TQTcpServer; +class TQTcpSocket; + + +class UiGuiIndentServer : public TQObject +{ + Q_OBJECT + + public: + UiGuiIndentServer(void); + ~UiGuiIndentServer(void); + + public slots: + void startServer(); + void stopServer(); + + private slots: + void handleNewConnection(); + void handleReceivedData(); + void sendMessage(const TQString &message); + void checkIfReadyForHandleRequest(); + + private: + TQTcpServer *_tcpServer; + TQByteArray _dataToSend; + bool _readyForHandleRequest; + TQTcpSocket *_currentClientConnection; + TQ_UINT32 _blockSize; +}; + +#endif // UIGUIINDENTSERVER_H diff --git a/src/__TODO/UiGuiIniFileParser.cpp b/src/__TODO/UiGuiIniFileParser.cpp new file mode 100644 index 0000000..e690139 --- /dev/null +++ b/src/__TODO/UiGuiIniFileParser.cpp @@ -0,0 +1,160 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UiGuiIniFileParser.h" + +#include +#include +#include +#include + +//! \defgroup grp_Settings All concerning applications settings. + +/*! + \class UiGuiIniFileParser + \ingroup grp_Settings + \brief UiGuiIniFileParser is a simple ini file format parser. + + These ini files need to have key-value pairs in the style + "keyname=keyvalue". Groups can be defined by writing the groupname + in the style [groupname] before some key-value pairs. + + The reason why I use my own class instead of TQSettings is mainly, that + TQSettings always internally sorts the groups alphabetically and also + rewrites a settings file sorted. Very annoying for me. +*/ + +/*! + \brief Init and empty all needed lists and strings. + */ +UiGuiIniFileParser::UiGuiIniFileParser(void) +{ + init(); +} + +/*! + \brief Directly loads and parses the file with name \a iniFileName. + */ +UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName) +{ + init(); + _iniFileName = iniFileName; + parseIniFile(); +} + +void UiGuiIniFileParser::init() +{ + _sections.clear(); + _keyValueMap.clear(); + _iniFileName = ""; +} + +UiGuiIniFileParser::~UiGuiIniFileParser(void) +{ +} + +/*! + \brief Returns the group/section names in the same order as they occurr in the ini file as TQStringList. + */ +TQStringList UiGuiIniFileParser::childGroups() +{ + TQStringList sectionsStringList; + + for (unsigned int i = 0; i < _sections.size(); i++) + { + sectionsStringList << _sections[i]; + } + + return sectionsStringList; +} + +/*! + \brief Returns the value of the defined \a keyName as TQVariant. + + The \a keyName is assembled by a section name, a slash and the key name itself. + For example if you wish to access the value of the following setting: + [NiceSection]
niceKeyName=2
you would have to call + value("NiceSection/niceKeyName"). + */ +TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue) +{ + return _keyValueMap.value(keyName, defaultValue); +} + +/*! + \brief Parses the ini file and stores the key value pairs in the internal vectors \a keys and \a values. + */ +void UiGuiIniFileParser::parseIniFile() +{ + TQFile iniFile(_iniFileName); + + if (iniFile.open(TQFile::ReadOnly)) + { + // Clear the vectors holding the keys and values. + _sections.clear(); + _keyValueMap.clear(); + + TQTextStream iniFileStream(&iniFile); + TQString line; + TQString currentSectionName = ""; + TQString keyName = ""; + TQString valueAsString = ""; + + while (!iniFileStream.atEnd()) + { + line = iniFileStream.readLine().trimmed(); + + // Test if the read line is a section name and if so remeber it. + if (line.startsWith("[") && line.endsWith("]")) + { + currentSectionName = line.remove(0, 1); + currentSectionName.chop(1); + + // Store the section name. + _sections.push_back(currentSectionName); + } + // Otherwise test whether the line has a assign char + else if (line.contains("=")) + { + int indexOfFirstAssign = line.indexOf("="); + keyName = line.left(indexOfFirstAssign); + + if (!keyName.isEmpty()) + { + valueAsString = line.remove(0, indexOfFirstAssign + 1); + // Remove any existing double quotes from the value. + if (valueAsString.startsWith("\"") && valueAsString.endsWith("\"")) + { + valueAsString = valueAsString.remove(0, 1); + valueAsString.chop(1); + } + + // Prepend an eventually section name to the key name. + if (!currentSectionName.isEmpty()) + { + keyName = currentSectionName + "/" + keyName; + } + + // Store the key and value in the map. + _keyValueMap.insert(keyName, valueAsString); + } + } + } + } +} diff --git a/src/__TODO/UiGuiIniFileParser.h b/src/__TODO/UiGuiIniFileParser.h new file mode 100644 index 0000000..0aebb09 --- /dev/null +++ b/src/__TODO/UiGuiIniFileParser.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UIGUIINIFILEPARSER_H +#define UIGUIINIFILEPARSER_H + +#include +#include + +#include + +class TQStringList; +class TQVariant; + + +class UiGuiIniFileParser +{ + public: + UiGuiIniFileParser(void); + UiGuiIniFileParser(const TQString &iniFileName); + ~UiGuiIniFileParser(void); + + TQVariant value(const TQString &keyName, const TQString &defaultValue = ""); + TQStringList childGroups(); + + protected: + void init(); + + private: + void parseIniFile(); + + TQString _iniFileName; + std::vector _sections; + TQMap _keyValueMap; +}; + +#endif // UIGUIINIFILEPARSER_H diff --git a/src/__TODO/UiGuiSettings.cpp b/src/__TODO/UiGuiSettings.cpp new file mode 100644 index 0000000..ebac977 --- /dev/null +++ b/src/__TODO/UiGuiSettings.cpp @@ -0,0 +1,933 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#include "UiGuiSettings.h" + +#include "SettingsPaths.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//! \defgroup grp_Settings All concerning the settings. + +/*! + \class UiGuiSettings + \ingroup grp_Settings + \brief Handles the settings of the program. Reads them on startup and saves them on exit. + Is a singleton class and can only be accessed via getInstance(). +*/ + +// Inits the single class instance pointer. +TQWeakPointer UiGuiSettings::_instance; + + +/*! + \brief The constructor for the settings. +*/ +UiGuiSettings::UiGuiSettings() : + TQObject() +{ + // Create the main application settings object from the UniversalIndentGUI.ini file. + _qsettings = new TQSettings( + SettingsPaths::getSettingsPath() + "/UniversalIndentGUI.ini", TQSettings::IniFormat, this); + + _indenterDirctoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters"; + readAvailableTranslations(); + initSettings(); +} + +/*! + \brief Returns the instance of the settings class. If no instance exists, ONE will be created. + */ +TQSharedPointer UiGuiSettings::getInstance() +{ + TQSharedPointer sharedInstance = _instance.toStrongRef(); + if (sharedInstance.isNull()) + { + // Create the settings object, which loads all UiGui settings from a file. + sharedInstance = TQSharedPointer(new UiGuiSettings()); + _instance = sharedInstance.toWeakRef(); + } + + return sharedInstance; +} + +/*! + \brief The destructor saves the settings to a file. + */ +UiGuiSettings::~UiGuiSettings() +{ + // Convert the language setting from an integer index to a string. + int index = _qsettings->value("UniversalIndentGUI/language", 0).toInt(); + if (index < 0 || index >= _availableTranslations.size()) + { + index = 0; + } + + _qsettings->setValue("UniversalIndentGUI/language", _availableTranslations.at(index)); +} + +/*! + \brief Scans the translations directory for available translation files and + stores them in the TQList \a _availableTranslations. + */ +void UiGuiSettings::readAvailableTranslations() +{ + TQString languageShort; + TQStringList languageFileList; + + // English is the default language. A translation file does not exist but to have a menu entry, + // added here. + languageFileList << "universalindent_en.qm"; + + // Find all translation files in the "translations" directory. + TQDir translationDirectory = TQDir(SettingsPaths::getGlobalFilesPath() + "/translations"); + languageFileList << translationDirectory.entryList(TQStringList("universalindent_*.qm")); + + // Loop for each found translation file + foreach(languageShort, languageFileList) + { + // Remove the leading string "universalindent_" from the filename. + languageShort.remove(0, 16); + // Remove trailing file extension ".qm". + languageShort.chop(3); + + _availableTranslations.append(languageShort); + } +} + +/*! + \brief Returns a list of the mnemonics of the available translations. + */ +TQStringList UiGuiSettings::getAvailableTranslations() +{ + return _availableTranslations; +} + +/*! + \brief Returns the value of the by \a settingsName defined setting as TQVariant. + + If the named setting does not exist, 0 is being returned. +*/ +TQVariant UiGuiSettings::getValueByName(TQString settingName) +{ + return _qsettings->value("UniversalIndentGUI/" + settingName); +} + +/*! + \brief Loads the settings for the main application. + + Settings are for example last selected indenter, last loaded source code file and so on. +*/ +bool UiGuiSettings::initSettings() +{ + // Read the version string saved in the settings file. + _qsettings->setValue("UniversalIndentGUI/version", + _qsettings->value("UniversalIndentGUI/version", "")); + + // Read windows last size and position from the settings file. + _qsettings->setValue("UniversalIndentGUI/maximized", + _qsettings->value("UniversalIndentGUI/maximized", false)); + _qsettings->setValue("UniversalIndentGUI/position", + _qsettings->value("UniversalIndentGUI/position", TQPoint(50, 50))); + _qsettings->setValue("UniversalIndentGUI/size", + _qsettings->value("UniversalIndentGUI/size", TQSize(800, 600))); + + // Read last selected encoding for the opened source code file. + _qsettings->setValue("UniversalIndentGUI/encoding", + _qsettings->value("UniversalIndentGUI/encoding", "UTF-8")); + + // Read maximum length of list for recently opened files. + _qsettings->setValue("UniversalIndentGUI/recentlyOpenedListSize", + _qsettings->value("UniversalIndentGUI/recentlyOpenedListSize", 5)); + + // Read if last opened source code file should be loaded on startup. + _qsettings->setValue("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", + _qsettings->value("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", true)); + + // Read last opened source code file from the settings file. + _qsettings->setValue("UniversalIndentGUI/lastSourceCodeFile", + _qsettings->value("UniversalIndentGUI/lastSourceCodeFile", + _indenterDirctoryStr + "/example.cpp")); + + // Read last selected indenter from the settings file. + int selectedIndenter = _qsettings->value("UniversalIndentGUI/selectedIndenter", 0).toInt(); + if (selectedIndenter < 0) + { + selectedIndenter = 0; + } + _qsettings->setValue("UniversalIndentGUI/selectedIndenter", selectedIndenter); + + // Read if syntax highlighting is enabled. + _qsettings->setValue("UniversalIndentGUI/SyntaxHighlightingEnabled", + _qsettings->value("UniversalIndentGUI/SyntaxHighlightingEnabled", true)); + + // Read if white space characters should be displayed. + _qsettings->setValue("UniversalIndentGUI/whiteSpaceIsVisible", + _qsettings->value("UniversalIndentGUI/whiteSpaceIsVisible", false)); + + // Read if indenter parameter tool tips are enabled. + _qsettings->setValue("UniversalIndentGUI/indenterParameterTooltipsEnabled", + _qsettings->value("UniversalIndentGUI/indenterParameterTooltipsEnabled", true)); + + // Read the tab width from the settings file. + _qsettings->setValue("UniversalIndentGUI/tabWidth", + _qsettings->value("UniversalIndentGUI/tabWidth", 4)); + + // Read the last selected language and stores the index it has in the list of available + // translations. + _qsettings->setValue("UniversalIndentGUI/language", + _availableTranslations.indexOf(_qsettings->value("UniversalIndentGUI/language", + "").toString())); + + // Read the update check settings from the settings file. + _qsettings->setValue("UniversalIndentGUI/CheckForUpdate", + _qsettings->value("UniversalIndentGUI/CheckForUpdate", false)); + _qsettings->setValue("UniversalIndentGUI/LastUpdateCheck", + _qsettings->value("UniversalIndentGUI/LastUpdateCheck", TQDate(1900, 1, 1))); + + // Read the main window state. + _qsettings->setValue("UniversalIndentGUI/MainWindowState", + _qsettings->value("UniversalIndentGUI/MainWindowState", TQByteArray())); + + return true; +} + +/*! + \brief Register the by \a propertyName defined property of \a obj to be connected to the setting defined by \a settingName. + + The \a propertyName must be one of those that are listed in the TQt "Properties" documentation section of a TQt Object. + All further needed info is retrieved via the \a obj's MetaObject, like the to the property bound signal. + */ +bool UiGuiSettings::registerObjectProperty(TQObject *obj, const TQString &propertyName, + const TQString &settingName) +{ + const TQMetaObject *metaObject = obj->metaObject(); + bool connectSuccess = false; + + // Connect to the objects destroyed signal, so that it will be correctly unregistered. + connectSuccess = + connect(obj, SIGNAL(destroyed(TQObject*)), this, + SLOT(unregisterObjectProperty(TQObject*))); + + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (connectSuccess && indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + + // Connect to the property's value changed signal. + if (mProp.hasNotifySignal()) + { + TQMetaMethod signal = mProp.notifySignal(); + //TQString teststr = qPrintable(SIGNAL() + TQString(signal.signature())); + // The command "SIGNAL() + TQString(signal.signature())" assembles the signal methods + // signature to a valid TQt SIGNAL. + connectSuccess = + connect(obj, qPrintable(SIGNAL() + TQString(signal.signature())), this, + SLOT(handleObjectPropertyChange())); + } + + if (connectSuccess) + { + _registeredObjectProperties[obj] = TQStringList() << propertyName << settingName; + } + else + { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(TQObject*)), this, + SLOT(unregisterObjectProperty(TQObject*))); + return false; + } + + // If setting already exists, set the objects property to the setting value. + if (_qsettings->contains("UniversalIndentGUI/" + settingName)) + { + mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); + } + // Otherwise add the setting and set it to the value of the objects property. + else + { + _qsettings->setValue("UniversalIndentGUI/" + settingName, mProp.read(obj)); + } + } + else + { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectProperty(TQObject*))); + return false; + } + + return true; +} + +/*! + \brief Searches the child TQObjects of \a obj for a property name and setting name definition within + their custom properties and registers this property name to that setting name if both were found. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. If the mentioned setting + name doesn't exist, it will be created. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::registerObjectPropertyRecursive(TQObject *obj) +{ + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::registerObjectProperty); +} + +/*! + \brief Assigns the by \a settingName defined setting value to the by \a propertyName defined property of \a obj. + + Returns true, if the value could be assigned, otherwise returns false, which is the case if settingName doesn't exist + within the settings or if the mentioned propertyName wasn't found for the \a obj. + */ +bool UiGuiSettings::setObjectPropertyToSettingValue(TQObject *obj, const TQString &propertyName, + const TQString &settingName) +{ + const TQMetaObject *metaObject = obj->metaObject(); + + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + + // If setting already exists, set the objects property to the setting value. + if (_qsettings->contains("UniversalIndentGUI/" + settingName)) + { + mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); + } + // The setting didn't exist so return that setting the objects property failed. + else + { + //TODO: Write a debug warning to the log. + return false; + } + } + else + { + //TODO: Write a debug warning to the log. + return false; + } + + return true; +} + +/*! + \brief Searches the child TQObjects of \a obj for a property name and setting name definition within + their custom properties and sets each property to settings value. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::setObjectPropertyToSettingValueRecursive(TQObject *obj) +{ + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setObjectPropertyToSettingValue); +} + +/*! + \brief Assigns the by \a propertyName defined property's value of \a obj to the by \a settingName defined setting. + + If the \a settingName didn't exist yet, it will be created. + + Returns true, if the value could be assigned, otherwise returns false, which is the case if the mentioned + propertyName wasn't found for the \a obj. + */ +bool UiGuiSettings::setSettingToObjectPropertyValue(TQObject *obj, const TQString &propertyName, + const TQString &settingName) +{ + const TQMetaObject *metaObject = obj->metaObject(); + + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + + setValueByName(settingName, mProp.read(obj)); + } + else + { + //TODO: Write a debug warning to the log. + return false; + } + + return true; +} + +/*! + \brief Searches the child TQObjects of \a obj for a property name and setting name definition within + their custom properties and sets each setting to the property value. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a TQObject property as it is documented in the TQtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. If the settingName + didn't exist yet, it will be created. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::setSettingToObjectPropertyValueRecursive(TQObject *obj) +{ + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setSettingToObjectPropertyValue); +} + +/*! + \brief Iterates over all \a objs child TQObjects and checks whether they have the custom properties + "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the \a callBackFunc + with both. + */ +bool UiGuiSettings::checkCustomPropertiesAndCallFunction(TQObject *obj, bool (UiGuiSettings::*callBackFunc)( + TQObject *obj, const TQString &propertyName, + const TQString &settingName)) +{ + bool success = true; + + // Find all widgets that have PropertyName and SettingName defined in their style sheet. + TQList allObjects = obj->findChildren(); + foreach(TQObject * object, allObjects) + { + TQString propertyName = object->property("connectedPropertyName").toString(); + TQString settingName = object->property("connectedSettingName").toString(); + + // If property and setting name were found, register that widget with the settings. + if (!propertyName.isEmpty() && !settingName.isEmpty()) + { + success &= (this->*callBackFunc)(object, propertyName, settingName); + } + } + + return success; +} + +/*! + \brief The with a certain property registered \a obj gets unregistered. + */ +void UiGuiSettings::unregisterObjectProperty(TQObject *obj) +{ + if (_registeredObjectProperties.contains(obj)) + { + const TQMetaObject *metaObject = obj->metaObject(); + TQString propertyName = _registeredObjectProperties[obj].first(); + TQString settingName = _registeredObjectProperties[obj].last(); + + bool connectSuccess = false; + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + + // Disconnect to the property's value changed signal. + if (mProp.hasNotifySignal()) + { + TQMetaMethod signal = mProp.notifySignal(); + // The command "SIGNAL() + TQString(signal.signature())" assembles the signal methods + // signature to a valid TQt SIGNAL. + connectSuccess = disconnect(obj, qPrintable(SIGNAL() + TQString( + signal.signature())), this, SLOT(handleObjectPropertyChange())); + } + } + _registeredObjectProperties.remove(obj); + } +} + +/*! + \brief Registers a slot form the \a obj by its \a slotName to be invoked, if the by \a settingName defined + setting changes. + + The registered slot may have no parameters or exactly one. If it accepts one parameter, whenever the setting + \a settingName changes the slot gets tried to be invoked with the settings value as parameter. This only works, + if the slot parameter is of the same type as the setting. + */ +bool UiGuiSettings::registerObjectSlot(TQObject *obj, const TQString &slotName, + const TQString &settingName) +{ + const TQMetaObject *metaObject = obj->metaObject(); + + bool connectSuccess = false; + // Connect to the objects destroyed signal, so that it will be correctly unregistered. + connectSuccess = + connect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); + + TQString normalizedSlotName = TQMetaObject::normalizedSignature(qPrintable(slotName)); + int indexOfMethod = metaObject->indexOfMethod(qPrintable(normalizedSlotName)); + if (connectSuccess && indexOfMethod > -1) + { + TQMetaMethod mMethod = metaObject->method(indexOfMethod); + //TQMetaMethod::Access access = mMethod.access(); + //TQMetaMethod::MethodType methType = mMethod.methodType(); + + // Since the method can at maximum be invoked with the setting value as argument, + // only methods taking max one argument are allowed. + if (mMethod.parameterTypes().size() <= 1) + { + _registeredObjectSlots.insert(obj, TQStringList() << normalizedSlotName << settingName); + } + else + { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); + return false; + } + } + else + { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(TQObject*)), this, SLOT(unregisterObjectSlot(TQObject*))); + return false; + } + + return true; +} + +/*! + \brief If \a obj, \a slotName and \a settingName are given, that certain connection is unregistered. + If only \a obj is given, all to this object registered slot-setting connections are unregistered. + */ +void UiGuiSettings::unregisterObjectSlot(TQObject *obj, const TQString &slotName, + const TQString &settingName) +{ + //const TQMetaObject *metaObject = obj->metaObject(); + TQString normalizedSlotName = TQMetaObject::normalizedSignature(qPrintable(slotName)); + TQMutableMapIterator it(_registeredObjectSlots); + while (it.hasNext()) + { + it.next(); + if (it.key() == obj && slotName.isEmpty() && settingName.isEmpty()) + { + it.remove(); + } + else if (it.key() == obj && it.value().first() == slotName && it.value().last() == settingName) + { + it.remove(); + } + } +} + +/*! + \brief This private slot gets invoked whenever a registered objects property changes + and distributes the new value to all other to the same settingName registered objects. + */ +void UiGuiSettings::handleObjectPropertyChange() +{ + TQObject *obj = TQObject::sender(); + TQString className = obj->metaObject()->className(); + const TQMetaObject *metaObject = obj->metaObject(); + TQString propertyName = _registeredObjectProperties[obj].first(); + TQString settingName = _registeredObjectProperties[obj].last(); + + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + setValueByName(settingName, mProp.read(obj)); + } +} + +/*! + \brief Sets the setting defined by \a settingName to \a value. + + When setting a changed value, all to this settingName registered objects get + the changed value set too. + If the \a settingName didn't exist yet, it will be created. + */ +void UiGuiSettings::setValueByName(const TQString &settingName, const TQVariant &value) +{ + // Do the updating only, if the setting was really changed. + if (_qsettings->value("UniversalIndentGUI/" + settingName) != value) + { + _qsettings->setValue("UniversalIndentGUI/" + settingName, value); + + // Set the new value for all registered object properties for settingName. + for (TQMap::ConstIterator it = _registeredObjectProperties.begin(); + it != _registeredObjectProperties.end(); ++it) + { + if (it.value().last() == settingName) + { + TQObject *obj = it.key(); + const TQMetaObject *metaObject = obj->metaObject(); + TQString propertyName = it.value().first(); + + int indexOfProp = metaObject->indexOfProperty(qPrintable(propertyName)); + if (indexOfProp > -1) + { + TQMetaProperty mProp = metaObject->property(indexOfProp); + mProp.write(obj, value); + } + } + } + + // Invoke all registered object methods for settingName. + for (TQMap::ConstIterator it = _registeredObjectSlots.begin(); + it != _registeredObjectSlots.end(); ++it) + { + if (it.value().last() == settingName) + { + TQObject *obj = it.key(); + const TQMetaObject *metaObject = obj->metaObject(); + TQString slotName = it.value().first(); + + int indexOfMethod = metaObject->indexOfMethod(qPrintable(slotName)); + if (indexOfMethod > -1) + { + TQMetaMethod mMethod = metaObject->method(indexOfMethod); + //TQMetaMethod::Access access = mMethod.access(); + //TQMetaMethod::MethodType methType = mMethod.methodType(); + + bool success = false; + + // Handle registered slots taking one parameter. + if (mMethod.parameterTypes().size() == 1) + { + if (mMethod.parameterTypes().first() == value.typeName()) + { + success = invokeMethodWithValue(obj, mMethod, value); + } + } + // Handle registered slots taking zero parameters. + else + { + success = mMethod.invoke(obj, TQt::DirectConnection); + } + + if (success == false) + { + // TODO: Write a warning to the log if no success. + } + } + } + } + } +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if TQT_VERSION >= 0x040600 + #include + #include +#endif + +bool UiGuiSettings::invokeMethodWithValue(TQObject *obj, TQMetaMethod mMethod, TQVariant value) +{ + switch (value.type()) + { + case TQVariant::BitArray: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBitArray, value.toBitArray())); + } + + case TQVariant::Bitmap: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBitmap, value.value())); + } + + case TQVariant::Bool: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(bool, value.toBool())); + } + + case TQVariant::Brush: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQBrush, value.value())); + } + + case TQVariant::ByteArray: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQByteArray, value.toByteArray())); + } + + case TQVariant::Char: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQChar, value.toChar())); + } + + case TQVariant::Color: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQColor, value.value())); + } + + case TQVariant::Cursor: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQCursor, value.value())); + } + + case TQVariant::Date: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQDate, value.toDate())); + } + + case TQVariant::DateTime: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQDateTime, value.toDateTime())); + } + + case TQVariant::Double: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(double, value.toDouble())); + } + + case TQVariant::Font: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQFont, value.value())); + } + + case TQVariant::Hash: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantHash, value.toHash())); + } + + case TQVariant::Icon: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQIcon, value.value())); + } + + case TQVariant::Image: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQImage, value.value())); + } + + case TQVariant::Int: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(int, value.toInt())); + } + + case TQVariant::KeySequence: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQKeySequence, + value.value())); + } + + case TQVariant::Line: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLine, value.toLine())); + } + + case TQVariant::LineF: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLineF, value.toLineF())); + } + + case TQVariant::List: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantList, value.toList())); + } + + case TQVariant::Locale: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQLocale, value.toLocale())); + } + + case TQVariant::LongLong: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(qlonglong, value.toLongLong())); + } + + case TQVariant::Map: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQVariantMap, value.toMap())); + } + + case TQVariant::Matrix: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQMatrix, value.value())); + } + + case TQVariant::Transform: + { + return mMethod.invoke(obj, TQt::DirectConnection, + Q_ARG(TQTransform, value.value())); + } + +#if TQT_VERSION >= 0x040600 + case TQVariant::Matrix4x4: + { + return mMethod.invoke(obj, TQt::DirectConnection, + Q_ARG(TQMatrix4x4, value.value())); + } + +#endif + case TQVariant::Palette: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPalette, value.value())); + } + + case TQVariant::Pen: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPen, value.value())); + } + + case TQVariant::Pixmap: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPixmap, value.value())); + } + + case TQVariant::Point: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPoint, value.toPoint())); + } + + // case TQVariant::PointArray : + // return Q_ARG(TQPointArray, value.value()) ); + case TQVariant::PointF: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPointF, value.toPointF())); + } + + case TQVariant::Polygon: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQPolygon, value.value())); + } + +#if TQT_VERSION >= 0x040600 + case TQVariant::Quaternion: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQQuaternion, + value.value())); + } + +#endif + case TQVariant::Rect: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRect, value.toRect())); + } + + case TQVariant::RectF: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRectF, value.toRectF())); + } + + case TQVariant::RegExp: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRegExp, value.toRegExp())); + } + + case TQVariant::Region: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQRegion, value.value())); + } + + case TQVariant::Size: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSize, value.toSize())); + } + + case TQVariant::SizeF: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSizeF, value.toSizeF())); + } + + case TQVariant::SizePolicy: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQSizePolicy, + value.value())); + } + + case TQVariant::String: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQString, value.toString())); + } + + case TQVariant::StringList: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQStringList, value.toStringList())); + } + + case TQVariant::TextFormat: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTextFormat, + value.value())); + } + + case TQVariant::TextLength: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTextLength, + value.value())); + } + + case TQVariant::Time: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQTime, value.toTime())); + } + + case TQVariant::UInt: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(uint, value.toUInt())); + } + + case TQVariant::ULongLong: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(qulonglong, value.toULongLong())); + } + + case TQVariant::Url: + { + return mMethod.invoke(obj, TQt::DirectConnection, Q_ARG(TQUrl, value.toUrl())); + } + +#if TQT_VERSION >= 0x040600 + case TQVariant::Vector2D: + { + return mMethod.invoke(obj, TQt::DirectConnection, + Q_ARG(TQVector2D, value.value())); + } + + case TQVariant::Vector3D: + { + return mMethod.invoke(obj, TQt::DirectConnection, + Q_ARG(TQVector3D, value.value())); + } + + case TQVariant::Vector4D: + { + return mMethod.invoke(obj, TQt::DirectConnection, + Q_ARG(TQVector4D, value.value())); + } + +#endif + default: + { + return false; + } + } +} diff --git a/src/__TODO/UiGuiSettings.h b/src/__TODO/UiGuiSettings.h new file mode 100644 index 0000000..5068d52 --- /dev/null +++ b/src/__TODO/UiGuiSettings.h @@ -0,0 +1,94 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#ifndef UIGUISETTINGS_H +#define UIGUISETTINGS_H + +#include +#include +/////#include + +class TQSettings; + + +class UiGuiSettings : public TQObject +{ + Q_OBJECT + + private: + UiGuiSettings(); + + static UiGuiSettings *_instance; + + public: + static UiGuiSettings* getInstance(); + + ~UiGuiSettings(); + + bool registerObjectProperty(TQObject *obj, const TQString &propertyName, + const TQString &settingName); + bool registerObjectPropertyRecursive(TQObject *obj); + bool setObjectPropertyToSettingValue(TQObject *obj, const TQString &propertyName, + const TQString &settingName); + bool setObjectPropertyToSettingValueRecursive(TQObject *obj); + bool setSettingToObjectPropertyValue(TQObject *obj, const TQString &propertyName, + const TQString &settingName); + bool setSettingToObjectPropertyValueRecursive(TQObject *obj); + bool registerObjectSlot(TQObject *obj, const TQString &slotName, + const TQString &settingName); + TQVariant getValueByName(TQString settingName); + TQStringList getAvailableTranslations(); + + public slots: + void setValueByName(const TQString &settingName, const TQVariant &value); + void unregisterObjectProperty(TQObject *obj); + void unregisterObjectSlot(TQObject *obj, const TQString &slotName = "", + const TQString &settingName = ""); + + protected: + bool initSettings(); + bool invokeMethodWithValue(TQObject *obj, TQMetaMethod mMethod, TQVariant value); + + bool checkCustomPropertiesAndCallFunction(TQObject * obj, + bool (UiGuiSettings::*callBackFunc)(TQObject *obj, const TQString &propertyName, + const TQString &settingName)); + + private slots: + void handleObjectPropertyChange(); + + private: + void readAvailableTranslations(); + + //! Stores the mnemonics of the available translations. + TQStringList _availableTranslations; + + //! The settings file. + TQSettings *_qsettings; + + //! Maps an TQObject to a string list containing the property name and the associated setting + // name. + TQMap _registeredObjectProperties; + + //! Maps TQObjects to a string list containing the method name and the associated setting name. + TQMultiMap _registeredObjectSlots; + + TQString _indenterDirctoryStr; +}; + +#endif // UIGUISETTINGS_H diff --git a/src/__TODO/UiGuiSettingsDialog.cpp b/src/__TODO/UiGuiSettingsDialog.cpp new file mode 100644 index 0000000..8bfe0e5 --- /dev/null +++ b/src/__TODO/UiGuiSettingsDialog.cpp @@ -0,0 +1,205 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#include "UiGuiSettingsDialog.h" +#include "ui_UiGuiSettingsDialog.h" + +#include "UiGuiSettings.h" + +/*! + \class UiGuiSettingsDialog + \ingroup grp_Settings + \brief Displays a dialog window with settings for UniversalIndentGUI +*/ + +/*! + \brief The constructor calls the setup function for the ui created by uic. +*/ +UiGuiSettingsDialog::UiGuiSettingsDialog(TQWidget *parent, + TQSharedPointer settings) : + TQDialog(parent) +{ + // Remember pointer to the UiGuiSettings object. + _settings = settings; + + // Init the user interface created by the UIC. + _settingsDialogForm = new Ui::SettingsDialog(); + _settingsDialogForm->setupUi(this); + + //TODO: This call has to be removed when the properties for the highlighters can be set + // with the settings dialog. + _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( + "(Will be implemented soon)" + + _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); + + // Connect the accepted signal to own function, to write values back to the UiGuiSettings object. + connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings())); + + // Init the language selection combobox. + initTranslationSelection(); +} + +/*! + \brief By calling this function the combobox for selecting the application language will + be initialized. + + Also the translation itself will be reinitialized. + */ +void UiGuiSettingsDialog::initTranslationSelection() +{ + // First empty the combo box. + _settingsDialogForm->languageSelectionComboBox->clear(); + + // Now add an entry into the box for every language short. + foreach(TQString languageShort, _settings->getAvailableTranslations()) + { + // Identify the language mnemonic and set the full name. + if (languageShort == "en") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("English")); + } + else if (languageShort == "fr") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("French")); + } + else if (languageShort == "de") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("German")); + } + else if (languageShort == "zh_TW") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("Chinese (Taiwan)")); + } + else if (languageShort == "ja") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("Japanese")); + } + else if (languageShort == "ru") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("Russian")); + } + else if (languageShort == "uk") + { + _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" + + languageShort + ".png")), tr("Ukrainian")); + } + else + { + _settingsDialogForm->languageSelectionComboBox->addItem(tr( + "Unknown language mnemonic ") + languageShort); + } + } +} + +/*! + \brief Displays the dialog by calling the dialogs exec function. + + Before it gets all the values needed from the UiGuiSettings object. + */ +int UiGuiSettingsDialog::showDialog() +{ + // Init all settings dialog objects with values from settings. + _settings->setObjectPropertyToSettingValueRecursive(this); + + // Execute the dialog. + return exec(); +} + +/*! + \brief This slot is called when the dialog box is closed by pressing the Ok button. + + Writes all settings to the UiGuiSettings object. + */ +void UiGuiSettingsDialog::writeWidgetValuesToSettings() +{ + // Write settings dialog object values to settings. + _settings->setSettingToObjectPropertyValueRecursive(this); +} + +/*! + \brief Catches language change events and retranslates all needed widgets. + */ +void UiGuiSettingsDialog::changeEvent(TQEvent *event) +{ + if (event->type() == TQEvent::LanguageChange) + { + _settingsDialogForm->retranslateUi(this); + // If this is not explicit set here, TQt < 4.3.0 does not translate the buttons. + _settingsDialogForm->buttonBox->setStandardButtons( + TQDialogButtonBox::Cancel | TQDialogButtonBox::NoButton | TQDialogButtonBox::Ok); + + //TODO: This has to be removed when the properties for the highlighters can be set. + _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( + "(Will be implemented soon)" + + _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); + + TQStringList languageShortList = _settings->getAvailableTranslations(); + + // Now retranslate every entry in the language selection box. + for (int i = 0; i < languageShortList.size(); i++) + { + TQString languageShort = languageShortList.at(i); + + // Identify the language mnemonic and set the full name. + if (languageShort == "en") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("English")); + } + else if (languageShort == "fr") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("French")); + } + else if (languageShort == "de") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("German")); + } + else if (languageShort == "zh_TW") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Chinese (Taiwan)")); + } + else if (languageShort == "ja") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Japanese")); + } + else if (languageShort == "ru") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Russian")); + } + else if (languageShort == "uk") + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Ukrainian")); + } + else + { + _settingsDialogForm->languageSelectionComboBox->setItemText(i, + tr("Unknown language mnemonic ") + languageShort); + } + } + } + else + { + TQWidget::changeEvent(event); + } +} diff --git a/src/__TODO/UiGuiSettingsDialog.h b/src/__TODO/UiGuiSettingsDialog.h new file mode 100644 index 0000000..8dc9543 --- /dev/null +++ b/src/__TODO/UiGuiSettingsDialog.h @@ -0,0 +1,55 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#ifndef UIGUISETTINGSDIALOG_H +#define UIGUISETTINGSDIALOG_H + +#include + +#include "UiGuiSettings.h" + +namespace Ui +{ + class SettingsDialog; +} + + +class UiGuiSettingsDialog : public TQDialog +{ + Q_OBJECT + + public: + UiGuiSettingsDialog(TQWidget *parent, TQSharedPointer settings); + + public slots: + int showDialog(); + + private slots: + void writeWidgetValuesToSettings(); + + private: + Ui::SettingsDialog *_settingsDialogForm; + + void changeEvent(TQEvent *event); + void initTranslationSelection(); + + TQSharedPointer _settings; +}; + +#endif // UIGUISETTINGSDIALOG_H diff --git a/src/__TODO/UiGuiSettingsDialog.ui b/src/__TODO/UiGuiSettingsDialog.ui new file mode 100755 index 0000000..2f96561 --- /dev/null +++ b/src/__TODO/UiGuiSettingsDialog.ui @@ -0,0 +1,625 @@ + + + SettingsDialog + + + TQt::ApplicationModal + + + + 0 + 0 + 503 + 336 + + + + Settings + + + + :/mainWindow/preferences-system.png:/mainWindow/preferences-system.png + + + + + + 0 + + + + + :/settingsDialog/applications-system.png:/settingsDialog/applications-system.png + + + Common + + + + + + + + Displays all available translations for UniversalIndentGui and lets you choose one. + + + Application language + + + languageSelectionComboBox + + + + + + + + 0 + 0 + + + + Displays all available translations for UniversalIndentGui and lets you choose one. + + + language + + + currentIndex + + + + + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + + + If selected opens the source code file on startup that was opened last time. + + + Automatically open last file on startup + + + loadLastSourceCodeFileOnStartup + + + checked + + + + + + + If checked, tool tips will show up if the mouse cursor remains over an indenter parameter for a while. + + + Enable Parameter Tooltips + + + indenterParameterTooltipsEnabled + + + checked + + + + + + + + + Sets how many files should be remembered in the list of recently opened files. + + + Number of files in recently opened list + + + + + + + + 0 + 0 + + + + Sets how many files should be remembered in the list of recently opened files. + + + 1 + + + 30 + + + 1 + + + recentlyOpenedListSize + + + value + + + + + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + + + TQt::Vertical + + + + 20 + 40 + + + + + + + + + + :/settingsDialog/accessories-text-editor.png:/settingsDialog/accessories-text-editor.png + + + Editor + + + + + + Enables or disables displaying of white space characters in the editor. + + + Display white space character (tabs, spaces, etc.) + + + whiteSpaceIsVisible + + + checked + + + + + + + + + Sets width in single spaces used for tabs + + + Defines how many spaces should be displayed in the editor for one tab. + + + Displayed width of tabs + + + + + + + + 0 + 0 + + + + Defines how many spaces should be displayed in the editor for one tab character. + + + 1 + + + 99 + + + 1 + + + tabWidth + + + value + + + + + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + + + TQt::Vertical + + + + 20 + 40 + + + + + + + + + + :/mainWindow/system-software-update.png:/mainWindow/system-software-update.png + + + Network + + + + + + Checks whether a new version of UniversalIndentGUI exists on program start, but only once a day. + + + Check online for update on program start + + + CheckForUpdate + + + checked + + + + + + + + + + + + + If checked, the made proxy settings will be applied for all network connections. Type of the used proxy is SOCKS5. + + + Enable proxy + + + ProxyEnabled + + + checked + + + + + + + false + + + + + + Host name: + + + proxyHostNameLineEdit + + + + + + + Host name of the to be used proxy. E.g.: proxy.example.com + + + ProxyHostName + + + text + + + + + + + Port: + + + proxyPortSpinBox + + + + + + + Port number to connect to the before named proxy. + + + TQt::AlignRight|TQt::AlignTrailing|TQt::AlignVCenter + + + TQAbstractSpinBox::NoButtons + + + 99999 + + + ProxyPort + + + text + + + + + + + User name: + + + proxyUserNameLineEdit + + + + + + + If the proxy needs authentification, enter the login name here. + + + ProxyUserName + + + text + + + + + + + Password: + + + proxyPasswordLineEdit + + + + + + + If the proxy needs authentification, enter the password here. + + + TQLineEdit::Password + + + ProxyPassword + + + text + + + + + + + + + + + + + + + :/settingsDialog/syntax-highlight.png:/settingsDialog/syntax-highlight.png + + + Syntax Highlighting + + + + + + By enabling special key words of the source code are highlighted. + + + Enable syntax highlighting + + + SyntaxHighlightingEnabled + + + checked + + + + + + + false + + + Lets you make settings for all properties of the available syntax highlighters, like font and color. + + + Highlighter settings + + + + + + -1 + + + + + + + -1 + + + + + + + + + Set the font for the current selected highlighter property. + + + Set Font + + + + + + + Set the color for the current selected highlighter property. + + + Set Color + + + + + + + TQt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + TQt::Vertical + + + + 20 + 40 + + + + + + + + + + + + TQt::Horizontal + + + TQDialogButtonBox::Cancel|TQDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + SettingsDialog + accept() + + + 250 + 316 + + + 153 + 236 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 327 + 316 + + + 282 + 236 + + + + + enableProxyCheckBox + toggled(bool) + widget + setEnabled(bool) + + + 73 + 68 + + + 76 + 95 + + + + + diff --git a/src/__TODO/UiGuiSystemInfo.cpp b/src/__TODO/UiGuiSystemInfo.cpp new file mode 100644 index 0000000..5456519 --- /dev/null +++ b/src/__TODO/UiGuiSystemInfo.cpp @@ -0,0 +1,317 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UiGuiSystemInfo.h" + +#include +#include +#include +#include + +UiGuiSystemInfo::UiGuiSystemInfo() +{ +} + +/*! + \brief Returns the operating system UiGUI is currently running on as one string. + + The String contains name and version of the os. E.g. Linux Ubuntu 9.04. + */ +TQString UiGuiSystemInfo::getOperatingSystem() +{ + TQString operatingSystemString = ""; + +#if defined (Q_WS_WIN) + switch (TQSysInfo::WindowsVersion) + { + case TQSysInfo::WV_32s: + { + operatingSystemString = "Windows 3.1 with Win 32s"; + break; + } + + case TQSysInfo::WV_95: + { + operatingSystemString = "Windows 95"; + break; + } + + case TQSysInfo::WV_98: + { + operatingSystemString = "Windows 98"; + break; + } + + case TQSysInfo::WV_Me: + { + operatingSystemString = "Windows Me"; + break; + } + + case TQSysInfo::WV_NT: + { + operatingSystemString = "Windows NT (operating system version 4.0)"; + break; + } + + case TQSysInfo::WV_2000: + { + operatingSystemString = "Windows 2000 (operating system version 5.0)"; + break; + } + + case TQSysInfo::WV_XP: + { + operatingSystemString = "Windows XP (operating system version 5.1)"; + break; + } + + case TQSysInfo::WV_2003: + { + operatingSystemString = + "Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)"; + break; + } + + case TQSysInfo::WV_VISTA: + { + operatingSystemString = "Windows Vista, Windows Server 2008 (operating system version 6.0)"; + break; + } + + case TQSysInfo::WV_WINDOWS7: + { + operatingSystemString = "Windows 7 (operating system version 6.1)"; + break; + } + + case TQSysInfo::WV_CE: + { + operatingSystemString = "Windows CE"; + break; + } + + case TQSysInfo::WV_CENET: + { + operatingSystemString = "Windows CE .NET"; + break; + } + + case TQSysInfo::WV_CE_5: + { + operatingSystemString = "Windows CE 5.x"; + break; + } + + case TQSysInfo::WV_CE_6: + { + operatingSystemString = "Windows CE 6.x"; + break; + } + + default: + { + operatingSystemString = "Unknown Windows operating system."; + break; + } + } +#elif defined (Q_WS_MAC) + switch (TQSysInfo::MacintoshVersion) + { + case TQSysInfo::MV_9: + { + operatingSystemString = "Mac OS 9 (unsupported)"; + break; + } + + case TQSysInfo::MV_10_0: + { + operatingSystemString = "Mac OS X 10.0 Cheetah (unsupported)"; + break; + } + + case TQSysInfo::MV_10_1: + { + operatingSystemString = "Mac OS X 10.1 Puma (unsupported)"; + break; + } + + case TQSysInfo::MV_10_2: + { + operatingSystemString = "Mac OS X 10.2 Jaguar (unsupported)"; + break; + } + + case TQSysInfo::MV_10_3: + { + operatingSystemString = "Mac OS X 10.3 Panther"; + break; + } + + case TQSysInfo::MV_10_4: + { + operatingSystemString = "Mac OS X 10.4 Tiger"; + break; + } + + case TQSysInfo::MV_10_5: + { + operatingSystemString = "Mac OS X 10.5 Leopard"; + break; + } + + case TQSysInfo::MV_10_6: + { + operatingSystemString = "Mac OS X 10.6 Snow Leopard"; + break; + } + + case TQSysInfo::MV_Unknown: + { + operatingSystemString = "An unknown and currently unsupported platform"; + break; + } + + default: + { + operatingSystemString = "Unknown Mac operating system."; + break; + } + } +#else + //TODO: Detect Unix, Linux etc. distro as described on + // http://www.novell.com/coolsolutions/feature/11251.html + operatingSystemString = "Linux"; + TQProcess process; + + process.start("uname -s"); + bool result = process.waitForFinished(1000); + TQString os = process.readAllStandardOutput().trimmed(); + + process.start("uname -r"); + result = process.waitForFinished(1000); + TQString rev = process.readAllStandardOutput().trimmed(); + + process.start("uname -m"); + result = process.waitForFinished(1000); + TQString mach = process.readAllStandardOutput().trimmed(); + + if (os == "SunOS") + { + os = "Solaris"; + + process.start("uname -p"); + result = process.waitForFinished(1000); + TQString arch = process.readAllStandardOutput().trimmed(); + + process.start("uname -v"); + result = process.waitForFinished(1000); + TQString timestamp = process.readAllStandardOutput().trimmed(); + + operatingSystemString = os + " " + rev + " (" + arch + " " + timestamp + ")"; + } + else if (os == "AIX") + { + process.start("oslevel -r"); + result = process.waitForFinished(1000); + TQString oslevel = process.readAllStandardOutput().trimmed(); + + operatingSystemString = os + "oslevel " + oslevel; + } + else if (os == "Linux") + { + TQString dist; + TQString pseudoname; + TQString kernel = rev; + + if (TQFile::exists("/etc/redhat-release")) + { + dist = "RedHat"; + + process.start("sh -c \"cat /etc/redhat-release | sed s/.*\\(// | sed s/\\)//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/redhat-release | sed s/.*release\\ // | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if (TQFile::exists("/etc/SUSE-release")) + { + process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' '| sed s/VERSION.*//\""); + result = process.waitForFinished(1000); + dist = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' ' | sed s/.*=\\ //\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if (TQFile::exists("/etc/mandrake-release")) + { + dist = "Mandrake"; + + process.start("sh -c \"cat /etc/mandrake-release | sed s/.*\\(// | sed s/\\)//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/mandrake-release | sed s/.*release\\ // | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if (TQFile::exists("/etc/lsb-release")) + { + dist = "Ubuntu"; + + TQString processCall = + "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_RELEASE=// | sed s/\\ .*//\""; + process.start(processCall); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + TQString errorStr = process.readAllStandardError(); + + process.start( + "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_CODENAME=// | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + } + else if (TQFile::exists("/etc/debian_version")) + { + dist = "Debian"; + + process.start("cat /etc/debian_version"); + result = process.waitForFinished(1000); + dist += process.readAllStandardOutput().trimmed(); + + rev = ""; + } + + if (TQFile::exists("/etc/UnitedLinux-release")) + { + process.start("sh -c \"cat /etc/UnitedLinux-release | tr '\\n' ' ' | sed s/VERSION.*//\""); + result = process.waitForFinished(1000); + dist += process.readAllStandardOutput().trimmed(); + } + + operatingSystemString = os + " " + dist + " " + rev + " (" + pseudoname + " " + kernel + " " + + mach + ")"; + } +#endif + + return operatingSystemString; +} diff --git a/src/__TODO/UiGuiSystemInfo.h b/src/__TODO/UiGuiSystemInfo.h new file mode 100644 index 0000000..4d6405d --- /dev/null +++ b/src/__TODO/UiGuiSystemInfo.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UIGUISYSTEMINFO_H +#define UIGUISYSTEMINFO_H + +class TQString; + + +class UiGuiSystemInfo +{ + public: + static TQString getOperatingSystem(); + + private: + UiGuiSystemInfo(); +}; + +#endif // UIGUISYSTEMINFO_H diff --git a/src/__TODO/UpdateCheckDialog.cpp b/src/__TODO/UpdateCheckDialog.cpp new file mode 100644 index 0000000..5c9b1e3 --- /dev/null +++ b/src/__TODO/UpdateCheckDialog.cpp @@ -0,0 +1,356 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "UpdateCheckDialog.h" +#include "ui_UpdateCheckDialog.h" + +#include "UiGuiSettings.h" +#include "UiGuiVersion.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class UpdateCheckDialog + \ingroup grp_MainWindow + \brief UpdateCheckDialog is a dialog widget that contains functions + for online checking for a new version of UniversalIndentGUI. +*/ + +/*! + \brief Initializes member variables and stores the version of UiGui and a pointer to the _settings object. + */ +UpdateCheckDialog::UpdateCheckDialog(TQSharedPointer settings, TQWidget *parent) : + TQDialog(parent), _manualUpdateRequested(false), _currentNetworkReply(NULL), + _roleOfClickedButton(TQDialogButtonBox::InvalidRole) +{ + _updateCheckDialogForm = new Ui::UpdateCheckDialog(); + _updateCheckDialogForm->setupUi(this); + + // Create object for _networkAccessManager request and connect it with the request return handler. + _networkAccessManager = new TQNetworkAccessManager(this); + connect(_networkAccessManager, SIGNAL(finished(TQNetworkReply*)), this, + SLOT(checkResultsOfFetchedPadXMLFile(TQNetworkReply*))); + + // Create a timer object used for the progress bar. + _updateCheckProgressTimer = new TQTimer(this); + _updateCheckProgressTimer->setInterval(5); + connect(_updateCheckProgressTimer, SIGNAL(timeout()), this, SLOT(updateUpdateCheckProgressBar())); + _updateCheckProgressCounter = 0; + + // Connect the dialogs buttonbox with a button click handler. + connect(_updateCheckDialogForm->buttonBox, SIGNAL(clicked(TQAbstractButton*)), this, + SLOT(handleUpdateCheckDialogButtonClicked(TQAbstractButton*))); + + settings->registerObjectSlot(this, "initProxySettings()", "ProxyEnabled"); + settings->registerObjectSlot(this, "initProxySettings()", "ProxyHostName"); + settings->registerObjectSlot(this, "initProxySettings()", "ProxyPort"); + settings->registerObjectSlot(this, "initProxySettings()", "ProxyUserName"); + settings->registerObjectSlot(this, "initProxySettings()", "ProxyPassword"); + + _settings = settings; + + initProxySettings(); + + // This dialog is always modal. + setModal(true); +} + +/*! + \brief On destroy cancels any currently running network request. + */ +UpdateCheckDialog::~UpdateCheckDialog() +{ + disconnect(_networkAccessManager, SIGNAL(finished(TQNetworkReply*)), this, + SLOT(checkResultsOfFetchedPadXMLFile(TQNetworkReply*))); + if (_currentNetworkReply != NULL) + { + _currentNetworkReply->abort(); + } +} + +/*! + \brief This slot should be called, if an update check is manually invoked. + + In difference to the automatic update check, during manual update check request + a modal progress indicator dialog will be shown. + */ +void UpdateCheckDialog::checkForUpdateAndShowDialog() +{ + _manualUpdateRequested = true; + getPadXMLFile(); + showCheckingForUpdateDialog(); +} + +/*! + \brief This slot should be called, if an update check is automatically invoked. + + An automatic invoked update check should run in background, so the user + gets not interrupted by a dialog box. + */ +void UpdateCheckDialog::checkForUpdate() +{ + _manualUpdateRequested = false; + getPadXMLFile(); +} + +/*! + \brief This function tries to download the UniversalIndentGui pad file from the SourceForge server. + */ +void UpdateCheckDialog::getPadXMLFile() +{ + //_networkAccessManager->setHost("universalindent.sourceforge.net"); + //_networkAccessManager->get("/universalindentgui_pad.xml"); + _currentNetworkReply = _networkAccessManager->get(TQNetworkRequest(TQUrl( + "http://universalindent.sourceforge.net/universalindentgui_pad.xml"))); +} + +/*! + \brief This slot is called after the update check has returned, either by successfully + retrieving the pad file, or on any kind of network error. + + Shows a message if check was successful or not. Offers the user to go to the + download page if a newer version exists. In case of an error during update + check, a message box with the error will be displayed. + */ +void UpdateCheckDialog::checkResultsOfFetchedPadXMLFile(TQNetworkReply *networkReply) +{ + Q_ASSERT(_currentNetworkReply == networkReply); + + // Stop the progress bar timer. + _updateCheckProgressTimer->stop(); + + if (networkReply->error() == TQNetworkReply::NoError) + { + // Try to find the version string. + TQString returnedString = networkReply->readAll(); + int leftPosition = returnedString.indexOf(""); + int rightPosition = returnedString.indexOf(""); + + // If the version string could be found in the returned string, show an update dialog and set + // last update check date. + if (leftPosition != -1 && rightPosition != -1) + { + // Get the pure version string from returned string. + returnedString = returnedString.mid(leftPosition + 17, rightPosition - (leftPosition + 17)); + + // Create integer values from the version strings. + int versionOnServerInt = convertVersionStringToNumber(returnedString); + int currentVersionInt = convertVersionStringToNumber(PROGRAM_VERSION_STRING); + + // Only show update dialog, if the current version number is lower than the one received from + // the server. + if (versionOnServerInt > currentVersionInt && currentVersionInt >= 0 && + versionOnServerInt >= 0) + { + // Show message box whether to download the new version. + showNewVersionAvailableDialog(returnedString); + + // If yes clicked, open the download url in the default browser. + if (_roleOfClickedButton == TQDialogButtonBox::YesRole) + { + TQDesktopServices::openUrl(TQUrl( + "_networkAccessManager://sourceforge.net/project/showfiles.php?group_id=167482")); + } + } + else if (_manualUpdateRequested) + { + showNoNewVersionAvailableDialog(); + } + // Set last update check date. + _settings->setValueByName("LastUpdateCheck", TQDate::currentDate()); + } + // In the returned string, the version string could not be found. + else + { + TQMessageBox::warning(this, tr("Update check error"), tr( + "There was an error while trying to check for an update! The retrieved file did not contain expected content.")); + } + } + // If there was some error while trying to retrieve the update info from server and not cancel was + // pressed. + else if (_roleOfClickedButton != TQDialogButtonBox::RejectRole) + { + TQMessageBox::warning(this, tr("Update check error"), + tr("There was an error while trying to check for an update! Error was : %1").arg( + networkReply->errorString())); + hide(); + } + _manualUpdateRequested = false; + networkReply->deleteLater(); + _currentNetworkReply = NULL; +} + +/*! + \brief Displays the progress bar during update check. + + For displaying activity during update check, a timer is started to + updated the progress bar. The user can press a cancel button to + stop the update check. + */ +void UpdateCheckDialog::showCheckingForUpdateDialog() +{ + // Reset the progress bar. + _updateCheckProgressCounter = 0; + _updateCheckDialogForm->progressBar->setValue(_updateCheckProgressCounter); + _updateCheckDialogForm->progressBar->setInvertedAppearance(false); + + _updateCheckProgressTimer->start(); + _updateCheckDialogForm->progressBar->show(); + setWindowTitle(tr("Checking for update...")); + _updateCheckDialogForm->label->setText(tr("Checking whether a newer version is available")); + _updateCheckDialogForm->buttonBox->setStandardButtons(TQDialogButtonBox::Cancel); + show(); +} + +/*! + \brief Displays the dialog with info about the new available version. + */ +void UpdateCheckDialog::showNewVersionAvailableDialog(TQString newVersion) +{ + _updateCheckDialogForm->progressBar->hide(); + setWindowTitle(tr("Update available")); + _updateCheckDialogForm->label->setText(tr( + "A newer version of UniversalIndentGUI is available.\nYour version is %1. New version is %2.\nDo you want to go to the download website?").arg( + PROGRAM_VERSION_STRING).arg(newVersion)); + _updateCheckDialogForm->buttonBox->setStandardButtons( + TQDialogButtonBox::No | TQDialogButtonBox::NoButton | TQDialogButtonBox::Yes); + exec(); +} + +/*! + \brief Displays the dialog, that no new version is available. + */ +void UpdateCheckDialog::showNoNewVersionAvailableDialog() +{ + _updateCheckDialogForm->progressBar->hide(); + setWindowTitle(tr("No new update available")); + _updateCheckDialogForm->label->setText(tr( + "You already have the latest version of UniversalIndentGUI.")); + _updateCheckDialogForm->buttonBox->setStandardButtons(TQDialogButtonBox::Ok); + exec(); +} + +/*! + \brief This slot is called, when a button in the dialog is clicked. + + If the clicked button was the cancel button, the user wants to cancel + the update check. So the _networkAccessManager request is aborted and the timer for the + progress bar animation is stopped. + + In any case if a button is clicked, the dialog box will be closed. + */ +void UpdateCheckDialog::handleUpdateCheckDialogButtonClicked(TQAbstractButton *clickedButton) +{ + _roleOfClickedButton = _updateCheckDialogForm->buttonBox->buttonRole(clickedButton); + + if (_roleOfClickedButton == TQDialogButtonBox::RejectRole) + { + // Abort the _networkAccessManager request. + _currentNetworkReply->abort(); + // Stop the progress bar timer. + _updateCheckProgressTimer->stop(); + } + + accept(); +} + +/*! + \brief This slot is responsible for the animation of the update check progress bar. + */ +void UpdateCheckDialog::updateUpdateCheckProgressBar() +{ + // Depending on the progress bar direction, decrease or increase the progressbar value. + if (_updateCheckDialogForm->progressBar->invertedAppearance()) + { + _updateCheckProgressCounter--; + } + else + { + _updateCheckProgressCounter++; + } + + // If the progress bar reaches 0 or 100 as value, swap the animation direction. + if (_updateCheckProgressCounter == 0 || _updateCheckProgressCounter == 100) + { + _updateCheckDialogForm->progressBar->setInvertedAppearance( + !_updateCheckDialogForm->progressBar->invertedAppearance()); + } + + // Update the progress bar value. + _updateCheckDialogForm->progressBar->setValue(_updateCheckProgressCounter); +} + +/*! + \brief Converts the as string given version \a versionString to an integer number. + + The \a versionString must have the format x.x.x where each x represents a number + of a maximum of 999. If the input format is wrong, -1 will be returned.The first + number will be multiplied by 1000000 the second by 1000 and then all three will + be summarized. + + Thus for example 12.5.170 will result in 12005170. + */ +int UpdateCheckDialog::convertVersionStringToNumber(TQString versionString) +{ + int versionInteger = 0; + int pos = 0; + + TQRegExp regEx("\\d{1,3}.\\d{1,3}.\\d{1,3}"); + TQRegExpValidator validator(regEx, NULL); + + if (validator.validate(versionString, pos) == TQValidator::Acceptable) + { + TQStringList versionNumberStringList = versionString.split("."); + versionInteger = versionNumberStringList.at(0).toInt() * 1000000; + versionInteger += versionNumberStringList.at(1).toInt() * 1000; + versionInteger += versionNumberStringList.at(2).toInt(); + } + else + { + versionInteger = -1; + } + + return versionInteger; +} + +void UpdateCheckDialog::initProxySettings() +{ + if (_settings->getValueByName("ProxyEnabled") == true) + { + TQString proxyHostName = _settings->getValueByName("ProxyHostName").toString(); + int proxyPort = _settings->getValueByName("ProxyPort").toInt(); + TQString proxyUserName = _settings->getValueByName("ProxyUserName").toString(); + TQString proxyPassword = _settings->getValueByName("ProxyPassword").toString(); + _networkAccessManager->setProxy(TQNetworkProxy(TQNetworkProxy::Socks5Proxy, proxyHostName, + proxyPort, proxyUserName, proxyPassword)); + } + else + { + _networkAccessManager->setProxy(TQNetworkProxy()); + } +} diff --git a/src/__TODO/UpdateCheckDialog.h b/src/__TODO/UpdateCheckDialog.h new file mode 100644 index 0000000..6f1116b --- /dev/null +++ b/src/__TODO/UpdateCheckDialog.h @@ -0,0 +1,74 @@ +/*************************************************************************** + * Copyright (C) 2006-2012 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef UPDATECHECKDIALOG_H +#define UPDATECHECKDIALOG_H + +#include +#include + +class UiGuiSettings; +namespace Ui +{ + class UpdateCheckDialog; +} + +class TQTimer; +class TQDesktopServices; +class TQNetworkAccessManager; +class TQNetworkReply; + + +class UpdateCheckDialog : public TQDialog +{ + Q_OBJECT + + public: + UpdateCheckDialog(TQSharedPointer settings, TQWidget *parent = NULL); + ~UpdateCheckDialog(); + + public slots: + void checkForUpdateAndShowDialog(); + void checkForUpdate(); + + private slots: + void checkResultsOfFetchedPadXMLFile(TQNetworkReply *networkReply); + void handleUpdateCheckDialogButtonClicked(TQAbstractButton *clickedButton); + void updateUpdateCheckProgressBar(); + void initProxySettings(); + + private: + Ui::UpdateCheckDialog *_updateCheckDialogForm; + + void getPadXMLFile(); + void showCheckingForUpdateDialog(); + void showNewVersionAvailableDialog(TQString newVersion); + void showNoNewVersionAvailableDialog(); + int convertVersionStringToNumber(TQString versionString); + + TQSharedPointer _settings; + bool _manualUpdateRequested; + TQNetworkAccessManager *_networkAccessManager; + TQNetworkReply *_currentNetworkReply; + TQDialogButtonBox::ButtonRole _roleOfClickedButton; + TQTimer *_updateCheckProgressTimer; + int _updateCheckProgressCounter; +}; + +#endif // UPDATECHECKDIALOG_H diff --git a/src/__TODO/UpdateCheckDialog.ui b/src/__TODO/UpdateCheckDialog.ui new file mode 100755 index 0000000..ebfc8bb --- /dev/null +++ b/src/__TODO/UpdateCheckDialog.ui @@ -0,0 +1,51 @@ + + + UpdateCheckDialog + + + TQt::WindowModal + + + + 0 + 0 + 323 + 108 + + + + Checking for update... + + + + + + Checking whether a newer version is available + + + + + + + 0 + + + false + + + + + + + TQDialogButtonBox::Cancel + + + true + + + + + + + + -- cgit v1.2.1