added brace wrapping after if and for
This commit is contained in:
@@ -37,8 +37,10 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset)
|
||||
|
||||
AttachedWindow::~AttachedWindow()
|
||||
{
|
||||
for (auto it = items.begin(); it != items.end(); it++) {
|
||||
if (it->window == this) {
|
||||
for (auto it = items.begin(); it != items.end(); it++)
|
||||
{
|
||||
if (it->window == this)
|
||||
{
|
||||
items.erase(it);
|
||||
break;
|
||||
}
|
||||
@@ -50,8 +52,10 @@ AttachedWindow::~AttachedWindow()
|
||||
AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
{
|
||||
AttachedWindow *window = [&]() {
|
||||
for (Item &item : items) {
|
||||
if (item.hwnd == target) {
|
||||
for (Item &item : items)
|
||||
{
|
||||
if (item.hwnd == target)
|
||||
{
|
||||
return item.window;
|
||||
}
|
||||
}
|
||||
@@ -64,26 +68,35 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
bool show = true;
|
||||
QSize size = window->size();
|
||||
|
||||
if (args.height != -1) {
|
||||
if (args.height == 0) {
|
||||
if (args.height != -1)
|
||||
{
|
||||
if (args.height == 0)
|
||||
{
|
||||
window->hide();
|
||||
show = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
window->height_ = args.height;
|
||||
size.setHeight(args.height);
|
||||
}
|
||||
}
|
||||
if (args.width != -1) {
|
||||
if (args.width == 0) {
|
||||
if (args.width != -1)
|
||||
{
|
||||
if (args.width == 0)
|
||||
{
|
||||
window->hide();
|
||||
show = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
window->width_ = args.width;
|
||||
size.setWidth(args.width);
|
||||
}
|
||||
}
|
||||
|
||||
if (show) {
|
||||
if (show)
|
||||
{
|
||||
window->updateWindowRect(window->target_);
|
||||
window->show();
|
||||
}
|
||||
@@ -93,8 +106,10 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
|
||||
void AttachedWindow::detach(const QString &winId)
|
||||
{
|
||||
for (Item &item : items) {
|
||||
if (item.winId == winId) {
|
||||
for (Item &item : items)
|
||||
{
|
||||
if (item.winId == winId)
|
||||
{
|
||||
item.window->deleteLater();
|
||||
}
|
||||
}
|
||||
@@ -113,7 +128,8 @@ void AttachedWindow::showEvent(QShowEvent *)
|
||||
void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (this->attached_) {
|
||||
if (this->attached_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +141,8 @@ void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
|
||||
QObject::connect(&this->timer_, &QTimer::timeout, [this, hwnd, attached] {
|
||||
// check process id
|
||||
if (!this->validProcessName_) {
|
||||
if (!this->validProcessName_)
|
||||
{
|
||||
DWORD processId;
|
||||
::GetWindowThreadProcessId(attached, &processId);
|
||||
|
||||
@@ -139,7 +156,8 @@ void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
QString::fromWCharArray(filename.get(), filenameLength);
|
||||
|
||||
if (!qfilename.endsWith("chrome.exe") &&
|
||||
!qfilename.endsWith("firefox.exe")) {
|
||||
!qfilename.endsWith("firefox.exe"))
|
||||
{
|
||||
qDebug() << "NM Illegal caller" << qfilename;
|
||||
this->timer_.stop();
|
||||
this->deleteLater();
|
||||
@@ -167,7 +185,8 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
RECT rect;
|
||||
::GetWindowRect(attached, &rect);
|
||||
|
||||
if (::GetLastError() != 0) {
|
||||
if (::GetLastError() != 0)
|
||||
{
|
||||
qDebug() << "NM GetLastError()" << ::GetLastError();
|
||||
|
||||
this->timer_.stop();
|
||||
@@ -182,7 +201,8 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
float scale = 1.f;
|
||||
if (auto dpi = getWindowDpi(attached)) {
|
||||
if (auto dpi = getWindowDpi(attached))
|
||||
{
|
||||
scale = dpi.get() / 96.f;
|
||||
|
||||
// for (auto w : this->ui_.split->findChildren<BaseWidget *>()) {
|
||||
@@ -191,12 +211,15 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
// this->ui_.split->setOverrideScale(scale);
|
||||
}
|
||||
|
||||
if (this->height_ == -1) {
|
||||
if (this->height_ == -1)
|
||||
{
|
||||
// ::MoveWindow(hwnd, rect.right - this->width_ - 8, rect.top +
|
||||
// this->yOffset_ - 8,
|
||||
// this->width_, rect.bottom - rect.top - this->yOffset_,
|
||||
// false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
::MoveWindow(hwnd, //
|
||||
int(rect.right - this->width_ * scale - 8), //
|
||||
int(rect.bottom - this->height_ * scale - 8), //
|
||||
|
||||
Reference in New Issue
Block a user