49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "public_def.h"
|
|
#include <QMessageBox>
|
|
#include <QFileDialog>
|
|
|
|
std::vector<std::string> splitString(const std::string& input, const std::string& delimiter)
|
|
{
|
|
std::vector<std::string> tokens;
|
|
size_t pos = 0;
|
|
std::string backup = input;
|
|
std::string token;
|
|
|
|
while ((pos = backup.find(delimiter)) != std::string::npos) {
|
|
token = backup.substr(0, pos);
|
|
tokens.push_back(token);
|
|
backup.erase(0, pos + delimiter.length());
|
|
}
|
|
// Push the remaining part after the last delimiter
|
|
tokens.push_back(backup);
|
|
|
|
return tokens;
|
|
}
|
|
|
|
void CUtil::msg(QWidget* parent, const QString& content)
|
|
{
|
|
QMessageBox::information(parent, u8"提示", content);
|
|
}
|
|
|
|
bool CUtil::affirm(QWidget* parent, const QString& titile, const QString& content)
|
|
{
|
|
QMessageBox questionBox(parent);
|
|
questionBox.setText(content);
|
|
questionBox.setWindowTitle(titile);
|
|
questionBox.setIcon(QMessageBox::Question);
|
|
questionBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
int result = questionBox.exec();
|
|
if (result != QMessageBox::Yes) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
QString CUtil::select_file(QWidget* parent, const QString& info, const QString& filter)
|
|
{
|
|
QString filePath =
|
|
QFileDialog::getOpenFileName(parent, info, QDir::homePath(), filter);
|
|
return filePath;
|
|
}
|