summaryrefslogtreecommitdiffstats
path: root/src/libgui/toplevel_ui.cpp
blob: 5e8db32fd7015b62dee60de1d81ce2f06e7aae4d (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
/***************************************************************************
 *   Copyright (C) 2005-2007 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 "toplevel_ui.h"

#include <qstyle.h>
#include <kiconloader.h>

#include "progs/list/prog_list.h"
#include "tools/list/tool_list.h"

//----------------------------------------------------------------------------
ProgrammerStatusWidget::ProgrammerStatusWidget(QWidget *parent)
  : QObject(parent), KeyPopupButton<QString>(parent)
{
  connect(widget(), SIGNAL(activated(int)), SLOT(activatedSlot(int)));
  widget()->appendAction(i18n("Configure..."), "configure", this, SIGNAL(configure()));
  widget()->appendSeparator();
  Programmer::Lister::ConstIterator it;
  for (it=Programmer::lister().begin(); it!=Programmer::lister().end(); ++it)
    appendItem(it.key(), it.data()->label());
}

void ProgrammerStatusWidget::activatedSlot(int id)
{
  emit selected(*Programmer::lister().group(key(id)));
}

//----------------------------------------------------------------------------
ToolStatusWidget::ToolStatusWidget(QWidget *parent)
  : QObject(parent), KeyPopupButton<QString>(parent)
{
  connect(widget(), SIGNAL(activated(int)), SLOT(activatedSlot(int)));
  widget()->appendAction(i18n("Configure Toolchain..."), "configure", this, SIGNAL(configureToolchain()));
  widget()->appendAction(i18n("Configure Compilation..."), "configure", this, SIGNAL(configure()));
  widget()->appendSeparator();
  Tool::Lister::ConstIterator it;
  for (it=Tool::lister().begin(); it!=Tool::lister().end(); ++it)
    appendItem(it.key(), it.data()->label());
}

void ToolStatusWidget::activatedSlot(int id)
{
  emit selected(*Tool::lister().group(key(id)));
}

//----------------------------------------------------------------------------
ViewMenuAction::ViewMenuAction(KDockWidget *widget)
  : KToggleAction(widget->tabPageLabel()), _widget(widget)
{}

void ViewMenuAction::slotActivated()
{
  KAction::slotActivated();
  emit activated(_widget);
}

//----------------------------------------------------------------------------
MenuBarButton::MenuBarButton(const QString &icon, QWidget *parent)
  : QToolButton(parent, "menu_bar_button")
{
  QFontMetrics fm(font());
  int h = fm.height() + 2*style().pixelMetric(QStyle::PM_DefaultFrameWidth, this);
  setFixedHeight(h);
  KIconLoader loader;
  setIconSet(loader.loadIconSet(icon, KIcon::Small, fm.height()-2));
  setUsesTextLabel(false);
  setAutoRaise(true);
}

QSize MenuBarButton::sizeHint() const
{
  return QSize(QToolButton::sizeHint().width(), height());
}