Commit 00184747 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

project: cleanup and use avmodel instead of legacy lrc media models

- removes shmclient, uri protocol startup, and some references to
  old lrc models

Change-Id: Ic663bf6526928e3f6c7363716b848c60f5a2da72
parent 7d7a41e8
......@@ -29,6 +29,7 @@
#include <QBuffer>
#include "settingskey.h"
#include "accountlistmodel.h"
#include "api/lrc.h"
#include "api/account.h"
......@@ -37,12 +38,12 @@
#include "api/newdevicemodel.h"
#include "api/newcodecmodel.h"
#include "api/behaviorcontroller.h"
#include "api/avmodel.h"
#include "api/conversation.h"
#include "api/contactmodel.h"
#include "api/contact.h"
#include "api/datatransfermodel.h"
#include "api/conversationmodel.h"
#include "accountlistmodel.h"
#include "account.h"
......@@ -59,6 +60,8 @@ public:
};
static void init() {
instance();
// TODO: remove when all platforms migrate to avModel
instance().avModel().deactivateOldVideoModels();
};
static Lrc& getAPI() {
return *(instance().lrc_);
......@@ -81,9 +84,15 @@ public:
static DataTransferModel* editableDataTransferModel() {
return const_cast<DataTransferModel*>(&instance().lrc_->getDataTransferModel());
};
static AVModel& avModel() {
return instance().lrc_->getAVModel();
};
static bool isConnected() {
return instance().lrc_->isConnected();
};
static std::vector<std::string> getActiveCalls() {
return instance().lrc_->activeCalls();
};
static const account::Info&
getCurrentAccountInfo() {
......@@ -92,7 +101,7 @@ public:
} catch (...) {
static account::Info invalid = {};
qWarning() << "getAccountInfo exception";
return std::reference_wrapper<account::Info>{invalid};
return invalid;
}
};
......
......@@ -23,12 +23,7 @@
#include <QFile>
#include <QMessageBox>
#include "callmodel.h"
#include "globalinstances.h"
#include "media/audio.h"
#include "media/file.h"
#include "media/text.h"
#include "media/video.h"
#include <QFontDatabase>
#include <QLibraryInfo>
......@@ -50,12 +45,6 @@
#include <gnutls/gnutls.h>
#endif
#ifdef URI_PROTOCOL
#include "shmclient.h"
#endif
REGISTER_MEDIA();
void
consoleDebug()
{
......@@ -69,7 +58,7 @@ consoleDebug()
coordInfo.Y = 9000;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordInfo);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_QUICK_EDIT_MODE| ENABLE_EXTENDED_FLAGS);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS);
#endif
}
......@@ -77,7 +66,6 @@ consoleDebug()
void
vsConsoleDebug()
{
// Print debug to output window if using VS
QObject::connect(
&LRCInstance::behaviorController(),
......@@ -115,7 +103,7 @@ main(int argc, char* argv[])
newArgv[argc] = ARG_DISABLE_WEB_SECURITY;
newArgv[argc + 1] = nullptr;
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && defined(PROCESS_DPI_AWARE)
SetProcessDPIAware();
#endif // Q_OS_WIN
......@@ -147,57 +135,30 @@ main(int argc, char* argv[])
GlobalInstances::setPixmapManipulator(std::make_unique<PixbufManipulator>());
LRCInstance::init();
QFile debugFile("debug.log");
QFile debugFile("daemon.log");
for (auto string : QCoreApplication::arguments()) {
if (string == "-m" || string == "--minimized") {
startMinimized = true;
}
if (string == "-f" || string == "--file") {
debugFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
debugFile.close();
fileDebug(debugFile);
}
if (string == "-d" || string == "--debug") {
consoleDebug();
}
#ifdef _MSC_VER
else if (string == "-c" || string == "--vsconsole") {
vsConsoleDebug();
}
#endif
if (string.startsWith("ring:")) {
if (string.startsWith("jami:")) {
uri = string;
}
}
#ifdef URI_PROTOCOL
QSharedMemory* shm = new QSharedMemory("RingShm");
QSystemSemaphore* sem = new QSystemSemaphore("RingSem", 0);
if (not shm->create(1024)) {
if (not uri.isEmpty()) {
shm->attach();
shm->lock();
char *to = (char*) shm->data();
QChar *data = uri.data();
while (!data->isNull()) {
memset(to, data->toLatin1(), 1);
++data;
++to;
} else {
if (string == "-m" || string == "--minimized") {
startMinimized = true;
}
if (string == "-f" || string == "--file") {
debugFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
debugFile.close();
fileDebug(debugFile);
}
if (string == "-d" || string == "--debug") {
consoleDebug();
}
memset(to, 0, 1); //null terminator
shm->unlock();
#ifdef _MSC_VER
if (string == "-c" || string == "--vsconsole") {
vsConsoleDebug();
}
#endif
}
sem->release();
delete shm;
exit(EXIT_SUCCESS);
}
//Client listening to shm event
memset((char*)shm->data(), 0, shm->size());
ShmClient* shmClient = new ShmClient(shm, sem);
#endif
auto appDir = qApp->applicationDirPath() + "/";
const auto locale_name = QLocale::system().name();
......@@ -246,11 +207,6 @@ main(int argc, char* argv[])
MainWindow::instance().createThumbBar();
if (not uri.isEmpty()) {
startMinimized = false;
MainWindow::instance().onRingEvent(uri);
}
if (not startMinimized)
MainWindow::instance().showWindow();
else {
......@@ -258,16 +214,7 @@ main(int argc, char* argv[])
MainWindow::instance().hide();
}
#ifdef URI_PROTOCOL
QObject::connect(shmClient, SIGNAL(RingEvent(QString)), &MainWindow::instance(), SLOT(onRingEvent(QString)));
QObject::connect(&a, &QApplication::aboutToQuit, [&a, &shmClient, &shm, &sem]() {
shmClient->terminate();
delete shmClient;
delete shm;
delete sem;
});
#endif
QObject::connect(&a, &QApplication::aboutToQuit, [&guard] { guard.release(); });
auto ret = a.exec();
......
......@@ -170,6 +170,8 @@ MainWindow::MainWindow(QWidget* parent)
lastScr_ = startScreen;
this->show();
#ifdef DEBUG_STYLESHEET
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout,
......@@ -209,16 +211,6 @@ void MainWindow::slotCurrentChanged(int index)
lastScr_ = scr;
}
void MainWindow::onRingEvent(const QString& uri)
{
this->showNormal();
if (not uri.isEmpty()) {
auto outCall = CallModel::instance().dialingCall();
outCall->setDialNumber(uri);
outCall->performAction(Call::Action::ACCEPT);
}
}
bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* result)
{
Q_UNUSED(eventType)
......@@ -302,7 +294,7 @@ void MainWindow::changeEvent(QEvent* e)
void MainWindow::closeEvent(QCloseEvent* event)
{
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
QSettings settings("jami.net", "Jami");
if (settings.value(SettingsKey::closeOrMinimized).toBool()) {
this->hide();
......@@ -339,7 +331,6 @@ void MainWindow::readSettingsFromRegistry()
void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
{
auto screenNumber = qApp->desktop()->screenNumber();
auto accountList = LRCInstance::accountModel().getAccountList();
if (scr == ScreenEnum::WizardScreen && !accountList.size()) {
hide();
......@@ -349,12 +340,15 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
setMaximumSize(QtMaxDimension, QtMaxDimension);
}
if (firstUse || !accountList.size()) {
#if defined(Q_OS_WIN) && !defined(PROCESS_DPI_AWARE)
auto screenNumber = qApp->desktop()->screenNumber();
setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
size(),
qApp->desktop()->screenGeometry(screenNumber)));
#endif
if (scr == ScreenEnum::WizardScreen) {
setWindowFlags(Qt::Dialog);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
......@@ -370,27 +364,19 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
void MainWindow::show()
{
QMainWindow::show();
#if defined(Q_OS_WIN) && !defined(PROCESS_DPI_AWARE)
disconnect(screenChangedConnection_);
screenChangedConnection_ = connect(windowHandle(), &QWindow::screenChanged,
this, &MainWindow::slotScreenChanged);
auto screenNumber = qApp->desktop()->screenNumber();
QScreen* screen = qApp->screens().at(screenNumber);
currentScalingRatio_ = screen->logicalDotsPerInchX() / 96;
qobject_cast<NavWidget*>(ui->navStack->currentWidget())->updateCustomUI();
this, &MainWindow::slotScreenChanged);
#endif
}
void MainWindow::slotScreenChanged(QScreen* screen)
{
currentScalingRatio_ = screen->logicalDotsPerInchX() / 96;
qobject_cast<NavWidget*>(ui->navStack->currentWidget())->updateCustomUI();
adjustSize();
updateGeometry();
update();
currentScalingRatio_ = screen->logicalDotsPerInchX() / 96;
// a little delay won't hurt ;)
QTimer::singleShot(100, this,
[this] {
qobject_cast<NavWidget*>(ui->navStack->currentWidget())->updateCustomUI();
});
}
void MainWindow::resizeEvent(QResizeEvent* event)
......
......@@ -64,9 +64,6 @@ protected:
signals:
void keyReleased(QKeyEvent*ke);
public slots:
void onRingEvent(const QString& uri);
private slots:
void slotCurrentChanged(int index);
void trayActivated(QSystemTrayIcon::ActivationReason reason);
......
......@@ -25,8 +25,6 @@
#include <QGraphicsOpacityEffect>
#include <QtConcurrent/QtConcurrent>
#include "video/previewmanager.h"
#include "utils.h"
#include "lrcinstance.h"
......@@ -59,7 +57,7 @@ PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
PhotoboothWidget::~PhotoboothWidget()
{
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
delete ui;
}
......@@ -67,8 +65,8 @@ void PhotoboothWidget::startBooth()
{
hasAvatar_ = false;
ui->videoFeed->setResetPreview(true);
Video::PreviewManager::instance().stopPreview();
Video::PreviewManager::instance().startPreview();
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
ui->videoFeed->show();
ui->avatarLabel->hide();
takePhotoState_ = true;
......@@ -77,7 +75,7 @@ void PhotoboothWidget::startBooth()
void PhotoboothWidget::stopBooth()
{
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
ui->videoFeed->hide();
ui->avatarLabel->show();
takePhotoState_ = false;
......@@ -87,16 +85,16 @@ void PhotoboothWidget::stopBooth()
void
PhotoboothWidget::on_importButton_clicked()
{
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
auto picturesDir = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first();
fileName_ = QFileDialog::getOpenFileName(this, tr("Choose File"),
picturesDir,
tr("Image Files (*.jpg *.jpeg *.png)"));
if (fileName_.isEmpty()) {
Video::PreviewManager::instance().startPreview();
LRCInstance::avModel().startPreview();
return;
}
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
auto image = Utils::cropImage(QImage(fileName_));
auto avatar = image.scaled(224, 224, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
avatarPixmap_ = QPixmap::fromImage(avatar);
......@@ -127,7 +125,7 @@ PhotoboothWidget::on_takePhotoButton_clicked()
QtConcurrent::run(
[this] {
Video::PreviewManager::instance().stopPreview();
LRCInstance::avModel().stopPreview();
auto photo = Utils::cropImage(ui->videoFeed->takePhoto());
auto avatar = photo.scaled(224, 224, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
avatarPixmap_ = QPixmap::fromImage(avatar);
......
......@@ -133,13 +133,13 @@ QVariant
PixbufManipulator::historySortingCategoryIcon(const CategorizedHistoryModel::SortedProxy::Categories cat) const
{
Q_UNUSED(cat)
return QVariant();
return QVariant();
}
QVariant
PixbufManipulator::contactSortingCategoryIcon(const CategorizedContactModel::SortedProxy::Categories cat) const
{
Q_UNUSED(cat)
return QVariant();
return QVariant();
}
QVariant
PixbufManipulator::userActionIcon(const UserActionElement& state) const
......@@ -192,10 +192,8 @@ QVariant PixbufManipulator::decorationRole(const Person* p)
QVariant PixbufManipulator::decorationRole(const Account* acc)
{
Q_UNUSED(acc)
return Utils::getCirclePhoto(ProfileModel::instance().
selectedProfile()->person()->photo().value<QImage>(),
IMAGE_SIZE.width());
Q_UNUSED(acc);
return QVariant();
}
QVariant
......
......@@ -82,7 +82,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<ObjectFileName>$(IntDir)</ObjectFileName>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>PROCESS_DPI_AWARE;_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
......@@ -121,7 +121,7 @@
<QtMoc>
<QTDIR>$(QTDIR)</QTDIR>
<OutputFile>.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</OutputFile>
<Define>_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</Define>
<Define>PROCESS_DPI_AWARE;_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</Define>
<CompilerFlavor>msvc</CompilerFlavor>
<Include>$(Configuration)/moc_predefs.h</Include>
<ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>
......@@ -169,6 +169,7 @@
<SDLCheck>true</SDLCheck>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>..\daemon\MSVC\x64\ReleaseLib_win32\bin\dring.lib;..\lrc\msvc\src\qtwrapper\Release\qtwrapper.lib;..\lrc\msvc\release\ringclient_static.lib;.\winsparkle\x64\release\WinSparkle.lib;.\qrencode-win32\qrencode-win32\vc8\qrcodelib\x64\Release-Lib\qrcodelib.lib;shell32.lib;Ole32.lib;Advapi32.lib;Shlwapi.lib;User32.lib;Gdi32.lib;Crypt32.lib;Strmiids.lib;$(QTDIR)\lib\qtmain.lib;$(QTDIR)\lib\Qt5Svg.lib;$(QTDIR)\lib\Qt5Widgets.lib;$(QTDIR)\lib\Qt5WinExtras.lib;$(QTDIR)\lib\Qt5Gui.lib;$(QTDIR)\lib\Qt5Xml.lib;$(QTDIR)\lib\Qt5Network.lib;$(QTDIR)\lib\Qt5Core.lib;$(QTDIR)\lib\Qt5Sql.lib;$(QTDIR)\lib\Qt5WebEngineWidgets.lib;$(QTDIR)\lib\Qt5WebChannel.lib;%(AdditionalDependencies)</AdditionalDependencies>
......
......@@ -19,23 +19,17 @@
#include "selectareadialog.h"
#ifdef Q_OS_WIN
#define WIN32_LEAN_AND_MEAN 1
#define NOMINMAX
#include <windows.h>
#include <winuser.h>
#undef OUT
#undef IN
#undef ERROR
#endif
#include <QApplication>
#include <QScreen>
#include <QPainter>
#include <QDesktopWidget>
#include "video/sourcemodel.h"
#include "media/video.h"
#include "callmodel.h"
#include "lrcinstance.h"
#include "utils.h"
SelectAreaDialog::SelectAreaDialog() :
rubberBand_(nullptr)
......@@ -50,9 +44,9 @@ SelectAreaDialog::SelectAreaDialog() :
grabMouse();
rubberBand_ = new QRubberBand(QRubberBand::Rectangle, this);
QApplication::setOverrideCursor(Qt::CrossCursor);
QScreen* screen = QGuiApplication::primaryScreen();
if (screen) {
originalPixmap_ = screen->grabWindow(0);
auto screenNumber = qApp->desktop()->screenNumber(this);
if (auto screen = qApp->screens().at(screenNumber)) {
originalPixmap_ = screen->grabWindow(screenNumber);
originalPixmap_.setDevicePixelRatio(screen->devicePixelRatio());
}
}
......@@ -83,36 +77,40 @@ void
SelectAreaDialog::mouseReleaseEvent(QMouseEvent* event)
{
Q_UNUSED(event)
if (!rubberBand_) {
return;
}
if(rubberBand_) {
QApplication::restoreOverrideCursor();
releaseMouse();
if (auto call = CallModel::instance().selectedCall()) {
if (auto outVideo = call->firstMedia<media::Video>(media::Media::Direction::OUT)) {
QRect realRect = rubberBand_->geometry();
#ifdef Q_OS_WIN
if (QGuiApplication::primaryScreen()->devicePixelRatio() > 1.0) {
auto scaledSize = QGuiApplication::primaryScreen()->geometry();
auto sourceHdc = GetDC(nullptr);
auto vertres = GetDeviceCaps(sourceHdc, VERTRES);
auto horzres = GetDeviceCaps(sourceHdc, HORZRES);
auto height = realRect.height() * QGuiApplication::primaryScreen()->devicePixelRatio();
auto width = realRect.width() * QGuiApplication::primaryScreen()->devicePixelRatio();
float xRatio = static_cast<float>(horzres) / static_cast<float>(scaledSize.width());
float yRatio = static_cast<float>(vertres) / static_cast<float>(scaledSize.height());
realRect.setX(static_cast<int>(realRect.x() * xRatio));
realRect.setY(static_cast<int>(realRect.y() * yRatio));
realRect.setWidth(static_cast<int>(width));
realRect.setHeight(static_cast<int>(height));
}
#endif
outVideo->sourceModel()->setDisplay(0, realRect);
}
}
delete rubberBand_;
rubberBand_ = nullptr;
reject();
auto screenNumber = qApp->desktop()->screenNumber(this);
QScreen* screen = qApp->screens().at(screenNumber);
if (!screen) {
screen = qApp->primaryScreen();
}
QApplication::restoreOverrideCursor();
releaseMouse();
QRect rect = rubberBand_->geometry();
#if defined(Q_OS_WIN) && !defined(PROCESS_DPI_AWARE)
if (screen && screen->devicePixelRatio() > 1.0) {
auto scaledSize = screen->geometry();
auto sourceHdc = GetDC(nullptr);
auto vertres = GetDeviceCaps(sourceHdc, VERTRES);
auto horzres = GetDeviceCaps(sourceHdc, HORZRES);
auto height = rect.height() * screen->devicePixelRatio();
auto width = rect.width() * screen->devicePixelRatio();
float xRatio = static_cast<float>(horzres) / static_cast<float>(scaledSize.width());
float yRatio = static_cast<float>(vertres) / static_cast<float>(scaledSize.height());
rect.setX(static_cast<int>(rect.x() * xRatio));
rect.setY(static_cast<int>(rect.y() * yRatio));
rect.setWidth(static_cast<int>(width));
rect.setHeight(static_cast<int>(height));
}
# endif
LRCInstance::avModel().setDisplay(screenNumber,
rect.x(), rect.y(), rect.width(), rect.height()
);
rubberBand_->deleteLater();
reject();
}
void
......@@ -120,6 +118,5 @@ SelectAreaDialog::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.drawPixmap(QPoint(0, 0), originalPixmap_);
}
This diff is collapsed.
......@@ -32,7 +32,6 @@
#include "api/datatransfermodel.h"
#include "typedefs.h"
#include "video/devicemodel.h"
namespace Ui {
class SettingsWidget;
......@@ -82,7 +81,7 @@ private:
void setConnections();
void populateGeneralSettings();
void populateAVSettings();
void setFormatListForDevice(Video::Device* device);
void setFormatListForDevice(const std::string& device);
void showPreview();
void startVideo();
void stopVideo();
......@@ -95,9 +94,8 @@ private:
QScrollArea* scrollArea_;
Button pastButton_ = Button::generalSettingsButton;
bool advancedSettingsDropped_ = false;
QList<QPair<int, int>> formatIndexList_;
Video::DeviceModel* deviceModel_;
QString currentDeviceName_;
QList<QPair<std::string, float>> formatIndexList_;
std::string currentDisplayedVideoDevice_;
AdvancedSIPSettingsWidget* advancedSIPSettingsWidget_;
QScrollArea* scrollSIPArea_;
bool advancedSIPSettingsDropped_ = false;
......@@ -136,7 +134,6 @@ private slots:
void slotSetUpdateAutomatic(bool state);
void outputDevIndexChangedSlot(int index);
void inputdevIndexChangedSlot(int index);
void deviceModelIndexChanged(int index);
void slotDeviceBoxCurrentIndexChanged(int index);
void slotFormatBoxCurrentIndexChanged(int index);
};
/***************************************************************************
* Copyright (C) 2017-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* 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 <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "shmclient.h"
#include <QTextStream>
ShmClient::ShmClient(QSharedMemory* shm, QSystemSemaphore *sem) :
shm_(shm),
sem_(sem)
{
start();
}
void ShmClient::run()
{
while (true) {
sem_->acquire();
shm_->lock();
char const *from = (char const*)shm_->data();
QString uri = "";
QTextStream stream(&uri);
while (from && *from)
{
stream << *from;
++from;
}
shm_->unlock();
emit RingEvent(uri);
}
}
/***************************************************************************
* Copyright (C) 2017-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* 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 <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include <QThread>
#include <QSystemSemaphore>
#include <QSharedMemory>
class ShmClient : public QThread
{
Q_OBJECT
public:
ShmClient(QSharedMemory* shm, QSystemSemaphore* sem);
void run();
private:
QSharedMemory* shm_;
QSystemSemaphore* sem_;
signals:
void RingEvent(const QString& uri = "");
};
......@@ -38,6 +38,7 @@
#include <QApplication>
#include <QFile>
#include <QMessageBox>
#include <QScreen>
#include <globalinstances.h>
......@@ -285,6 +286,17 @@ void Utils::showSystemNotification(QWidget* widget,
QApplication::alert(widget, delay);
}
QSize
Utils::getRealSize(QScreen* screen)
{
DEVMODE dmThisScreen;
ZeroMemory(&dmThisScreen, sizeof(dmThisScreen));
EnumDisplaySettings((const wchar_t *)screen->name().utf16(),
ENUM_CURRENT_SETTINGS,
(DEVMODE*)&dmThisScreen);
return QSize(dmThisScreen.dmPelsWidth, dmThisScreen.dmPelsHeight);
}
void
Utils::cleanUpdateFiles()
{
......
......@@ -67,6 +67,7 @@ void InvokeMailto(const QString& subject, const QString& body, const QString& at
void setStackWidget(QStackedWidget *stack, QWidget *widget);
void showSystemNotification(QWidget* widget, const QString& message, long delay = 5000);
void showSystemNotification(QWidget* widget, const QString& sender, const QString& message, long delay = 5000);
QSize getRealSize(QScreen* screen);
// updates
void cleanUpdateFiles();
......
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* *
* 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 *
......@@ -30,6 +31,7 @@
#include <QMimeData>
#include <QSplitter>
#include <QScreen>
#include <QWindow>
#include <memory>
......@@ -192,29 +194,36 @@ void
VideoView::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
event->accept();
}
void
VideoView::dragLeaveEvent(QDragLeaveEvent* event)
{
event->accept();
}
void
VideoView::dragMoveEvent(QDragMoveEvent* event)
{
if (event->mimeData()->hasUrls())
event->accept();
}
void
VideoView::dropEvent(QDropEvent* event)