Skip to content

Commit 6db295d

Browse files
committed
Plugin: fix AdaptWindows in COperateDesktop bug
1 parent 6338a54 commit 6db295d

4 files changed

Lines changed: 76 additions & 45 deletions

File tree

Src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ set(PLUGIN_UI_FILES
107107
if(WIN32)
108108
list(APPEND PLUGIN_HEADER_FILES Windows/HookWindows.h)
109109
list(APPEND PLUGIN_SOURCE_FILES Windows/HookWindows.cpp)
110+
if(MSVC)
111+
list(APPEND PLUGIN_PRIVATE_DEFINITIONS NOMINMAX)
112+
endif()
110113
list(APPEND PLUGIN_LIBS Ws2_32)
111114
endif()
112115

Src/OperateDesktop.cpp

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const QString COperateDesktop::Id()
4747
if(!GetParameter()->m_Net.GetHost().isEmpty())
4848
szId += "_" + GetParameter()->m_Net.GetHost()
4949
+ "_" + QString::number(GetParameter()->m_Net.GetPort());
50-
50+
5151
CParameterNet* net = nullptr;
5252
QString szType;
5353
switch(GetParameter()->m_Proxy.GetUsedType())
@@ -72,7 +72,7 @@ const QString COperateDesktop::Id()
7272
default:
7373
break;
7474
}
75-
75+
7676
if(!szType.isEmpty() && !net->GetHost().isEmpty()) {
7777
szId += "_" + szType + "_";
7878
szId += net->GetHost() + "_" + QString::number(net->GetPort());
@@ -89,7 +89,7 @@ const QString COperateDesktop::Name()
8989
if(GetParameter() && GetParameter()->GetGlobalParameters()
9090
&& GetParameter()->GetGlobalParameters()->GetShowProtocolPrefix())
9191
szName = Protocol() + ":";
92-
92+
9393
if(GetParameter() && !(GetParameter()->GetName().isEmpty()))
9494
szName += GetParameter()->GetName();
9595
else
@@ -102,10 +102,10 @@ const QString COperateDesktop::Description()
102102
QString szDescription;
103103
if(!Name().isEmpty())
104104
szDescription = tr("Name: ") + Name() + "\n";
105-
105+
106106
if(!GetTypeName().isEmpty())
107107
szDescription += tr("Type:") + GetTypeName() + "\n";
108-
108+
109109
if(!Protocol().isEmpty()) {
110110
szDescription += tr("Protocol: ") + Protocol();
111111
#ifdef DEBUG
@@ -165,21 +165,21 @@ int COperateDesktop::Initial()
165165
qDebug(log) << Q_FUNC_INFO;
166166
int nRet = 0;
167167
bool check = false;
168-
168+
169169
nRet = COperate::Initial();
170170
if(nRet)
171171
return nRet;
172-
172+
173173
Q_ASSERT(!(m_pFrmViewer && m_pScroll));
174174
m_pFrmViewer = new CFrmViewer(); // The owner is m_pScroll
175175
m_pScroll = new CFrmScroll(m_pFrmViewer);
176-
176+
177177
check = connect(m_pFrmViewer, SIGNAL(sigViewerFocusIn(QWidget*)),
178178
this, SIGNAL(sigViewerFocusIn(QWidget*)));
179179
Q_ASSERT(check);
180-
180+
181181
nRet = InitialMenu();
182-
182+
183183
return nRet;
184184
}
185185

@@ -237,20 +237,28 @@ int COperateDesktop::InitialMenu()
237237
m_pZoomIn = pMenuZoom->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom in"));
238238
m_pZoomIn->setCheckable(true);
239239
check = connect(
240-
m_pZoomIn, &QAction::toggled, this,
240+
m_pZoomIn, &QAction::triggered, this,
241241
[&](){
242-
if(m_psbZoomFactor)
243-
m_psbZoomFactor->setValue((m_pFrmViewer->GetZoomFactor() + 0.1) * 100);
242+
double factor = 0;
243+
if(m_psbZoomFactor) {
244+
factor = (m_pFrmViewer->GetZoomFactor() + 0.1) * 100;
245+
qDebug(log) << "Zoom in:" << factor;
246+
m_psbZoomFactor->setValue(factor);
247+
}
244248
});
245249
Q_ASSERT(check);
246250
m_pZoomOut = pMenuZoom->addAction(
247251
QIcon::fromTheme("zoom-out"), tr("Zoom out"));
248252
m_pZoomOut->setCheckable(true);
249253
check = connect(
250-
m_pZoomOut, &QAction::toggled, this,
254+
m_pZoomOut, &QAction::triggered, this,
251255
[&](){
252-
if(m_psbZoomFactor)
253-
m_psbZoomFactor->setValue((m_pFrmViewer->GetZoomFactor() - 0.1) * 100);
256+
double factor = 100;
257+
if(m_psbZoomFactor) {
258+
factor = (m_pFrmViewer->GetZoomFactor() - 0.1) * 100;
259+
qDebug(log) << "Zoom out:" << factor;
260+
m_psbZoomFactor->setValue(factor);
261+
}
254262
});
255263
Q_ASSERT(check);
256264
QActionGroup* pGBViewZoom = new QActionGroup(this);
@@ -260,6 +268,14 @@ int COperateDesktop::InitialMenu()
260268
pGBViewZoom->addAction(m_pZoomOriginal);
261269
pGBViewZoom->addAction(m_pZoomIn);
262270
pGBViewZoom->addAction(m_pZoomOut);
271+
check = connect(pGBViewZoom, &QActionGroup::triggered,
272+
this, [&](QAction* a){
273+
if(a == m_pZoomIn || a == m_pZoomOut)
274+
m_psbZoomFactor->setEnabled(true);
275+
else {
276+
m_psbZoomFactor->setEnabled(false);
277+
}
278+
});
263279
}
264280
m_psbZoomFactor = new QSpinBox(pMenuZoom);
265281
m_psbZoomFactor->setRange(0, 9999999);
@@ -363,6 +379,7 @@ int COperateDesktop::SetGlobalParameters(CParameterPlugin *pPara)
363379
this, SLOT(slotUpdateName()));
364380
Q_ASSERT(check);
365381
}
382+
LoadAdaptWindows();
366383
return 0;
367384
} else {
368385
QString szMsg = "There is not parameters! "
@@ -424,25 +441,8 @@ int COperateDesktop::SetParameter(CParameterBase *p)
424441
return 0;
425442
}
426443

