File indexing completed on 2024-05-19 05:40:37

0001 /***************************************************************************
0002  *  Copyright (C) 2020 by Renaud Guezennec                               *
0003  *   http://www.rolisteam.org/contact                                      *
0004  *                                                                         *
0005  *   This software is free software; you can redistribute it and/or modify *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #include "controller/view_controller/webpagecontroller.h"
0021 
0022 WebpageController::WebpageController(const QString& id, QObject* parent)
0023     : MediaControllerBase(id, Core::ContentType::WEBVIEW, parent)
0024 {
0025 }
0026 
0027 bool WebpageController::hideUrl() const
0028 {
0029     return m_hideUrl;
0030 }
0031 
0032 bool WebpageController::keepSharing() const
0033 {
0034     return m_keepSharing;
0035 }
0036 
0037 QString WebpageController::html() const
0038 {
0039     return m_html;
0040 }
0041 
0042 WebpageController::State WebpageController::state() const
0043 {
0044     return m_state;
0045 }
0046 
0047 void WebpageController::setHideUrl(bool hideUrl)
0048 {
0049     if(m_hideUrl == hideUrl)
0050         return;
0051 
0052     m_hideUrl= hideUrl;
0053     emit hideUrlChanged(m_hideUrl);
0054 }
0055 
0056 void WebpageController::setKeepSharing(bool keepSharing)
0057 {
0058     if(m_keepSharing == keepSharing)
0059         return;
0060 
0061     m_keepSharing= keepSharing;
0062     emit keepSharingChanged(m_keepSharing);
0063 }
0064 
0065 void WebpageController::setHtml(QString html)
0066 {
0067     if(m_html == html)
0068         return;
0069 
0070     m_html= html;
0071     emit htmlChanged(m_html);
0072 }
0073 
0074 void WebpageController::setState(WebpageController::State state)
0075 {
0076     if(m_state == state)
0077         return;
0078 
0079     m_state= state;
0080     emit stateChanged(m_state);
0081 }
0082 
0083 bool WebpageController::htmlSharing() const
0084 {
0085     return Html == m_mode;
0086 }
0087 
0088 bool WebpageController::urlSharing() const
0089 {
0090     return Url == m_mode;
0091 }
0092 
0093 void WebpageController::setHtmlSharing(bool sharing)
0094 {
0095     if(htmlSharing() == sharing)
0096         return;
0097 
0098     if(sharing)
0099         setSharingMode(Html);
0100     else
0101         setSharingMode(None);
0102 
0103     emit htmlSharingChanged(sharing);
0104 }
0105 
0106 void WebpageController::setUrlSharing(bool sharing)
0107 {
0108     if(urlSharing() == sharing)
0109         return;
0110 
0111     if(sharing)
0112         setSharingMode(Url);
0113     else
0114         setSharingMode(None);
0115     emit urlSharingChanged(sharing);
0116 }
0117 
0118 void WebpageController::setSharingMode(WebpageController::SharingMode mode)
0119 {
0120     if(mode == m_mode)
0121         return;
0122 
0123     auto update= false;
0124     if(mode == None || m_mode == None)
0125         update= true;
0126     m_mode= mode;
0127 
0128     if(update)
0129         emit sharingModeChanged(mode);
0130 }
0131 
0132 void WebpageController::setPageUrl(QUrl url)
0133 {
0134     if(url == m_pageUrl)
0135         return;
0136     m_pageUrl= url;
0137     emit pageUrlChanged();
0138 }
0139 
0140 WebpageController::SharingMode WebpageController::sharingMode() const
0141 {
0142     return m_mode;
0143 }
0144 
0145 QUrl WebpageController::pageUrl() const
0146 {
0147     return m_pageUrl;
0148 }