-
Notifications
You must be signed in to change notification settings - Fork 3
/
SettingsMode.h
executable file
·155 lines (130 loc) · 4.71 KB
/
SettingsMode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//
// Copyright 2015 CutePoisonX ([email protected])
//
// This file is part of PoisonConvert.
//
// PoisonConvert is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// PoisonConvert is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with PoisonConvert. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef SETTINGSMODE_H
#define SETTINGSMODE_H
#include "Mode.h"
#include "Settings.h"
#include <string>
#include <vector>
using namespace std;
class UserInterface;
class SettingsMode : public Mode {
public:
//order of variables in enum must be exactly as order of vector element-settings in settings_vector_
enum SETTING_SPECIFIER {
CONFIGNAME = 0,
CONFIGLOC,
FFMPEG_CMD,
FFPROBE_CMD,
QT_CMD,
DELETESET,
OPTIMIZESET,
LOGPATH,
MOVIEPATH,
DESTINATION,
EXCLUDE
};
enum SAVE_SETTINGS {
DONT_SAVE_SETTINGS = -1,
SAVE_SETTINGS = -2
};
SettingsMode(UserInterface& ui);
SettingsMode(const SettingsMode& orig);
virtual ~SettingsMode();
int executeCommand();
template <typename SettingsClass>
SettingsClass const* const getSpecialSetting(unsigned int setting_nr) const
{
return dynamic_cast<SettingsClass const* const>(settings_vector_.at(setting_nr));
}
const string getSettingsParam(unsigned int setting_nr) const
{
if(setting_nr >= 0)
{
return settings_vector_.at(setting_nr)->getParam();
} else
{
return "ERROR - INDEX OUT OF BOUNCE";
}
}
const string getSettingsName(unsigned int setting_nr)
{
if(setting_nr >= 0)
{
return settings_vector_.at(setting_nr)->getName();
} else
{
return "ERROR - INDEX OUT OF BOUNCE";
}
}
const unsigned int getVectorLen()
{
return settings_vector_.size();
}
const Settings::PARAM_CHANGE_RETURN writeParam(string new_setting, SETTING_SPECIFIER setting_nr, bool manually_changed, bool force_change)
{
Settings::PARAM_CHANGE_RETURN changes_success = settings_vector_.at(setting_nr)->setParamSilent(new_setting, force_change);
if (manually_changed && changes_success == Settings::PARAM_CHANGE_SUCCESS)
{
there_were_changes_to_settings_ = true;
}
return changes_success;
}
const Settings::PARAM_CHANGE_RETURN writeParam(string new_setting, std::string setting_name, bool manually_changed, bool force_change)
{
for (unsigned int setting_num = 0; setting_num < settings_vector_.size(); ++ setting_num)
{
SETTING_SPECIFIER setting_specifier = static_cast<SETTING_SPECIFIER>(setting_num);
if (setting_name == settings_vector_[setting_specifier]->getName())
{
return writeParam(new_setting, setting_specifier, manually_changed, force_change);
}
}
return Settings::PARAM_CHANGE_ERROR;
}
const Settings::PARAM_CHANGE_RETURN checkParam(SETTING_SPECIFIER setting_nr, bool ui_output) const
{
return settings_vector_.at(setting_nr)->checkParam(ui_output);
}
bool checkIfSettingExists(std::string const& setting_name)
{
for (unsigned int setting_num = 0; setting_num < settings_vector_.size(); ++ setting_num)
{
SETTING_SPECIFIER setting_specifier = static_cast<SETTING_SPECIFIER>(setting_num);
if (setting_name == settings_vector_[setting_specifier]->getName())
{
return true;
}
}
return false;
}
private:
//----------------------------------------------------------------------------
vector<Settings*> settings_vector_;
bool there_were_changes_to_settings_;
//----------------------------------------------------------------------------
void standartExecutePrompt();
void changeDeleteOriginal(); //Second setting
void changeOptimizeForStreaming(); //Third setting
int changeFilename(); //first_setting
int listSettings();
void AlignSpaces(unsigned int align_len, unsigned int vec_element);
unsigned int IdentifyLongestName();
};
#endif /* SETTINGSMODE_H */