File: kfilereplace.cpp

package info (click to toggle)
kdewebdev 4%3A4.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,240 kB
  • sloc: cpp: 78,045; xml: 258; perl: 82; ruby: 59; sh: 32; makefile: 4
file content (117 lines) | stat: -rw-r--r-- 4,174 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
               kfilereplace.cpp  -  KFileReplace shell implementation
                             -------------------
    begin                : Thu Sep 16 14:14:09 2004
    copyright            : (C) 2004 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

//kde includes
#include <kedittoolbar.h>
#include <klibloader.h>
#include <klocale.h>
#include <kshortcutsdialog.h>
#include <kmessagebox.h>
#include <kxmlguifactory.h>
//app includes
#include "kfilereplace.h"
//Added by qt3to4:
#include <kactioncollection.h>
#include <kstandardaction.h>

KFileReplace::KFileReplace()
  : KParts::MainWindow()
{
    setObjectName("KFileReplace");
    KLibFactory *factory = KLibLoader::self()->factory("libkfilereplacepart");
    if (factory)
    {
        m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this, "KParts::ReadOnlyPart"));

        if (m_part)
        {
            m_part->setObjectName("kfilereplace_part");
            setCentralWidget(m_part->widget());
            KStandardAction::quit(this, SLOT(close()), actionCollection());
            KStandardAction::keyBindings(this, SLOT(slotConfigureKeys()), actionCollection());
            KStandardAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
            setStandardToolBarMenuEnabled(true);
            createGUI(m_part);
            removeDuplicatedActions();
        } else
        {
          KMessageBox::error(this, i18n("Could not load the KFileReplace part."));
          close();
          return;
        }
    }
    else
    {
        KMessageBox::error(this, i18n("Could not find the KFileReplace part."));
        close();
        return;
    }
}


KFileReplace::~KFileReplace()
{
}

void KFileReplace::openURL(const KUrl &url)
{
  m_part->openUrl(url);
}

void KFileReplace::slotConfigureKeys()
{
	KShortcutsDialog dlg( KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this );
    QList<KXMLGUIClient*> clients = guiFactory()->clients();
  	foreach(KXMLGUIClient *client, clients)
    	dlg.addCollection(client->actionCollection());
	dlg.configure();
}

void KFileReplace::slotConfigureToolbars()
{
    saveMainWindowSettings(KGlobal::config()->group( autoSaveGroup()) );
    KEditToolBar dlg(factory());
    connect(&dlg, SIGNAL(newToolbarConfig()),
            this, SLOT(applyNewToolbarConfig()));
    dlg.exec();
}

void KFileReplace::applyNewToolbarConfig()
{
    applyMainWindowSettings(KGlobal::config()->group( autoSaveGroup()) );
}


void KFileReplace::removeDuplicatedActions()
{
    KActionCollection* part_action_collection = m_part->actionCollection();
    QAction* part_about_action = part_action_collection->action("help_about_kfilereplace");
    QAction* part_report_action = part_action_collection->action("report_bug");
    QAction* part_help_action= part_action_collection->action("help_kfilereplace");

    if (!part_about_action || !part_report_action || !part_help_action || !part_action_collection)
      return;

    QWidget* container = part_about_action->associatedWidgets().value(0);
    container->removeAction(part_about_action);
    container->removeAction(part_report_action);
    container->removeAction(part_help_action);
    part_action_collection->removeAction(part_about_action);
    part_action_collection->removeAction(part_report_action);
    part_action_collection->removeAction(part_help_action);
}

#include "kfilereplace.moc"