mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
[win] online-installer: fix checkbox alignment
This commit is contained in:
@ -190,8 +190,9 @@ void MainWindow::initInstallationMode(const std::wstring &url)
|
||||
/* Check box section*/
|
||||
CheckBox *chkBox = new CheckBox(m_cenPanel, _TR(CHECK_SILENT));
|
||||
chkBox->setChecked(m_is_checked);
|
||||
chkBox->setGeometry(m_cenPanel->size().width/2 - 60, 254, 180, 18);
|
||||
setSelectorStyle(chkBox);
|
||||
chkBox->adjustSizeBasedOnContent();
|
||||
chkBox->move(m_cenPanel->size().width/2 - chkBox->size().width/2, 254);
|
||||
chkBox->onClick([chkBox, this]() {
|
||||
m_is_checked = chkBox->isChecked();
|
||||
});
|
||||
@ -218,7 +219,7 @@ void MainWindow::initInstallationMode(const std::wstring &url)
|
||||
});
|
||||
|
||||
m_resize_conn = m_cenPanel->onResize([chkBox, comntLbl, instlBtn](int w, int h) {
|
||||
chkBox->setGeometry(w/2 - 60, 254, 180, 18);
|
||||
chkBox->move(w/2 - chkBox->size().width/2, 254);
|
||||
comntLbl->setGeometry(0, h - 130, w, 48);
|
||||
instlBtn->setGeometry(w/2 - 50, h - 76, 100, 28);
|
||||
});
|
||||
@ -338,8 +339,9 @@ void MainWindow::finishInstall(const std::wstring &app_path)
|
||||
m_is_checked = true;
|
||||
CheckBox *chkBox = new CheckBox(m_cenPanel, _TR(CHECK_LAUNCH));
|
||||
chkBox->setChecked(m_is_checked);
|
||||
chkBox->setGeometry(m_cenPanel->size().width/2 - 43, 254, 180, 18);
|
||||
setSelectorStyle(chkBox);
|
||||
chkBox->adjustSizeBasedOnContent();
|
||||
chkBox->move(m_cenPanel->size().width/2 - chkBox->size().width/2, 254);
|
||||
chkBox->onClick([chkBox, this]() {
|
||||
m_is_checked = chkBox->isChecked();
|
||||
});
|
||||
@ -364,7 +366,7 @@ void MainWindow::finishInstall(const std::wstring &app_path)
|
||||
});
|
||||
|
||||
m_resize_conn = m_cenPanel->onResize([chkBox, comntLbl, closeBtn](int w, int h) {
|
||||
chkBox->setGeometry(w/2 - 43, 254, 180, 18);
|
||||
chkBox->move(w/2 - chkBox->size().width/2, 254);
|
||||
comntLbl->setGeometry(0, h - 130, w, 48);
|
||||
closeBtn->setGeometry(w/2 - 50, h - 76, 100, 28);
|
||||
});
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "abstractbutton.h"
|
||||
#include "palette.h"
|
||||
#include "metrics.h"
|
||||
|
||||
|
||||
AbstractButton::AbstractButton(Widget *parent, const std::wstring &text) :
|
||||
@ -20,6 +21,19 @@ void AbstractButton::setText(const std::wstring &text)
|
||||
update();
|
||||
}
|
||||
|
||||
void AbstractButton::adjustSizeBasedOnContent()
|
||||
{
|
||||
HDC hdc = GetDC(nativeWindowHandle());
|
||||
HFONT hOldFont = (HFONT)SelectObject(hdc, m_hFont);
|
||||
SIZE textSize{0, 0};
|
||||
GetTextExtentPoint32(hdc, m_text.c_str(), m_text.length(), &textSize);
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(nativeWindowHandle(), hdc);
|
||||
int w = textSize.cx + 2*metrics()->value(Metrics::IconWidth) + metrics()->value(Metrics::TextMarginLeft) + metrics()->value(Metrics::TextMarginRight);
|
||||
int h = max(textSize.cy + metrics()->value(Metrics::TextMarginTop) + metrics()->value(Metrics::TextMarginBottom), metrics()->value(Metrics::IconHeight)) + 1;
|
||||
resize(w, h);
|
||||
}
|
||||
|
||||
int AbstractButton::onClick(const FnVoidVoid &callback)
|
||||
{
|
||||
m_click_callbacks[++m_connectionId] = callback;
|
||||
|
||||
@ -12,6 +12,7 @@ public:
|
||||
virtual ~AbstractButton();
|
||||
|
||||
void setText(const std::wstring &text);
|
||||
void adjustSizeBasedOnContent();
|
||||
|
||||
/* callback */
|
||||
int onClick(const FnVoidVoid &callback);
|
||||
|
||||
Reference in New Issue
Block a user