Files
branch_switcher/src/main.cpp
daiqingshuang fc9c8dbb44 多线程
2025-05-27 16:03:26 +08:00

59 lines
1.4 KiB
C++

#include <wx/wx.h>
#include "git_repository.h"
#include "config_manager.h"
#include "main_frame.h"
#include "git_command.h"
#include "task_manager.h"
class GitBranchApp : public wxApp {
public:
bool OnInit() override {
// 加载配置
auto& config = ConfigManager::Instance();
if (!config.Load()) {
// 配置不存在或无效,初始化新配置
if (!InitializeConfig()) {
return false;
}
}
// 创建并显示主窗口
auto* frame = new MainFrame("Git Branch Manager");
frame->Show(true);
return true;
}
int OnExit() override {
// 保存配置
ConfigManager::Instance().Save();
return 0;
}
private:
bool InitializeConfig() {
// 显示目录选择对话框
wxDirDialog dialog(nullptr, "Select Git Repository", "",
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (dialog.ShowModal() != wxID_OK) {
return false;
}
std::string path = dialog.GetPath().ToStdString();
if (!IsGitRepository(path)) {
wxMessageBox("Please select a valid Git repository", "Error", wxICON_ERROR);
return false;
}
auto& config = ConfigManager::Instance();
config.SetRepositoryPath(path);
config.Save();
return true;
}
};
wxIMPLEMENT_APP(GitBranchApp);