Revision daaf346e
Added by david.sorber 8 months ago
| src/main.cc | ||
|---|---|---|
|
#endif
|
||
|
|
||
|
const std::string APP_NAME("pwmgr");
|
||
|
const std::string VERSION("v0.1.4");
|
||
|
const std::string VERSION("v0.1.5");
|
||
|
const std::string DEFAULT_FILEPATH("/home/dsorber/Documents/chicken_soup/chicken_soup.txt.enc");
|
||
|
|
||
|
const std::string BOLD{"\033[1m"};
|
||
| ... | ... | |
|
const char* STR_PWD = "enter password and click \"Load\"";
|
||
|
const char* STR_LOADING = "Loading...";
|
||
|
const char* STR_BAD_FILE = "specified input file does not exist";
|
||
|
const char* STR_EMPTY_PWD = "password may not be empty";
|
||
|
|
||
|
static ImGuiInputTextFlags MULTILINE_TEXT_FLAGS =
|
||
|
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_ReadOnly;
|
||
| ... | ... | |
|
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data,
|
||
|
RobotoMedium_compressed_size,
|
||
|
28.0f);
|
||
|
ImFont* tinyfont = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data,
|
||
|
RobotoMedium_compressed_size,
|
||
|
12.0f);
|
||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||
| ... | ... | |
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||
|
ImGui::Begin("inner_window", nullptr,
|
||
|
ImGuiWindowFlags_NoDecoration |
|
||
|
ImGuiWindowFlags_MenuBar |
|
||
|
// ImGuiWindowFlags_MenuBar |
|
||
|
ImGuiWindowFlags_NoSavedSettings);
|
||
|
|
||
|
|
||
| ... | ... | |
|
//---Data loading screen----------------------------------------
|
||
|
ImGui::Text("Hello from the loading screen");
|
||
|
ImGui::InputText("Input file", filePathBuffer,
|
||
|
IM_ARRAYSIZE(filePathBuffer));
|
||
|
IM_ARRAYSIZE(filePathBuffer),
|
||
|
((argc > 1) ? ImGuiInputTextFlags_ReadOnly : ImGuiInputTextFlags_None));
|
||
|
|
||
|
// Set default focus on the password text box
|
||
|
// See: https://github.com/ocornut/imgui/issues/455
|
||
| ... | ... | |
|
|
||
|
if (ImGui::Button("Load"))
|
||
|
{
|
||
|
if (sfs::exists(filePathBuffer))
|
||
|
{
|
||
|
loading = true;
|
||
|
statusText = STR_LOADING;
|
||
|
}
|
||
|
else
|
||
|
if (! sfs::exists(filePathBuffer))
|
||
|
{
|
||
|
statusText = STR_BAD_FILE;
|
||
|
//TODO:
|
||
|
std::cerr << ERROR_MSG << "Input file: \""
|
||
|
<< filePathBuffer << "\" does not exist!"
|
||
|
<< std::endl;
|
||
|
}
|
||
|
else if (std::strlen(passwdBuffer) == 0)
|
||
|
{
|
||
|
statusText = STR_EMPTY_PWD;
|
||
|
std::cerr << ERROR_MSG << "Password must not be empty!"
|
||
|
<< std::endl;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
loading = true;
|
||
|
statusText = STR_LOADING;
|
||
|
}
|
||
|
}
|
||
|
ImGui::SameLine();
|
||
|
|
||
|
// Show status text
|
||
|
ImGui::Text("Status: %s", statusText);
|
||
|
|
||
|
if (loading)
|
||
|
{
|
||
|
|
||
|
|
||
|
// Load the catalog from the encrypted file
|
||
|
int rc = catalog.load(filePathBuffer,
|
||
|
passwdBuffer,
|
||
| ... | ... | |
|
else
|
||
|
{
|
||
|
//---[Menu bar]-----------------------------------------------------
|
||
|
if (ImGui::BeginMenuBar())
|
||
|
// NOTE: DBS -- 20251127
|
||
|
// I had a hell of a time getting the menubar so that its full height was shown.
|
||
|
// This approach using a child window with a specific height finally seems to
|
||
|
// work.
|
||
|
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
||
|
{
|
||
|
if (ImGui::BeginMenu("File"))
|
||
|
bool showAboutPopup = false;
|
||
|
|
||
|
// Get parent window width to make the menubar extend the full width
|
||
|
ImVec2 contentRegionAvailable = ImGui::GetContentRegionAvail();
|
||
|
float parentWidth = contentRegionAvailable.x;
|
||
|
|
||
|
ImGui::BeginChild("menu_pane", ImVec2(parentWidth, 46.0f),
|
||
|
ImGuiChildFlags_AutoResizeX |
|
||
|
ImGuiChildFlags_AutoResizeY |
|
||
|
ImGuiChildFlags_AlwaysAutoResize,
|
||
|
ImGuiWindowFlags_MenuBar);
|
||
|
|
||
|
if (ImGui::BeginMenuBar())
|
||
|
{
|
||
|
if (ImGui::MenuItem("Close", "Ctrl+W"))
|
||
|
if (ImGui::BeginMenu("File"))
|
||
|
{
|
||
|
if (ImGui::MenuItem("Close", "Ctrl+W"))
|
||
|
{
|
||
|
std::cerr << ERROR_MSG << "Closing it out"
|
||
|
<< std::endl;
|
||
|
done = true;
|
||
|
}
|
||
|
ImGui::EndMenu();
|
||
|
}
|
||
|
|
||
|
// Experimental.. maybe make this the "About" window?
|
||
|
if (ImGui::BeginMenu("Misc"))
|
||
|
{
|
||
|
std::cerr << ERROR_MSG << "Closing it out"
|
||
|
<< std::endl;
|
||
|
done = true;
|
||
|
if (ImGui::MenuItem("About", "Ctrl+M"))
|
||
|
{
|
||
|
// Set show popup flag here (see below)
|
||
|
showAboutPopup = true;
|
||
|
}
|
||
|
ImGui::EndMenu();
|
||
|
}
|
||
|
ImGui::EndMenu();
|
||
|
ImGui::EndMenuBar();
|
||
|
}
|
||
|
|
||
|
// Experimental.. maybe make this the "About" window?
|
||
|
if (ImGui::BeginMenu("Misc"))
|
||
|
// Extra logic needed to trigger about popup from menu item
|
||
|
if (showAboutPopup)
|
||
|
{
|
||
|
if (ImGui::MenuItem("About", "Ctrl+M"))
|
||
|
{ ;
|
||
|
}
|
||
|
ImGui::EndMenu();
|
||
|
ImGui::OpenPopup("about_popup");
|
||
|
showAboutPopup = false;
|
||
|
}
|
||
|
|
||
|
// About popup
|
||
|
if (ImGui::BeginPopup("about_popup"))
|
||
|
{
|
||
|
const uint32_t sepBufferSize(16);
|
||
|
char sepBuffer[sepBufferSize];
|
||
|
std::snprintf(sepBuffer, sepBufferSize, "About %s", APP_NAME.c_str());
|
||
|
ImGui::SeparatorText(sepBuffer);
|
||
|
ImGui::Text("%s version: %s", APP_NAME.c_str(),
|
||
|
VERSION.c_str());
|
||
|
ImGui::Text("Compiled on: %s ", __TIMESTAMP__);
|
||
|
ImGui::Text("Created by: dsorber");
|
||
|
ImGui::PushFont(tinyfont);
|
||
|
ImGui::Text("(click anywhere outside to close)");
|
||
|
ImGui::PopFont();
|
||
|
ImGui::EndPopup();
|
||
|
}
|
||
|
ImGui::EndMenuBar();
|
||
|
|
||
|
ImGui::EndChild();
|
||
|
}
|
||
|
|
||
|
//---[Left side]----------------------------------------------------
|
||
|
ImGui::SetNextWindowPos(ImVec2(0.0f, 46.0f));
|
||
|
static int selected = 0;
|
||
|
static bool firstTime = true;
|
||
|
{
|
||
|
ImGui::BeginChild("left_pane", ImVec2(150, 0),
|
||
|
ImGuiChildFlags_Borders |
|
||
| ... | ... | |
|
|
||
|
// Set default focus on the filter text box
|
||
|
// See: https://github.com/ocornut/imgui/issues/455
|
||
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||
|
if (/*ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||
|
!ImGui::IsAnyItemActive() &&
|
||
|
!ImGui::IsMouseClicked(0))
|
||
|
!ImGui::IsMouseClicked(0) && */
|
||
|
firstTime)
|
||
|
{
|
||
|
ImGui::SetKeyboardFocusHere(0);
|
||
|
firstTime = false;
|
||
|
}
|
||
|
|
||
|
ImGui::InputText("Filter", filterBuffer,
|
||
| ... | ... | |
|
}
|
||
|
ImGui::EndGroup();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
Add error message if password is not specified. Also finally fix menubar
issue by creating it in a child window. Bump version to 0.1.5.