KDevelop API Documentation

buildtools/autotools/addicondlg.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include "addicondlg.h" 00013 00014 #include <qcombobox.h> 00015 #include <qlabel.h> 00016 #include <qlineedit.h> 00017 #include <kdebug.h> 00018 #include <klocale.h> 00019 #include <kprocess.h> 00020 #include <kstandarddirs.h> 00021 #include <kicontheme.h> 00022 #include <kdeversion.h> // fix me! 00023 00024 #include "autolistviewitems.h" 00025 00026 #include "autoprojectpart.h" 00027 #include "autoprojectwidget.h" 00028 00029 00030 const char *type_map[] = { 00031 "app", "action", "device", "filesys", "mime" 00032 }; 00033 00034 00035 const char *size_map[] = { 00036 "hi16", "hi22", "hi32", "hi48", "hi64", "hi128" 00037 }; 00038 00039 00040 AddIconDialog::AddIconDialog(AutoProjectPart *part, AutoProjectWidget *widget, 00041 SubprojectItem *spitem, TargetItem *titem, 00042 QWidget *parent, const char *name) 00043 : AddIconDialogBase(parent, name, true) 00044 { 00045 type_combo->insertItem(i18n("Application")); 00046 type_combo->insertItem(i18n("Action")); 00047 type_combo->insertItem(i18n("Device")); 00048 type_combo->insertItem(i18n("File System")); 00049 type_combo->insertItem(i18n("MIME Type")); 00050 00051 size_combo->insertItem("16"); 00052 size_combo->insertItem("22"); 00053 size_combo->insertItem("32"); 00054 size_combo->insertItem("48"); 00055 size_combo->insertItem("64"); 00056 size_combo->insertItem("128"); 00057 00058 somethingChanged(); 00059 00060 setIcon ( SmallIcon ( "iconadd_kdevelop" ) ); 00061 00062 m_part = part; 00063 m_widget = widget; 00064 m_subProject = spitem; 00065 m_target = titem; 00066 } 00067 00068 00069 AddIconDialog::~AddIconDialog() 00070 {} 00071 00072 00073 void AddIconDialog::somethingChanged() 00074 { 00075 QString size = size_map[size_combo->currentItem()]; 00076 QString type = type_map[type_combo->currentItem()]; 00077 QString name = name_edit->text(); 00078 00079 filename_edit->setText(size + "-" + type + "-" + name + ".png"); 00080 } 00081 00082 00083 void AddIconDialog::accept() 00084 { 00085 QString name = filename_edit->text(); 00086 00087 QString destdir = m_subProject->subdir; 00088 QString destpath = destdir + "/" + name; 00089 00090 QString size = size_combo->currentText(); 00091 #if KDE_VERSION < 310 00092 QString unknown = "unknown"; // fix me! 00093 #else 00094 QString unknown = KIconTheme::defaultThemeName()+ "/" + size + "x" + size + "/mimetypes/unknown.png"; 00095 #endif 00096 QString templateFileName = locate("icon", unknown); 00097 kdDebug(9020) << "Unknown: " << unknown << ", template: " << templateFileName << endl; 00098 00099 if (!templateFileName.isEmpty()) { 00100 KProcess proc; 00101 proc << "cp"; 00102 proc << templateFileName; 00103 proc << destpath; 00104 proc.start(KProcess::DontCare); 00105 } 00106 00107 FileItem *fitem = m_widget->createFileItem(name, m_subProject); 00108 m_target->sources.append(fitem); 00109 m_target->insertItem(fitem); 00110 00111 m_part->startMakeCommand(destdir, QString::fromLatin1("force-reedit")); 00112 00113 m_widget->emitAddedFile(destpath); 00114 00115 QDialog::accept(); 00116 } 00117 00118 #include "addicondlg.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:38:53 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003