修改全屏窗口导航定位位置

This commit is contained in:
lixueman 2022-09-16 17:34:46 +08:00
parent 5f26786e33
commit c7a716aeac
7 changed files with 61 additions and 38 deletions

View File

@ -314,13 +314,13 @@ void TabletListView::mousePressEvent(QMouseEvent *event)
if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && (((pressedpos.x() % Style::TabletItemSizeWidthFirst) >= Style::FirstPageSpace) &&
((pressedpos.x() % Style::TabletItemSizeWidthFirst) <= (Style::FirstPageSpace + Style::AppListIconSize)) &&
((pressedpos.y() % Style::AppListItemSizeHeight) >= Style::AppTopSpace) &&
((pressedpos.y() % Style::AppListItemSizeHeight) <= (Style::AppTopSpace + Style::AppListIconSize)))) ||
((pressedpos.y() % Style::AppListItemSizeHeight) >= Style::m_appTopSpace) &&
((pressedpos.y() % Style::AppListItemSizeHeight) <= (Style::m_appTopSpace + Style::AppListIconSize)))) ||
((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) &&
(pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace &&
pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize &&
pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) {
pressedpos.y() % Style::AppListItemSizeHeight >= Style::m_appTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::m_appTopSpace + Style::AppListIconSize))) {
pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole);
iconClick = true;
startPos = event->pos();
@ -339,13 +339,13 @@ void TabletListView::mousePressEvent(QMouseEvent *event)
if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && ((pressedpos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace &&
(pressedpos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize &&
pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) ||
pressedpos.y() % Style::AppListItemSizeHeight >= Style::m_appTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::m_appTopSpace + Style::AppListIconSize)) ||
((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) &&
(pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace &&
pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize &&
pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) {
pressedpos.y() % Style::AppListItemSizeHeight >= Style::m_appTopSpace &&
pressedpos.y() % Style::AppListItemSizeHeight <= Style::m_appTopSpace + Style::AppListIconSize))) {
pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole);
right_iconClick = true;
right_pressedpos = pressedpos;
@ -626,13 +626,13 @@ void TabletListView::insertApplication(QPoint pressedpos, QPoint releasepos)
if (((this->indexAt(releasepos).isValid()) && (m_pageNum == FIRSTPAGE) && ((releasepos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace &&
(releasepos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize &&
releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace &&
releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) ||
releasepos.y() % Style::AppListItemSizeHeight >= Style::m_appTopSpace &&
releasepos.y() % Style::AppListItemSizeHeight <= Style::m_appTopSpace + Style::AppListIconSize)) ||
((this->indexAt(releasepos).isValid()) && (m_pageNum == OTHERPAGE) &&
(releasepos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace &&
releasepos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize &&
releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace &&
releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) {
releasepos.y() % Style::AppListItemSizeHeight >= Style::m_appTopSpace &&
releasepos.y() % Style::AppListItemSizeHeight <= Style::m_appTopSpace + Style::AppListIconSize))) {
return;
}

View File

@ -122,7 +122,7 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QRect iconRect;
QRect textRect;
iconRect = QRect(rect.x() + (rect.width() - Style::AppListIconSize) / 2,
rect.y() + 20,
rect.y() + Style::m_appTopSpace,
Style::AppListIconSize,
Style::AppListIconSize);
icon.paint(painter, iconRect);
@ -145,7 +145,7 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
textRect = QRect(rect.x() + 5,
iconRect.bottom() + Style::AppSpaceBetweenIconText,
rect.width() - 10,
rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText);
Style::m_appTextRectHeight);
painter->save();
//添加最近安装蓝色标签
bool is_recentapp = false;
@ -158,7 +158,7 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
textRect = QRect(rect.x() + 18,
iconRect.bottom() + Style::AppSpaceBetweenIconText,
rect.width() - 23,
rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText);
Style::m_appTextRectHeight);
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QColor("#4d94ff"));
int x = 0;

View File

