mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-09 11:27:53 +00:00
qt: fixes #1529
This commit is contained in:
parent
d4b6485102
commit
242e3d007c
@ -177,7 +177,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
|
|||||||
|
|
||||||
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
|
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
|
||||||
|
|
||||||
initFileChooser( OPTION("","conf",[](){return "";}), uiSettings->configFileLineEdit, uiSettings->configFileBrowsePushButton, false);
|
initFileChooser( OPTION("","conf",[](){return "";}), uiSettings->configFileLineEdit, uiSettings->configFileBrowsePushButton, false, true);
|
||||||
initFileChooser( OPTION("","tunconf",[](){return "";}), uiSettings->tunnelsConfigFileLineEdit, uiSettings->tunnelsConfigFileBrowsePushButton, false);
|
initFileChooser( OPTION("","tunconf",[](){return "";}), uiSettings->tunnelsConfigFileLineEdit, uiSettings->tunnelsConfigFileBrowsePushButton, false);
|
||||||
initFileChooser( OPTION("","pidfile",[]{return "";}), uiSettings->pidFileLineEdit, uiSettings->pidFileBrowsePushButton, false);
|
initFileChooser( OPTION("","pidfile",[]{return "";}), uiSettings->pidFileLineEdit, uiSettings->pidFileBrowsePushButton, false);
|
||||||
|
|
||||||
@ -649,9 +649,9 @@ MainWindow::~MainWindow()
|
|||||||
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
FileChooserItem* MainWindow::initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton, bool requireExistingFile){
|
FileChooserItem* MainWindow::initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton, bool requireExistingFile, bool readOnly){
|
||||||
FileChooserItem* retVal;
|
FileChooserItem* retVal;
|
||||||
retVal=new FileChooserItem(option, fileNameLineEdit, fileBrowsePushButton, this, requireExistingFile);
|
retVal=new FileChooserItem(option, fileNameLineEdit, fileBrowsePushButton, this, requireExistingFile, readOnly);
|
||||||
MainWindowItem* super=retVal;
|
MainWindowItem* super=retVal;
|
||||||
configItems.append(super);
|
configItems.append(super);
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -102,12 +102,14 @@ class MainWindow;
|
|||||||
|
|
||||||
class MainWindowItem : public QObject {
|
class MainWindowItem : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
private:
|
||||||
ConfigOption option;
|
ConfigOption option;
|
||||||
QWidget* widgetToFocus;
|
QWidget* widgetToFocus;
|
||||||
QString requirementToBeValid;
|
QString requirementToBeValid;
|
||||||
|
const bool readOnly;
|
||||||
public:
|
public:
|
||||||
MainWindowItem(ConfigOption option_, QWidget* widgetToFocus_, QString requirementToBeValid_) :
|
MainWindowItem(ConfigOption option_, QWidget* widgetToFocus_, QString requirementToBeValid_, bool readOnly_=false) :
|
||||||
option(option_), widgetToFocus(widgetToFocus_), requirementToBeValid(requirementToBeValid_) {}
|
option(option_), widgetToFocus(widgetToFocus_), requirementToBeValid(requirementToBeValid_), readOnly(readOnly_) {}
|
||||||
QWidget* getWidgetToFocus(){return widgetToFocus;}
|
QWidget* getWidgetToFocus(){return widgetToFocus;}
|
||||||
QString& getRequirementToBeValid() { return requirementToBeValid; }
|
QString& getRequirementToBeValid() { return requirementToBeValid; }
|
||||||
ConfigOption& getConfigOption() { return option; }
|
ConfigOption& getConfigOption() { return option; }
|
||||||
@ -125,6 +127,7 @@ public:
|
|||||||
:boost::any_cast<boost::program_options::variable_value>(programOption).value();
|
:boost::any_cast<boost::program_options::variable_value>(programOption).value();
|
||||||
}
|
}
|
||||||
virtual void saveToStringStream(std::stringstream& out){
|
virtual void saveToStringStream(std::stringstream& out){
|
||||||
|
if(readOnly)return; //should readOnly items (conf=) error somewhere, instead of silently skipping save?
|
||||||
if(isType<std::string>(optionValue)) {
|
if(isType<std::string>(optionValue)) {
|
||||||
std::string v = boost::any_cast<std::string>(optionValue);
|
std::string v = boost::any_cast<std::string>(optionValue);
|
||||||
if(v.empty())return;
|
if(v.empty())return;
|
||||||
@ -170,8 +173,8 @@ class BaseStringItem : public MainWindowItem {
|
|||||||
public:
|
public:
|
||||||
QLineEdit* lineEdit;
|
QLineEdit* lineEdit;
|
||||||
MainWindow *mainWindow;
|
MainWindow *mainWindow;
|
||||||
BaseStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString requirementToBeValid_, MainWindow* mainWindow_):
|
BaseStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString requirementToBeValid_, MainWindow* mainWindow_, bool readOnly=false):
|
||||||
MainWindowItem(option_, lineEdit_, requirementToBeValid_),
|
MainWindowItem(option_, lineEdit_, requirementToBeValid_, readOnly),
|
||||||
lineEdit(lineEdit_),
|
lineEdit(lineEdit_),
|
||||||
mainWindow(mainWindow_)
|
mainWindow(mainWindow_)
|
||||||
{};
|
{};
|
||||||
@ -197,8 +200,8 @@ protected:
|
|||||||
const bool requireExistingFile;
|
const bool requireExistingFile;
|
||||||
public:
|
public:
|
||||||
QPushButton* browsePushButton;
|
QPushButton* browsePushButton;
|
||||||
FileOrFolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFile_) :
|
FileOrFolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFile_, bool readOnly) :
|
||||||
BaseStringItem(option_, lineEdit_, QString(), mw), requireExistingFile(requireExistingFile_), browsePushButton(browsePushButton_) {}
|
BaseStringItem(option_, lineEdit_, QString(), mw, readOnly), requireExistingFile(requireExistingFile_), browsePushButton(browsePushButton_) {}
|
||||||
virtual ~FileOrFolderChooserItem(){}
|
virtual ~FileOrFolderChooserItem(){}
|
||||||
};
|
};
|
||||||
class FileChooserItem : public FileOrFolderChooserItem {
|
class FileChooserItem : public FileOrFolderChooserItem {
|
||||||
@ -206,8 +209,8 @@ class FileChooserItem : public FileOrFolderChooserItem {
|
|||||||
private slots:
|
private slots:
|
||||||
void pushButtonReleased();
|
void pushButtonReleased();
|
||||||
public:
|
public:
|
||||||
FileChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFile) :
|
FileChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFile, bool readOnly) :
|
||||||
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_, mw, requireExistingFile) {
|
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_, mw, requireExistingFile, readOnly) {
|
||||||
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -217,7 +220,7 @@ private slots:
|
|||||||
void pushButtonReleased();
|
void pushButtonReleased();
|
||||||
public:
|
public:
|
||||||
FolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFolder) :
|
FolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_, MainWindow* mw, bool requireExistingFolder) :
|
||||||
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_, mw, requireExistingFolder) {
|
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_, mw, requireExistingFolder, false) {
|
||||||
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -521,7 +524,7 @@ protected:
|
|||||||
//LogDestinationComboBoxItem* logOption;
|
//LogDestinationComboBoxItem* logOption;
|
||||||
FileChooserItem* logFileNameOption;
|
FileChooserItem* logFileNameOption;
|
||||||
|
|
||||||
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton, bool requireExistingFile);
|
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton, bool requireExistingFile, bool readOnly=false);
|
||||||
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
||||||
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
void initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox);
|
void initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
|
Loading…
Reference in New Issue
Block a user