mirror of
https://github.com/LibreOffice/core.git
synced 2025-07-26 15:45:26 +00:00

Set the allowed range using weld::SpinButton::set_range
so that weld::SpinButton makes sure that a value within
the correct range is set, instead of having a custom
handler called when the text of the spinbutton changes
that effectively does the same thing (+ manually setting
cursor to the end of the edit, but sticking to the toolkit
default there instead makes sense to me for consistency).
Adjust the test case to no longer type invalid input
for the page number ("3a"), as SalInstanceSpinButton
doesn't parse the number then, but would set the value to
the minimum (here: 1) instead.
(If a different behavior were intended here, that
should be implemented in SalInstanceSpinButton or
the underlying VCL widgets to be consistent
across dialogs.)
In GotoPageDlg::GetPageSelection, use weld::SpinButton::get_value
to get the integer value right away, instead of
getting the text and converting that into an
integer manually.
All that custom handling provided an interesting test case
while implementing support for that dialog using native
Qt widgets, see commits up to
commit 70825e677f
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Thu Nov 28 00:30:10 2024 +0100
tdf#130857 qt weld: Notify about spinbox combined value+text change
, but apart from that (which is done now), I think
that a more standard approach makes more sense.
Change-Id: I06492b6629a4210c6325d50467da8e195daa4c94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177463
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <svx/dialog/gotodlg.hxx>
|
|
|
|
using namespace com::sun::star;
|
|
|
|
namespace svx
|
|
{
|
|
GotoPageDlg::GotoPageDlg(weld::Window* pParent, const OUString& title, const OUString& label,
|
|
sal_uInt16 curPagePos, sal_uInt16 pageCnt)
|
|
: GenericDialogController(pParent, u"svx/ui/gotopagedialog.ui"_ustr, u"GotoPageDialog"_ustr)
|
|
, mxMtrPageCtrl(m_xBuilder->weld_spin_button(u"page"_ustr))
|
|
, mxPageNumberLbl(m_xBuilder->weld_label(u"page_count"_ustr))
|
|
, mxPageLbl(m_xBuilder->weld_label(u"page_label"_ustr))
|
|
{
|
|
set_title(title);
|
|
mxPageLbl->set_label(label);
|
|
|
|
mxMtrPageCtrl->set_range(1, pageCnt);
|
|
mxMtrPageCtrl->set_value(curPagePos);
|
|
|
|
OUString sStr = mxPageNumberLbl->get_label();
|
|
mxPageNumberLbl->set_label(sStr.replaceFirst("$1", OUString::number(pageCnt)));
|
|
|
|
mxMtrPageCtrl->select_region(0, -1);
|
|
}
|
|
}
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|