KDevelop API Documentation

buildtools/autotools/addtranslationdlg.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2001 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 "addtranslationdlg.h" 00013 00014 #include <qcombobox.h> 00015 #include <qfile.h> 00016 #include <qfileinfo.h> 00017 #include <qhbox.h> 00018 #include <qlabel.h> 00019 #include <qlayout.h> 00020 #include <qlineedit.h> 00021 #include <qpushbutton.h> 00022 #include <qstrlist.h> 00023 #include <kbuttonbox.h> 00024 #include <kdialog.h> 00025 #include <klocale.h> 00026 #include <kmessagebox.h> 00027 #include <kstdguiitem.h> 00028 00029 #include "misc.h" 00030 #include "autoprojectpart.h" 00031 00032 00033 AddTranslationDialog::AddTranslationDialog(AutoProjectPart *part, QWidget *parent, const char *name) 00034 : QDialog(parent, name, true) 00035 { 00036 setCaption(i18n("Add Translation")); 00037 00038 m_part = part; 00039 00040 QHBox *hbox = new QHBox(this); 00041 (void) new QLabel(i18n("Language:"), hbox); 00042 lang_combo = new QComboBox(hbox); 00043 00044 QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); 00045 layout->addWidget(hbox); 00046 00047 QFrame *frame = new QFrame(this); 00048 frame->setFrameStyle(QFrame::HLine | QFrame::Sunken); 00049 layout->addWidget(frame, 0); 00050 00051 KButtonBox *buttonbox = new KButtonBox(this); 00052 buttonbox->addStretch(); 00053 QPushButton *ok_button = buttonbox->addButton(KStdGuiItem::ok().text()); 00054 QPushButton *cancel_button = buttonbox->addButton(KStdGuiItem::cancel().text()); 00055 ok_button->setDefault(true); 00056 connect( ok_button, SIGNAL(clicked()), this, SLOT(accept()) ); 00057 connect( cancel_button, SIGNAL(clicked()), this, SLOT(reject()) ); 00058 buttonbox->layout(); 00059 layout->addWidget(buttonbox, 0); 00060 00061 QStringList rawlist, list; 00062 rawlist << "af" << "ar" << "bg" << "bo" << "br" << "bs" << "ca" << "cs" << "cy" << "da" 00063 << "de" << "el" << "en_GB" << "eo" << "es" << "et" << "eu" << "fi" << "fr"; 00064 rawlist << "ga" << "gl" << "gu" << "he" << "hi" << "hu" << "id" << "is" << "it" << "ja" 00065 << "km" << "ko" << "lt" << "lv" << "mi" << "mk" << "mr" << "nl" << "no" << "no_NY"; 00066 rawlist << "oc" << "pl" << "pt" << "pt_BR" << "ro" << "ru" << "sk" << "sl" << "sr" << "sv" 00067 << "ta" << "th" << "tr" << "uk" << "wa" << "zh_CN.GB2312" << "zh_TW.Big5"; 00068 00069 // Remove already added languages 00070 QStringList::ConstIterator it; 00071 for (it = rawlist.begin(); it != rawlist.end(); ++it) { 00072 QFileInfo fi(m_part->projectDirectory() + "/po/" + (*it) + ".po"); 00073 if (!fi.exists()) 00074 list.append(*it); 00075 } 00076 00077 if (list.isEmpty()) { 00078 KMessageBox::information(this, i18n("Your sourcecode is already translated to all supported languages.")); 00079 ok_button->setEnabled(false); 00080 } 00081 lang_combo->insertStringList(list); 00082 } 00083 00084 00085 AddTranslationDialog::~AddTranslationDialog() 00086 {} 00087 00088 00089 void AddTranslationDialog::accept() 00090 { 00091 QString dir = m_part->projectDirectory() + "/po"; 00092 QString fileName = dir + "/" + lang_combo->currentText() + ".po"; 00093 00094 QFile f(fileName); 00095 if (f.exists()) { 00096 KMessageBox::information(this, i18n("A translation file for the language %1 exists already.")); 00097 return; 00098 } 00099 f.open(IO_WriteOnly); 00100 f.close(); 00101 00102 dir = m_part->buildDirectory() + "/po"; 00103 m_part->startMakeCommand(dir, QString::fromLatin1("force-reedit")); 00104 00105 QDialog::accept(); 00106 } 00107 00108 #include "addtranslationdlg.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 Tue Oct 19 08:01:36 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003