/* * Moonlight|3D Copyright (C) 2006 The Moonlight|3D team * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on Sep 2, 2006 */ package ml.ui.core; import com.trolltech.qt.core.QObject; import com.trolltech.qt.gui.QAction; import com.trolltech.qt.gui.QIcon; public class Action extends QAction { private String name; private String defaultText; private String defaultMenuLocation="Other"; private String defaultToolbar="Other"; private String category="Other"; public Action(String name, QIcon icon, String text, QObject parent) { super(icon, text, parent); this.name=name; this.defaultText=text; setToolTip(text); setStatusTip(text); } public Action(String name, QObject parent) { super(parent); this.name=name; } public Action(String name, String text, QObject parent) { super(text, parent); this.name=name; this.defaultText=text; setToolTip(text); setStatusTip(text); } public void run() throws Exception { } public String getName() { return name; } public String getDefaultMenuLocation() { return defaultMenuLocation; } public void setDefaultMenuLocation(String defaultMenuLocation) { this.defaultMenuLocation = defaultMenuLocation; } public String getDefaultToolbar() { return defaultToolbar; } public void setDefaultToolbar(String defaultToolbar) { this.defaultToolbar = defaultToolbar; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public String getDefaultText() { return defaultText; } public void setDefaultText(String defaultText) { this.defaultText = defaultText; } /** * This is used as a workaround for a shortcoming of Qt. To * create a QIcon object to be passed as an icon to a QAction * or similar a connection to a graphical user interface must * exist or Qt will abort hard. Moonlight plugins load icons * as part their actions, which leads to Moonlight aborting * in batch mode unless icon loading is prevented. Therefore, * setting action icons must be done through this wrapper * function which properly avoids the icon loading step in * batchmode. * * @param filename the filename of the icon to be loaded */ public void setIcon(String filename) { if(!ml.core.State.getInstance().getBatchMode()) { setIcon(new QIcon(filename)); } } }