Skip to content

Commit 183e320

Browse files
authored
Merge pull request #105 from nonlin-lin-chaos-order-etc-etal/nonl_patch
Fix #103
2 parents d7dfa22 + 44e1c37 commit 183e320

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/i2pd

Submodule i2pd updated 61 files

src/mainwindow.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
306306
initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit);
307307
initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit);
308308

309-
initUInt16Box( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
309+
initUIntBox( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
310310
initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles"));
311311
initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize"));
312312

@@ -709,6 +709,9 @@ void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) {
709709
void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
710710
configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this));
711711
}
712+
void MainWindow::initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
713+
configItems.append(new UIntStringItem(option, numberLineEdit, fieldNameTranslated, this));
714+
}
712715
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
713716
configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this));
714717
}

src/mainwindow.h

+21
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class MainWindowItem : public QObject {
158158
out << boost::any_cast<uint32_t>(optionValue);
159159
}else if(isType<int>(optionValue)) {
160160
out << boost::any_cast<int>(optionValue);
161+
}else if(isType<unsigned long>(optionValue)) {
162+
out << boost::any_cast<unsigned long>(optionValue);
161163
}else if(isType<unsigned short>(optionValue)) {
162164
out << boost::any_cast<unsigned short>(optionValue);
163165
}else out << boost::any_cast<std::string>(optionValue); //let it throw
@@ -330,6 +332,24 @@ class IntegerStringItem : public BaseFormattedStringItem {
330332
virtual QString toString(){return QString::number(boost::any_cast<int>(optionValue));}
331333
virtual boost::any fromString(QString s){return boost::any(std::stoi(s.toStdString()));}
332334
};
335+
class UIntStringItem : public BaseFormattedStringItem {
336+
public:
337+
UIntStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) :
338+
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_,
339+
QApplication::tr("Must be a valid integer."), mw) {}
340+
virtual ~UIntStringItem(){}
341+
virtual bool isValid(bool & alreadyDisplayedIfWrong){
342+
bool correct = BaseFormattedStringItem::isValid(alreadyDisplayedIfWrong);
343+
if(!correct)return false;
344+
alreadyDisplayedIfWrong = false;
345+
auto str=lineEdit->text();
346+
bool ok;
347+
str.toUInt(&ok);
348+
return ok;
349+
}
350+
virtual QString toString(){return QString::number(boost::any_cast<unsigned int>(optionValue));}
351+
virtual boost::any fromString(QString s){return boost::any(std::stoul(s.toStdString()));}
352+
};
333353
class UShortStringItem : public BaseFormattedStringItem {
334354
public:
335355
UShortStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) :
@@ -543,6 +563,7 @@ public slots:
543563
void initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated);
544564
void initCheckBox(ConfigOption option, QCheckBox* checkBox);
545565
void initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
566+
void initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
546567
void initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
547568
void initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
548569
void initStringBox(ConfigOption option, QLineEdit* lineEdit);

0 commit comments

Comments
 (0)