@ -48,7 +48,7 @@ void FullFunctionWidget::initUi()
m_iconListWid = new QWidget(this);
m_iconListWid->setAttribute(Qt::WA_TranslucentBackground);
m_iconListWid->setAutoFillBackground(false);
m_applistWid->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight);
m_applistWid->setFixedWidth(Style::m_applistAreaWidth);
m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight);
m_verticalScrollBar = new QScrollBar(m_scrollArea);
m_verticalScrollBar->installEventFilter(this);
@ -122,7 +122,7 @@ void FullFunctionWidget::initAppListWidget()
m_scrollArea->setWidgetResizable(true);
m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid);
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWidLayout->setSpacing(0);
layout->addWidget(m_scrollArea);
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, &FullFunctionWidget::valueChangedSlot);
@ -186,7 +186,7 @@ void FullFunctionWidget::fillAppList()
void FullFunctionWidget::insertClassificationBtn(QString category)
{
SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 12, 30, 2);
SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 12, 50, 2);
classificationbtn->setAttribute(Qt::WA_TranslucentBackground);
classificationbtn->setAutoFillBackground(false);
m_scrollAreaWidLayout->addWidget(classificationbtn);
@ -292,7 +292,7 @@ void FullFunctionWidget::resizeScrollAreaControls()
row++;
}
m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight - 10);
m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight);
}
/**
@ -316,7 +316,7 @@ void FullFunctionWidget::initIconListWidget()
void FullFunctionWidget::on_setScrollBarValue(int value)
{
m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight);
m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight + Style::m_scrollBarHeight);
m_verticalScrollBar->setValue(value);
}
@ -408,13 +408,18 @@ void FullFunctionWidget::valueChangedSlot(int value)
int index = 0;
while (index <= m_classificationList.count() - 1) {
int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y();
int min = 0;
int max = 0;
if (index == m_classificationList.count() - 1) {
min = m_scrollAreaWidLayout->itemAt(2 * index - 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
max = m_scrollAreaWid->height();
} else if (index == 0) {
min = 0;
max = m_scrollAreaWidLayout->itemAt(2 * index + 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
} else {
max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y();
min = m_scrollAreaWidLayout->itemAt(2 * index - 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
max = m_scrollAreaWidLayout->itemAt(2 * index + 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
}
if (value >= min && value < max) {
@ -467,7 +472,7 @@ void FullFunctionWidget::setFunctionBtnGeometry()
void FullFunctionWidget::repaintWidget()
{
m_applistWid->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight);
m_applistWid->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight + Style::m_scrollBarHeight);
m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight);
m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height());
updateAppListView();

View File

@ -47,7 +47,7 @@ void FullLetterWidget::initUi()
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->setAttribute(Qt::WA_TranslucentBackground);
m_letterListWid = new QWidget(this);
m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight);
m_letterListWid->setFixedWidth(Style::m_leftWidWidth);
m_verticalScrollBar = new QScrollBar(m_scrollArea);
m_verticalScrollBar->installEventFilter(this);
m_verticalScrollBar->setOrientation(Qt::Vertical);
@ -89,7 +89,7 @@ void FullLetterWidget::initAppListWidget()
m_scrollArea->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight);
m_scrollAreaWidLayout = new QVBoxLayout;
m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0);
m_scrollAreaWidLayout->setSpacing(10);
m_scrollAreaWidLayout->setSpacing(0);
m_scrollAreaWid->setLayout(m_scrollAreaWidLayout);
m_mainLayout->addWidget(m_scrollArea);
QSpacerItem *m_spaceItem1 = nullptr;
@ -193,7 +193,7 @@ void FullLetterWidget::fillAppList()
m_letterList.append(letterstr);//存储分类字符
//插入字母分类按钮
SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 12, 30, 1);
SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 12, 50, 1);
m_scrollAreaWidLayout->addWidget(letterbtn);
//插入应用列表
FullListView *listview = new FullListView(this, 1);
@ -272,7 +272,7 @@ void FullLetterWidget::updateAppListView()
void FullLetterWidget::on_setScrollBarValue(int value)
{
m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight);
m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight + Style::m_scrollBarHeight);
m_verticalScrollBar->setValue(value);
}
@ -299,12 +299,13 @@ void FullLetterWidget::resizeScrollAreaControls()
rowcount = listview->model()->rowCount() / dividend;
}
listview->setFixedHeight(listview->gridSize().height()*rowcount);
areaHeight += listview->height() + 50;
listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height() * rowcount);
areaHeight += (listview->height() + 50);
row++;
}
m_scrollArea->widget()->setFixedHeight(areaHeight - 10);
m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight);
}
/**
@ -422,13 +423,19 @@ void FullLetterWidget::valueChangedSlot(int value)
int index = 0;
while (index <= m_letterList.count() - 1) {
int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y();
int min = 0;
int max = 0;
if (index == m_letterList.count() - 1) {
min = m_scrollAreaWidLayout->itemAt(2 * index - 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
max = m_scrollAreaWid->height();
} else if (index == 0) {
min = 0;
max = m_scrollAreaWidLayout->itemAt(2 * index + 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
} else {
max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y();
min = m_scrollAreaWidLayout->itemAt(2 * index - 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
max = m_scrollAreaWidLayout->itemAt(2 * index + 1)->widget()->geometry().bottom() - Style::m_boundaryOffset;
}
if (value >= min && value < max) {
@ -475,7 +482,7 @@ void FullLetterWidget::setLetterBtnGeometry()
void FullLetterWidget::repaintWidget()
{
m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight);
m_scrollArea->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight);
m_scrollArea->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight + Style::m_scrollBarHeight);
m_scrollAreaWid->setFixedWidth(Style::m_applistWidWidth);
updateAppListView();
}

View File

@ -45,7 +45,7 @@ void SplitBarFrame::initAppBtn()
layout->setContentsMargins(15, 0, 0, 0);
layout->setSpacing(6);
m_textLabel->setAutoFillBackground(false);
m_textLabel->setAlignment(Qt::AlignCenter);
m_textLabel->setAlignment(Qt::AlignTop);
m_textLabel->setText(m_category);
m_textLabel->adjustSize();
QPalette pe = m_textLabel->palette();

View File

@ -58,8 +58,11 @@ int Style::LeftSpaceBetweenItem = 0;
int Style::m_applistWidWidth = 0;
int Style::m_applistAreaWidth = 0;
int Style::m_applistWidHeight = 0;
int Style::m_scrollBarHeight = 0;
int Style::AppListIconSize = 0;
int Style::AppListBigIconSize = 0;
int Style::m_appTextRectHeight = 0;
int Style::m_boundaryOffset = 0;
int Style::AppListItemSizeWidth = 0;
int Style::TabletItemSizeWidthOther = 0;
int Style::TabletItemSizeWidthFirst = 0;
@ -67,7 +70,7 @@ int Style::FirsPageViewWidth = 0;
int Style::OtherPageViewWidth = 0;
int Style::m_applistGridSizeWidth = 0;
int Style::AppLeftSpace = 0;
int Style::AppTopSpace = 0;
int Style::m_appTopSpace = 0;
int Style::AppSpaceBetweenIconText = 0;
int Style::FirstPageSpace = 0;
int Style::OtherPageSpace = 0;
@ -217,12 +220,17 @@ void Style::initWidStyle()
rightViewWidth = 324;
rightViewHeight = 470;
LeftSpaceIconText = 14;
m_appTextRectHeight = 30;
m_appTopSpace = (AppListItemSizeWidth - AppSpaceBetweenIconText - AppListIconSize - m_appTextRectHeight) / 2;
m_boundaryOffset = (m_applistGridSizeWidth - AppListItemSizeWidth) + m_appTopSpace + 10;
m_applistWidWidth = m_availableScreenWidth / 1.25;
m_applistWidWidth = m_applistWidWidth - (m_applistWidWidth % m_applistGridSizeWidth) + 2;
m_applistWidHeight = m_availableScreenHeight - 120;
m_applistWidHeight = m_applistWidHeight - (m_applistWidHeight % m_applistGridSizeWidth);
m_leftWidWidth = (m_availableScreenWidth - m_applistWidWidth) / 2 + 1;
m_applistAreaWidth = m_applistWidWidth + 20;
m_scrollBarHeight = 10;
} else {
ScreenWidth = QApplication::primaryScreen()->geometry().width();
ScreenHeight = QApplication::primaryScreen()->geometry().height();
@ -247,7 +255,7 @@ void Style::initWidStyle()
AppListItemSizeHeight = CenterWindHeight / appLine;
AppListIconSize = 96;
AppListBigIconSize = 108;
AppTopSpace = (AppListItemSizeHeight - AppListIconSize) / 2;
m_appTopSpace = (AppListItemSizeHeight - AppListIconSize) / 2;
AppLeftSpace = (TabletItemSizeWidthFirst - AppListIconSize) / 2;
TimeWidgetTop = (CenterWindHeight - 870) / 2;
TimeWidgetLeft = (m_leftWidWidth - 400) / 2;

View File

@ -113,8 +113,11 @@ public:
static int m_applistWidWidth; //宽度
static int m_applistAreaWidth;
static int m_applistWidHeight; //高度
static int m_scrollBarHeight;
static int AppListIconSize; //图标大小
static int AppListBigIconSize;
static int m_appTextRectHeight;
static int m_boundaryOffset;
static int AppListItemSizeWidth; //item大小
static int TabletItemSizeWidthFirst;
static int TabletItemSizeWidthOther;
@ -122,7 +125,7 @@ public:
static int OtherPageViewWidth;
static int m_applistGridSizeWidth; //网格大小
static int AppLeftSpace;//左侧边距
static int AppTopSpace;//上侧边距
static int m_appTopSpace;//上侧边距
static int AppSpaceBetweenIconText;//图标与文字边距
static int FirstPageSpace;
static int OtherPageSpace;