Allow main window to resize to much smaller size when needed. Should help people with small screens to resize RS window appropriately (patch from Manuel Davis)

This commit is contained in:
csoler 2016-01-26 22:16:45 -05:00
parent 2072ca4ade
commit f063e5ba6f
2 changed files with 34 additions and 0 deletions

View File

@ -20,6 +20,26 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
/* ccr . 2015 Aug 01 . Resize Main page and Main window.
*
* On very small legacy CRTs of about 15" (38 cm) RetroShare pages are
* initially too deep (too tall) to fit the screen at 1024x768
* resolution. Some can be shrunk down manually from their initial
* size. Others cannot. This patch tries to allow each page to be
* shrunk somewhat. Then code that runs elsewhere to fit the logical
* Main window into the physical screen will have a better chance of
* success. Notably, on Linux -- Gnome3 -- X11 systems, only when the
* Main window first fits entirely into the physical screen, can it
* then be maximized.
*
* This code is borrowed from a Stack Overflow post:
*
* o Darkgaze. "Resize QStackedWidget to the Page Which Is Opened." 23
* Jan. 2013. Online posting. Stack Overflow. 1 Aug. 2015
* <https://stackoverflow.com/questions/14480696/resize-qstackedwidget-to-the-page-which-is-opened>.
*
*/
#include <QAction>
#include "mainpagestack.h"
@ -34,6 +54,7 @@ void
MainPageStack::add(MainPage *page, QAction *action)
{
_pages.insert(action, page);
page->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); /* 2015 Aug 01 */
insertWidget(count(), page);
}
@ -61,3 +82,14 @@ MainPageStack::showPage(QAction *pageAction)
setCurrentWidget(_pages.value(pageAction));
}
/** Adjusts the size of the Main page and the Main window. */
void
MainPageStack::onCurrentChanged(int index) /* 2015 Aug 01 */
{
QWidget* pWidget = widget(index);
Q_ASSERT(pWidget);
pWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
pWidget->adjustSize();
adjustSize();
}

View File

@ -50,6 +50,8 @@ public:
public slots:
/** Displays the page associated with the activated action. */
void showPage(QAction *pageAction);
/** Adjusts the size of the Main page and the Main window. */
void onCurrentChanged(int index);
private:
/** Maps an action to a Main page. */