save
This commit is contained in:
parent
821192906e
commit
580457ae12
51
src/librssguard/gui/colortoolbutton.cpp
Normal file
51
src/librssguard/gui/colortoolbutton.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "gui/colortoolbutton.h"
|
||||||
|
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
ColorToolButton::ColorToolButton(QWidget* parent) : QToolButton(parent), m_color(Qt::GlobalColor::black) {
|
||||||
|
connect(this, &ColorToolButton::clicked, this, [this]() {
|
||||||
|
auto new_color = QColorDialog::getColor(m_color, parentWidget(), tr("Select new color"),
|
||||||
|
QColorDialog::ColorDialogOption::DontUseNativeDialog |
|
||||||
|
QColorDialog::ColorDialogOption::ShowAlphaChannel);
|
||||||
|
|
||||||
|
if (new_color.isValid()) {
|
||||||
|
setColor(new_color);
|
||||||
|
emit colorChanged(new_color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor ColorToolButton::color() const {
|
||||||
|
return m_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorToolButton::setColor(const QColor& color) {
|
||||||
|
m_color = color;
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorToolButton::paintEvent(QPaintEvent* e) {
|
||||||
|
Q_UNUSED(e)
|
||||||
|
QPainter p(this);
|
||||||
|
QRect rect(QPoint(0, 0), size());
|
||||||
|
|
||||||
|
if (isEnabled()) {
|
||||||
|
if (underMouse() || isChecked()) {
|
||||||
|
p.setOpacity(0.7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.setOpacity(0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
path.addRoundedRect(QRectF(rect), 3, 3);
|
||||||
|
|
||||||
|
p.fillPath(path, m_color);
|
||||||
|
}
|
27
src/librssguard/gui/colortoolbutton.h
Normal file
27
src/librssguard/gui/colortoolbutton.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef COLORTOOLBUTTON_H
|
||||||
|
#define COLORTOOLBUTTON_H
|
||||||
|
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
class ColorToolButton : public QToolButton {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ColorToolButton(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
QColor color() const;
|
||||||
|
void setColor(const QColor& color);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorChanged(const QColor& new_color);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paintEvent(QPaintEvent* e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COLORTOOLBUTTON_H
|
19
src/librssguard/gui/dialogs/formaddeditlabel.cpp
Normal file
19
src/librssguard/gui/dialogs/formaddeditlabel.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "gui/dialogs/formaddeditlabel.h"
|
||||||
|
|
||||||
|
#include "services/abstract/label.h"
|
||||||
|
|
||||||
|
FormAddEditLabel::FormAddEditLabel(QWidget* parent) : QDialog(parent), ui(new Ui::FormAddEditLabel) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
FormAddEditLabel::~FormAddEditLabel() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
Label* FormAddEditLabel::execForAdd() {
|
||||||
|
auto exit_code = exec();
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
30
src/librssguard/gui/dialogs/formaddeditlabel.h
Normal file
30
src/librssguard/gui/dialogs/formaddeditlabel.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef FORMADDEDITLABEL_H
|
||||||
|
#define FORMADDEDITLABEL_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "ui_formaddeditlabel.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class FormAddEditLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Label;
|
||||||
|
|
||||||
|
class FormAddEditLabel : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FormAddEditLabel(QWidget* parent = nullptr);
|
||||||
|
~FormAddEditLabel();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
Label* execForAdd();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::FormAddEditLabel* ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FORMADDEDITLABEL_H
|
114
src/librssguard/gui/dialogs/formaddeditlabel.ui
Normal file
114
src/librssguard/gui/dialogs/formaddeditlabel.ui
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>FormAddEditLabel</class>
|
||||||
|
<widget class="QDialog" name="FormAddEditLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="widget" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="ColorToolButton" name="toolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LineEditWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lineeditwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ColorToolButton</class>
|
||||||
|
<extends>QToolButton</extends>
|
||||||
|
<header>colortoolbutton.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>FormAddEditLabel</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>FormAddEditLabel</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -21,8 +21,6 @@ class PlainToolButton : public QToolButton {
|
|||||||
void reactOnSenderActionChange();
|
void reactOnSenderActionChange();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Custom look.
|
|
||||||
void paintEvent(QPaintEvent* e);
|
void paintEvent(QPaintEvent* e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -47,9 +47,11 @@ HEADERS += core/feeddownloader.h \
|
|||||||
exceptions/ioexception.h \
|
exceptions/ioexception.h \
|
||||||
gui/baselineedit.h \
|
gui/baselineedit.h \
|
||||||
gui/basetoolbar.h \
|
gui/basetoolbar.h \
|
||||||
|
gui/colortoolbutton.h \
|
||||||
gui/comboboxwithstatus.h \
|
gui/comboboxwithstatus.h \
|
||||||
gui/dialogs/formabout.h \
|
gui/dialogs/formabout.h \
|
||||||
gui/dialogs/formaddaccount.h \
|
gui/dialogs/formaddaccount.h \
|
||||||
|
gui/dialogs/formaddeditlabel.h \
|
||||||
gui/dialogs/formbackupdatabasesettings.h \
|
gui/dialogs/formbackupdatabasesettings.h \
|
||||||
gui/dialogs/formdatabasecleanup.h \
|
gui/dialogs/formdatabasecleanup.h \
|
||||||
gui/dialogs/formmain.h \
|
gui/dialogs/formmain.h \
|
||||||
@ -195,9 +197,11 @@ SOURCES += core/feeddownloader.cpp \
|
|||||||
exceptions/ioexception.cpp \
|
exceptions/ioexception.cpp \
|
||||||
gui/baselineedit.cpp \
|
gui/baselineedit.cpp \
|
||||||
gui/basetoolbar.cpp \
|
gui/basetoolbar.cpp \
|
||||||
|
gui/colortoolbutton.cpp \
|
||||||
gui/comboboxwithstatus.cpp \
|
gui/comboboxwithstatus.cpp \
|
||||||
gui/dialogs/formabout.cpp \
|
gui/dialogs/formabout.cpp \
|
||||||
gui/dialogs/formaddaccount.cpp \
|
gui/dialogs/formaddaccount.cpp \
|
||||||
|
gui/dialogs/formaddeditlabel.cpp \
|
||||||
gui/dialogs/formbackupdatabasesettings.cpp \
|
gui/dialogs/formbackupdatabasesettings.cpp \
|
||||||
gui/dialogs/formdatabasecleanup.cpp \
|
gui/dialogs/formdatabasecleanup.cpp \
|
||||||
gui/dialogs/formmain.cpp \
|
gui/dialogs/formmain.cpp \
|
||||||
@ -325,6 +329,7 @@ mac {
|
|||||||
|
|
||||||
FORMS += gui/dialogs/formabout.ui \
|
FORMS += gui/dialogs/formabout.ui \
|
||||||
gui/dialogs/formaddaccount.ui \
|
gui/dialogs/formaddaccount.ui \
|
||||||
|
gui/dialogs/formaddeditlabel.ui \
|
||||||
gui/dialogs/formbackupdatabasesettings.ui \
|
gui/dialogs/formbackupdatabasesettings.ui \
|
||||||
gui/dialogs/formdatabasecleanup.ui \
|
gui/dialogs/formdatabasecleanup.ui \
|
||||||
gui/dialogs/formmain.ui \
|
gui/dialogs/formmain.ui \
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "services/abstract/labelsnode.h"
|
#include "services/abstract/labelsnode.h"
|
||||||
|
|
||||||
|
#include "gui/dialogs/formaddeditlabel.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
@ -19,9 +20,17 @@ QList<QAction*> LabelsNode::contextMenuFeedsList() {
|
|||||||
if (m_actLabelNew == nullptr) {
|
if (m_actLabelNew == nullptr) {
|
||||||
// Initialize it all.
|
// Initialize it all.
|
||||||
m_actLabelNew = new QAction(qApp->icons()->fromTheme("tag-new"), tr("New label"), this);
|
m_actLabelNew = new QAction(qApp->icons()->fromTheme("tag-new"), tr("New label"), this);
|
||||||
|
|
||||||
|
connect(m_actLabelNew, &QAction::triggered, this, &LabelsNode::createLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QList<QAction*> {
|
return QList<QAction*> {
|
||||||
m_actLabelNew
|
m_actLabelNew
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabelsNode::createLabel() {
|
||||||
|
FormAddEditLabel frm(qApp->mainFormWidget());
|
||||||
|
|
||||||
|
frm.execForAdd();
|
||||||
|
}
|
||||||
|
@ -13,6 +13,9 @@ class LabelsNode : public RootItem {
|
|||||||
|
|
||||||
virtual QList<QAction*> contextMenuFeedsList();
|
virtual QList<QAction*> contextMenuFeedsList();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void createLabel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction* m_actLabelNew;
|
QAction* m_actLabelNew;
|
||||||
};
|
};
|
||||||
|
@ -153,18 +153,18 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>LineEditWithStatus</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>lineeditwithstatus.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>LabelWithStatus</class>
|
<class>LabelWithStatus</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>labelwithstatus.h</header>
|
<header>labelwithstatus.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LineEditWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lineeditwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>m_spinLimitMessages</tabstop>
|
<tabstop>m_spinLimitMessages</tabstop>
|
||||||
|
@ -142,6 +142,7 @@ void StandardServiceRoot::loadFromDatabase() {
|
|||||||
// As the last item, add recycle bin, which is needed.
|
// As the last item, add recycle bin, which is needed.
|
||||||
appendChild(recycleBin());
|
appendChild(recycleBin());
|
||||||
appendChild(importantNode());
|
appendChild(importantNode());
|
||||||
|
appendChild(new LabelsNode(this));
|
||||||
updateCounts(true);
|
updateCounts(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user