Files
pilotclient/src/blackgui/singleapplicationui.cpp
Klaus Basan 57ede8b04c refs #901, utility class for single UI widgets
(disables widget when >1 swift application runs)
2017-04-17 23:58:41 +01:00

34 lines
1.0 KiB
C++

/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "singleapplicationui.h"
#include "guiapplication.h"
#include <QWidget>
using namespace BlackMisc;
namespace BlackGui
{
CSingleApplicationUi::CSingleApplicationUi(QWidget *ui) : m_ui(ui)
{
QObject::connect(&m_timer, &QTimer::timeout, [ = ] { this->evaluate(); });
m_timer.setInterval(5000);
m_timer.start();
}
void CSingleApplicationUi::evaluate()
{
if (!sGui) { return; }
if (!m_ui) { return; }
const CApplicationInfoList apps = sGui->getRunningApplications();
const bool enable = apps.size() < 2;
m_ui->setEnabled(enable);
}
} // ns