Skip to content

Commit

Permalink
fix gtk include + some utf8 encoding in civitai
Browse files Browse the repository at this point in the history
  • Loading branch information
fszontagh committed Nov 7, 2024
1 parent 7bcc41c commit 3991eb8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "ui/MainWindowUI.h"
#include <csignal>
#include "ui/embedded_files/splash_image.h"
#include "wx/gtk/app.h"

// Define the MainApp
class MainApp : public wxApp {
Expand Down
18 changes: 10 additions & 8 deletions src/ui/MainWindowCivitAiWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "MainWindowCivitAiWindow.h"
#include "../helpers/simplecurl.h"
#include "ver.hpp"
#include "wx/string.h"

MainWindowCivitAiWindow::MainWindowCivitAiWindow(wxWindow* parent)
: CivitAiWindow(parent) {
Expand Down Expand Up @@ -208,7 +209,7 @@ void MainWindowCivitAiWindow::OnThreadMessage(wxThreadEvent& e) {
// add to the table
wxVector<wxVariant> data;

data.push_back(wxVariant(std::filesystem::path(item->local_file).filename().string()));
data.push_back(wxVariant(wxString::FromUTF8Unchecked(std::filesystem::path(item->local_file).filename().string())));
auto s = sd_gui_utils::humanReadableFileSize(item->targetSize);
data.push_back(wxString::Format("%.2f %s", s.first, s.second));
data.push_back(wxVariant(CivitAi::DownloadItemStateNames[item->state]));
Expand Down Expand Up @@ -340,7 +341,7 @@ void MainWindowCivitAiWindow::showImages(int version_id, bool from_thread) {
for (auto& bm : this->bitmaps) {
auto img = static_cast<CivitAi::PreviewImage*>(bm->GetClientData());
if (img->downloaded && std::filesystem::exists(img->localpath)) {
auto resized = sd_gui_utils::cropResizeImage(img->localpath, 200, 200, wxColour(0, 0, 0), this->config->thumbs_path);
auto resized = sd_gui_utils::cropResizeImage(wxString::FromUTF8Unchecked(img->localpath), 200, 200, wxColour(0, 0, 0), wxString::FromUTF8Unchecked(this->config->thumbs_path));
bm->SetBitmap(resized);
}
}
Expand All @@ -354,7 +355,7 @@ void MainWindowCivitAiWindow::showImages(int version_id, bool from_thread) {

for (auto& img : this->previewImages) {
if (img.second->downloaded && std::filesystem::exists(img.second->localpath)) {
auto resized = sd_gui_utils::cropResizeImage(img.second->localpath, 200, 200, wxColour(0, 0, 0), this->config->thumbs_path);
auto resized = sd_gui_utils::cropResizeImage(wxString::FromUTF8Unchecked(img.second->localpath), 200, 200, wxColour(0, 0, 0, 0), wxString::FromUTF8Unchecked(this->config->thumbs_path));
wxStaticBitmap* bitmap = new wxStaticBitmap(m_scrolledWindow4, wxID_ANY, resized, wxDefaultPosition, wxSize(200, 200), 0);
bitmap->SetClientData((void*)img.second);
image_container->Add(bitmap, 0, wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 1);
Expand Down Expand Up @@ -429,7 +430,7 @@ void MainWindowCivitAiWindow::populateVersions(nlohmann::json js) {

for (auto modelVersion : js["modelVersions"]) {
if (modelVersion.contains("name") && !modelVersion["name"].is_null()) {
data.push_back(modelVersion["name"].get<std::string>());
data.push_back(wxString::FromUTF8Unchecked(modelVersion["name"].get<std::string>()));
} else {
data.push_back("");
}
Expand Down Expand Up @@ -479,7 +480,7 @@ void MainWindowCivitAiWindow::populateVersions(nlohmann::json js) {
this->m_model_details->Refresh();

if (js.contains("description") && !js["description"].is_null()) {
this->m_model_description->SetPage(js["description"].get<std::string>());
this->m_model_description->SetPage(wxString::FromUTF8Unchecked(js["description"].get<std::string>()));
} else {
this->m_model_description->SetPage("");
}
Expand Down Expand Up @@ -648,7 +649,7 @@ void MainWindowCivitAiWindow::JsonToTable(std::string json_str) {
wxDataViewIconText icont;

if ((*it).contains("name") && !(*it).is_null()) {
data.push_back((*it)["name"].get<std::string>());
data.push_back(wxString::FromUTF8Unchecked((*it)["name"].get<std::string>()));
} else {
data.push_back(_("N/A"));
}
Expand Down Expand Up @@ -799,7 +800,8 @@ void MainWindowCivitAiWindow::SetModelManager(std::shared_ptr<ModelInfo::Manager

void MainWindowCivitAiWindow::populateFiles(nlohmann::json js) {
if (js.contains("description") && !js["description"].is_null()) {
this->m_model_version_description->SetPage(js["description"].get<std::string>());
std::string description = js["description"].get<std::string>();
this->m_model_version_description->SetPage(wxString::FromUTF8Unchecked(description));
} else {
this->m_model_version_description->SetPage("");
}
Expand All @@ -808,7 +810,7 @@ void MainWindowCivitAiWindow::populateFiles(nlohmann::json js) {
for (auto file : js["files"]) {
wxVector<wxVariant> data;
if (file.contains("name") && file["name"].is_string()) {
data.push_back(file["name"].get<std::string>());
data.push_back(wxString::FromUTF8Unchecked(file["name"].get<std::string>()));
} else {
data.push_back(_("N/A"));
}
Expand Down
19 changes: 9 additions & 10 deletions src/ui/MainWindowUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,25 +1477,25 @@ void MainWindowUI::OnPopupClick(wxCommandEvent& evt) {
this->ChangeGuiFromQueueItem(*qitem);
break;
case 3:
this->m_prompt->SetValue(qitem->params.prompt);
this->m_neg_prompt->SetValue(qitem->params.negative_prompt);
this->m_prompt->SetValue(wxString::FromUTF8Unchecked(qitem->params.prompt));
this->m_neg_prompt->SetValue(wxString::FromUTF8Unchecked(qitem->params.negative_prompt));
break;
case 4:
this->m_prompt2->SetValue(qitem->params.prompt);
this->m_neg_prompt2->SetValue(qitem->params.negative_prompt);
this->m_prompt2->SetValue(wxString::FromUTF8Unchecked(qitem->params.prompt));
this->m_neg_prompt2->SetValue(wxString::FromUTF8Unchecked(qitem->params.negative_prompt));
break;
case 5: {
auto model = this->ModelManager->getInfo(qitem->params.model_path);
this->ChangeModelByInfo(model);
} break;
case 6: {
this->m_upscaler_filepicker->SetPath(qitem->images.back().pathname);
this->onUpscaleImageOpen(qitem->images.back().pathname);
this->m_upscaler_filepicker->SetPath(wxString::FromUTF8Unchecked(qitem->images.back().pathname));
this->onUpscaleImageOpen(wxString::FromUTF8Unchecked(qitem->images.back().pathname));
this->m_notebook1302->SetSelection(3); // switch to the upscaler
} break;
case 7: {
this->m_img2imgOpen->SetPath(qitem->images.back().pathname);
this->onimg2ImgImageOpen(qitem->images.back().pathname);
this->m_img2imgOpen->SetPath(wxString::FromUTF8Unchecked(qitem->images.back().pathname));
this->onimg2ImgImageOpen(wxString::FromUTF8Unchecked(qitem->images.back().pathname));
this->m_notebook1302->SetSelection(2); // switch to the img2img
} break;
case 8: {
Expand Down Expand Up @@ -2980,8 +2980,7 @@ void MainWindowUI::UpdateJobInfoDetailsFromJobQueueList(std::shared_ptr<QM::Queu
wxLaunchDefaultApplication(wxString::FromUTF8Unchecked(img.pathname));
} break;
case 7: {
std::string parent = std::filesystem::path(img.pathname).parent_path().string();
wxLaunchDefaultApplication(wxString::FromUTF8Unchecked(parent));
wxLaunchDefaultApplication(wxString::FromUTF8Unchecked(std::filesystem::path(img.pathname).parent_path().string()));
} break;
default: {
return;
Expand Down

0 comments on commit 3991eb8

Please sign in to comment.