summaryrefslogtreecommitdiff
path: root/src/gui/windows/mailwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows/mailwindow.cpp')
-rw-r--r--src/gui/windows/mailwindow.cpp55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 5b91b099b..ddc91603f 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -1,9 +1,9 @@
/*
- * The ManaPlus Client
+ * The ManaVerse Client
* Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2023 The ManaVerse Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
*
- * This file is part of The ManaPlus Client.
+ * This file is part of The ManaVerse Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -92,25 +92,39 @@ MailWindow::MailWindow() :
if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- setDefaultSize(310, 180, ImagePosition::CENTER, 0, 0);
- setMinWidth(310);
- setMinHeight(250);
center();
+ // use line wrapping of mail subjects, instead.
mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- ContainerPlacer placer(nullptr, nullptr);
- placer = getPlacer(0, 0);
-
- placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
- placer(4, 0, mRefreshButton, 1, 1);
- placer(4, 1, mOpenButton, 1, 1);
- placer(4, 2, mNewButton, 1, 1);
- placer(4, 3, mDeleteButton, 1, 1);
- placer(4, 4, mReturnButton, 1, 1);
+ // set reasonable minimum width for calculations below
+ mListScrollArea->setWidth(200);
+
+ // at 0,0 and spawns/spans 4 columns and 6 rows
+ place(0, 0, mListScrollArea, 1, 6).setPadding(3);
+ // at column 5 and row 0...
+ place(1, 0, mRefreshButton, 1, 1);
+ place(1, 1, mOpenButton, 1, 1);
+ place(1, 2, mNewButton, 1, 1);
+ // Leave intentional gap in grid so that the button column (and thus,
+ // the whole window) can be resized without resizing any of the buttons.
+ // note: the empty cell still seems to enforce some padding, but this
+ // is fine.
+ place(1, 4, mDeleteButton, 1, 1);
+ place(1, 5, mReturnButton, 1, 1);
Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
+ // scrollarea column and 4th row eat all remaining available screen space.
+ layout.setColWidth(0, LayoutType::SET);
+ layout.setRowHeight(3, LayoutType::SET);
+
+ // Enforce a minimum size.
+ int width = 0;
+ int height = 0;
+ layout.reflow(width, height);
+ setContentSize(width, height);
+ setMinWidth(getWidth());
+ setMinHeight(getHeight());
+ setDefaultSize(getWidth(), getHeight(), ImagePosition::CENTER, 0, 0);
loadWindowState();
enableVisibleSound(true);
@@ -255,6 +269,13 @@ void MailWindow::removeMail(const int64_t id)
if (message != nullptr)
mMailModel->add(getMailHeader(message));
}
+
+ // if player deleted the selected mail, then selection does not change
+ // (selects next one in list). However, if they deleted the last one,
+ // then we go to the previous one in list.
+ const auto lastIndex = mMailModel->getNumberOfElements() - 1;
+ if (mListBox->getSelected() > lastIndex)
+ mListBox->setSelected(lastIndex);
}
void MailWindow::showMessage(MailMessage *const mail,