From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- buildtools/autotools/addicondlg.cpp | 115 ++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 buildtools/autotools/addicondlg.cpp (limited to 'buildtools/autotools/addicondlg.cpp') diff --git a/buildtools/autotools/addicondlg.cpp b/buildtools/autotools/addicondlg.cpp new file mode 100644 index 00000000..251601f7 --- /dev/null +++ b/buildtools/autotools/addicondlg.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * Copyright (C) 2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "addicondlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include // fix me! + +#include "autolistviewitems.h" + +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + + +const char *type_map[] = { + "app", "action", "device", "filesys", "mime" +}; + + +const char *size_map[] = { + "hi16", "hi22", "hi32", "hi48", "hi64", "hi128" +}; + + +AddIconDialog::AddIconDialog(AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *spitem, TargetItem *titem, + QWidget *parent, const char *name) + : AddIconDialogBase(parent, name, true) +{ + type_combo->insertItem(i18n("Application")); + type_combo->insertItem(i18n("Action")); + type_combo->insertItem(i18n("Device")); + type_combo->insertItem(i18n("File System")); + type_combo->insertItem(i18n("MIME Type")); + + size_combo->insertItem("16"); + size_combo->insertItem("22"); + size_combo->insertItem("32"); + size_combo->insertItem("48"); + size_combo->insertItem("64"); + size_combo->insertItem("128"); + + somethingChanged(); + + setIcon ( SmallIcon ( "iconadd_kdevelop" ) ); + + m_part = part; + m_widget = widget; + m_subProject = spitem; + m_target = titem; +} + + +AddIconDialog::~AddIconDialog() +{} + + +void AddIconDialog::somethingChanged() +{ + QString size = size_map[size_combo->currentItem()]; + QString type = type_map[type_combo->currentItem()]; + QString name = name_edit->text(); + + filename_edit->setText(size + "-" + type + "-" + name + ".png"); +} + + +void AddIconDialog::accept() +{ + QString name = filename_edit->text(); + + QString destdir = m_subProject->subdir; + QString destpath = destdir + "/" + name; + + QString size = size_combo->currentText(); + QString unknown = KIconTheme::defaultThemeName()+ "/" + size + "x" + size + "/mimetypes/unknown.png"; + + QString templateFileName = locate("icon", unknown); + kdDebug(9020) << "Unknown: " << unknown << ", template: " << templateFileName << endl; + + if (!templateFileName.isEmpty()) { + KProcess proc; + proc << "cp"; + proc << templateFileName; + proc << destpath; + proc.start(KProcess::DontCare); + } + + FileItem *fitem = m_widget->createFileItem(name, m_subProject); + m_target->sources.append(fitem); + m_target->insertItem(fitem); + + m_part->startMakeCommand(destdir, QString::fromLatin1("force-reedit")); + + m_widget->emitAddedFile(destpath); + + QDialog::accept(); +} + +#include "addicondlg.moc" -- cgit v1.2.1