Files
OrcaSlicer/src/slic3r/GUI/OAuthDialog.cpp
T
HanifKoh 1a5f91d727 Add Missing Includes Across src/slic3r/GUI (#16048)
* Add Missing Includes Across src/slic3r/GUI

Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained.

* Drop the OS-Specific Includes Added Outside Their Platform Guards

GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build.

* Add the clang-tidy Configuration That Generated These Includes

Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly.

* Match Windows Paths in the clang-tidy Ignore List

Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
2026-10-02 14:56:56 +08:00

94 lines
2.6 KiB
C++

#include "OAuthDialog.hpp"
#include "GUI_App.hpp"
#include "Jobs/BoostThreadWorker.hpp"
#include "Jobs/PlaterWorker.hpp"
#include "wxExtensions.hpp"
#include "Widgets/DialogButtons.hpp"
#include "slic3r/GUI/Jobs/OAuthJob.hpp"
#include "slic3r/GUI/GUI_Utils.hpp"
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/dialog.h>
#include <memory>
#include <wx/sizer.h>
#include "slic3r/GUI/Jobs/Worker.hpp"
#include <utility>
#include <wx/utils.h>
namespace Slic3r {
namespace GUI {
#define BORDER_W FromDIP(10)
OAuthDialog::OAuthDialog(wxWindow* parent, OAuthParams params)
: DPIDialog(parent, wxID_ANY, _L("Login"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE)
, _params(params)
{
SetFont(wxGetApp().normal_font());
SetBackgroundColour(*wxWHITE);
m_worker = std::make_unique<PlaterWorker<BoostThreadWorker>>(this, nullptr, "auth_worker");
auto dlg_btns = new DialogButtons(this, {"Cancel"});
dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, &OAuthDialog::on_cancel, this);
const auto message_sizer = new wxBoxSizer(wxVERTICAL);
const auto message = new wxStaticText(this, wxID_ANY, _L("Authorizing..."), wxDefaultPosition, wxDefaultSize, 0);
message->SetForegroundColour(*wxBLACK);
message_sizer->Add(message, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, BORDER_W);
const auto topSizer = new wxBoxSizer(wxVERTICAL);
topSizer->Add(message_sizer, 0, wxEXPAND | wxALL, BORDER_W);
topSizer->Add(dlg_btns, 0, wxEXPAND);
Bind(wxEVT_CLOSE_WINDOW, &OAuthDialog::on_cancel, this);
SetSizer(topSizer);
topSizer->SetSizeHints(this);
this->CenterOnParent();
wxGetApp().UpdateDlgDarkUI(this);
}
void OAuthDialog::on_cancel(wxEvent& event)
{
m_worker->cancel_all();
m_worker->wait_for_idle();
EndModal(wxID_NO);
}
bool OAuthDialog::Show(bool show)
{
if (show) {
// Prepare login job
_result = std::make_shared<OAuthResult>();
auto job = std::make_unique<OAuthJob>(OAuthData{_params, _result});
job->set_event_handle(this);
Bind(EVT_OAUTH_COMPLETE_MESSAGE, [this](wxCommandEvent& evt) { EndModal(wxID_NO); });
// Start auth job
replace_job(*m_worker, std::move(job));
// Open login URL in external browser
wxLaunchDefaultBrowser(_params.login_url);
}
return DPIDialog::Show(show);
}
void OAuthDialog::on_dpi_changed(const wxRect& suggested_rect)
{
const int& em = em_unit();
msw_buttons_rescale(this, em, {wxID_CANCEL});
const wxSize& size = wxSize(45 * em, 35 * em);
SetMinSize(size);
Fit();
Refresh();
}
}}