diff --git a/src/callview/qml/streaming.qml b/src/callview/qml/streaming.qml index 76447124..8441665a 100644 --- a/src/callview/qml/streaming.qml +++ b/src/callview/qml/streaming.qml @@ -1,72 +1,73 @@ /*************************************************************************** * Copyright (C) 2017 by Bluesystems * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * 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. If not, see . * **************************************************************************/ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import Ring 1.0 +import net.lvindustries.ringqtquick 1.0 as RingQtQuick ColumnLayout { id: streaming property QtObject call: null property string currentFile: "" Component { id: fileDelegate Item { height: 30 Text { text: display color: "white" anchors.fill: parent anchors.margins: 5 } } } ListView { - model: RecentFileModel + model: RingSession.recentFileModel Layout.fillWidth: true Layout.fillHeight: true delegate: fileDelegate } Button { Layout.fillWidth: true text: i18n("Select file") onClicked: { - streaming.currentFile = RecentFileModel.addFile() + streaming.currentFile = RingSession.recentFileModel.addFile() } } Item { Layout.fillWidth: true height:streamButton.height Button { id: streamButton text: i18n("Stream") anchors.right: parent.right onClicked: { if (!streaming.call) return if (!streaming.call.sourceModel) return streaming.call.sourceModel.setFile(streaming.currentFile) } } } } diff --git a/src/implementation.cpp b/src/implementation.cpp index 39ba3c60..cba7162d 100644 --- a/src/implementation.cpp +++ b/src/implementation.cpp @@ -1,198 +1,229 @@ /*************************************************************************** * Copyright (C) 2013-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * 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. If not, see . * **************************************************************************/ #include "implementation.h" //Qt #include #include #include #include #include #include #include #include #include #include +#include //KDE #include #include //Ring #include #include #include #include #include #include #include #include #include "klib/kcfg_settings.h" #include #include "icons/icons.h" #include ColorDelegate::ColorDelegate() : m_Pal(QGuiApplication::palette()) { m_Green = QColor(m_Pal.color(QPalette::Base)); if (m_Green.green()+20 >= 255) { m_Green.setRed ( ((int)m_Green.red() -20)); m_Green.setBlue( ((int)m_Green.blue() -20)); } else m_Green.setGreen(((int)m_Green.green()+20)); m_Red = QColor(m_Pal.color(QPalette::Base)); if (m_Red.red()+20 >= 255) { m_Red.setGreen( ((int)m_Red.green() -20)); m_Red.setBlue( ((int)m_Red.blue() -20)); } else m_Red.setRed( ((int)m_Red.red() +20)); m_Yellow = QColor(m_Pal.color(QPalette::Base)); if (m_Yellow.red()+20 >= 255 || m_Green.green()+20 >= 255) { m_Yellow.setBlue(((int)m_Yellow.blue() -20)); } else { m_Yellow.setGreen(((int)m_Yellow.green()+20)); m_Yellow.setRed( ((int)m_Yellow.red() +20)); } } QVariant ColorDelegate::color(const Account* a) { switch(a->registrationState()) { case Account::RegistrationState::READY: return m_Green; case Account::RegistrationState::UNREGISTERED: return m_Pal.color(QPalette::Base); case Account::RegistrationState::TRYING: case Account::RegistrationState::INITIALIZING: return m_Yellow; case Account::RegistrationState::ERROR: return m_Red; case Account::RegistrationState::COUNT__: break; }; return QVariant(); } QVariant ColorDelegate::icon(const Account* a) { if (a->editState() == Account::EditState::MODIFIED_COMPLETE) return QIcon::fromTheme(QStringLiteral("document-save")); if (a->editState() == Account::EditState::MODIFIED_INCOMPLETE) return QIcon::fromTheme(QStringLiteral("dialog-warning")); else if (a->editState() == Account::EditState::OUTDATED) { return QIcon::fromTheme(QStringLiteral("view-refresh")); } return QVariant(); } QVariant KDEShortcutDelegate::createAction(Macro* macro) { Q_UNUSED(macro) return {}; } void KDEActionExtender::editPerson(Person* p) { QPointer d = new QQuickView( RingApplication::engine(), nullptr ); d->setSource(QUrl(QStringLiteral("qrc:/ContactDialog.qml"))); d->setResizeMode(QQuickView::SizeRootObjectToView); auto item = d->rootObject(); item->setProperty("currentPerson", QVariant::fromValue(p)); item->setProperty("showStat" , false ); item->setProperty("showImage" , true ); item->setProperty("forcedState", "profile" ); d->resize(800, 600); d->show(); } void KDEActionExtender::viewChatHistory(ContactMethod* cm) { if (!cm) return; // Get a real contact method when necessary if (cm->type() == ContactMethod::Type::TEMPORARY) { cm = Session::instance()->individualDirectory()->getExistingNumberIf( cm->uri(), [](const ContactMethod* cm) -> bool { return cm->textRecording() && !cm->textRecording()->isEmpty(); }); } if (!cm) return; //FIXME open the timeline } void KDEActionExtender::viewChatHistory(Person* p) { if (!p) return; foreach(ContactMethod* cm, p->individual()->phoneNumbers()) viewChatHistory(cm); } void KDEActionExtender::copyInformation(QMimeData* data) { QClipboard* clipboard = QGuiApplication::clipboard(); clipboard->setMimeData(data); } bool KDEActionExtender::warnDeletePerson(Person* p) { const int ret = KMessageBox::questionYesNo(nullptr, i18n("Are you sure you want to permanently delete %1?", p->formattedName()), i18n("Delete contact") ); return ret == KMessageBox::Yes; } bool KDEActionExtender::warnDeleteCall(Call* c) { Q_UNUSED(c) const int ret = KMessageBox::questionYesNo(nullptr, i18n("Are you sure you wish to remove this call?"), i18n("Delete call") ); return ret == KMessageBox::Yes; } Person* KDEActionExtender::selectPerson(FlagPack hints, const QVariant& hintVar) const { Q_UNUSED(hints) Q_UNUSED(hintVar) return nullptr; } ContactMethod* KDEActionExtender::selectContactMethod(FlagPack hints, const QVariant& hintVar) const { Q_UNUSED(hints) Q_UNUSED(hintVar) return nullptr; } -// kate: space-indent on; indent-width 3; replace-tabs on; +QUrl KDEDesktopFileProvider::getAnyFile(const QStringList& extensions) const +{ + return QFileDialog::getOpenFileName( + nullptr, + QStringLiteral("Open File"), + QDir::currentPath(), + QStringLiteral("Media Files (*.png *.jpg *.gif *.mp4 *.mkv *.webm *.txt *.avi *.mpg)") + ); +} + +QList KDEDesktopFileProvider::recentFiles() const +{ + const QStringList files = ConfigurationSkeleton::recentStreamedFiles(); + QList ret; + + for (const auto& f : qAsConst(files)) + ret << f; + + return ret; +} + +void KDEDesktopFileProvider::addRecentFile(const QUrl& path) const +{ + QStringList files = ConfigurationSkeleton::recentStreamedFiles(); + files << path.path(); + + ConfigurationSkeleton::setRecentStreamedFiles(files); + +} + +// kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/implementation.h b/src/implementation.h index 246ca6c3..ebd714d6 100644 --- a/src/implementation.h +++ b/src/implementation.h @@ -1,83 +1,97 @@ /*************************************************************************** * Copyright (C) 2013-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * 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. If not, see . * **************************************************************************/ #ifndef IMPLEMENTATION_H #define IMPLEMENTATION_H // Qt #include #include #include // Ring #include #include #include #include #include +#include class Macro; //Implement all client dependant libringqt abstract interfaces class ColorDelegate final : public QObject, public Interfaces::AccountListColorizerI { Q_OBJECT public: explicit ColorDelegate(); ColorDelegate(const ColorDelegate&) = delete; ColorDelegate& operator=(const ColorDelegate&) = delete; virtual Q_INVOKABLE QVariant color(const Account* a) override; virtual Q_INVOKABLE QVariant icon(const Account* a) override; private: QPalette m_Pal; QColor m_Green; QColor m_Yellow; QColor m_Red; }; class KDEShortcutDelegate final : public Interfaces::ShortcutCreatorI { public: virtual ~KDEShortcutDelegate(){} virtual QVariant createAction(Macro* macro) override; }; class LIB_EXPORT KDEActionExtender final : public Interfaces::ActionExtenderI { public: explicit KDEActionExtender() = default; KDEActionExtender(const KDEActionExtender&) = delete; KDEActionExtender& operator=(const KDEActionExtender&) = delete; virtual void editPerson(Person* p) override; virtual void viewChatHistory(ContactMethod* cm) override; virtual void viewChatHistory(Person* p) override; virtual void copyInformation(QMimeData* data) override; virtual bool warnDeletePerson(Person* p) override; virtual bool warnDeleteCall(Call* c) override; virtual Person* selectPerson(FlagPack hints, const QVariant& hintVar) const override; virtual ContactMethod* selectContactMethod(FlagPack, const QVariant& hintVar) const override; }; +class KDEDesktopFileProvider : public Interfaces::FileProviderI +{ +public: + explicit KDEDesktopFileProvider() = default; + + virtual QUrl getAnyFile(const QStringList& extensions) const override; + + virtual QList recentFiles() const override; + + virtual void addRecentFile(const QUrl& path) const override; + +}; + #endif -// kate: space-indent on; indent-width 3; replace-tabs on; +// kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/qmlwidgets/CMakeLists.txt b/src/qmlwidgets/CMakeLists.txt index 698db4cc..d6f81274 100644 --- a/src/qmlwidgets/CMakeLists.txt +++ b/src/qmlwidgets/CMakeLists.txt @@ -1,91 +1,90 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) ADD_DEFINITIONS("-std=c++11") PROJECT(libqmlwidgets) IF(POLICY CMP0063) CMAKE_POLICY(SET CMP0063 NEW) ENDIF(POLICY CMP0063) FIND_PACKAGE(ECM 1.1.0 REQUIRED NO_MODULE) INCLUDE(ECMInstallIcons) INCLUDE(ECMOptionalAddSubdirectory) INCLUDE(KDEInstallDirs) INCLUDE(KDECMakeSettings) INCLUDE(KDECompilerSettings) SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTORCC ON) SET(CMAKE_AUTOUIC ON) FIND_PACKAGE ( LibRingQt QUIET ) FIND_PACKAGE(Qt5 CONFIG REQUIRED Core Gui Quick QuickWidgets QuickControls2 ) FIND_PACKAGE(KF5 REQUIRED COMPONENTS I18n Config ConfigWidgets ) INCLUDE_DIRECTORIES(SYSTEM ${Qt5Widgets_INCLUDES} ${Qt5Core_INCLUDES} ${ringqt_INCLUDE_DIR}) ADD_DEFINITIONS(${Qt5Core_DEFINITIONS}) SET(GENERIC_LIB_VERSION "1.0.0") #File to compile SET( libqmlwidgets_LIB_SRCS bubble.cpp plugin.cpp messagebuilder.cpp contactbuilder.cpp cmiconengine.cpp personiconengine.cpp treehelper.cpp multicall.cpp - recentfilemodel.cpp snapshotadapter.cpp timelinedots.cpp qmlaction.cpp qactionbinder.cpp symboliccolorizer.cpp ) QT5_ADD_RESOURCES(libqmlwidgets_LIB_SRCS qmlwidgets.qrc ) ADD_LIBRARY( libqmlwidgets STATIC ${libqmlwidgets_LIB_SRCS} ) target_link_libraries( libqmlwidgets ringqt libkring Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickWidgets Qt5::QuickControls2 KF5::ConfigCore KF5::ConfigGui KF5::ConfigWidgets KF5::XmlGui ) SET( libqmlwidgets_LIB_HDRS bubble.h plugin.h messagebuilder.h ) diff --git a/src/qmlwidgets/recentfilemodel.cpp b/src/qmlwidgets/recentfilemodel.cpp deleted file mode 100644 index 3e405d1b..00000000 --- a/src/qmlwidgets/recentfilemodel.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2017 by Bluesystems * - * Author : Emmanuel Lepage Vallee * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * 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. If not, see . * - **************************************************************************/ -#include "recentfilemodel.h" - -#include -#include -#include - -class RecentFileModelPrivate -{ -public: - QStringList m_lFiles; -}; - -RecentFileModel::RecentFileModel() : - QStringListModel(QCoreApplication::instance()), d_ptr(new RecentFileModelPrivate) -{ - d_ptr->m_lFiles = ConfigurationSkeleton::recentStreamedFiles(); - setStringList(d_ptr->m_lFiles); -} - -RecentFileModel::~RecentFileModel() -{ - delete d_ptr; -} - -RecentFileModel& RecentFileModel::instance() -{ - static auto i = new RecentFileModel(); - return *i; -} - -QString RecentFileModel::addFile() -{ - const auto fileName = QFileDialog::getOpenFileName( - nullptr, - QStringLiteral("Open File"), - QDir::currentPath(), - QStringLiteral("Media Files (*.png *.jpg *.gif *.mp4 *.mkv *.webm *.txt *.avi *.mpg)") - ); - - d_ptr->m_lFiles << fileName; - ConfigurationSkeleton::setRecentStreamedFiles(d_ptr->m_lFiles); - - setStringList(d_ptr->m_lFiles); - - return QStringLiteral("file://")+fileName; -} diff --git a/src/qmlwidgets/recentfilemodel.h b/src/qmlwidgets/recentfilemodel.h deleted file mode 100644 index 468559a6..00000000 --- a/src/qmlwidgets/recentfilemodel.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2017 by Bluesystems * - * Author : Emmanuel Lepage Vallee * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * 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. If not, see . * - **************************************************************************/ -#pragma once - -#include - -class RecentFileModelPrivate; - -class RecentFileModel : public QStringListModel -{ - Q_OBJECT -public: - static RecentFileModel& instance(); - - Q_INVOKABLE QString addFile(); - -private: - explicit RecentFileModel(); - virtual ~RecentFileModel(); - - RecentFileModelPrivate* d_ptr; - Q_DECLARE_PRIVATE(RecentFileModel) -}; diff --git a/src/ringapplication.cpp b/src/ringapplication.cpp index 0b8d097f..fe29e9f2 100644 --- a/src/ringapplication.cpp +++ b/src/ringapplication.cpp @@ -1,579 +1,577 @@ /*************************************************************************** * Copyright (C) 2009-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Valle * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * 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. If not, see . * **************************************************************************/ //Parent #include "ringapplication.h" //Qt #include #include #include #include #include #include #include #include #include #include #include #include #include //KDE #include #include #include #include //LRC #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include