mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
fix VCaptain to change avatar's border color on mode change
This commit is contained in:
parent
24349f4cc7
commit
5e323cd9ab
@ -43,6 +43,11 @@ content_bg=#FFFFFF
|
||||
selection_fg=#000000
|
||||
selection_bg=#64b5f6
|
||||
|
||||
[soft_defined]
|
||||
; VAvatar.
|
||||
; The border background color of the avatar when Captain mode is triggered.
|
||||
avatar_captain_mode_border_bg=#6C6C6C
|
||||
|
||||
[widgets]
|
||||
; Widget color attributes.
|
||||
|
||||
|
@ -199,7 +199,7 @@ void VCaptain::exitCaptainMode()
|
||||
|
||||
restoreFocus();
|
||||
|
||||
qDebug() << "exit Captain mode";
|
||||
emit captainModeChanged(false);
|
||||
}
|
||||
|
||||
bool VCaptain::registerCaptainTarget(const QString &p_name,
|
||||
@ -255,14 +255,14 @@ bool VCaptain::navigationModeByCaptain(void *p_target, void *p_data)
|
||||
|
||||
void VCaptain::triggerCaptainMode()
|
||||
{
|
||||
qDebug() << "trigger Captain mode";
|
||||
|
||||
m_widgetBeforeCaptain = QApplication::focusWidget();
|
||||
|
||||
m_ignoreFocusChange = false;
|
||||
|
||||
setMode(CaptainMode::Pending);
|
||||
|
||||
emit captainModeChanged(true);
|
||||
|
||||
// Focus to listen pending key press.
|
||||
setFocus();
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ public:
|
||||
void *p_target,
|
||||
CaptainFunc p_func);
|
||||
|
||||
signals:
|
||||
// Emit when mode changed.
|
||||
void captainModeChanged(bool p_captainMode);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -33,11 +33,14 @@
|
||||
#include "vsnippetlist.h"
|
||||
#include "vtoolbox.h"
|
||||
#include "vbuttonmenuitem.h"
|
||||
#include "vpalette.h"
|
||||
|
||||
VMainWindow *g_mainWin;
|
||||
|
||||
extern VConfigManager *g_config;
|
||||
|
||||
extern VPalette *g_palette;
|
||||
|
||||
VNote *g_vnote;
|
||||
|
||||
const int VMainWindow::c_sharedMemTimerInterval = 1000;
|
||||
@ -110,6 +113,17 @@ void VMainWindow::initCaptain()
|
||||
// VCaptain should be visible to accpet key focus. But VCaptain
|
||||
// may hide other widgets.
|
||||
m_captain = new VCaptain(this);
|
||||
connect(m_captain, &VCaptain::captainModeChanged,
|
||||
this, [this](bool p_captainMode) {
|
||||
static QString normalBaseColor = m_avatar->getBaseColor();
|
||||
static QString captainModeColor = g_palette->color("avatar_captain_mode_border_bg");
|
||||
|
||||
if (p_captainMode) {
|
||||
m_avatar->updateBaseColor(captainModeColor);
|
||||
} else {
|
||||
m_avatar->updateBaseColor(normalBaseColor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void VMainWindow::registerCaptainAndNavigationTargets()
|
||||
|
@ -20,6 +20,7 @@ void VPalette::init(const QString &p_file)
|
||||
QSettings settings(p_file, QSettings::IniFormat);
|
||||
initMetaData(&settings, "metadata");
|
||||
initPaleteFromSettings(&settings, "phony");
|
||||
initPaleteFromSettings(&settings, "soft_defined");
|
||||
initPaleteFromSettings(&settings, "widgets");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user