fixed:#I5XHG7【计算器】【平板模式】未全屏化

This commit is contained in:
lidecheng 2023-09-05 13:48:58 +08:00
parent 09957371f0
commit 5ded44706b
6 changed files with 160 additions and 49 deletions

View File

@ -37,7 +37,6 @@ void DataWarehouse::init(void)
void DataWarehouse::getPlatForm(void)
{
this->platform = "xc-tablet";
return;
char *projectName = kdk_system_get_projectName();
if (projectName == NULL) {

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
kylin-calculator (1.2.0.0-ok3) yangtze; urgency=medium
* BUG号#I5XHG7 【计算器】【平板模式】未全屏化
* 任务号:无
* 其他更改说明:无
* 其他改动影响域:无
-- lidecheng <lidecheng@kylinos.cn> Tue, 05 Sep 2023 13:43:48 +0800
kylin-calculator (1.2.0.0-ok2) v101; urgency=medium
* BUG号

View File

@ -42,6 +42,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
/* 设置组件样式 */
setWidgetStyle();
//监听平板模式切换
m_statusSessionDbus = new QDBusInterface("com.kylin.statusmanager.interface",
"/",
"com.kylin.statusmanager.interface",
QDBusConnection::sessionBus(),
this);
if (m_statusSessionDbus->isValid()) {
QDBusReply<bool> isTabletMode = m_statusSessionDbus->call("get_current_tabletmode");
this->setIsTabletMode(isTabletMode);
tabletModeChange(isTabletMode);
connect(m_statusSessionDbus, SIGNAL(mode_change_signal(bool)), this, SLOT(tabletModeChange(bool)));
} else {
tabletModeChange(false);
}
/* 初始化横竖屏的初值start */
hLayoutFlag = PCMode;
if (DataWarehouse::getInstance()->platform == QString("intel")) {
@ -216,8 +231,6 @@ void MainWindow::setWidgetUi()
mainLayout->setSpacing(0);
this->mainWid->setLayout(mainLayout);
this->resize(STANDARD_WINDOWW, STANDARD_WINDOWH);
return;
}
@ -269,25 +282,81 @@ void MainWindow::setCommonUi()
return;
}
/* 设置UI界面大小 */
void MainWindow::setWindowSize() {
QString currentPlatform = DataWarehouse::getInstance()->platform;
QString label = this->currentModel;
// 根据当前模式获得显示UI的界面size值
int currentWindowW = 0;
int currentWindowH = 0;
if (label == PROGRAMMER) {
if (!m_prograModel->isBinWinShow()) {
currentWindowW = PROGRAM_WIN_WIDTH;
currentWindowH = PROGRAM_WIN_HEIGHT;
} else {
currentWindowW = PROGRAM_WIN_WIDTH;
currentWindowH = PROGRAM_WIN_HEIGHT + PROGRAM_BIN_HEIGHT;
}
} else if (label == SCIENTIFIC) {
if (currentPlatform == QString("intel")) {
currentWindowW = INTEL_SCIENTIFIC_WINDOWW;
currentWindowH = INTEL_SCIENTIFIC_WINDOWH;
}
else {
currentWindowW = SCIENTIFIC_WINDOWW;
currentWindowH = SCIENTIFIC_WINDOWH;
}
} else if (label == STANDARD) {
if (currentPlatform == QString("intel")) {
currentWindowW = INTEL_STANDARD_WINDOWW;
currentWindowH = INTEL_STANDARD_WINDOWH;
}
else {
currentWindowW = STANDARD_WINDOWW;
currentWindowH = STANDARD_WINDOWH;
}
} else {
currentWindowW = STANDARD_WINDOWW;
currentWindowH = STANDARD_WINDOWH;
}
// 根据当前系统平台设置对应UI界面的size
if (currentPlatform == QString("intel")) {
if (!this->isTabletMode() && this->windowState() == Qt::WindowNoState) {
this->setMinimumSize(INTEL_STANDARD_WINDOWW, INTEL_STANDARD_WINDOWH);
this->resize(INTEL_STANDARD_WINDOWW, INTEL_STANDARD_WINDOWH);
}
} else if (currentPlatform == QString("xc-tablet")) {
/* xc 平板平台 */
if(this->isTabletMode()){ //平板模式下界面大小直接设置为最大值
this->setMinimumSize(1, 1);
this->setMaximumSize(99999, 99999);
setWindowState(windowState() | Qt::WindowMaximized);
} else { //PC 模式下界面设置为对应模式固定值
setWindowState(windowState() & ~Qt::WindowMaximized);
this->setFixedSize(currentWindowW, currentWindowH);
// this->resize(currentWindowW, currentWindowH);
}
} else {
this->setFixedSize(currentWindowW, currentWindowH);
// this->resize(currentWindowW, currentWindowH);
}
}
/* 标准计算界面布局 */
void MainWindow::setStandardUi()
{
m_hisNumMax = PC_HIS_NUM;
if (DataWarehouse::getInstance()->platform == QString("intel")) {
if (hLayoutFlag == deviceMode::PCMode && this->windowState() == Qt::WindowNoState) {
this->setMinimumSize(INTEL_STANDARD_WINDOWW, INTEL_STANDARD_WINDOWH);
this->resize(INTEL_STANDARD_WINDOWW, INTEL_STANDARD_WINDOWH);
}
} else if (DataWarehouse::getInstance()->platform == QString("xc-tablet")) {
/* xc 平板 */
this->setMinimumSize(STANDARD_WINDOWW, STANDARD_WINDOWH);
} else {
this->setFixedSize(STANDARD_WINDOWW, STANDARD_WINDOWH);
}
/* 设置当前模式 */
this->currentModel = STANDARD;
/* 设置当前界面大小*/
this->setWindowSize();
if (standardOutput == nullptr) {
standardOutput = new StandardOutput(this);
standardModel = new StandardModel(this);
@ -348,20 +417,13 @@ void MainWindow::setStandardUi()
void MainWindow::setScientificUi()
{
m_hisNumMax = PC_HIS_NUM;
if (DataWarehouse::getInstance()->platform == QString("intel")) {
if (hLayoutFlag == deviceMode::PCMode && this->windowState() == Qt::WindowNoState) {
this->setMinimumSize(INTEL_SCIENTIFIC_WINDOWW, INTEL_SCIENTIFIC_WINDOWH);
this->resize(INTEL_SCIENTIFIC_WINDOWW, INTEL_SCIENTIFIC_WINDOWH);
}
} else if (DataWarehouse::getInstance()->platform == QString("xc-tablet")) {
this->setMinimumSize(SCIENTIFIC_WINDOWW, SCIENTIFIC_WINDOWH);
} else {
this->setFixedSize(SCIENTIFIC_WINDOWW, SCIENTIFIC_WINDOWH);
}
/* 设置当前模式 */
this->currentModel = SCIENTIFIC;
/* 设置当前界面大小*/
this->setWindowSize();
/* 初始化界面布局 */
if (scientificOutput == nullptr) {
scientificOutput = new ScientificOutput(this);
@ -445,17 +507,13 @@ void MainWindow::setScientificUi()
void MainWindow::setToolUi()
{
qInfo() << "Switch to exchange rate mode.";
/* 固定窗口大小 */
if (DataWarehouse::getInstance()->platform == QString("xc-tablet")) {
/* xc 平板 */
this->setMinimumSize(STANDARD_WINDOWW, STANDARD_WINDOWH);
} else {
this->setFixedSize(STANDARD_WINDOWW, STANDARD_WINDOWH);
}
// 设置当前模式
this->currentModel = EXCHANGE_RATE;
/* 设置当前界面大小*/
this->setWindowSize();
// 初始化数据输出界面
if (toolModelOutput == nullptr) {
toolModelOutput = new ToolModelOutput(this);
@ -499,6 +557,7 @@ void MainWindow::setToolUi()
return;
}
/* 程序员模式界面布局 */
void MainWindow::setProgrammerUi()
{
qInfo() << "Switch to programmer mode.";
@ -514,20 +573,8 @@ void MainWindow::setProgrammerUi()
&MainWindow::myCustomContextMenuRequested);
}
/* xc 平板 */
if (DataWarehouse::getInstance()->platform == QString("xc-tablet")) {
if (!m_prograModel->isBinWinShow()) {
this->setMinimumSize(QSize(PROGRAM_WIN_WIDTH, PROGRAM_WIN_HEIGHT));
} else {
this->setMinimumSize(QSize(PROGRAM_WIN_WIDTH, PROGRAM_WIN_HEIGHT + PROGRAM_BIN_HEIGHT));
}
} else {
if (!m_prograModel->isBinWinShow()) {
this->setFixedSize(QSize(PROGRAM_WIN_WIDTH, PROGRAM_WIN_HEIGHT));
} else {
this->setFixedSize(QSize(PROGRAM_WIN_WIDTH, PROGRAM_WIN_HEIGHT + PROGRAM_BIN_HEIGHT));
}
}
/* 设置当前界面大小*/
this->setWindowSize();
if (WidgetStyle::ThemeColor::LIGHT == WidgetStyle::themeColor) {
m_prograModel->setLightUI();
@ -643,6 +690,7 @@ QString MainWindow::addComma(QString s)
return s;
}
}
// 换算器输入响应事件
void MainWindow::unitCalc()
{
@ -1324,6 +1372,23 @@ void MainWindow::unitConversion()
this->lab_prepare->setText(addComma(lab_prepare->text()));
}
/* 设置是否平板模式*/
void MainWindow::setIsTabletMode(bool is) {
m_isTabletMode = is;
}
/* 是否平板模式 */
bool MainWindow::isTabletMode() {
return m_isTabletMode;
}
/* 平板模式切换 */
void MainWindow::tabletModeChange(bool isTabletMode)
{
this->setIsTabletMode(isTabletMode);
this->setWindowSize();
}
/* 鼠标移动事件 , 用于点击主界面时来隐藏模式切换列表 */
void MainWindow::mousePressEvent(QMouseEvent *event)
{
@ -1417,4 +1482,4 @@ void MainWindow::setIntelModeChange(deviceMode mode)
}
}
}
}
}

View File

@ -128,6 +128,14 @@ public:
void initGsetting(void);
QDBusInterface *m_intelModeDbus = nullptr;
/* 设置是否平板模式 */
void setIsTabletMode(bool isTabletMode);
/* 是否平板模式 */
bool isTabletMode();
/* 设置当前界面的大小*/
void setWindowSize();
public slots:
// 键盘响应事件
@ -171,6 +179,9 @@ public slots:
/* 平板中的自动屏幕旋转on/off */
void slotIntelModeChanged(bool);
/* 平板模式切换 */
void tabletModeChange(bool isTabletMode);
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
@ -180,6 +191,11 @@ private:
void setIntelModeChange(deviceMode mode);
quint32 m_winId = 0;
// 监控是否平板的dbus接口
QDBusInterface * m_statusSessionDbus = nullptr;
// 是否平板模式
bool m_isTabletMode = false;
//平板中的横竖屏切换部分
deviceMode hLayoutFlag = PCMode; //默认横屏

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <QProcess>
#include <QTime>
#include <usermanual.h>
@ -36,7 +37,7 @@ void menuModule::initAction()
{
iconSize = QSize(30, 30);
menuButton = new QToolButton(this);
menuButton->setToolTip(tr("Menu"));
menuButton->setToolTip(tr("Options"));
menuButton->setProperty("isWindowButton", 0x1);
menuButton->setProperty("useIconHighlightEffect", 0x2);
menuButton->setPopupMode(QToolButton::InstantPopup);
@ -100,7 +101,7 @@ void menuModule::triggerMenu(QAction *act)
void menuModule::aboutAction()
{
m_aboutWindow = new kdk::KAboutDialog(this, QIcon::fromTheme("kylin-calculator"), QString(tr("Calculator")),
tr("Version: ") + qApp->applicationVersion());
tr("Version: ") + getVersion());
m_aboutWindow->setAttribute(Qt::WA_DeleteOnClose);
m_aboutWindow->setBodyText(
tr("Calculator is a lightweight calculator based on Qt5, which provides standard calculation, "
@ -124,6 +125,26 @@ void menuModule::helpAction()
}
}
QString menuModule::getVersion()
{
QString version;
QString command = "dpkg -l kylin-calculator | grep kylin-calculator";
QProcess process;
QStringList args;
args << "-c" << command;
process.start("bash", args);
process.waitForFinished();
process.waitForReadyRead();
version = process.readAll();
QStringList fields = version.split(QRegularExpression("[ \t]+"));
if (fields.size() >= 3)
version = fields.at(2);
else
version = "none";
return version;
}
void menuModule::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_F1) {
@ -131,4 +152,4 @@ void menuModule::keyPressEvent(QKeyEvent *event)
} else {
QWidget::keyPressEvent(event);
}
}
}

View File

@ -66,6 +66,7 @@ private:
void triggerMenu(QAction *act); //主菜单动作4
void aboutAction();
void helpAction();
QString getVersion();
};
#endif // MENUMODULE_H