summaryrefslogtreecommitdiffstats
path: root/src/libgui/main_global.cpp
blob: 8741a44b64710984cc7ce97ad6bdfc8d0608d118 (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
/***************************************************************************
 *   Copyright (C) 2005 Nicolas Hadacek <hadacek@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.                                   *
 ***************************************************************************/
#include "main_global.h"

#include <qpopupmenu.h>

#include "toplevel.h"
#include "common/global/about.h"
#include "global_config.h"
#include "devices/list/device_list.h"
#include "project_manager.h"
#include "editor_manager.h"
#include "tools/list/compile_config.h"
#include "gui_prog_manager.h"
#include "device_editor.h"

Main::State Main::_state = Main::Idle;
MainWindow *Main::_toplevel = 0;
EditorManager *Main::_editorManager = 0;
ProjectManager::View *Main::_projectManager = 0;
Breakpoint::View *Main::_breakpointsView = 0;
Register::WatchView *Main::_watchView = 0;
Compile::LogWidget *Main::_compileLog = 0;
Compile::Manager *Main::_compileManager = 0;
ConsoleView *Main::_consoleView = 0;

void Main::setState(State state)
{
  _state = state;
  _toplevel->updateGUI();
}

Programmer::Base *Main::programmer()
{
  return Programmer::manager->programmer();
}

const Programmer::Group &Main::programmerGroup()
{
  return GlobalConfig::programmerGroup();
}

Programmer::State Main::programmerState()
{
  return (programmer() ? programmer()->state() : Programmer::NotConnected);
}

KAction *Main::action(const char* name)
{
  return _toplevel->KMainWindow::action(name);
}
KAction *Main::action(KStdAction::StdAction action)
{
  return _toplevel->KMainWindow::action(KStdAction::name(action));
}

QPopupMenu &Main::popup(const char *name)
{
  QPopupMenu *popup = static_cast<QPopupMenu *>(_toplevel->factory()->container(name, _toplevel));
  Q_ASSERT(popup);
  return *popup;
}

const Device::Data *Main::deviceData()
{
  QString name = device();
  if ( name==Device::AUTO_DATA.name )
    name = DeviceEditor::guessDeviceFromFile(_projectManager->projectUrl());
  return Device::lister().data(name);
}

Editor *Main::currentEditor() { return _editorManager->currentEditor(); }
Project *Main::project() { return _projectManager->project(); }
QString Main::device() { return Compile::Config::device(project()); }
const Tool::Group &Main::toolGroup() { return Compile::Config::toolGroup(project()); }