16551需求:优化
This commit is contained in:
parent
6d7a534c09
commit
faf1c699c4
|
@ -28,9 +28,9 @@
|
|||
|
||||
const QPixmap ImageUtil::loadTheme(const QString &theme, const QString &defaultTheme, const QString& color, int size)
|
||||
{
|
||||
int origSize = size;
|
||||
// int origSize = size;
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
size = origSize * ratio;
|
||||
// size = origSize * ratio;
|
||||
|
||||
QIcon icon = QIcon::fromTheme(theme, QIcon(defaultTheme));
|
||||
QPixmap pixmap = icon.pixmap(icon.actualSize(QSize(size, size)));
|
||||
|
@ -40,11 +40,11 @@ const QPixmap ImageUtil::loadTheme(const QString &theme, const QString &defaultT
|
|||
|
||||
const QPixmap ImageUtil::loadTheme(const QString &theme, const QString &defaultTheme, const QString& color, QSize size)
|
||||
{
|
||||
int origWidth = size.width();
|
||||
int origHeight = size.height();
|
||||
// int origWidth = size.width();
|
||||
// int origHeight = size.height();
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
size.setWidth(origWidth * ratio);
|
||||
size.setHeight(origHeight * ratio);
|
||||
// size.setWidth(origWidth * ratio);
|
||||
// size.setHeight(origHeight * ratio);
|
||||
|
||||
QIcon icon = QIcon::fromTheme(theme, QIcon(defaultTheme));
|
||||
QPixmap pixmap = icon.pixmap(icon.actualSize(size));
|
||||
|
|
|
@ -71,6 +71,7 @@ void LeftsiderbarWidget::initUi()
|
|||
m_idxToFunctype.clear();
|
||||
int index = 0;
|
||||
m_navigationBar = new KNavigationBar(this);
|
||||
m_navigationBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
FuncTypeConverter kvConverter;
|
||||
for (int type = 0; type < funcNum; ++type) {
|
||||
QString mnameString = kvConverter.keycodeTokeystring(type); //设置TEXT
|
||||
|
|
|
@ -121,6 +121,8 @@ void MainDialog::initUI()
|
|||
initTileBar();
|
||||
}
|
||||
|
||||
#define PC_TITLE_BAR_SIZE 30
|
||||
#define TABLET_TITLE_BAR_SIZE 48
|
||||
void MainDialog::initTileBar()
|
||||
{
|
||||
m_titleLayout = new QHBoxLayout;
|
||||
|
@ -140,25 +142,25 @@ void MainDialog::initTileBar()
|
|||
m_menuOptionBtn->setProperty("isWindowButton", 0x1);
|
||||
m_menuOptionBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_menuOptionBtn->setIcon(QIcon::fromTheme("open-menu-symbolic"));
|
||||
m_menuOptionBtn->setFixedSize(30, 30);
|
||||
m_menuOptionBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_menuOptionBtn->setAutoRaise(true);
|
||||
m_menuOptionBtn->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
m_minBtn->setProperty("isWindowButton", 0x1);
|
||||
m_minBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_minBtn->setFixedSize(30, 30);
|
||||
m_minBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_minBtn->setFlat(true);
|
||||
m_minBtn->setIcon(QIcon::fromTheme("window-minimize-symbolic"));
|
||||
|
||||
m_maxBtn->setProperty("isWindowButton", 0x1);
|
||||
m_maxBtn->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_maxBtn->setFixedSize(30, 30);
|
||||
m_maxBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_maxBtn->setFlat(true);
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
|
||||
m_closeBtn->setProperty("isWindowButton", 0x2);
|
||||
m_closeBtn->setProperty("useIconHighlightEffect", 0x8);
|
||||
m_closeBtn->setFixedSize(30, 30);
|
||||
m_closeBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_closeBtn->setFlat(true);
|
||||
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
||||
|
||||
|
@ -223,19 +225,14 @@ void MainDialog::initConnect()
|
|||
connect(m_maxBtn, &QPushButton::clicked, this, [=] {
|
||||
if (isMaximized()) {
|
||||
showNormal();
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Maximize"));
|
||||
} else {
|
||||
showMaximized();
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Normal"));
|
||||
}
|
||||
});
|
||||
|
||||
//关闭按钮
|
||||
connect(m_closeBtn, &QPushButton::clicked, this, &MainDialog::closeBtn);
|
||||
|
||||
if (Utils::isTablet()) {
|
||||
//监听平板模式切换
|
||||
m_statusSessionDbus = new QDBusInterface("com.kylin.statusmanager.interface",
|
||||
"/",
|
||||
|
@ -245,21 +242,11 @@ void MainDialog::initConnect()
|
|||
if (m_statusSessionDbus->isValid()) {
|
||||
QDBusReply<bool> is_tabletmode = m_statusSessionDbus->call("get_current_tabletmode");
|
||||
GlobelBackupInfo::inst().setIsTabletMode(is_tabletmode);
|
||||
if (is_tabletmode) {
|
||||
if (!isMinimized())
|
||||
showMaximized();
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Normal"));
|
||||
m_maxBtn->setVisible(false);
|
||||
} else {
|
||||
m_maxBtn->setVisible(true);
|
||||
}
|
||||
tabletModeChange(is_tabletmode);
|
||||
connect(m_statusSessionDbus, SIGNAL(mode_change_signal(bool)), this, SLOT(tabletModeChange(bool)));
|
||||
} else {
|
||||
GlobelBackupInfo::inst().setIsTabletMode(false);
|
||||
m_maxBtn->setVisible(true);
|
||||
|
||||
qDebug() << "Create statusmanager Interface Failed When : " << QDBusConnection::systemBus().lastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,12 +258,18 @@ void MainDialog::tabletModeChange(bool isTabletMode)
|
|||
{
|
||||
GlobelBackupInfo::inst().setIsTabletMode(isTabletMode);
|
||||
if(isTabletMode){
|
||||
if (!isMinimized())
|
||||
showMaximized();
|
||||
m_menuOptionBtn->setFixedSize(TABLET_TITLE_BAR_SIZE, TABLET_TITLE_BAR_SIZE);
|
||||
m_minBtn->setFixedSize(TABLET_TITLE_BAR_SIZE, TABLET_TITLE_BAR_SIZE);
|
||||
m_maxBtn->setFixedSize(TABLET_TITLE_BAR_SIZE, TABLET_TITLE_BAR_SIZE);
|
||||
m_closeBtn->setFixedSize(TABLET_TITLE_BAR_SIZE, TABLET_TITLE_BAR_SIZE);
|
||||
m_titleWidget->setFixedHeight(50);
|
||||
m_maxBtn->setVisible(false);
|
||||
} else {
|
||||
if (!isMinimized())
|
||||
showNormal();
|
||||
m_menuOptionBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_minBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_maxBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_closeBtn->setFixedSize(PC_TITLE_BAR_SIZE, PC_TITLE_BAR_SIZE);
|
||||
m_titleWidget->setFixedHeight(40);
|
||||
m_maxBtn->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -284,14 +277,21 @@ void MainDialog::tabletModeChange(bool isTabletMode)
|
|||
void MainDialog::changeEvent(QEvent *event)
|
||||
{
|
||||
if (QEvent::WindowStateChange == event->type()) {
|
||||
// 如果是平板模式
|
||||
if (GlobelBackupInfo::inst().isTabletMode()) {
|
||||
Qt::WindowStates state = this->windowState();
|
||||
if (state == Qt::WindowMaximized) {
|
||||
event->accept();
|
||||
showMaximized();
|
||||
return ;
|
||||
}
|
||||
switch (state) {
|
||||
case Qt::WindowMaximized:
|
||||
case Qt::WindowFullScreen:
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Normal"));
|
||||
|
||||
break;
|
||||
case Qt::WindowNoState:
|
||||
m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
|
||||
m_maxBtn->setToolTip(tr("Maximize"));
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue