why does this not work
This commit is contained in:
parent
aa713ed9c9
commit
4ad0f6bec7
2 changed files with 60 additions and 11 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#include "newFilePicker.h"
|
||||
#include "IconsFontAwesome4.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
#include "../ta-log.h"
|
||||
#include <algorithm>
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -130,6 +132,8 @@ void FurnaceFilePicker::readDirectory(String path) {
|
|||
delete i;
|
||||
}
|
||||
entries.clear();
|
||||
chosenEntries.clear();
|
||||
updateEntryName();
|
||||
|
||||
// start new file thread
|
||||
this->path=path;
|
||||
|
|
@ -145,6 +149,16 @@ void FurnaceFilePicker::setHomeDir(String where) {
|
|||
homeDir=where;
|
||||
}
|
||||
|
||||
void FurnaceFilePicker::updateEntryName() {
|
||||
if (chosenEntries.empty()) {
|
||||
entryName="";
|
||||
} else if (chosenEntries.size()>1) {
|
||||
entryName="<multiple files selected>";
|
||||
} else {
|
||||
entryName=chosenEntries[0]->name;
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceFilePicker::sortFiles() {
|
||||
entryLock.lock();
|
||||
sortedEntries=entries;
|
||||
|
|
@ -214,6 +228,8 @@ bool FurnaceFilePicker::draw() {
|
|||
if (!haveFiles) {
|
||||
ImGui::Text("Loading... (%s)",path.c_str());
|
||||
} else {
|
||||
bool acknowledged=false;
|
||||
|
||||
if (haveStat) {
|
||||
ImGui::Text("Hiya! (%s)",path.c_str());
|
||||
} else {
|
||||
|
|
@ -267,13 +283,17 @@ bool FurnaceFilePicker::draw() {
|
|||
ImGui::PushStyleColor(ImGuiCol_Text,0xff00ffff);
|
||||
}
|
||||
ImGui::PushID(index++);
|
||||
if (ImGui::Selectable("##File",false)) {
|
||||
if (i->type==FP_TYPE_DIR || i->type==FP_TYPE_LINK) {
|
||||
if (*path.rbegin()=='/') {
|
||||
newDir=path+i->name;
|
||||
} else {
|
||||
newDir=path+'/'+i->name;
|
||||
}
|
||||
if (ImGui::Selectable("CLICK ME....##File",i->isSelected)) {
|
||||
for (FileEntry* j: chosenEntries) {
|
||||
j->isSelected=false;
|
||||
}
|
||||
chosenEntries.clear();
|
||||
chosenEntries.push_back(i);
|
||||
i->isSelected=true;
|
||||
updateEntryName();
|
||||
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
|
||||
logV("the fucking hell.......\n");
|
||||
acknowledged=true;
|
||||
}
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
|
@ -282,7 +302,7 @@ bool FurnaceFilePicker::draw() {
|
|||
ImGui::TextUnformatted(i->name.c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (i->hasSize) {
|
||||
if (i->hasSize && !i->isDir) {
|
||||
ImGui::Text("%" PRIu64,i->size);
|
||||
}
|
||||
|
||||
|
|
@ -308,12 +328,32 @@ bool FurnaceFilePicker::draw() {
|
|||
if (ImGui::InputText("##EntryName",&entryName)) {
|
||||
}
|
||||
|
||||
ImGui::Button("OK");
|
||||
ImGui::BeginDisabled(chosenEntries.empty());
|
||||
if (ImGui::Button("OK")) {
|
||||
// accept entry
|
||||
acknowledged=true;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
curStatus=FP_STATUS_CLOSED;
|
||||
isOpen=false;
|
||||
}
|
||||
|
||||
if (acknowledged) {
|
||||
if (!chosenEntries.empty()) {
|
||||
if (chosenEntries.size()==1) {
|
||||
if (chosenEntries[0]->isDir) {
|
||||
// go there unless we've been required to select a directory
|
||||
if (*path.rbegin()=='/') {
|
||||
newDir=path+chosenEntries[0]->name;
|
||||
} else {
|
||||
newDir=path+'/'+chosenEntries[0]->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
|
@ -340,6 +380,14 @@ FilePickerStatus FurnaceFilePicker::getStatus() {
|
|||
return retStatus;
|
||||
}
|
||||
|
||||
void FurnaceFilePicker::loadSettings(DivConfig& conf) {
|
||||
|
||||
}
|
||||
|
||||
void FurnaceFilePicker::saveSettings(DivConfig& conf) {
|
||||
|
||||
}
|
||||
|
||||
FurnaceFilePicker::FurnaceFilePicker():
|
||||
fileThread(NULL),
|
||||
haveFiles(false),
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ class FurnaceFilePicker {
|
|||
String path;
|
||||
String name;
|
||||
String ext;
|
||||
bool hasSize, hasTime, isDir;
|
||||
bool hasSize, hasTime, isDir, isSelected;
|
||||
uint64_t size;
|
||||
struct tm time;
|
||||
FileType type;
|
||||
FileEntry():
|
||||
hasSize(false), hasTime(false), isDir(false),
|
||||
hasSize(false), hasTime(false), isDir(false), isSelected(false),
|
||||
size(0), type(FP_TYPE_UNKNOWN) {}
|
||||
};
|
||||
std::vector<FileEntry*> entries;
|
||||
|
|
@ -69,6 +69,7 @@ class FurnaceFilePicker {
|
|||
void sortFiles();
|
||||
void filterFiles();
|
||||
void clearAllFiles();
|
||||
void updateEntryName();
|
||||
void readDirectory(String path);
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue