KXmlGui

kmainwindowiface.cpp
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2001 Ian Reinhart Geiser <[email protected]>
4  SPDX-FileCopyrightText: 2006 Thiago Macieira <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "kmainwindowiface_p.h"
10 
11 #include "kactioncollection.h"
12 #include "kxmlguiwindow.h"
13 
14 #include <QApplication>
15 #include <QAction>
16 #include <QClipboard>
17 
18 KMainWindowInterface::KMainWindowInterface(KXmlGuiWindow *mainWindow)
19  : QDBusAbstractAdaptor(mainWindow)
20 {
21  m_MainWindow = mainWindow;
22 }
23 
24 KMainWindowInterface::~KMainWindowInterface()
25 {
26 }
27 
28 QStringList KMainWindowInterface::actions()
29 {
30  QStringList tmp_actions;
31  const QList<QAction *> lst = m_MainWindow->actionCollection()->actions();
32  for (QAction *it : lst) {
33  if (!it->associatedWidgets().isEmpty()) {
34  tmp_actions.append(it->objectName());
35  }
36  }
37  return tmp_actions;
38 }
39 
40 bool KMainWindowInterface::activateAction(const QString &action)
41 {
42  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
43  if (tmp_Action) {
44  tmp_Action->trigger();
45  return true;
46  } else {
47  return false;
48  }
49 }
50 
51 bool KMainWindowInterface::disableAction(const QString &action)
52 {
53  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
54  if (tmp_Action) {
55  tmp_Action->setEnabled(false);
56  return true;
57  } else {
58  return false;
59  }
60 }
61 
62 bool KMainWindowInterface::enableAction(const QString &action)
63 {
64  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
65  if (tmp_Action) {
66  tmp_Action->setEnabled(true);
67  return true;
68  } else {
69  return false;
70  }
71 }
72 
73 bool KMainWindowInterface::actionIsEnabled(const QString &action)
74 {
75  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
76  if (tmp_Action) {
77  return tmp_Action->isEnabled();
78  } else {
79  return false;
80  }
81 }
82 
83 QString KMainWindowInterface::actionToolTip(const QString &action)
84 {
85  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
86  if (tmp_Action) {
87  return tmp_Action->toolTip();
88  } else {
89  return QStringLiteral("Error no such object!");
90  }
91 }
92 
93 qlonglong KMainWindowInterface::winId()
94 {
95  return qlonglong(m_MainWindow->winId());
96 }
97 
98 void KMainWindowInterface::grabWindowToClipBoard()
99 {
100  QClipboard *clipboard = QApplication::clipboard();
101  clipboard->setPixmap(m_MainWindow->grab());
102 }
103 
104 #include "moc_kmainwindowiface_p.cpp"
void trigger()
void append(const T &value)
Top level main window with predefined action layout.
Definition: kxmlguiwindow.h:45
void setPixmap(const QPixmap &pixmap, QClipboard::Mode mode)
QClipboard * clipboard()
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:50:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.