/* * Moonlight|3D Copyright (C) 2005 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 Jan 14, 2005 */ package ml.ui.core; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryUsage; import java.util.ArrayList; import java.util.List; import com.trolltech.qt.core.Qt; import com.trolltech.qt.gui.QDialog; import com.trolltech.qt.gui.QHBoxLayout; import com.trolltech.qt.gui.QLabel; import com.trolltech.qt.gui.QListWidget; import com.trolltech.qt.gui.QPushButton; import com.trolltech.qt.gui.QTabWidget; import com.trolltech.qt.gui.QVBoxLayout; import com.trolltech.qt.gui.QWidget; /** * Displays a simple modal About dialog for Moonlight|3D. * * @author gregor */ public class AboutDialog extends QDialog { QTabWidget tab; QWidget programPage; QPushButton okButton; QLabel label; QWidget pluginsPage; QListWidget pluginList; QWidget memoryPage; QLabel memoryLabel; private static ArrayList pageFactories; static { pageFactories=new ArrayList(); } public static void registerAboutDialogPageFactory(AboutDialogPageFactory pageFactory) { pageFactories.add(pageFactory); } public static void unregisterAboutDialogPageFactory(AboutDialogPageFactory pageFactory) { pageFactories.remove(pageFactory); } /** * @param parentShell The parent for this (modal) dialog */ public AboutDialog(QWidget parent) { super(parent); setWindowTitle("About Moonlight|3D"); tab=new QTabWidget(parent); okButton=new QPushButton(this); okButton.setText("OK"); okButton.clicked.connect(this,"close()"); QVBoxLayout tabLayout=new QVBoxLayout(this); tabLayout.addWidget(tab,1); tabLayout.addWidget(okButton); setLayout(tabLayout); programPage=new QWidget(tab); tab.addTab(programPage, "Program"); createProgramPage(programPage); pluginsPage=new QWidget(tab); tab.addTab(pluginsPage, "Plugins"); createPluginsPage(pluginsPage); memoryPage=new QWidget(tab); tab.addTab(memoryPage,"Memory usage"); createMemoryPage(memoryPage); for(AboutDialogPageFactory pageFactory : pageFactories) { QWidget page=new QWidget(tab); tab.addTab(page, pageFactory.getName()); pageFactory.generateAboutDialogPage(page); } } public void createProgramPage(QWidget parent) { label=new QLabel(parent); label.setText("Moonlight|3D " + ml.core.State.Version.asString() + "\n(C) 2003-2007 The Moonlight Team\n\nGregor Mueckl\nPeter Brinkler"); QVBoxLayout layout=new QVBoxLayout(parent); layout.addWidget(label,1,Qt.AlignmentFlag.AlignCenter); parent.setLayout(layout); } public void createPluginsPage(QWidget parent) { pluginList=new QListWidget(parent); List pluginList=ml.core.State.getInstance().getPluginManager().getPluginList(); for(int i=0;i