You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Kernel/FITKAppFramework/FITKAbstractMainWinGenerato...

77 lines
1.9 KiB
C++

#include "FITKAbstractMainWinGenerator.h"
#include <QFile>
#include <QApplication>
#include <QTranslator>
#include <QDebug>
namespace AppFrame
{
bool FITKAbstractMainwindowGenerator::loadQssStyle()
{
//打开qss文件
QString styleFile = this->getQssStyle();
if (styleFile.isEmpty()) return false;
QFile qssFile(styleFile);
if (!qssFile.open(QFile::ReadOnly)) return false;
//读取qss
const QString q = qssFile.readAll();
qssFile.close();
//加载qss
qApp->setStyleSheet(q);
return true;
}
bool FITKAbstractMainwindowGenerator::loadTranslatorQmFiles()
{
//获取全部翻译文件
QStringList qmFiles = this->getTranslatorQmFiles();
for (QString qmfile : qmFiles)
{
//遍历加载翻译文件
if(qmfile.isEmpty()) continue;
QTranslator* translator = new QTranslator(this);
bool ok = translator->load(qmfile);
//加载失败则报错释放translator
if (!ok)
{
qDebug() << QString("Failed to load lang file: %1").arg(qmfile);
delete translator;
continue;
}
//加载翻译
qApp->installTranslator(translator);
}
return true;
}
QWidget* FITKAbstractMainwindowGenerator::genMainWindow()
{
//虚函数错误值
return nullptr;
}
void FITKAbstractMainwindowGenerator::showMaximize(bool max)
{
//最大化
_showMaximize = max;
}
bool FITKAbstractMainwindowGenerator::showMaximize()
{
return _showMaximize;
}
QString FITKAbstractMainwindowGenerator::getQssStyle()
{
return QString();
}
QStringList FITKAbstractMainwindowGenerator::getTranslatorQmFiles()
{
return QStringList();
}
}