00001
00012
00013
00014 #include "algorithm_settings_widget.h"
00015 #include "../../global/settings.h"
00016
00017 #include <iostream>
00018
00019 #include <QFileDialog>
00020
00021 namespace imedgine
00022 {
00023
00024
00025
00026 AlgorithmSettingsWidget::AlgorithmSettingsWidget(QWidget* parent)
00027 : QWidget(parent),
00028 AlgorithmSettingsWidgetBase(),
00029 data_changed_(false)
00030 {
00031 setupUi(this);
00032 initializeGUI();
00033 }
00034
00035
00036
00037 AlgorithmSettingsWidget::~AlgorithmSettingsWidget()
00038 {
00039 }
00040
00041
00042
00043 void AlgorithmSettingsWidget::checkChanges()
00044 {
00045 if(data_changed_)
00046 {
00047 this->applyChanges();
00048 }
00049 }
00050
00051
00052
00053 void AlgorithmSettingsWidget::dataChanged()
00054 {
00055 data_changed_ = true;
00056 }
00057
00058
00059
00060 void AlgorithmSettingsWidget::applyChanges()
00061 {
00062 (Settings::getInstance())->setValue("algorithms_config_path",
00063 QVariant((algorithm_config_path_line_edit_->text())));
00064
00065 (Settings::getInstance())->setValue("algorithms_path",
00066 QVariant((algorithm_path_line_edit_->text())));
00067 }
00068
00069
00070
00071 void AlgorithmSettingsWidget::openAlgorithmConfigPathSelectionDialog()
00072 {
00073
00074 QVariant previous_open_path =
00075 (Settings::getInstance())->getValue("algorithm_config_path", "/");
00076
00077 QFileDialog open_dialog(this);
00078
00079 QString open_path = open_dialog.getOpenFileName(
00080 this,
00081 tr("Choose a File to Open"),
00082 previous_open_path.toString(),
00083 "Algorithm Configuration Files (*.xml)");
00084
00085 if(!open_path.isEmpty())
00086 {
00087 algorithm_config_path_line_edit_->setText(open_path);
00088 }
00089 }
00090
00091
00092
00093 void AlgorithmSettingsWidget::openAlgorithmPathSelectionDialog()
00094 {
00095
00096 QVariant previous_open_path =
00097 (Settings::getInstance())->getValue("algorithm_path", "/");
00098
00099 QFileDialog open_dialog(this);
00100 QString open_path = open_dialog.getExistingDirectory(
00101 this,
00102 tr("Choose the Location of the Algorithms"),
00103 previous_open_path.toString());
00104
00105 if(!open_path.isEmpty())
00106 {
00107 algorithm_path_line_edit_->setText(open_path);
00108 }
00109 }
00110
00111
00112
00113 void AlgorithmSettingsWidget::initializeGUI()
00114 {
00115
00116 select_algorithm_config_path_push_button_->setIcon(QIcon(":icons/document-open.png"));
00117 algorithm_config_path_line_edit_->
00118 setText(((Settings::getInstance())->
00119 getValue("algorithms_config_path")).toString());
00120
00121 connect(select_algorithm_config_path_push_button_, SIGNAL(clicked()),
00122 this, SLOT(openAlgorithmConfigPathSelectionDialog()));
00123
00124 connect(algorithm_config_path_line_edit_, SIGNAL(textChanged(const QString&)),
00125 this, SLOT(dataChanged()));
00126
00127
00128 select_algorithm_path_push_button_->setIcon(QIcon(":icons/document-open.png"));
00129 algorithm_path_line_edit_->
00130 setText(((Settings::getInstance())->
00131 getValue("algorithms_path")).toString());
00132
00133 connect(select_algorithm_path_push_button_, SIGNAL(clicked()),
00134 this, SLOT(openAlgorithmPathSelectionDialog()));
00135
00136 connect(algorithm_path_line_edit_, SIGNAL(textChanged(const QString&)),
00137 this, SLOT(dataChanged()));
00138 }
00139 }