File indexing completed on 2024-04-28 04:02:31
0001 /*************************************************************************** 0002 dlgimportexportprofile.cpp - description 0003 ------------------- 0004 begin : Ne júl 20 2003 0005 copyright : (C) 2003 by Tomas Mecir 0006 email : kmuddy@kmuddy.com 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #include "dlgimportexportprofile.h" 0019 0020 #include <KLocalizedString> 0021 #include <kmessagebox.h> 0022 0023 #include <QComboBox> 0024 #include <QDialogButtonBox> 0025 #include <QFileDialog> 0026 #include <QGridLayout> 0027 #include <QLabel> 0028 #include <QLineEdit> 0029 #include <QPushButton> 0030 0031 dlgImportExportProfile::dlgImportExportProfile (bool isImport, 0032 QWidget *parent) : QDialog (parent) 0033 { 0034 import = isImport; 0035 0036 //initial dialog size 0037 setWindowTitle (isImport ? i18n ("Import profile") : i18n ("Export profile")); 0038 0039 QGridLayout *layout = new QGridLayout (this); 0040 0041 QLabel *l1 = new QLabel (i18n ("&Profile name"), this); 0042 if (isImport) 0043 { 0044 edprofile = new QLineEdit (this); 0045 l1->setBuddy (edprofile); 0046 } 0047 else 0048 { 0049 cbprofile = new QComboBox (this); 0050 //cProfiles p; 0051 //cbprofile->addItems (p.getprofiles()); 0052 l1->setBuddy (cbprofile); 0053 } 0054 QLabel *l2 = new QLabel (isImport ? i18n ("&Import from") : 0055 i18n ("&Export to"), this); 0056 edfname = new QLineEdit (this); 0057 l2->setBuddy (edfname); 0058 QPushButton *button = new QPushButton (i18n ("Browse..."), this); 0059 0060 QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0061 connect (buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); 0062 connect (buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); 0063 0064 layout->setSpacing (10); 0065 layout->addWidget (l1, 0, 0); 0066 layout->addWidget (l2, 1, 0); 0067 if (isImport) 0068 layout->addWidget (edprofile, 0, 1); 0069 else 0070 layout->addWidget (cbprofile, 0, 1); 0071 layout->addWidget (edfname, 1, 1); 0072 layout->addWidget (button, 1, 2); 0073 layout->addWidget (buttons, 0, 3, 0, 2); 0074 layout->setRowStretch (2, 10); 0075 0076 connect (button, &QPushButton::clicked, this, &dlgImportExportProfile::browse); 0077 } 0078 0079 dlgImportExportProfile::~dlgImportExportProfile () 0080 { 0081 0082 } 0083 0084 QSize dlgImportExportProfile::sizeHint() const 0085 { 0086 return QSize (300, 150); 0087 } 0088 0089 void dlgImportExportProfile::doThings () 0090 { 0091 KMessageBox::error (this, i18n ("I am sorry, but import and export is currently disabled. The functionality should be re-enabled before the final release.")); 0092 /* 0093 if (exec() == QDialog::Accepted) 0094 { 0095 QString fName = edfname->text(); 0096 QString pName; 0097 if (import) 0098 pName = edprofile->text (); 0099 else 0100 pName = cbprofile->currentText (); 0101 QString msg; 0102 cProfiles p; 0103 if (import) 0104 { 0105 if (p.importProfile (pName, fName)) 0106 msg = QString(); 0107 else 0108 msg = p.lastError(); 0109 } 0110 else 0111 { 0112 if (p.exportProfile (pName, fName)) 0113 msg = QString(); 0114 else 0115 msg = p.lastError(); 0116 } 0117 if (msg == QString()) 0118 KMessageBox::information (this, import ? 0119 i18n ("Profile has been successfully imported.") : 0120 i18n ("Profile has been successfully exported.")); 0121 else 0122 KMessageBox::error (this, msg); 0123 } 0124 */ 0125 } 0126 0127 void dlgImportExportProfile::browse () 0128 { 0129 if (import) 0130 { 0131 QString n = QFileDialog::getOpenFileName (this, i18n ("Choose file with profile")); 0132 if (!(n.isEmpty())) 0133 edfname->setText (n); 0134 } 0135 else 0136 { 0137 QString n = QFileDialog::getSaveFileName (this, i18n ("Enter target file")); 0138 if (!(n.isEmpty())) 0139 edfname->setText (n); 0140 } 0141 } 0142 0143 #include "moc_dlgimportexportprofile.cpp"