From 731b82a96da98b728796813f95928c286b878393 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Sat, 30 Oct 2021 15:30:39 -0500 Subject: [PATCH] Changed initilization to remove deprecated warnings (#2023) * Changed initilization to remove deprecated warnings * fixing clang formate * Need to do a Qt version check * cleaned up formatting --- src/utils/confighandler.cpp | 164 +++++++++++++++++++----------------- 1 file changed, 88 insertions(+), 76 deletions(-) diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 7cde01ca..49bac2a4 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -18,6 +18,7 @@ #include #include #include + #if defined(Q_OS_MACOS) #include #endif @@ -72,97 +73,96 @@ bool verifyLaunchFile() */ // clang-format off static QMap> - recognizedGeneralOptions = { + recognizedGeneralOptions = { // KEY TYPE DEFAULT_VALUE - OPTION("showHelp" ,Bool ( true )), - OPTION("showSidePanelButton" ,Bool ( true )), - OPTION("showDesktopNotification" ,Bool ( true )), - OPTION("disabledTrayIcon" ,Bool ( false )), - OPTION("historyConfirmationToDelete" ,Bool ( true )), - OPTION("checkForUpdates" ,Bool ( true )), + OPTION("showHelp" ,Bool ( true )), + OPTION("showSidePanelButton" ,Bool ( true )), + OPTION("showDesktopNotification" ,Bool ( true )), + OPTION("disabledTrayIcon" ,Bool ( false )), + OPTION("historyConfirmationToDelete" ,Bool ( true )), + OPTION("checkForUpdates" ,Bool ( true )), #if defined(Q_OS_MACOS) - OPTION("startupLaunch" ,Bool ( false )), + OPTION("startupLaunch" ,Bool ( false )), #else - OPTION("startupLaunch" ,Bool ( true )), + OPTION("startupLaunch" ,Bool ( true )), #endif - OPTION("showStartupLaunchMessage" ,Bool ( true )), - OPTION("copyAndCloseAfterUpload" ,Bool ( true )), - OPTION("copyPathAfterSave" ,Bool ( false )), - OPTION("antialiasingPinZoom" ,Bool ( true )), + OPTION("showStartupLaunchMessage" ,Bool ( true )), + OPTION("copyAndCloseAfterUpload" ,Bool ( true )), + OPTION("copyPathAfterSave" ,Bool ( false )), + OPTION("antialiasingPinZoom" ,Bool ( true )), #if !defined(Q_OS_MACOS) - OPTION("useJpgForClipboard" ,Bool ( false )), + OPTION("useJpgForClipboard" ,Bool ( false )), #endif - OPTION("saveAfterCopy" ,Bool ( false )), - OPTION("savePath" ,ExistingDir ( )), - OPTION("savePathFixed" ,Bool ( false )), - OPTION("setSaveAsFileExtension" ,SaveFileExtension ( )), - OPTION("uploadHistoryMax" ,LowerBoundedInt(0 , 25 )), - OPTION("undoLimit" ,BoundedInt(0, 999 , 100 )), - // Interface tab - OPTION("uiColor" ,Color ( {116, 0, 150} )), - OPTION("contrastUiColor" ,Color ( {39, 0, 50} )), - OPTION("contrastOpacity" ,BoundedInt(0, 255 , 190 )), - OPTION("buttons" ,ButtonList ( {} )), - // Filename Editor tab - OPTION("filenamePattern" ,FilenamePattern ( {} )), - // Others - OPTION("drawThickness" ,LowerBoundedInt(1 , 3 )), - OPTION("drawFontSize" ,LowerBoundedInt(1 , 8 )), - OPTION("drawColor" ,Color ( Qt::red )), - OPTION("userColors" ,UserColors ( )), - OPTION("ignoreUpdateToVersion" ,String ( "" )), - OPTION("keepOpenAppLauncher" ,Bool ( false )), - OPTION("fontFamily" ,String ( "" )), - // NOTE: If another tool size is added besides drawThickness and - // drawFontSize, remember to update ConfigHandler::toolSize - }; + OPTION("saveAfterCopy" ,Bool ( false )), + OPTION("savePath" ,ExistingDir ( )), + OPTION("savePathFixed" ,Bool ( false )), + OPTION("setSaveAsFileExtension" ,SaveFileExtension ( )), + OPTION("uploadHistoryMax" ,LowerBoundedInt(0 , 25 )), + OPTION("undoLimit" ,BoundedInt(0, 999 , 100 )), + // Interface tab + OPTION("uiColor" ,Color ( {116, 0, 150} )), + OPTION("contrastUiColor" ,Color ( {39, 0, 50} )), + OPTION("contrastOpacity" ,BoundedInt(0, 255 , 190 )), + OPTION("buttons" ,ButtonList ( {} )), + // Filename Editor tab + OPTION("filenamePattern" ,FilenamePattern ( {} )), + // Others + OPTION("drawThickness" ,LowerBoundedInt(1 , 3 )), + OPTION("drawFontSize" ,LowerBoundedInt(1 , 8 )), + OPTION("drawColor" ,Color ( Qt::red )), + OPTION("userColors" ,UserColors ( )), + OPTION("ignoreUpdateToVersion" ,String ( "" )), + OPTION("keepOpenAppLauncher" ,Bool ( false )), + OPTION("fontFamily" ,String ( "" )), + // NOTE: If another tool size is added besides drawThickness and + // drawFontSize, remember to update ConfigHandler::toolSize +}; static QMap> recognizedShortcuts = { // NAME DEFAULT_SHORTCUT - SHORTCUT("TYPE_PENCIL" , "P" ), - SHORTCUT("TYPE_DRAWER" , "D" ), - SHORTCUT("TYPE_ARROW" , "A" ), - SHORTCUT("TYPE_SELECTION" , "S" ), - SHORTCUT("TYPE_RECTANGLE" , "R" ), - SHORTCUT("TYPE_CIRCLE" , "C" ), - SHORTCUT("TYPE_MARKER" , "M" ), - SHORTCUT("TYPE_MOVESELECTION" , "Ctrl+M" ), - SHORTCUT("TYPE_UNDO" , "Ctrl+Z" ), - SHORTCUT("TYPE_COPY" , "Ctrl+C" ), - SHORTCUT("TYPE_SAVE" , "Ctrl+S" ), - SHORTCUT("TYPE_ACCEPT" , "Return" ), - SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ), - SHORTCUT("TYPE_IMAGEUPLOADER" , ), + SHORTCUT("TYPE_PENCIL" , "P" ), + SHORTCUT("TYPE_DRAWER" , "D" ), + SHORTCUT("TYPE_ARROW" , "A" ), + SHORTCUT("TYPE_SELECTION" , "S" ), + SHORTCUT("TYPE_RECTANGLE" , "R" ), + SHORTCUT("TYPE_CIRCLE" , "C" ), + SHORTCUT("TYPE_MARKER" , "M" ), + SHORTCUT("TYPE_MOVESELECTION" , "Ctrl+M" ), + SHORTCUT("TYPE_UNDO" , "Ctrl+Z" ), + SHORTCUT("TYPE_COPY" , "Ctrl+C" ), + SHORTCUT("TYPE_SAVE" , "Ctrl+S" ), + SHORTCUT("TYPE_ACCEPT" , "Return" ), + SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ), + SHORTCUT("TYPE_IMAGEUPLOADER" , ), #if !defined(Q_OS_MACOS) - SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ), + SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ), #endif - SHORTCUT("TYPE_PIXELATE" , "B" ), - SHORTCUT("TYPE_INVERT" , "I" ), - SHORTCUT("TYPE_REDO" , "Ctrl+Shift+Z" ), - SHORTCUT("TYPE_TEXT" , "T" ), - SHORTCUT("TYPE_TOGGLE_PANEL" , "Space" ), - SHORTCUT("TYPE_RESIZE_LEFT" , "Shift+Left" ), - SHORTCUT("TYPE_RESIZE_RIGHT" , "Shift+Right" ), - SHORTCUT("TYPE_RESIZE_UP" , "Shift+Up" ), - SHORTCUT("TYPE_RESIZE_DOWN" , "Shift+Down" ), - SHORTCUT("TYPE_SELECT_ALL" , "Ctrl+A" ), - SHORTCUT("TYPE_MOVE_LEFT" , "Left" ), - SHORTCUT("TYPE_MOVE_RIGHT" , "Right" ), - SHORTCUT("TYPE_MOVE_UP" , "Up" ), - SHORTCUT("TYPE_MOVE_DOWN" , "Down" ), - SHORTCUT("TYPE_COMMIT_CURRENT_TOOL" , "Ctrl+Return" ), + SHORTCUT("TYPE_PIXELATE" , "B" ), + SHORTCUT("TYPE_INVERT" , "I" ), + SHORTCUT("TYPE_REDO" , "Ctrl+Shift+Z" ), + SHORTCUT("TYPE_TEXT" , "T" ), + SHORTCUT("TYPE_TOGGLE_PANEL" , "Space" ), + SHORTCUT("TYPE_RESIZE_LEFT" , "Shift+Left" ), + SHORTCUT("TYPE_RESIZE_RIGHT" , "Shift+Right" ), + SHORTCUT("TYPE_RESIZE_UP" , "Shift+Up" ), + SHORTCUT("TYPE_RESIZE_DOWN" , "Shift+Down" ), + SHORTCUT("TYPE_SELECT_ALL" , "Ctrl+A" ), + SHORTCUT("TYPE_MOVE_LEFT" , "Left" ), + SHORTCUT("TYPE_MOVE_RIGHT" , "Right" ), + SHORTCUT("TYPE_MOVE_UP" , "Up" ), + SHORTCUT("TYPE_MOVE_DOWN" , "Down" ), + SHORTCUT("TYPE_COMMIT_CURRENT_TOOL" , "Ctrl+Return" ), #if defined(Q_OS_MACOS) - SHORTCUT("TYPE_DELETE_CURRENT_TOOL" , "Backspace" ), + SHORTCUT("TYPE_DELETE_CURRENT_TOOL" , "Backspace" ), #else - SHORTCUT("TYPE_DELETE_CURRENT_TOOL" , "Delete" ), + SHORTCUT("TYPE_DELETE_CURRENT_TOOL" , "Delete" ), #endif - SHORTCUT("TYPE_PIN" , ), - SHORTCUT("TYPE_SELECTIONINDICATOR" , ), - SHORTCUT("TYPE_SIZEINCREASE" , ), - SHORTCUT("TYPE_SIZEDECREASE" , ), - SHORTCUT("TYPE_CIRCLECOUNT" , ), + SHORTCUT("TYPE_PIN" , ), + SHORTCUT("TYPE_SELECTIONINDICATOR" , ), + SHORTCUT("TYPE_SIZEINCREASE" , ), + SHORTCUT("TYPE_SIZEDECREASE" , ), + SHORTCUT("TYPE_CIRCLECOUNT" , ), }; - // clang-format on // CLASS CONFIGHANDLER @@ -464,15 +464,27 @@ QVariant ConfigHandler::value(const QString& key) const QSet& ConfigHandler::recognizedGeneralOptions() { + +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + static QSet options = + QSet(::recognizedGeneralOptions.keys().begin(), + ::recognizedGeneralOptions.keys().end()); +#else static QSet options = QSet::fromList(::recognizedGeneralOptions.keys()); +#endif return options; } QSet& ConfigHandler::recognizedShortcutNames() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + static QSet names = QSet( + recognizedShortcuts.keys().begin(), recognizedShortcuts.keys().end()); +#else static QSet names = QSet::fromList(recognizedShortcuts.keys()); +#endif return names; }