source: src/UIElements/Views/Qt4/QtToolBar.cpp@ e0feb3

Candidate_v1.7.0 stable
Last change on this file since e0feb3 was e0feb3, checked in by Frederik Heber <frederik.heber@…>, 2 months ago

Increases size of icons in toolbar.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * QtToolBar.cpp
25 *
26 * Created on: Apr 26, 2012
27 * Author: ankele
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "QtToolBar.hpp"
36
37//#include "CodePatterns/MemDebug.hpp"
38
39#include "CodePatterns/Observer/Notification.hpp"
40
41#include "Actions/ActionQueue.hpp"
42
43QtToolBar::QtToolBar(QWidget * _parent) :
44 QToolBar(_parent),
45 Observer("QToolBar"),
46 ActionQueue_observing(false),
47 undoaction(addActionItem("undo", "undo the last Action", "edit-undo")),
48 redoaction(addActionItem("redo", "redo the last Action", "edit-redo"))
49{
50 // gray out undo/redo buttons initially
51 undoaction->setEnabled(false);
52 redoaction->setEnabled(false);
53
54 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
55 setMinimumHeight(64);
56 setIconSize(QSize(60, 60));
57
58 // sign in
59 MoleCuilder::ActionQueue::getInstance().signOn(this, MoleCuilder::ActionQueue::ActionQueued);
60 ActionQueue_observing = true;
61}
62
63
64QtToolBar::~QtToolBar()
65{
66 // sign off
67 if (ActionQueue_observing)
68 MoleCuilder::ActionQueue::getInstance().signOff(this, MoleCuilder::ActionQueue::ActionQueued);
69}
70
71
72QAction * QtToolBar::addActionItem(
73 const std::string &token,
74 const std::string &description,
75 const std::string &icon_name)
76{
77 QAction *action = addAction(QString(description.c_str()));
78 action->setIcon(FavActions.getIcon(token, icon_name));
79 action->setToolTip(QString(description.c_str()));
80 QtMenuPipe *pipe = new QtMenuPipe(token,action);
81 QObject::connect(action, SIGNAL(triggered()),pipe,SLOT(called()));
82 plumbing.push_back(pipe);
83 present_actions.insert( token );
84 return action;
85}
86
87void QtToolBar::addFavoriteActionItems(const unsigned int _max)
88{
89 // separate favorite actions
90 addSeparator();
91 FavActions.addToolBarActions(*this, _max);
92}
93
94void QtToolBar::update(Observable *publisher)
95{
96 ASSERT(0, "QtToolBar::update() - this should never be called, we are only subscribed to channels.");
97}
98
99void QtToolBar::subjectKilled(Observable *publisher)
100{
101 ActionQueue_observing = false;
102}
103
104void QtToolBar::recieveNotification(Observable *publisher, Notification_ptr notification)
105{
106 if (dynamic_cast<MoleCuilder::ActionQueue *>(publisher) != NULL) {
107 switch(notification->getChannelNo()) {
108 case MoleCuilder::ActionQueue::ActionQueued:
109 undoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canUndo());
110 redoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canRedo());
111 break;
112 default:
113 ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, not subscribed to channel "
114 +toString(notification->getChannelNo()));
115 break;
116 }
117 } else {
118 ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, we are only subscribed to ActionQueue.");
119 }
120}
Note: See TracBrowser for help on using the repository browser.