File indexing completed on 2024-04-14 15:17:41
0001 /******************************************************************************** 0002 Copyright (C) 2012 by Michel Ludwig (michel.ludwig@kdemail.net) 0003 ********************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 ***************************************************************************/ 0013 0014 #include "livepreview_utils.h" 0015 0016 #include "kileconfig.h" 0017 0018 namespace KileTool { 0019 0020 LivePreviewUserStatusHandler::LivePreviewUserStatusHandler() 0021 : m_userSpecifiedLivePreviewStatus(false), 0022 m_livePreviewEnabled(true), 0023 m_livePreviewTool(LIVEPREVIEW_DEFAULT_TOOL_NAME, DEFAULT_TOOL_CONFIGURATION) 0024 { 0025 // if something is configured, use that as global default 0026 QString defaultToolName = KileConfig::livePreviewDefaultTool(); 0027 if(!defaultToolName.isEmpty()) { 0028 m_livePreviewTool = KileTool::ToolConfigPair::fromConfigStringRepresentation(defaultToolName); 0029 } 0030 } 0031 0032 bool LivePreviewUserStatusHandler::userSpecifiedLivePreviewStatus() const 0033 { 0034 return m_userSpecifiedLivePreviewStatus; 0035 } 0036 0037 bool LivePreviewUserStatusHandler::isLivePreviewEnabled() const 0038 { 0039 return (m_userSpecifiedLivePreviewStatus ? m_livePreviewEnabled : KileConfig::previewEnabledForFreshlyOpenedDocuments()); 0040 } 0041 0042 void LivePreviewUserStatusHandler::setLivePreviewEnabled(bool b) 0043 { 0044 m_userSpecifiedLivePreviewStatus = true; 0045 m_livePreviewEnabled = b; 0046 } 0047 0048 ToolConfigPair LivePreviewUserStatusHandler::livePreviewTool() const 0049 { 0050 return m_livePreviewTool; 0051 } 0052 0053 bool LivePreviewUserStatusHandler::setLivePreviewTool(const ToolConfigPair& p) 0054 { 0055 if(m_livePreviewTool == p) { 0056 return false; 0057 } 0058 m_livePreviewTool = p; 0059 return true; 0060 } 0061 0062 }