source: smplayer/trunk/src/myaction.cpp@ 113

Last change on this file since 113 was 112, checked in by Silvan Scherrer, 15 years ago

Smplayer: eol-style

  • Property svn:eol-style set to LF
File size: 2.5 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "myaction.h"
20#include <QWidget>
21
22MyAction::MyAction ( QObject * parent, const char * name, bool autoadd )
23 : QAction(parent)
24{
25 //qDebug("MyAction::MyAction: name: '%s'", name);
26 setObjectName(name);
27 if (autoadd) addActionToParent();
28}
29
30
31MyAction::MyAction( QObject * parent, bool autoadd )
32 : QAction(parent)
33{
34 //qDebug("MyAction::MyAction: QObject, bool");
35 if (autoadd) addActionToParent();
36}
37
38MyAction::MyAction(const QString & text, QKeySequence accel,
39 QObject * parent, const char * name, bool autoadd )
40 : QAction(parent)
41{
42 setObjectName(name);
43 setText(text);
44 setShortcut(accel);
45 if (autoadd) addActionToParent();
46}
47
48MyAction::MyAction(QKeySequence accel, QObject * parent, const char * name,
49 bool autoadd )
50 : QAction(parent)
51{
52 setObjectName(name);
53 setShortcut(accel);
54 if (autoadd) addActionToParent();
55}
56
57MyAction::~MyAction() {
58}
59
60void MyAction::addActionToParent() {
61 if (parent()) {
62 if (parent()->inherits("QWidget")) {
63 QWidget *w = static_cast<QWidget*> (parent());
64 w->addAction(this);
65 }
66 }
67}
68
69void MyAction::change(const QIcon & icon, const QString & text) {
70 setIcon( icon );
71 change(text);
72}
73
74void MyAction::change(const QString & text ) {
75 setText( text );
76
77 QString accel_text = shortcut().toString();
78
79 QString s = text;
80 s.replace("&","");
81 if (!accel_text.isEmpty()) {
82 setToolTip( s + " ("+ accel_text +")");
83 setIconText( s );
84 }
85
86 /*
87 if (text.isEmpty()) {
88 QString s = menuText;
89 s = s.replace("&","");
90 setText( s );
91
92 if (!accel_text.isEmpty())
93 setToolTip( s + " ("+ accel_text +")");
94 } else {
95 setText( text );
96 if (!accel_text.isEmpty())
97 setToolTip( text + " ("+ accel_text +")");
98 }
99 */
100}
101
Note: See TracBrowser for help on using the repository browser.