Added new tool 'Crapnote'

This commit is contained in:
Valentino Orlandi 2022-08-18 20:56:06 +02:00
parent 63b3d97baf
commit f9623e96c6
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
3 changed files with 286 additions and 0 deletions

View File

@ -0,0 +1,78 @@
#include "crapnote.h"
#include "ui_crapnote.h"
#include "modules/exceptions.h"
Crapnote::Crapnote(QWidget *parent) :
QWidget(parent),
ui(new Ui::Crapnote)
{
ui->setupUi(this);
}
Crapnote::~Crapnote()
{
delete ui;
}
void Crapnote::setTextFont( const QFont& font )
{
QFont f = QFont( font );
f.setPointSize( this->font_size );
this->ui->textEdit->setFont( f );
}
void Crapnote::setColorScheme( const int& scheme_id )
{
QColor b, t;
// update the colors palette
switch ( scheme_id ) {
case 0:
this->ui->textEdit->setPalette( QPalette() );
break;
case 1:
// breeze
b = QColor(255,198,102);
t = QColor(31,28,27);
this->ui->textEdit->setPalette( QPalette(t,b,b,b,b,t,b) );
break;
case 2:
// monokai
b = QColor(166,226,46);
t = QColor(39,40,34);
this->ui->textEdit->setPalette( QPalette(t,b,b,b,b,t,b) );
break;
case 3:
// radical
b = QColor(20,19,34);
t = QColor(213,53,143);
this->ui->textEdit->setPalette( QPalette(t,b,b,b,b,t,b) );
break;
default:
// wrong
throw GenericException( "Unexpected ColorScheme ID for Crapnote: "+std::to_string( scheme_id ) );
}
}
void Crapnote::on_spinBox_FontSize_valueChanged(int arg1)
{
this->font_size = arg1;
this->setTextFont( this->ui->textEdit->font() );
}
void Crapnote::on_button_FontSize_Minus_clicked()
{
this->ui->spinBox_FontSize->setValue( this->font_size-1 );
}
void Crapnote::on_button_FontSize_Plus_clicked()
{
this->ui->spinBox_FontSize->setValue( this->font_size+1 );
}

View File

@ -0,0 +1,34 @@
#ifndef CRAPNOTE_H
#define CRAPNOTE_H
#include <QWidget>
namespace Ui {
class Crapnote;
}
class Crapnote : public QWidget
{
Q_OBJECT
public:
explicit Crapnote(QWidget *parent = nullptr);
~Crapnote();
void setTextFont( const QFont& font );
void setColorScheme( const int& color_scheme_id );
private slots:
void on_spinBox_FontSize_valueChanged(int arg1);
void on_button_FontSize_Minus_clicked();
void on_button_FontSize_Plus_clicked();
private:
Ui::Crapnote *ui;
int font_size = 17;
};
#endif // CRAPNOTE_H

View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Crapnote</class>
<widget class="QWidget" name="Crapnote">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">LogDoctor - BlockNote</string>
</property>
<property name="windowIcon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/logo/logo/logdoctor.svg</normaloff>:/logo/logo/logdoctor.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame_Font">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>203</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_FontSize_Minus">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="toolTip">
<string>Reduce the font size</string>
</property>
<property name="text">
<string notr="true"></string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_FontSize">
<property name="minimumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Font size</string>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>17</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_FontSize_Plus">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="toolTip">
<string>Increase the font size</string>
</property>
<property name="text">
<string notr="true"></string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>203</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_Note">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>16</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>16</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property>
<item row="0" column="0">
<widget class="QTextEdit" name="textEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>