Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
terroo committed Feb 6, 2021
1 parent d6e820a commit 7ed03fd
Show file tree
Hide file tree
Showing 48 changed files with 4,374 additions and 0 deletions.
59 changes: 59 additions & 0 deletions TerminalFinances.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
QT += core gui sql printsupport

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = terminal-finances

TEMPLATE = app

SOURCES += \
accountslist.cpp \
filesave.cpp \
gendoc.cpp \
initial.cpp \
main.cpp \
model.cpp \
start.cpp \
terminalfinances.cpp \
tools.cpp \
updatefields.cpp \
views.cpp

HEADERS += \
accountslist.h \
filesave.h \
gendoc.h \
initial.h \
model.h \
start.h \
terminalfinances.h \
tools.h \
updatefields.h \
views.h

FORMS += \
terminalfinances.ui \
updatefields.ui

TRANSLATIONS += \
terminalfinances/TerminalFinances_en_US.ts \
terminalfinances/TerminalFinances_es_ES.ts

CONFIG+=lrelease

shortcut.path = /usr/share/applications
shortcut.files = terminal-finances.desktop

images.path = /usr/share/pixmaps
images.files = assets/terminal-finances

configs.path = /etc/xdg
configs.files = terminalfinances

trans.path = = /etc/xdg/terminalfinances
trans.commands = @mv .qm/* /etc/xdg/terminalfinances

target.path = /usr/local/bin

INSTALLS += target shortcut images configs trans

268 changes: 268 additions & 0 deletions TerminalFinances.pro.user

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions accountslist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "accountslist.h"

AccountsList::AccountsList(QWidget *parent) : QWidget(parent){}

QStringList AccountsList::m_accounts( int z){
Views v;
QStringList adds;
adds << v.m_msg[37] << v.m_msg[38] << v.m_msg[39] << v.m_msg[40] ;
QStringList dels;
dels << v.m_msg[41] << v.m_msg[42] << v.m_msg[43] << v.m_msg[44] << v.m_msg[45] << v.m_msg[46] ;
return ( z == 0 ? adds : dels );
}
15 changes: 15 additions & 0 deletions accountslist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef ACCOUNTSLIST_H
#define ACCOUNTSLIST_H

#include <QWidget>
#include "views.h"

class AccountsList : public QWidget {
Q_OBJECT
public:
explicit AccountsList(QWidget *parent = nullptr);
QStringList m_accounts(int);
signals:
};

#endif // ACCOUNTSLIST_H
Binary file added assets/terminal-finances/balance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/db.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/es.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/mail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/pt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/send-credit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/send-debit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/spreadsheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/tab3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/terminal-finances/terminal-finances.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions filesave.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "filesave.h"

FileSave::FileSave(QWidget *parent) : QWidget(parent){}

bool FileSave::m_file_exists(QString path){
QFileInfo check_file(path);

return (check_file.exists() && check_file.isFile());
}

void FileSave::m_save_file( QString content ){
Views v;
QFile file( m_filename );
if ( m_file_exists( m_filename ) ){
if( !file.remove() ){
qDebug() << v.m_msg[47];
}
}
if( ! file.open(QFile::ReadWrite|QFile::Text)){
QMessageBox::critical( this, v.m_msg[48], v.m_msg[49] );
return;
}
QTextStream out_file( &file );
out_file << content << '\n';
file.flush();
file.close();
}

QString FileSave::m_save_content(){
Views v;
QString str {};
QFile file( m_filename );
if( ! file.open(QFile::ReadOnly|QFile::Text)){
qDebug() << v.m_msg[50];
str = v.m_msg[14];
}else{
QTextStream out_file( &file );
str = out_file.read( 9999999999 );
file.flush();
file.close();
}
return str;
}

24 changes: 24 additions & 0 deletions filesave.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef FILESAVE_H
#define FILESAVE_H

#include <QWidget>
#include <QFileInfo>
#include <QFile>
#include <QDebug>
#include <QMessageBox>
#include <QProcess>
#include "views.h"

class FileSave : public QWidget{
Q_OBJECT
public:
explicit FileSave(QWidget *parent = nullptr);
void m_save_file( QString );
bool m_file_exists( QString );
QString m_filename = "/tmp/reports-finances.html";
QString m_save_content();
signals:

};

#endif // FILESAVE_H
64 changes: 64 additions & 0 deletions gendoc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "gendoc.h"

GenDoc::GenDoc(QWidget *parent) : QWidget(parent){}

const QString GenDoc::m_gen_tags( QStringList result ){
Tools t;
Initial z;
Views v;
QString combo_month = result[0], combo_year = result[1], total_cred = result[2], total_deb = result[3], balance_color = result[4], balance_string = result[5];
if( combo_month == v.m_msg[3] && combo_year == v.m_msg[3] ){ combo_month = ""; combo_year = ""; };
QString result_r = "<style>"
"div {text-align:center!important}"
".table{width:100%;margin-bottom:1rem;color:#212529;background:#fff;}"
".table td,.table th{padding:2px;vertical-align:top;border-top:1px solid #a9aeb4}"
".table thead th{vertical-align:bottom;border-bottom:2px solid #dee2e6}"
".table tbody+tbody{border-top:2px solid #dee2e6}"
".table-bordered{border:1px solid #dee2e6}"
".table-bordered td,.table-bordered th{border:1px solid #a9aeb4}"
".table-bordered thead td,.table-bordered thead th{border-bottom-width:2px}"
".container,.container-fluid{width:100%;padding-right:3px;padding-left:3px;margin-right:auto;margin-left:auto}"
".text-center{text-align:center!important}"
".success {color:#1e7e34;}.danger{color:#a71d2a}"
"h2 {font-weight:500;line-height:1.2}"
".container {max-width:1000px;}"
"</style>"
"<div class='container'>"
"<table class='table table-bordered'>"
"<thead>"
"<tr><th colspan='6'><h2>" + combo_month.toUpper() + " " + combo_year.toUpper() + "</h2></th></tr>"
"<tr><th colspan='2'>" + v.m_msg[51] + z.m_currency.leftJustified(6, ' ') + " <strong class='success'>" + t.m_currency( total_cred ) + "</strong> </th>"
"<th colspan='1'>" + v.m_msg[52] + z.m_currency.leftJustified(6, ' ') + " <strong class='danger'>" + t.m_currency( total_deb ) + "</strong> </th> "
"<th colspan='3' class='text-center'>" + v.m_msg[53] + z.m_currency.leftJustified(6, ' ') + " <strong style='color: " + balance_color + "'>" + t.m_currency( balance_string ) + "</strong></th>"
"<tr>"
"<th>" + v.m_msg[54] + "</th>"
"<th>" + v.m_msg[28] + "</th>"
"<th>" + v.m_msg[55] + "</th>"
"<th>" + v.m_msg[27] + "</th>"
"<th>" + v.m_msg[25] + "</th>"
"<th>" + v.m_msg[24] + "</th>"
"</tr>"
"</thead>"
"<tbody>";
return result_r;
}

void GenDoc::m_set_t(){
m_t << "<tr>" << "<td>" << "</td>" << "</tr>" <<
"</tbody></table></div>" << "</div>" <<
"<div style='max-width:1200px;margin:auto;'>" <<
"background: #fff;color:#000;border:1px solid #2D3037;text-align:center;";
}

const QStringList GenDoc::m_gen_color(){
Views v;
const QStringList r = {
"#1e7e34", v.m_msg[56], v.m_msg[57],
"color:#00b5ad;text-align:center;", "#57B4C0",
v.m_msg[58], v.m_msg[59],
"color: #2D3037;text-align:center;", "#a71d2a",
v.m_msg[60] , v.m_msg[61],
"color: #ef325a;text-align:center;"
};
return r;
}
22 changes: 22 additions & 0 deletions gendoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef GENDOC_H
#define GENDOC_H

#include <QWidget>
#include "tools.h"
#include "initial.h"
#include "views.h"

class GenDoc : public QWidget
{
Q_OBJECT
public:
explicit GenDoc(QWidget *parent = nullptr);
const QString m_gen_tags( QStringList );
const QStringList m_gen_color();
QStringList m_t;
void m_set_t();
signals:

};

#endif // GENDOC_H
64 changes: 64 additions & 0 deletions initial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "initial.h"

Initial::Initial(QWidget *parent) : QWidget(parent){}

bool Initial::m_check_file(){
QFileInfo local_file( m_path_file );
if( local_file.exists() ){
m_read_file();
}else{
QDir().mkpath( m_dir );
m_file_create();
}
return true;
}

void Initial::m_file_create(){
QFile file( m_path_file );
QTextStream out_file( &file );
m_set_content();
file.open(QFile::ReadWrite|QFile::Text);
out_file << m_content << '\n';
file.flush();
file.close();
}

void Initial::m_set_content(){
QString content = "# --------------------------------\n"
"# Terminal Finances 1.0.0\n"
"# Developed by Marcos Oliveira\n"
"# <https://terminalroot.com.br/>\n"
"# --------------------------------\n"
"lang = " + m_lang + "\n"
"theme = " + m_theme + "\n"
"currency = " + m_currency;
m_content = content;
}

void Initial::m_read_file(){
QFile inputFile( m_path_file );
if(inputFile.open( QFile::ReadOnly | QFile::Text )){
QTextStream content(&inputFile);
while ( ! content.atEnd() ){

QString line = content.readLine();
line.replace(" ", "");
//line.remove('#');
QStringList fullline = line.split('=');

if( fullline.first() == "lang" ){
m_lang = fullline.last();
}

if( fullline.first() == "theme" ){
m_theme = fullline.last();
}

if( fullline.first() == "currency" ){
m_currency = fullline.last();
}

}
}
inputFile.close();
}
33 changes: 33 additions & 0 deletions initial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef INITIAL_H
#define INITIAL_H

#include <QWidget>
#include <QDir>
#include <QFileInfo>
#include <QFile>
#include <QProcess>
#include <QDebug>

class Initial : public QWidget{
Q_OBJECT
public:
explicit Initial(QWidget *parent = nullptr);
const QString m_home = qgetenv("HOME"),
m_file_ini = "config.ini",
m_dir = m_home + "/.config/terminalfinances",
m_path_file = m_dir + "/" + m_file_ini,
m_en = "/etc/xdg/terminalfinances/TerminalFinances_en_US.qm",
m_es = "/etc/xdg/terminalfinances/TerminalFinances_en_US.qm";

QString m_content, m_lang = "pt", m_theme = "light",
m_get_lang = qgetenv("LANG"), m_currency = "R$";

bool m_check_file();
void m_file_create();
void m_set_content();
void m_read_file();
signals:

};

#endif // INITIAL_H
26 changes: 26 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "terminalfinances.h"
#include <QApplication>
#include "initial.h"
#include <QTranslator>
#include <QMessageBox>

int main(int argc, char ** argv ){
QApplication a(argc, argv);
Initial z;
QTranslator t;
z.m_check_file();

if( z.m_lang == "en" ){
t.load( z.m_en );
}else if( z.m_lang == "es" ){
t.load( z.m_es );
}

if( z.m_lang != "pt" ){
a.installTranslator( &t );
}

TerminalFinances w;
w.show();
return a.exec();
}
Loading

0 comments on commit 7ed03fd

Please sign in to comment.