~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to src/core.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <qtimer.h>
2
 
 
3
 
 
4
 
#include <kapplication.h>
5
 
#include <kdebug.h>
6
 
#include <kstatusbar.h>
7
 
#include <kmainwindow.h>
8
 
#include <kconfig.h>
9
 
#include <kdeversion.h>
10
 
#include <kstandarddirs.h>
11
 
#include <kglobal.h>
12
 
#include <kactioncollection.h>
13
 
 
14
 
#include "toplevel.h"
15
 
#include "partcontroller.h"
16
 
#include "api.h"
17
 
#include "projectmanager.h"
18
 
 
19
 
#include "core.h"
20
 
 
21
 
 
22
 
Core *Core::s_instance = 0;
23
 
 
24
 
 
25
 
Core *Core::getInstance()
26
 
{
27
 
  if (!s_instance)
28
 
    s_instance = new Core;
29
 
  return s_instance;
30
 
}
31
 
 
32
 
void Core::setupShourtcutTips(KXMLGUIClient * client)
33
 
{
34
 
  QPtrList<KXMLGUIClient> clients;
35
 
  if (client != 0)
36
 
    clients.append(client);
37
 
  else
38
 
    clients = TopLevel::getInstance()->main()->guiFactory()->clients();
39
 
  
40
 
  for( QPtrListIterator<KXMLGUIClient> it(clients); it.current(); ++it ) {
41
 
    KActionCollection *actionCollection = (*it)->actionCollection();
42
 
    for (int i = 0; i < actionCollection->count(); i++) {
43
 
      KAction *action = actionCollection->action(i);
44
 
            
45
 
      QString tooltip = action->toolTip();
46
 
      if (tooltip.isEmpty())
47
 
        tooltip = action->text().remove('&');
48
 
      else {
49
 
        int i = tooltip.findRev('(');
50
 
        if (i > 0) tooltip = tooltip.left(i).stripWhiteSpace();
51
 
      }
52
 
 
53
 
      QString shortcut = action->shortcutText();
54
 
      if (!shortcut.isEmpty())
55
 
        tooltip += " (" + shortcut + ")";
56
 
        action->setToolTip(tooltip);
57
 
      }
58
 
  }
59
 
}
60
 
 
61
 
Core::Core()
62
 
  : KDevCore()
63
 
{
64
 
}
65
 
 
66
 
 
67
 
Core::~Core()
68
 
{
69
 
}
70
 
 
71
 
bool Core::queryClose()
72
 
{
73
 
  // save the the project to open it automaticly on startup if needed
74
 
  KConfig* config = kapp->config();
75
 
  config->setGroup("General Options");
76
 
  config->writePathEntry("Last Project",ProjectManager::getInstance()->projectFile().url());
77
 
  
78
 
  if ( !PartController::getInstance()->querySaveFiles() )
79
 
          return false;
80
 
  
81
 
  if ( !ProjectManager::getInstance()->closeProject( true ) )
82
 
      return false;
83
 
  
84
 
  if ( !PartController::getInstance()->readyToClose() )
85
 
      return false;
86
 
  
87
 
  return true;
88
 
}
89
 
 
90
 
 
91
 
void Core::running(KDevPlugin * which, bool runs)
92
 
{
93
 
  emit activeProcessChanged( which, runs );
94
 
}
95
 
 
96
 
 
97
 
void Core::fillContextMenu(QPopupMenu *popup, const Context *context)
98
 
{
99
 
  emit contextMenu(popup, context);
100
 
}
101
 
 
102
 
 
103
 
void Core::openProject(const QString& projectFileName)
104
 
{
105
 
  ProjectManager::getInstance()->loadProject(KURL( projectFileName ));
106
 
}
107
 
 
108
 
namespace MainWindowUtils{
109
 
QString beautifyToolTip(const QString& text)
110
 
{
111
 
    QString temp = text;
112
 
    temp.replace(QRegExp("&"), "");
113
 
    temp.replace(QRegExp("\\.\\.\\."), "");
114
 
    return temp;
115
 
}
116
 
}
117
 
 
118
 
#include "core.moc"