mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add vnote.qss for style sheet
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
fe4a2cdcc8
commit
dcc7e6a0f7
@ -1,6 +1,8 @@
|
||||
#include "vmainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextCodec>
|
||||
#include "utils/vutils.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -13,5 +15,11 @@ int main(int argc, char *argv[])
|
||||
VMainWindow w;
|
||||
w.show();
|
||||
|
||||
QString style = VUtils::readFileFromDisk(":/resources/vnote.qss");
|
||||
if (!style.isEmpty()) {
|
||||
VUtils::processStyle(style);
|
||||
app.setStyleSheet(style);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -2,13 +2,9 @@
|
||||
<!-- 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">
|
||||
<g>
|
||||
<path d="M430.1,192H81.9c-17.7,0-18.6,9.2-17.6,20.5l13,183c0.9,11.2,3.5,20.5,21.1,20.5h316.2c18,0,20.1-9.2,21.1-20.5l12.1-185.3
|
||||
C448.7,199,447.8,192,430.1,192z"/>
|
||||
<g>
|
||||
<path d="M426.2,143.3c-0.5-12.4-4.5-15.3-15.1-15.3c0,0-121.4,0-143.2,0c-21.8,0-24.4,0.3-40.9-17.4C213.3,95.8,218.7,96,190.4,96
|
||||
c-22.6,0-75.3,0-75.3,0c-17.4,0-23.6-1.5-25.2,16.6c-1.5,16.7-5,57.2-5.5,63.4h343.4L426.2,143.3z"/>
|
||||
</g>
|
||||
</g>
|
||||
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
|
||||
<path d="M437.334,144H256.006l-42.668-48H74.666C51.197,96,32,115.198,32,138.667v234.666C32,396.802,51.197,416,74.666,416h362.668
|
||||
C460.803,416,480,396.802,480,373.333V186.667C480,163.198,460.803,144,437.334,144z M448,373.333
|
||||
c0,5.782-4.885,10.667-10.666,10.667H74.666C68.884,384,64,379.115,64,373.333V176h373.334c5.781,0,10.666,4.885,10.666,10.667
|
||||
V373.333z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 914 B After Width: | Height: | Size: 850 B |
37
src/resources/vnote.qss
Normal file
37
src/resources/vnote.qss
Normal file
@ -0,0 +1,37 @@
|
||||
QPushButton[OnMainWindow="true"] {
|
||||
padding: 3px;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QPushButton[OnMainWindow="true"]::menu-indicator {
|
||||
image: none;
|
||||
}
|
||||
|
||||
QPushButton[OnMainWindow="true"]::hover {
|
||||
background-color: @hover-color;
|
||||
}
|
||||
|
||||
QToolBar {
|
||||
border: none;
|
||||
}
|
||||
|
||||
QToolButton::hover {
|
||||
background-color: @hover-color;
|
||||
}
|
||||
|
||||
QMenuBar {
|
||||
border: none;
|
||||
}
|
||||
|
||||
QMenuBar::item:selected {
|
||||
background-color: @hover-color;
|
||||
}
|
||||
|
||||
QDockWidget::close-button, QDockWidget::float-button {
|
||||
border: none;
|
||||
}
|
||||
|
||||
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
|
||||
background-color: @hover-color;
|
||||
}
|
@ -76,3 +76,18 @@ QString VUtils::generateImageFileName(const QString &path, const QString &title,
|
||||
}
|
||||
return imageName;
|
||||
}
|
||||
|
||||
void VUtils::processStyle(QString &style)
|
||||
{
|
||||
QVector<QPair<QString, QString> > varMap;
|
||||
|
||||
// Initialize varMap
|
||||
addQssVarToMap(varMap, "base-color", "#4CAF50");
|
||||
addQssVarToMap(varMap, "hover-color", "#42A5F5");
|
||||
|
||||
// Process style
|
||||
for (int i = 0; i < varMap.size(); ++i) {
|
||||
const QPair<QString, QString> &map = varMap[i];
|
||||
style.replace("@" + map.first, map.second);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <QVector>
|
||||
#include <QPair>
|
||||
#include "vconfigmanager.h"
|
||||
|
||||
class VUtils
|
||||
@ -16,6 +18,16 @@ public:
|
||||
static QRgb QRgbFromString(const QString &str);
|
||||
static QString generateImageFileName(const QString &path, const QString &title,
|
||||
const QString &format = "png");
|
||||
static void processStyle(QString &style);
|
||||
private:
|
||||
static inline void addQssVarToMap(QVector<QPair<QString, QString> > &map,
|
||||
const QString &key, const QString &value);
|
||||
};
|
||||
|
||||
inline void VUtils::addQssVarToMap(QVector<QPair<QString, QString> > &map,
|
||||
const QString &key, const QString &value)
|
||||
{
|
||||
map.append(QPair<QString, QString>(key, value));
|
||||
}
|
||||
|
||||
#endif // VUTILS_H
|
||||
|
@ -21,6 +21,7 @@ void VEditArea::setupUI()
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout();
|
||||
mainLayout->addWidget(splitter);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
@ -258,6 +258,7 @@ void VEditTab::updateTocFromHtml(const QString &tocHtml)
|
||||
QVector<VHeader> &headers = tableOfContent.headers;
|
||||
headers.clear();
|
||||
|
||||
if (!tocHtml.isEmpty()) {
|
||||
QXmlStreamReader xml(tocHtml);
|
||||
if (xml.readNextStartElement()) {
|
||||
if (xml.name() == "ul") {
|
||||
@ -270,6 +271,7 @@ void VEditTab::updateTocFromHtml(const QString &tocHtml)
|
||||
qWarning() << "error: fail to parse TOC in HTML";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tableOfContent.filePath = QDir::cleanPath(QDir(noteFile->basePath).filePath(noteFile->fileName));
|
||||
tableOfContent.valid = true;
|
||||
|
@ -42,6 +42,7 @@ void VEditWindow::setupCornerWidget()
|
||||
|
||||
rightBtn = new QPushButton(QIcon(":/resources/icons/corner_menu.svg"),
|
||||
"", this);
|
||||
rightBtn->setProperty("OnMainWindow", true);
|
||||
QMenu *rightMenu = new QMenu(this);
|
||||
rightMenu->addAction(splitAct);
|
||||
rightMenu->addAction(removeSplitAct);
|
||||
@ -54,6 +55,7 @@ void VEditWindow::setupCornerWidget()
|
||||
this, &VEditWindow::tabListJump);
|
||||
leftBtn = new QPushButton(QIcon(":/resources/icons/corner_tablist.svg"),
|
||||
"", this);
|
||||
leftBtn->setProperty("OnMainWindow", true);
|
||||
QMenu *leftMenu = new QMenu(this);
|
||||
leftBtn->setMenu(leftMenu);
|
||||
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
||||
|
@ -20,6 +20,7 @@ void VFileList::setupUI()
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(fileList);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
connect(fileList, &QListWidget::customContextMenuRequested,
|
||||
this, &VFileList::contextMenuRequested);
|
||||
|
@ -42,10 +42,13 @@ void VMainWindow::setupUI()
|
||||
|
||||
newNotebookBtn = new QPushButton(QIcon(":/resources/icons/create_notebook.svg"), "");
|
||||
newNotebookBtn->setToolTip(tr("Create a new notebook"));
|
||||
newNotebookBtn->setProperty("OnMainWindow", true);
|
||||
deleteNotebookBtn = new QPushButton(QIcon(":/resources/icons/delete_notebook.svg"), "");
|
||||
deleteNotebookBtn->setToolTip(tr("Delete current notebook"));
|
||||
deleteNotebookBtn->setProperty("OnMainWindow", true);
|
||||
notebookInfoBtn = new QPushButton(QIcon(":/resources/icons/notebook_info.svg"), "");
|
||||
notebookInfoBtn->setToolTip(tr("View and edit current notebook's information"));
|
||||
notebookInfoBtn->setProperty("OnMainWindow", true);
|
||||
|
||||
notebookComboBox = new QComboBox();
|
||||
notebookComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
@ -57,14 +60,13 @@ void VMainWindow::setupUI()
|
||||
nbBtnLayout->addWidget(newNotebookBtn);
|
||||
nbBtnLayout->addWidget(deleteNotebookBtn);
|
||||
nbBtnLayout->addWidget(notebookInfoBtn);
|
||||
QHBoxLayout *dirBtnLayout = new QHBoxLayout;
|
||||
dirBtnLayout->addWidget(directoryLabel);
|
||||
dirBtnLayout->addStretch();
|
||||
nbBtnLayout->setContentsMargins(0, 0, 0, 0);
|
||||
QVBoxLayout *nbLayout = new QVBoxLayout;
|
||||
nbLayout->addLayout(nbBtnLayout);
|
||||
nbLayout->addWidget(notebookComboBox);
|
||||
nbLayout->addLayout(dirBtnLayout);
|
||||
nbLayout->addWidget(directoryLabel);
|
||||
nbLayout->addWidget(directoryTree);
|
||||
nbLayout->setContentsMargins(5, 0, 0, 0);
|
||||
QWidget *nbContainer = new QWidget();
|
||||
nbContainer->setLayout(nbLayout);
|
||||
nbContainer->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
|
@ -61,5 +61,6 @@
|
||||
<file>resources/icons/create_rootdir_tb.svg</file>
|
||||
<file>resources/icons/vnote.svg</file>
|
||||
<file>resources/icons/vnote.ico</file>
|
||||
<file>resources/vnote.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user