blob: 61c22403c029626d80b72d8fec0196f5f7105b32 (
plain)
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
118
|
#include <tqtimer.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kstatusbar.h>
#include <kmainwindow.h>
#include <kconfig.h>
#include <tdeversion.h>
#include <kstandarddirs.h>
#include <kglobal.h>
#include <kactioncollection.h>
#include "toplevel.h"
#include "partcontroller.h"
#include "api.h"
#include "projectmanager.h"
#include "core.h"
Core *Core::s_instance = 0;
Core *Core::getInstance()
{
if (!s_instance)
s_instance = new Core;
return s_instance;
}
void Core::setupShourtcutTips(KXMLGUIClient * client)
{
TQPtrList<KXMLGUIClient> clients;
if (client != 0)
clients.append(client);
else
clients = TopLevel::getInstance()->main()->guiFactory()->clients();
for( TQPtrListIterator<KXMLGUIClient> it(clients); it.current(); ++it ) {
KActionCollection *actionCollection = (*it)->actionCollection();
for (int i = 0; i < actionCollection->count(); i++) {
KAction *action = actionCollection->action(i);
TQString tooltip = action->toolTip();
if (tooltip.isEmpty())
tooltip = action->text().remove('&');
else {
int i = tooltip.findRev('(');
if (i > 0) tooltip = tooltip.left(i).stripWhiteSpace();
}
TQString shortcut = action->shortcutText();
if (!shortcut.isEmpty())
tooltip += " (" + shortcut + ")";
action->setToolTip(tooltip);
}
}
}
Core::Core()
: KDevCore()
{
}
Core::~Core()
{
}
bool Core::queryClose()
{
// save the the project to open it automaticly on startup if needed
KConfig* config = kapp->config();
config->setGroup("General Options");
config->writePathEntry("Last Project",ProjectManager::getInstance()->projectFile().url());
if ( !PartController::getInstance()->querySaveFiles() )
return false;
if ( !ProjectManager::getInstance()->closeProject( true ) )
return false;
if ( !PartController::getInstance()->readyToClose() )
return false;
return true;
}
void Core::running(KDevPlugin * which, bool runs)
{
emit activeProcessChanged( which, runs );
}
void Core::fillContextMenu(TQPopupMenu *popup, const Context *context)
{
emit contextMenu(popup, context);
}
void Core::openProject(const TQString& projectFileName)
{
ProjectManager::getInstance()->loadProject(KURL( projectFileName ));
}
namespace MainWindowUtils{
TQString beautifyToolTip(const TQString& text)
{
TQString temp = text;
temp.replace(TQRegExp("&"), "");
temp.replace(TQRegExp("\\.\\.\\."), "");
return temp;
}
}
#include "core.moc"
|