mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-08 22:59:58 +01:00
Include some fonts to QElectroTech
- include Liberation-Fonts and osifont (thanks elevatormind!) - use "Liberation Sans" as default-font - adjust License-Tab in About-Form - Bugfix: When selecting a font, the current font is highlighted in dialog - adjust some whitespace and English comments
This commit is contained in:
@@ -63,13 +63,13 @@ QColor Diagram::background_color = Qt::white;
|
||||
*/
|
||||
Diagram::Diagram(QETProject *project) :
|
||||
QGraphicsScene (project),
|
||||
m_project (project),
|
||||
m_project (project),
|
||||
draw_grid_ (true),
|
||||
use_border_ (true),
|
||||
draw_terminals_ (true),
|
||||
draw_colored_conductors_ (true),
|
||||
m_event_interface (nullptr),
|
||||
m_freeze_new_elements (false),
|
||||
m_event_interface (nullptr),
|
||||
m_freeze_new_elements (false),
|
||||
m_freeze_new_conductors_ (false)
|
||||
{
|
||||
setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
Constructeur / Constructor
|
||||
@param editor L'editeur d'element concerne
|
||||
@param p La partie a editer
|
||||
@param parent le Widget parent
|
||||
@@ -582,17 +582,17 @@ bool StyleEditor::isStyleEditable(QList<CustomElementPart *> cep_list)
|
||||
*/
|
||||
void StyleEditor::activeConnections(bool active) {
|
||||
if (active) {
|
||||
connect (outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
|
||||
connect(line_style, SIGNAL(activated(int)), this, SLOT(updatePartLineStyle()));
|
||||
connect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
|
||||
connect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
|
||||
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||
connect (outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
|
||||
connect(line_style, SIGNAL(activated(int)), this, SLOT(updatePartLineStyle()));
|
||||
connect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
|
||||
connect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
|
||||
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||
} else {
|
||||
disconnect(outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
|
||||
disconnect(line_style, SIGNAL(activated(int)), this, SLOT(updatePartLineStyle()));
|
||||
disconnect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
|
||||
disconnect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
|
||||
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||
disconnect(outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
|
||||
disconnect(line_style, SIGNAL(activated(int)), this, SLOT(updatePartLineStyle()));
|
||||
disconnect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
|
||||
disconnect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
|
||||
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QTextStream>
|
||||
#include <QRegularExpression>
|
||||
#include <QActionGroup>
|
||||
#include <QStringBuilder>
|
||||
|
||||
/**
|
||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||
@@ -403,7 +404,7 @@ QList<QDomElement> QET::findInDomElement(
|
||||
QString QET::license()
|
||||
{
|
||||
// Recuperation du texte de la GNU/GPL dans un fichier integre a l'application
|
||||
QFile *file_license = new QFile(":/LICENSE");
|
||||
QFile *file_license = new QFile(":/licenses/QElectroTech.LICENSE");
|
||||
QString txt_license;
|
||||
// verifie que le fichier existe
|
||||
if (!file_license -> exists()) {
|
||||
@@ -424,6 +425,44 @@ QString QET::license()
|
||||
return(txt_license);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Retrieves the text of a license for a specific component
|
||||
@param name The identifier of the license to retrieve
|
||||
@return A tuple containing <notice_text, license_text> for the requested license
|
||||
|
||||
This function manages licenses for components used in QElectroTech.
|
||||
Currently supported licenses:
|
||||
- QElectroTech itself
|
||||
- QET-Elements
|
||||
- "liberation-fonts": License for Liberation Fonts
|
||||
- "osifont": License for osifont
|
||||
*/
|
||||
std::tuple<QString, QString> QET::licenses(const QString &name)
|
||||
{
|
||||
// Map of supported license identifiers to their resource paths
|
||||
const QMap<QString, QString> licenses = {
|
||||
{"QElectroTech", ":/licenses/QElectroTech"},
|
||||
{"QET-Elements", ":/licenses/QET-Elements"},
|
||||
{"liberation-fonts", ":/fonts/liberation-fonts"},
|
||||
{"osifont", ":/fonts/osifont"}
|
||||
};
|
||||
|
||||
// Get base path for the license files
|
||||
const QString base_path = licenses.value(name);
|
||||
QFile license_file(base_path % QString(".LICENSE"));
|
||||
QFile notice_file(base_path % QString(".NOTICE"));
|
||||
|
||||
// Helper lambda to read file content
|
||||
auto readFile = [](QFile &file) -> QString {
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
QTextStream stream(&file);
|
||||
QString content = stream.readAll();
|
||||
file.close();
|
||||
return content;
|
||||
};
|
||||
|
||||
return std::make_tuple((readFile(notice_file)).trimmed(), readFile(license_file));
|
||||
}
|
||||
|
||||
/**
|
||||
@return la liste des caracteres interdits dans les noms de fichiers sous
|
||||
|
||||
@@ -28,7 +28,8 @@ class QActionGroup;
|
||||
anywhere else within the QElectroTech application.
|
||||
*/
|
||||
namespace QET {
|
||||
QString license();
|
||||
QString license(); // only QETs license
|
||||
std::tuple<QString, QString> licenses(const QString &); // all licenses
|
||||
|
||||
//Describe the current state of a graphic item
|
||||
enum GraphicsItemState {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <iostream>
|
||||
#define QUOTE(x) STRINGIFY(x)
|
||||
#define STRINGIFY(x) #x
|
||||
#include <QFontDatabase>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegularExpression>
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
@@ -111,6 +112,7 @@ QETApp::QETApp() :
|
||||
initConfiguration();
|
||||
initLanguage();
|
||||
QET::Icons::initIcons();
|
||||
initFonts();
|
||||
initStyle();
|
||||
initSplashScreen();
|
||||
initSystemTray();
|
||||
@@ -1234,7 +1236,7 @@ bool QETApp::closeEveryEditor()
|
||||
/**
|
||||
@brief QETApp::diagramTextsFont
|
||||
The font to use
|
||||
By default the font is "Sans Serif" and size 9.
|
||||
By default the font is "Liberation Sans" and size 9.
|
||||
@param size : the size of font
|
||||
@return the font to use
|
||||
*/
|
||||
@@ -1244,13 +1246,14 @@ QFont QETApp::diagramTextsFont(qreal size)
|
||||
|
||||
//Font to use
|
||||
QString diagram_texts_family = settings.value("diagramitemfont",
|
||||
"Sans Serif").toString();
|
||||
"Liberation Sans").toString();
|
||||
qreal diagram_texts_size = settings.value("diagramitemsize",
|
||||
9.0).toDouble();
|
||||
auto diagram_texts_item_weight =
|
||||
static_cast<QFont::Weight>(
|
||||
settings.value("diagramitemweight", QFont::Normal).toInt());
|
||||
QString diagram_texts_item_style = settings.value("diagramitemstyle").toString();
|
||||
QString diagram_texts_item_style = settings.value("diagramitemstyle",
|
||||
"Regular").toString();
|
||||
|
||||
if (size != -1.0) {
|
||||
diagram_texts_size = size;
|
||||
@@ -1276,14 +1279,14 @@ QFont QETApp::diagramTextsItemFont(qreal size)
|
||||
|
||||
//Font to use
|
||||
QString diagram_texts_item_family = settings.value("diagramitemfont",
|
||||
"Sans Serif").toString();
|
||||
"Liberation Sans").toString();
|
||||
qreal diagram_texts_item_size = settings.value("diagramitemsize",
|
||||
9.0).toDouble();
|
||||
auto diagram_texts_item_weight =
|
||||
static_cast<QFont::Weight>(
|
||||
settings.value("diagramitemweight", QFont::Normal).toInt());
|
||||
QString diagram_texts_item_style = settings.value("diagramitemstyle",
|
||||
"normal").toString();
|
||||
"Regular").toString();
|
||||
|
||||
if (size != -1.0) {
|
||||
diagram_texts_item_size = size;
|
||||
@@ -2104,6 +2107,50 @@ void QETApp::initLanguage()
|
||||
setLanguage(langFromSetting());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETApp::initFonts
|
||||
Setup the fonts to use in the application
|
||||
*/
|
||||
void QETApp::initFonts()
|
||||
{
|
||||
QStringList fonts = {
|
||||
|
||||
/** "Liberation Fonts" Font Software is licensed under the SIL Open Font License, Version 1.1
|
||||
|
||||
See the file "fonts/liberation-fonts.LICENSE" for license information. */
|
||||
":/fonts/LiberationMono-Regular.ttf",
|
||||
":/fonts/LiberationMono-Bold.ttf",
|
||||
":/fonts/LiberationMono-Italic.ttf",
|
||||
":/fonts/LiberationMono-BoldItalic.ttf",
|
||||
":/fonts/LiberationSans-Regular.ttf",
|
||||
":/fonts/LiberationSans-Bold.ttf",
|
||||
":/fonts/LiberationSans-Italic.ttf",
|
||||
":/fonts/LiberationSans-BoldItalic.ttf",
|
||||
":/fonts/LiberationSerif-Regular.ttf",
|
||||
":/fonts/LiberationSerif-Bold.ttf",
|
||||
":/fonts/LiberationSerif-Italic.ttf",
|
||||
":/fonts/LiberationSerif-BoldItalic.ttf",
|
||||
|
||||
/** "osifont" Font Software is licensed under the GNU GENERAL PUBLIC LICENSE, Version 3
|
||||
As a special exception, if you create a document which uses this font, and embed this font or unaltered
|
||||
portions of this font into the document, this font does not by itself cause the resulting document to be
|
||||
covered by the GNU General Public License. This exception does not however invalidate any other reasons why
|
||||
the document might be covered by the GNU General Public License. If you modify this font, you may extend
|
||||
this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so,
|
||||
delete this exception statement from your version.
|
||||
|
||||
See the file "fonts/osifont.LICENSE" for license information. */
|
||||
":/fonts/osifont.ttf",
|
||||
":/fonts/osifont-italic.ttf",
|
||||
};
|
||||
|
||||
for (const QString &font : fonts) {
|
||||
if (QFontDatabase::addApplicationFont(font) == -1) {
|
||||
qWarning() << "Failed to load font:" << font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETApp::initStyle
|
||||
Setup the gui style
|
||||
|
||||
@@ -281,6 +281,7 @@ class QETApp : public QObject
|
||||
void initSplashScreen();
|
||||
void setSplashScreenStep(const QString & = QString());
|
||||
void initLanguage();
|
||||
void initFonts();
|
||||
void initStyle();
|
||||
void initConfiguration();
|
||||
void initSystemTray();
|
||||
|
||||
@@ -540,8 +540,8 @@ void QETDiagramEditor::setUpActions()
|
||||
//Files action
|
||||
QAction *new_file = m_file_actions_group.addAction(QET::Icons::ProjectNew, tr("&Nouveau"));
|
||||
QAction *open_file = m_file_actions_group.addAction(QET::Icons::DocumentOpen, tr("&Ouvrir"));
|
||||
m_save_file = m_file_actions_group.addAction(QET::Icons::DocumentSave, tr("&Enregistrer"));
|
||||
m_save_file_as = m_file_actions_group.addAction(QET::Icons::DocumentSaveAs, tr("Enregistrer sous"));
|
||||
m_save_file = m_file_actions_group.addAction(QET::Icons::DocumentSave, tr("&Enregistrer"));
|
||||
m_save_file_as = m_file_actions_group.addAction(QET::Icons::DocumentSaveAs, tr("Enregistrer sous"));
|
||||
m_close_file = m_file_actions_group.addAction(QET::Icons::ProjectClose, tr("&Fermer"));
|
||||
|
||||
new_file ->setShortcut(QKeySequence::New);
|
||||
|
||||
@@ -41,7 +41,7 @@ AboutQETDialog::AboutQETDialog(QWidget *parent) :
|
||||
setVersion();
|
||||
setAnnexProject();
|
||||
setLibraries();
|
||||
setLicence();
|
||||
setLicenses();
|
||||
setLoginfo();
|
||||
}
|
||||
|
||||
@@ -195,11 +195,14 @@ void AboutQETDialog::setLibraries()
|
||||
}
|
||||
|
||||
/**
|
||||
@brief AboutQETDialog::setLicence
|
||||
@brief AboutQETDialog::setLicenses
|
||||
*/
|
||||
void AboutQETDialog::setLicence()
|
||||
void AboutQETDialog::setLicenses()
|
||||
{
|
||||
ui->m_license_text_edit->setPlainText(QET::license());
|
||||
ui->m_licenses_comboBox->addItem("QElectroTech");
|
||||
ui->m_licenses_comboBox->addItem("QET-Elements");
|
||||
ui->m_licenses_comboBox->addItem("liberation-fonts");
|
||||
ui->m_licenses_comboBox->addItem("osifont");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,6 +260,32 @@ void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QStrin
|
||||
label->setText(new_text);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Updates the displayed license text when a different one is selected
|
||||
|
||||
This slot is called when the user selects a different license in the
|
||||
licenses combo box. It retrieves the selected license text from QET's
|
||||
license collection and displays it in the text edit widgets.
|
||||
|
||||
@param license_name The identifier of the selected license
|
||||
*/
|
||||
void AboutQETDialog::on_m_licenses_comboBox_currentTextChanged(
|
||||
const QString &license_name)
|
||||
{
|
||||
std::tuple<QString, QString> license_info = QET::licenses(license_name);
|
||||
ui->m_licenses_notice_plainTextEdit->setPlainText(std::get<0>(license_info));
|
||||
ui->m_licenses_license_plainTextEdit->setPlainText(std::get<1>(license_info));
|
||||
//adjust height of notice-field:
|
||||
int LineCount = ui->m_licenses_notice_plainTextEdit->blockCount();
|
||||
if (LineCount <= 4) {
|
||||
QFontMetrics qfm (ui->m_licenses_notice_plainTextEdit->font());
|
||||
int LineHeight = qfm.lineSpacing();
|
||||
ui->m_licenses_notice_plainTextEdit->setMaximumHeight((LineCount + 1) * LineHeight);
|
||||
} else {
|
||||
ui->m_licenses_notice_plainTextEdit->setMaximumHeight(16777215);
|
||||
}
|
||||
}
|
||||
|
||||
void AboutQETDialog::on_m_log_comboBox_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QFile log_File(arg1);
|
||||
|
||||
@@ -46,7 +46,7 @@ class AboutQETDialog : public QDialog
|
||||
void setVersion();
|
||||
void setAnnexProject();
|
||||
void setLibraries();
|
||||
void setLicence();
|
||||
void setLicenses();
|
||||
void setLoginfo();
|
||||
void addAuthor(
|
||||
QLabel *label,
|
||||
@@ -58,6 +58,7 @@ class AboutQETDialog : public QDialog
|
||||
const QString &link);
|
||||
|
||||
private slots:
|
||||
void on_m_licenses_comboBox_currentTextChanged(const QString &arg1);
|
||||
void on_m_log_comboBox_currentTextChanged(const QString &arg1);
|
||||
};
|
||||
|
||||
|
||||
@@ -503,20 +503,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_6">
|
||||
<widget class="QWidget" name="tab_9">
|
||||
<attribute name="title">
|
||||
<string>Accord de licence</string>
|
||||
<string>Licenses</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_license_label">
|
||||
<property name="text">
|
||||
<string>Ce programme est sous licence GNU/GPL.</string>
|
||||
<widget class="QComboBox" name="m_licenses_comboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="m_licenses_notice_plainTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="m_license_text_edit">
|
||||
<widget class="QPlainTextEdit" name="m_licenses_license_plainTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
@@ -87,13 +87,11 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
ui->m_border_0->setChecked(settings.value("border-columns_0", false).toBool());
|
||||
ui->m_autosave_sb->setValue(settings.value("diagrameditor/autosave-interval", 0).toInt());
|
||||
|
||||
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
||||
settings.value("diagramitemsize").toString() + " (" +
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
QString fontInfos = settings.value("diagramitemfont", "Liberation Sans").toString() + " " +
|
||||
settings.value("diagramitemsize", "9").toString() + " (" +
|
||||
settings.value("diagramitemstyle", "Regular").toString() + ")";
|
||||
ui->m_font_pb->setText(fontInfos);
|
||||
|
||||
|
||||
|
||||
|
||||
//Dynamic element text item
|
||||
ui->m_dyn_text_rotation_sb->setValue(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt());
|
||||
@@ -107,7 +105,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
font.styleName() + ")";
|
||||
ui->m_dyn_text_font_pb->setText(fontInfos);
|
||||
}
|
||||
} else { ui->m_dyn_text_font_pb->setText("Liberation Sans 9 (Regular)"); }
|
||||
|
||||
//Independent text item
|
||||
ui->m_indi_text_rotation_sb->setValue(settings.value("diagrameditor/independent_text_rotation",0).toInt());
|
||||
@@ -120,7 +118,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
font.styleName() + ")";
|
||||
ui->m_indi_text_font_pb->setText(fontInfos);
|
||||
}
|
||||
} else { ui->m_indi_text_font_pb->setText("Liberation Sans 9 (Regular)"); }
|
||||
|
||||
ui->m_highlight_integrated_elements->setChecked(settings.value("diagrameditor/highlight-integrated-elements", true).toBool());
|
||||
ui->m_default_elements_info->setPlainText(settings.value("elementeditor/default-informations", "").toString());
|
||||
@@ -266,7 +264,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
if (path != settings.value("elements-collections/common-collection-path").toString()) {
|
||||
QETApp::resetCollectionsPath();
|
||||
}
|
||||
|
||||
|
||||
path = settings.value("elements-collections/company-collection-path").toString();
|
||||
if (ui->m_company_elmt_path_cb->currentIndex() == 1)
|
||||
{
|
||||
@@ -405,7 +403,10 @@ void GeneralConfigurationPage::on_m_font_pb_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont font = QFontDialog::getFont(&ok, QFont("Sans Serif", 9), this);
|
||||
QFont curFont = QFont(settings.value("diagramitemfont", "Liberation Sans").toString());
|
||||
curFont.setPointSizeF(settings.value("diagramitemsize", "9").toInt());
|
||||
curFont.setStyleName (settings.value("diagramitemstyle", "Regular").toString());
|
||||
QFont font = QFontDialog::getFont(&ok, curFont, this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("diagramitemfont", font.family());
|
||||
@@ -427,7 +428,9 @@ void GeneralConfigurationPage::on_m_dyn_text_font_pb_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont font = QFontDialog::getFont(&ok, QFont("Sans Serif", 9), this);
|
||||
QFont curFont;
|
||||
curFont.fromString(settings.value("diagrameditor/dynamic_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QFont font = QFontDialog::getFont(&ok, curFont, this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("diagrameditor/dynamic_text_font", font.toString());
|
||||
@@ -516,7 +519,9 @@ void GeneralConfigurationPage::on_m_indi_text_font_pb_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont font = QFontDialog::getFont(&ok, QFont("Sans Serif", 9), this);
|
||||
QFont curFont;
|
||||
curFont.fromString(settings.value("diagrameditor/independent_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QFont font = QFontDialog::getFont(&ok, curFont, this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("diagrameditor/independent_text_font", font.toString());
|
||||
|
||||
Reference in New Issue
Block a user