mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
support stay-on-top
This commit is contained in:
parent
b63e5def85
commit
a5271d409d
11
src/resources/icons/stay_on_top.svg
Normal file
11
src/resources/icons/stay_on_top.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<path fill="#000000" d="M331.8,228C331.8,228,331.8,228,331.8,228c-1.2-0.5-2.4-1-3.5-1.7c-7-4-12.2-10.9-13.9-19.2L295.9,89.4l-0.2-5.8
|
||||
c0-7.1,4.1-10.2,10-13l0,0c0.7-0.3,1.4-0.6,2.1-0.9c7.2-3.4,12.1-7.8,12.1-16.3c0-20.1-6.5-21.4-18.2-21.4h-91.3
|
||||
c-11.7,0-18.2,1.2-18.2,21.4c0,8.5,4.9,12.9,12.1,16.3c0.7,0.3,1.4,0.5,2.1,0.9c0,0,0,0,0,0c5.9,2.9,10,6,10,13l-0.2,5.8
|
||||
l-18.5,117.7c-1.7,8.3-6.9,15.2-13.9,19.2c-1.1,0.7-2.3,1.2-3.5,1.7c0,0,0,0,0,0c-19.7,10.2-36.2,30.8-36.2,54.7
|
||||
c0,15.9,3.5,21.3,15.2,21.3H240l12,176h8l12-176h80.8c11.7,0,15.2-4.7,15.2-21.3C368,258.8,351.5,238.2,331.8,228z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
@ -381,6 +381,14 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
||||
}
|
||||
});
|
||||
|
||||
QAction *stayOnTopAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/stay_on_top.svg"),
|
||||
tr("Stay On Top"),
|
||||
this);
|
||||
stayOnTopAct->setStatusTip(tr("Toggle stay-on-top"));
|
||||
stayOnTopAct->setCheckable(true);
|
||||
connect(stayOnTopAct, &QAction::triggered,
|
||||
this, &VMainWindow::stayOnTop);
|
||||
|
||||
QAction *menuBarAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/menubar.svg"),
|
||||
tr("Menu Bar"),
|
||||
this);
|
||||
@ -396,6 +404,7 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
||||
QMenu *viewMenu = new QMenu(this);
|
||||
viewMenu->setToolTipsVisible(true);
|
||||
viewMenu->addAction(fullScreenAct);
|
||||
viewMenu->addAction(stayOnTopAct);
|
||||
viewMenu->addAction(menuBarAct);
|
||||
|
||||
expandViewAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/expand.svg"),
|
||||
@ -3187,3 +3196,25 @@ void VMainWindow::showNotebookPanel()
|
||||
changePanelView(PanelViewState::VerticalMode);
|
||||
m_naviBox->setCurrentIndex(NAVI_BOX_NOTEBOOKS_IDX, false);
|
||||
}
|
||||
|
||||
void VMainWindow::stayOnTop(bool p_enabled)
|
||||
{
|
||||
bool shown = isVisible();
|
||||
Qt::WindowFlags flags = this->windowFlags();
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
Qt::WindowFlags magicFlag = Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
|
||||
#else
|
||||
Qt::WindowFlags magicFlag = Qt::WindowStaysOnTopHint;
|
||||
#endif
|
||||
|
||||
if (p_enabled) {
|
||||
setWindowFlags(flags | magicFlag);
|
||||
} else {
|
||||
setWindowFlags(flags ^ magicFlag);
|
||||
}
|
||||
|
||||
if (shown) {
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
@ -193,6 +193,8 @@ private slots:
|
||||
// Activate Universal Entry.
|
||||
void activateUniversalEntry();
|
||||
|
||||
void stayOnTop(bool p_enabled);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -223,5 +223,6 @@
|
||||
<file>resources/icons/open_location.svg</file>
|
||||
<file>resources/icons/unstar.svg</file>
|
||||
<file>resources/icons/explore_root.svg</file>
|
||||
<file>resources/icons/stay_on_top.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user