1 /*
2   This file is part of Lokalize
3 
4   SPDX-FileCopyrightText: 2008-2014 Nick Shaforostoff <shafff@ukr.net>
5   SPDX-FileCopyrightText: 2018-2019 Simon Depiets <sdepiets@gmail.com>
6 
7   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
8 */
9 
10 #ifndef ACTIONPROXY_H
11 #define ACTIONPROXY_H
12 
13 #include <QObject>
14 #include <QKeySequence>
15 #include <QMap>
16 #include <QVector>
17 
18 class QLabel;
19 class QStatusBar;
20 
21 #if 0
22 
23 /**
24  * used for connecting qactions to subwindows:
25  * forwards signals and saves/restores state on subwindow switch
26  */
27 class ActionProxy: public QObject
28 {
29     Q_OBJECT
30 
31 public:
32     ActionProxy(QObject* parent, QObject* receiver = 0, const char* slot = 0);
33     ~ActionProxy();
34 
35     void registerAction(QAction*);
36     void unregisterAction(/*QAction**/);
37 
38     void setStatusTip(const QString& st)
39     {
40         m_statusTip = st;   //for TM suggestions
41     }
42     QKeySequence shortcut()
43     {
44         return m_keySequence;
45     };//for TM suggestions
46 
47 public Q_SLOTS:
48     void setDisabled(bool);
49     void setEnabled(bool enabled)
50     {
51         setDisabled(!enabled);
52     }
53     void setChecked(bool);
54 
55 private Q_SLOTS:
56     void handleToggled(bool);
57 
58 Q_SIGNALS:
59     void triggered(bool = false);
60     void toggled(bool);
61 
62 private:
63     QAction* m_currentAction;
64     bool m_disabled;
65     bool m_checked;
66     QString m_statusTip;
67     QKeySequence m_keySequence;
68 };
69 
70 #endif
71 
72 class StatusBarProxy: public QMap<int, QString>
73 {
74 public:
StatusBarProxy()75     StatusBarProxy(): m_currentStatusBar(nullptr) {}
~StatusBarProxy()76     ~StatusBarProxy() {}
77 
78     void insert(int, const QString&);
79 
80     void registerStatusBar(QStatusBar*, const QVector<QLabel*>& statusBarLabels);
unregisterStatusBar()81     void unregisterStatusBar()
82     {
83         m_currentStatusBar = nullptr;
84     }
85 
86 private:
87     QStatusBar* m_currentStatusBar;
88     QVector<QLabel*> m_statusBarLabels;
89 };
90 
91 
92 #define ID_STATUS_CURRENT 0
93 #define ID_STATUS_TOTAL 1
94 #define ID_STATUS_FUZZY 2
95 #define ID_STATUS_UNTRANS 3
96 #define ID_STATUS_ISFUZZY 4
97 #define ID_STATUS_PROGRESS 5
98 //#define TOTAL_ID_STATUSES 6
99 //#define ID_STATUS_READONLY 6
100 //#define ID_STATUS_CURSOR 7
101 
102 #endif
103