427-
int COperateDesktop::Load(QSettings &set)
444+
int COperateDesktop::LoadAdaptWindows()
428445
{
429-
int nRet = 0;
430-
Q_ASSERT(m_pFrmViewer);
431-
nRet = COperate::Load(set);
432-
if(m_pPara)
433-
nRet = m_pPara->Load(set);
434-
else {
435-
QString szMsg = "There is not parameters! "
436-
"please first create parameters, "
437-
"then call SetParameter() in the ";
438-
szMsg += metaObject()->className() + QString("::")
439-
+ metaObject()->className();
440-
szMsg += QString("() or ") + metaObject()->className()
441-
+ QString("::") + "Initial()";
442-
szMsg += " to set the parameters pointer. ";
443-
qWarning(log) << szMsg.toStdString().c_str();
444-
Q_ASSERT(false);//TODO: delete it
445-
}
446446
if(m_pFrmViewer && GetParameter())
447447
{
448448
m_pFrmViewer->slotSetZoomFactor(GetParameter()->GetZoomFactor());
@@ -463,6 +463,30 @@ int COperateDesktop::Load(QSettings &set)
463463
m_pZoomIn->setChecked(true);
464464
}
465465
}
466+
return 0;
467+
}
468+
469+
int COperateDesktop::Load(QSettings &set)
470+
{
471+
int nRet = 0;
472+
Q_ASSERT(m_pFrmViewer);
473+
nRet = COperate::Load(set);
474+
if(m_pPara)
475+
nRet = m_pPara->Load(set);
476+
else {
477+
QString szMsg = "There is not parameters! "
478+
"please first create parameters, "
479+
"then call SetParameter() in the ";
480+
szMsg += metaObject()->className() + QString("::")
481+
+ metaObject()->className();
482+
szMsg += QString("() or ") + metaObject()->className()
483+
+ QString("::") + "Initial()";
484+
szMsg += " to set the parameters pointer. ";
485+
qWarning(log) << szMsg.toStdString().c_str();
486+
Q_ASSERT(false);//TODO: delete it
487+
}
488+
489+
LoadAdaptWindows();
466490
return nRet;
467491
}
468492

@@ -514,6 +538,7 @@ void COperateDesktop::slotRecorderStateChanged(
514538

515539
void COperateDesktop::slotValueChanged(int v)
516540
{
541+
qDebug(log) << "zoom:" << v;
517542
if(!m_pScroll || !m_pFrmViewer) return;
518543
m_pFrmViewer->slotSetZoomFactor(((double)v) / 100);
519544
m_pScroll->slotSetAdaptWindows(CFrmViewer::ADAPT_WINDOWS::Zoom);

Src/OperateDesktop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ private Q_SLOTS:
169169
//! \~chinese \note 仅由 CBackendDesktop::SetConnect() 使用
170170
//! \~english \note The slot only is used by CBackendDesktop::SetConnect()
171171
virtual void slotSetServerName(const QString &szName);
172+
173+
private:
174+
int LoadAdaptWindows();
172175

173176
protected:
174177
QAction* m_pMenuZoom;

snap/snapcraft.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ description: |
3232
# See: https://snapcraft.io/docs/reference-architectures
3333
# See: https://snapcraft.io/docs/architectures
3434
base: core24 # the base snap is the execution environment for this snap
35-
#platforms:
36-
# amd64:
37-
# arm64:
35+
platforms:
36+
amd64:
37+
arm64:
3838
#base: core22
3939
#architectures:
4040
# - build-on: amd64
@@ -322,18 +322,18 @@ parts:
322322
snapcraftctl stage
323323
prime:
324324
- -usr/bin/cmark
325-
- -opt/RabbitRemoteControl/bin/cmark
326-
- -opt/RabbitRemoteControl/include
327-
- -opt/RabbitRemoteControl/lib/cmake
328-
- -opt/RabbitRemoteControl/lib/pkgconfig
329-
- -opt/RabbitRemoteControl/lib/*.a
325+
- -usr/local/bin/cmark
326+
- -usr/local/include
327+
- -usr/local/lib/cmake
328+
- -usr/local/lib/pkgconfig
329+
- -usr/local/lib/*.a
330330

331331
apps:
332332
rabbitremotecontrol:
333-
#command: opt/RabbitRemoteControl/bin/start.sh
334-
command: opt/RabbitRemoteControl/bin/RabbitRemoteControlApp
333+
#command: usr/local/bin/start.sh
334+
command: usr/local/bin/RabbitRemoteControlApp
335335
# See: https://snapcraft.io/docs/desktop-menu-support#heading--desktop-key
336-
desktop: opt/RabbitRemoteControl/share/applications/io.github.KangLin.RabbitRemoteControl.desktop
336+
desktop: usr/local/share/applications/io.github.KangLin.RabbitRemoteControl.desktop
337337
environment:
338338
LD_LIBRARY_PATH: ${SNAP}/usr/local/lib::${LD_LIBRARY_PATH}
339339
PATH: $SNAP/usr/local/bin:$PATH

0 commit comments

Comments
 (0)