• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • xmlgui
kmainwindowiface.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2001 Ian Reinhart Geiser <geiseri@yahoo.com>
3  Copyright (C) 2006 Thiago Macieira <thiago@kde.org>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the Lesser GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the Lesser GNU General Public License
16  along with this program; see the file COPYING. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "kmainwindowiface_p.h"
22 
23 #include <kactioncollection.h>
24 #include <kapplication.h>
25 #include <kxmlguiwindow.h>
26 #include <kaction.h>
27 #include <QtGui/QClipboard>
28 
29 
30 KMainWindowInterface::KMainWindowInterface(KXmlGuiWindow * mainWindow)
31  : QDBusAbstractAdaptor(mainWindow)
32 {
33  m_MainWindow = mainWindow;
34 }
35 
36 KMainWindowInterface::~KMainWindowInterface()
37 {
38 }
39 
40 QStringList KMainWindowInterface::actions()
41 {
42  QStringList tmp_actions;
43  QList<QAction *> lst = m_MainWindow->actionCollection()->actions();
44  foreach( QAction* it, lst ) {
45  if (it->associatedWidgets().count()>0)
46  tmp_actions.append( it->objectName() );
47  }
48  return tmp_actions;
49 }
50 
51 bool KMainWindowInterface::activateAction( const QString& action )
52 {
53  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
54  if (tmp_Action)
55  {
56  tmp_Action->trigger();
57  return true;
58  }
59  else
60  return false;
61 }
62 
63 bool KMainWindowInterface::disableAction( const QString& action)
64 {
65  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
66  if (tmp_Action)
67  {
68  tmp_Action->setEnabled(false);
69  return true;
70  }
71  else
72  return false;
73 }
74 
75 bool KMainWindowInterface::enableAction( const QString& action)
76 {
77  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
78  if (tmp_Action)
79  {
80  tmp_Action->setEnabled(true);
81  return true;
82  }
83  else
84  return false;
85 }
86 
87 bool KMainWindowInterface::actionIsEnabled( const QString& action)
88 {
89  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
90  if (tmp_Action)
91  {
92  return tmp_Action->isEnabled();
93  }
94  else
95  return false;
96 }
97 
98 QString KMainWindowInterface::actionToolTip( const QString& action)
99 {
100  QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
101  if (tmp_Action)
102  {
103  return tmp_Action->toolTip().toUtf8();
104  }
105  else
106  return "Error no such object!";
107 }
108 
109 qlonglong KMainWindowInterface::winId()
110 {
111  return qlonglong(m_MainWindow->winId());
112 }
113 
114 void KMainWindowInterface::grabWindowToClipBoard()
115 {
116  QClipboard *clipboard = QApplication::clipboard();
117  clipboard->setPixmap(QPixmap::grabWidget(m_MainWindow));
118 }
119 
120 #include "kmainwindowiface_p.moc"
kapplication.h
kactioncollection.h
kxmlguiwindow.h
QAction::toolTip
toolTip
QAction::trigger
void trigger()
QClipboard
QDBusAbstractAdaptor
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
KXmlGuiWindow
KDE top level main window with predefined action layout
Definition: kxmlguiwindow.h:61
QClipboard::setPixmap
void setPixmap(const QPixmap &pixmap, Mode mode)
QApplication::clipboard
QClipboard * clipboard()
QObject::objectName
objectName
QString
QList< QAction * >
QStringList
kaction.h
QAction
QPixmap::grabWidget
QPixmap grabWidget(QWidget *widget, const QRect &rectangle)
QAction::associatedWidgets
QList< QWidget * > associatedWidgets() const
QAction::setEnabled
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal