Warning, file /sdk/lokalize/src/actionproxy.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002   This file is part of Lokalize
0003 
0004   SPDX-FileCopyrightText: 2008-2014 Nick Shaforostoff <shafff@ukr.net>
0005   SPDX-FileCopyrightText: 2018-2019 Simon Depiets <sdepiets@gmail.com>
0006 
0007   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0008 */
0009 
0010 #include "actionproxy.h"
0011 
0012 #include <QLabel>
0013 
0014 #if 0
0015 #include <QAction>
0016 
0017 
0018 ActionProxy::ActionProxy(QObject* parent, QObject* receiver, const char* slot)
0019     : QObject(parent)
0020     , m_currentAction(0)
0021     , m_disabled(false)
0022     , m_checked(false)
0023 // , m_checkable(false)
0024 {
0025     if (receiver)
0026         connect(this, SIGNAL(triggered(bool)), receiver, slot);
0027 
0028     connect(this, &ActionProxy::toggled, this, &ActionProxy::handleToggled);
0029 }
0030 
0031 ActionProxy::~ActionProxy()
0032 {
0033     // if the view is closed...
0034 }
0035 
0036 void ActionProxy::registerAction(QAction* a)
0037 {
0038     if (a == m_currentAction)
0039         return;
0040 
0041     m_currentAction = a;
0042     a->setChecked(m_checked);
0043     a->setDisabled(m_disabled);
0044     a->setStatusTip(m_statusTip);
0045     m_keySequence = a->shortcut();
0046 
0047     connect(a, SIGNAL(triggered(bool)), this, SIGNAL(triggered(bool)));
0048     connect(a, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
0049 }
0050 void ActionProxy::unregisterAction(/*QAction**/)
0051 {
0052     disconnect(m_currentAction, SIGNAL(triggered(bool)), this, SIGNAL(triggered(bool)));
0053     disconnect(m_currentAction, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
0054     m_currentAction->setStatusTip(QString());
0055     m_currentAction = 0;
0056 }
0057 
0058 void ActionProxy::handleToggled(bool checked)
0059 {
0060     m_checked = checked;
0061 }
0062 
0063 void ActionProxy::setDisabled(bool disabled)
0064 {
0065     if (m_currentAction)
0066         m_currentAction->setDisabled(disabled);
0067 
0068     m_disabled = disabled;
0069 }
0070 
0071 void ActionProxy::setChecked(bool checked)
0072 {
0073     if (m_currentAction)
0074         m_currentAction->setChecked(checked); //handleToggled is called implicitly via signal/slot mechanism
0075     else
0076         m_checked = checked;
0077 }
0078 
0079 
0080 #endif
0081 
0082 void StatusBarProxy::insert(int key, const QString& str)
0083 {
0084     if (m_currentStatusBar)
0085         if (key < m_statusBarLabels.size()) m_statusBarLabels.at(key)->setText(str);
0086     QMap<int, QString>::insert(key, str);
0087 }
0088 
0089 void StatusBarProxy::registerStatusBar(QStatusBar* bar, const QVector<QLabel*>& statusBarLabels)
0090 {
0091     m_currentStatusBar = bar;
0092     m_statusBarLabels = statusBarLabels;
0093     for (int i = 0; i < statusBarLabels.size(); i++)
0094         statusBarLabels.at(i)->setText(QString());
0095 
0096     QMap<int, QString>::const_iterator i = constBegin();
0097     while (i != constEnd()) {
0098         if (i.key() < statusBarLabels.size()) statusBarLabels.at(i.key())->setText(i.value());
0099         ++i;
0100     }
0101 }
0102