kylin-printer/common/common.h

68 lines
1.5 KiB
C++

#ifndef KYLIN_PRINTER_COMMON_H
#define KYLIN_PRINTER_COMMON_H
#include <QString>
#include <QStringList>
#include <QMap>
#include <map>
#define QTC(x) (qstringTochar(x))
enum CheckRes{
CHECK_FALSE = 0,
MAINWINDOW,
POPWINDOW,
DEBUG,
};
enum class PopWinStatus : int
{
HIDE = 0,
INSTALLING,
INSTALL_SUCCESS,
INSTALL_FAIL,
};
CheckRes checkCommand(const QStringList &command);
QString getRetFromCommand(const QStringList &command);
void runCommand(const QStringList &command);
const char *qstringTochar(const QString &qstr);
QString getUserName();
bool isAdministratorUser();
const QMap<QString, QString> mfgConvertMap = {
std::map<QString, QString>::value_type("Lenovo Image", "Lenovo"),
std::map<QString, QString>::value_type("Fuji Xerox", "Fuji-Xerox"),
std::map<QString, QString>::value_type("INDEX BRAILLE", "INDEX-BRAILLE"),
std::map<QString, QString>::value_type("KONICA MINOLTA", "KONICA-MINOLTA"),
std::map<QString, QString>::value_type("Hewlett-Packard", "HP")
};
void specialDeviceCheck(QString &vendor, QString &model);
extern QString devicePathCheck(const QString &path);
extern bool ipIsValid(const QString &ipAddr);
extern bool printerNameIsLegal(const QString &printerName);
enum class CommonStatusFlag : int
{
NONE = 0,
SUCCESS,
FAIL,
ERROR_EXIST_SAME_PRINTER,
};
struct CommonStatus {
CommonStatusFlag status{CommonStatusFlag::NONE};
QString message{QString()};
};
#endif // KYLIN_PRINTER_COMMON_H