window drawing bugfix
This commit is contained in:
1 parent
6f3556009a
commit
19006fac6c
5 files changed
+36
-27
No files matched your search
+14
-14
@@ -115,13 +115,12 @@ QString incrementFileName(const QString &fileName)
|
||||
|
||||
} // namespace
|
||||
|
||||
StartDlg::StartDlg(DirectDlg *direct, QWidget *parent)
|
||||
: BufferedDrawDlg(parent), m_direct(direct), ui(new Ui::StartDlg)
|
||||
StartDlg::StartDlg(DirectDlg *direct, Background *background)
|
||||
: BufferedDrawDlg(background), m_direct(direct), m_background(background), ui(new Ui::StartDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setMouseTracking(true);
|
||||
setWindowFlag(Qt::WindowStaysOnTopHint, true);
|
||||
m_background = std::make_unique<Background>();
|
||||
// A child of the background window: it is always drawn above it, and is placed relative to it.
|
||||
m_background->setAnchor(this);
|
||||
|
||||
titleHeight = 0;
|
||||
@@ -282,14 +281,12 @@ StartDlg::StartDlg(DirectDlg *direct, QWidget *parent)
|
||||
if (m_showTab == Tab::PreviousGame)
|
||||
GameServer::previewMap(m_startLandMass); // avoid delay on first tab change
|
||||
changeTab(m_showTab);
|
||||
m_background->setEnabled(false);
|
||||
updateMusic();
|
||||
};
|
||||
onHide = [this] {
|
||||
m_diff0 = Database::difficulty[0];
|
||||
m_listIndex[static_cast<std::size_t>(m_tab)] = ui->list->currentRow();
|
||||
m_showTab = m_tab;
|
||||
m_background->setEnabled(true);
|
||||
const int formerIndex = m_listIndex[static_cast<std::size_t>(Tab::PreviousGame)];
|
||||
m_lastGame = formerIndex >= 0 && formerIndex < m_formerGames.count() ? m_formerGames[formerIndex].nameOnly()
|
||||
: QString();
|
||||
@@ -300,7 +297,14 @@ StartDlg::StartDlg(DirectDlg *direct, QWidget *parent)
|
||||
if (ui->list->count() > 0 && ui->list->currentItem())
|
||||
ui->list->scrollToItem(ui->list->currentItem());
|
||||
};
|
||||
onClose = [this] { m_direct->close(); };
|
||||
// Closing the start screen ends the application (the original's main form, DirectDlg, closes).
|
||||
// DirectDlg is hidden by then and the start screen is only a child window, so closing them
|
||||
// would not by itself make Qt quit.
|
||||
onClose = [this] {
|
||||
m_direct->close();
|
||||
m_background->close();
|
||||
QCoreApplication::quit();
|
||||
};
|
||||
}
|
||||
|
||||
StartDlg::~StartDlg()
|
||||
@@ -374,11 +378,9 @@ void StartDlg::loadAiBrainsPictures()
|
||||
|
||||
void StartDlg::updateInterface()
|
||||
{
|
||||
const QRect screen = Dpi::Screen::primaryMonitor().boundsRect();
|
||||
// The background window sizes itself and places this dialog.
|
||||
m_background->updateInterface();
|
||||
if (fullScreen) {
|
||||
const QPoint shift((screen.width() - std::min(screen.width(), 800)) * 3 / 8,
|
||||
(screen.height() - std::min(screen.height(), 600)) / 3);
|
||||
move(screen.left() + shift.x(), screen.top() + screen.height() - height() - shift.y());
|
||||
// Only the quit button area above the tab strip stays visible, as in the original window region.
|
||||
QRegion region(0, 0, width(), height());
|
||||
region -= QRegion(TabOffset + 4 * TabSize + 2, 0, width() - (TabOffset + 4 * TabSize + 2), TabHeight);
|
||||
@@ -386,7 +388,6 @@ void StartDlg::updateInterface()
|
||||
setMask(region);
|
||||
} else {
|
||||
clearMask();
|
||||
centerToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +755,6 @@ void StartDlg::keyPressEvent(QKeyEvent *event)
|
||||
if (KeyBindings::bFullScreen && KeyBindings::bFullScreen->test(shortcut)) {
|
||||
fullScreen = !fullScreen;
|
||||
updateInterface();
|
||||
m_background->updateInterface();
|
||||
activateWindow();
|
||||
} else if (KeyBindings::bHelp && KeyBindings::bHelp->test(shortcut)) {
|
||||
GameServer::directHelp(cStartHelp);
|
||||
@@ -1106,7 +1106,7 @@ void StartDlg::renameClicked()
|
||||
: QStringLiteral("TITLE_MAPNAME")));
|
||||
const int row = ui->list->currentRow();
|
||||
inputDlg.editInput()->setText(ui->list->item(row)->text());
|
||||
inputDlg.centerToRect(geometry());
|
||||
inputDlg.centerToRect(QRect(mapToGlobal(QPoint(0, 0)), size()));
|
||||
inputDlg.showModal();
|
||||
QString newName = inputDlg.editInput()->text();
|
||||
while (GameServer::isAutoSaveFileName(newName))
|
||||
|
||||
Reference in new issue
Block a user