mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
change the look of the notebook combobox
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
e77c10df36
commit
0298b8bfe1
@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
QString style = VUtils::readFileFromDisk(":/resources/vnote.qss");
|
||||
if (!style.isEmpty()) {
|
||||
VUtils::processStyle(style);
|
||||
VUtils::processStyle(style, w.getPalette());
|
||||
app.setStyleSheet(style);
|
||||
}
|
||||
|
||||
|
9
src/resources/icons/arrow_dropdown.svg
Normal file
9
src/resources/icons/arrow_dropdown.svg
Normal file
@ -0,0 +1,9 @@
|
||||
<?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" enable-background="new 0 0 512 512" xml:space="preserve">
|
||||
<g>
|
||||
<polygon points="128,192 256,320 384,192 "/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 542 B |
@ -35,3 +35,44 @@ QDockWidget::close-button, QDockWidget::float-button {
|
||||
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
|
||||
background-color: @hover-color;
|
||||
}
|
||||
|
||||
/* QComboBox */
|
||||
QComboBox[OnMainWindow="true"] {
|
||||
border: 1px solid grey;
|
||||
background-color: @base-background;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]:on { /* shift the text when the popup opens */
|
||||
padding-top: 3px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]::drop-down {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: top right;
|
||||
width: 20px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]::down-arrow {
|
||||
image: url(:/resources/icons/arrow_dropdown.svg);
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]::down-arrow:on { /* shift the arrow when popup is open */
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]::item {
|
||||
padding-left: 20px;
|
||||
border: none;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
QComboBox[OnMainWindow="true"]::item:selected {
|
||||
padding-left: 20px;
|
||||
border: none;
|
||||
background-color: @hover-color;
|
||||
}
|
||||
|
@ -87,14 +87,8 @@ QString VUtils::generateImageFileName(const QString &path, const QString &title,
|
||||
return imageName;
|
||||
}
|
||||
|
||||
void VUtils::processStyle(QString &style)
|
||||
void VUtils::processStyle(QString &style, const QVector<QPair<QString, QString> > &varMap)
|
||||
{
|
||||
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];
|
||||
|
@ -19,7 +19,7 @@ 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);
|
||||
static void processStyle(QString &style, const QVector<QPair<QString, QString> > &varMap);
|
||||
static bool isMarkdown(const QString &fileName);
|
||||
static inline QString directoryNameFromPath(const QString& path);
|
||||
static QString fileNameFromPath(const QString &path);
|
||||
@ -28,17 +28,8 @@ public:
|
||||
static void makeDirectory(const QString &path);
|
||||
static ClipboardOpType opTypeInClipboard();
|
||||
static bool copyFile(const QString &p_srcFilePath, const QString &p_destFilePath, bool p_isCut);
|
||||
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));
|
||||
}
|
||||
|
||||
inline QString VUtils::directoryNameFromPath(const QString &path)
|
||||
{
|
||||
return fileNameFromPath(path);
|
||||
|
@ -19,6 +19,7 @@ VMainWindow::VMainWindow(QWidget *parent)
|
||||
setWindowIcon(QIcon(":/resources/icons/vnote.ico"));
|
||||
// Must be called before those who uses VConfigManager
|
||||
vnote = new VNote();
|
||||
vnote->initPalette(palette());
|
||||
initPredefinedColorPixmaps();
|
||||
setupUI();
|
||||
initActions();
|
||||
@ -52,6 +53,7 @@ void VMainWindow::setupUI()
|
||||
notebookInfoBtn->setProperty("OnMainWindow", true);
|
||||
|
||||
notebookComboBox = new QComboBox();
|
||||
notebookComboBox->setProperty("OnMainWindow", true);
|
||||
notebookComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
directoryTree = new VDirectoryTree(vnote);
|
||||
|
||||
@ -821,3 +823,8 @@ void VMainWindow::restoreStateAndGeometry()
|
||||
}
|
||||
toolDock->setVisible(vconfig.getToolsDockChecked());
|
||||
}
|
||||
|
||||
const QVector<QPair<QString, QString> >& VMainWindow::getPalette() const
|
||||
{
|
||||
return vnote->getPallete();
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
#define VMAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVector>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
|
||||
class QLabel;
|
||||
class QComboBox;
|
||||
@ -27,6 +30,7 @@ class VMainWindow : public QMainWindow
|
||||
public:
|
||||
VMainWindow(QWidget *parent = 0);
|
||||
~VMainWindow();
|
||||
const QVector<QPair<QString, QString> > &getPalette() const;
|
||||
|
||||
private slots:
|
||||
void setCurNotebookIndex(int index);
|
||||
|
@ -21,6 +21,17 @@ VNote::VNote() : QObject()
|
||||
emit notebooksChanged(notebooks);
|
||||
}
|
||||
|
||||
void VNote::initPalette(QPalette palette)
|
||||
{
|
||||
m_palette.clear();
|
||||
|
||||
m_palette.append(QPair<QString, QString>("base-background",
|
||||
palette.background().color().name()));
|
||||
m_palette.append(QPair<QString, QString>("base-foreground",
|
||||
palette.background().color().name()));
|
||||
m_palette.append(QPair<QString, QString>("hover-color", "#42A5F5"));
|
||||
}
|
||||
|
||||
void VNote::initTemplate()
|
||||
{
|
||||
if (templateHtml.isEmpty() || preTemplateHtml.isEmpty()
|
||||
|
11
src/vnote.h
11
src/vnote.h
@ -6,7 +6,9 @@
|
||||
#include <QSettings>
|
||||
#include <QFont>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QHash>
|
||||
#include <QPalette>
|
||||
#include "vnotebook.h"
|
||||
|
||||
enum OpenFileMode {Read = 0, Edit};
|
||||
@ -34,6 +36,9 @@ public:
|
||||
|
||||
QString getNotebookPath(const QString &name);
|
||||
|
||||
inline const QVector<QPair<QString, QString> > &getPallete() const;
|
||||
void initPalette(QPalette palette);
|
||||
|
||||
public slots:
|
||||
void updateTemplate();
|
||||
|
||||
@ -48,6 +53,12 @@ signals:
|
||||
private:
|
||||
QVector<VNotebook> notebooks;
|
||||
QHash<QString, QString> notebookPathHash;
|
||||
QVector<QPair<QString, QString> > m_palette;
|
||||
};
|
||||
|
||||
inline const QVector<QPair<QString, QString> >& VNote::getPallete() const
|
||||
{
|
||||
return m_palette;
|
||||
}
|
||||
|
||||
#endif // VNOTE_H
|
||||
|
@ -69,5 +69,6 @@
|
||||
<file>resources/icons/paste.svg</file>
|
||||
<file>resources/icons/dir_item.svg</file>
|
||||
<file>resources/icons/notebook_item.svg</file>
|
||||
<file>resources/icons/arrow_dropdown.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user