MCPcopy Create free account
hub / github.com/bluescan/tacentview / DoDeleteFileModal

Method DoDeleteFileModal

Src/Dialogs.cpp:119–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119void Viewer::DoDeleteFileModal(bool deleteFilePressed)
120{
121 Config::ProfileData& profile = Config::GetProfileData();
122 if (deleteFilePressed)
123 {
124 if (!profile.ConfirmDeletes)
125 DeleteImageFile(CurrImage->Filename, true);
126 else
127 ImGui::OpenPopup("Delete File");
128 }
129
130 // The unused isOpenDeleteFile bool is just so we get a close button in ImGui.
131 bool isOpenDeleteFile = true;
132 if (!ImGui::BeginPopupModal("Delete File", &isOpenDeleteFile, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar))
133 return;
134
135 float buttonWidth = Gutil::GetUIParamScaled(76.0f, 2.5f);
136 tString fullname = CurrImage->Filename;
137 tString file = tSystem::tGetFileName(fullname);
138 tString dir = tSystem::tGetDir(fullname);
139
140 // The overall width is based on the larger of the filename and directory. We clamp
141 // the width of these two by calling CropStringToWidth.
142 float maxPathWidth = Gutil::GetUIParamScaled(380.0f, 2.5f);
143 float minPathWidth = Gutil::GetUIParamScaled(296.0f, 2.5f);
144 float fileWidth = 0.0f;
145 tString croppedFile = Gutil::CropStringToWidth(file, maxPathWidth, true, &fileWidth);
146 float dirWidth = 0.0f;
147 tString croppedDir = Gutil::CropStringToWidth(dir, maxPathWidth, true, &dirWidth);
148 float pathWidth = tMax(fileWidth, dirWidth, minPathWidth);
149
150 ImGui::Text("Delete File");
151 ImGui::Indent();
152 ImGui::Text("%s", croppedFile.Chr());
153 ImGui::Unindent();
154 if (croppedFile != file)
155 Gutil::ToolTip(file.Chr());
156
157 ImGui::Text("In Folder");
158 ImGui::Indent();
159 ImGui::Text("%s", croppedDir.Chr());
160 ImGui::Unindent();
161 if (croppedDir != dir)
162 Gutil::ToolTip(dir.Chr());
163
164 ImGuiStyle& style = ImGui::GetStyle();
165 ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y);
166 ImGui::Separator();
167
168 ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y);
169 ImGui::Checkbox("Confirm file deletions in the future?", &profile.ConfirmDeletes);
170 ImGui::SetCursorPosY(ImGui::GetCursorPosY() + style.ItemSpacing.y);
171
172 if (Gutil::Button("Cancel", tVector2(buttonWidth, 0.0f)))
173 ImGui::CloseCurrentPopup();
174
175 ImGui::SameLine();
176 float okOffset = ImGui::GetStyle().IndentSpacing + pathWidth - buttonWidth + ImGui::GetStyle().ItemSpacing.x;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected