Merge pull request #986 from manongjohn/ot_patches_misc2_and_linux_fix
OpenToonz patches and Linux font size fix
This commit is contained in:
commit
a05b3e7fb2
13 changed files with 187 additions and 34 deletions
|
@ -310,7 +310,7 @@ QMenu {
|
|||
}
|
||||
QMenu::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #a35293;
|
||||
|
|
|
@ -310,7 +310,7 @@ QMenu {
|
|||
}
|
||||
QMenu::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #a35293;
|
||||
|
|
|
@ -310,7 +310,7 @@ QMenu {
|
|||
}
|
||||
QMenu::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #d97fbe;
|
||||
|
|
|
@ -310,7 +310,7 @@ QMenu {
|
|||
}
|
||||
QMenu::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #a35293;
|
||||
|
|
|
@ -140,7 +140,7 @@ QMenu {
|
|||
padding: 2 0;
|
||||
&::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
&:selected {
|
||||
background-color: @menu-item-bg-color-selected;
|
||||
color: @menu-item-text-color-selected;
|
||||
|
|
|
@ -310,7 +310,7 @@ QMenu {
|
|||
}
|
||||
QMenu::item {
|
||||
border: 0;
|
||||
padding: 3 28;
|
||||
padding: 3 28 3 8;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #c16099;
|
||||
|
|
|
@ -200,7 +200,10 @@ public:
|
|||
QStringList getLanguageList() const { return m_languageList; }
|
||||
QMap<int, QString> getRoomMap() const { return m_roomMaps; }
|
||||
|
||||
QString getCurrentStyleSheetPath() const; // OK
|
||||
QString getCurrentStyleSheet() const;
|
||||
QString getAdditionalStyleSheet() const {
|
||||
return getStringValue(additionalStyleSheet);
|
||||
}
|
||||
bool getPixelsOnly() const { return getBoolValue(pixelsOnly); }
|
||||
QString getOldUnits() const { return getStringValue(oldUnits); }
|
||||
QString getOldCameraUnits() const { return getStringValue(oldCameraUnits); }
|
||||
|
|
|
@ -24,6 +24,7 @@ enum PreferencesItemId {
|
|||
//----------
|
||||
// Interface
|
||||
CurrentStyleSheetName,
|
||||
additionalStyleSheet,
|
||||
iconTheme,
|
||||
pixelsOnly,
|
||||
oldUnits,
|
||||
|
|
|
@ -339,10 +339,10 @@ int main(int argc, char *argv[]) {
|
|||
QApplication a(argc, argv);
|
||||
|
||||
#ifdef MACOSX
|
||||
// This workaround is to avoid missing left button problem on Qt5.6.0.
|
||||
// To invalidate m_rightButtonClicked in Qt/qnsview.mm, sending
|
||||
// NSLeftButtonDown event before NSLeftMouseDragged event propagated to
|
||||
// QApplication. See more details in ../mousedragfilter/mousedragfilter.mm.
|
||||
// This workaround is to avoid missing left button problem on Qt5.6.0.
|
||||
// To invalidate m_rightButtonClicked in Qt/qnsview.mm, sending
|
||||
// NSLeftButtonDown event before NSLeftMouseDragged event propagated to
|
||||
// QApplication. See more details in ../mousedragfilter/mousedragfilter.mm.
|
||||
|
||||
#include "mousedragfilter.h"
|
||||
|
||||
|
@ -762,7 +762,7 @@ int main(int argc, char *argv[]) {
|
|||
a.processEvents();
|
||||
|
||||
// Carico lo styleSheet
|
||||
QString currentStyle = Preferences::instance()->getCurrentStyleSheetPath();
|
||||
QString currentStyle = Preferences::instance()->getCurrentStyleSheet();
|
||||
a.setStyleSheet(currentStyle);
|
||||
|
||||
// Perspective grid tool - custom grid
|
||||
|
|
|
@ -3310,12 +3310,8 @@ class ReloadStyle final : public MenuItemHandler {
|
|||
public:
|
||||
ReloadStyle() : MenuItemHandler("MI_ReloadStyle") {}
|
||||
void execute() override {
|
||||
QString currentStyle = Preferences::instance()->getCurrentStyleSheetPath();
|
||||
QFile file(currentStyle);
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QString(file.readAll());
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
file.close();
|
||||
QString currentStyle = Preferences::instance()->getCurrentStyleSheet();
|
||||
qApp->setStyleSheet(currentStyle);
|
||||
}
|
||||
} reloadStyle;
|
||||
|
||||
|
|
|
@ -355,6 +355,53 @@ PreferencesPopup::Display30bitChecker::~Display30bitChecker() {
|
|||
QSurfaceFormat::setDefaultFormat(m_currentDefaultFormat);
|
||||
}
|
||||
|
||||
//**********************************************************************************
|
||||
// PreferencesPopup::AdditionalStyleEdit implementation
|
||||
//**********************************************************************************
|
||||
|
||||
PreferencesPopup::AdditionalStyleEdit::AdditionalStyleEdit(
|
||||
PreferencesPopup* parent)
|
||||
: DVGui::Dialog(parent, true, false, "AdditionalStyleEdit") {
|
||||
setWindowTitle(tr("Additional Style Sheet"));
|
||||
setModal(true);
|
||||
|
||||
m_edit = new QTextEdit(this);
|
||||
QPushButton* okButton = new QPushButton(tr("OK"), this);
|
||||
QPushButton* applyButton = new QPushButton(tr("Apply"), this);
|
||||
QPushButton* closeButton = new QPushButton(tr("Close"), this);
|
||||
|
||||
QString placeHolderTxt(
|
||||
"/* Type additional style sheet here to customize GUI. \n"
|
||||
" Example: To enlarge the Style Editor buttons */\n\n"
|
||||
"#StyleEditor #bottomWidget QPushButton{ \n padding : 13 21; \n }");
|
||||
m_edit->setPlaceholderText(placeHolderTxt);
|
||||
m_edit->setAcceptRichText(false);
|
||||
|
||||
m_topLayout->addWidget(m_edit);
|
||||
|
||||
addButtonBarWidget(okButton, applyButton, closeButton);
|
||||
|
||||
bool ret = true;
|
||||
ret = ret && connect(okButton, SIGNAL(pressed()), this, SLOT(onOK()));
|
||||
ret = ret && connect(applyButton, SIGNAL(pressed()), this, SLOT(onApply()));
|
||||
ret = ret && connect(closeButton, SIGNAL(pressed()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void PreferencesPopup::AdditionalStyleEdit::showEvent(QShowEvent*) {
|
||||
m_edit->setPlainText(Preferences::instance()->getAdditionalStyleSheet());
|
||||
}
|
||||
|
||||
void PreferencesPopup::AdditionalStyleEdit::onOK() {
|
||||
onApply();
|
||||
close();
|
||||
}
|
||||
|
||||
void PreferencesPopup::AdditionalStyleEdit::onApply() {
|
||||
Preferences::instance()->setValue(additionalStyleSheet,
|
||||
m_edit->toPlainText());
|
||||
emit additionalSheetEdited();
|
||||
}
|
||||
|
||||
//**********************************************************************************
|
||||
// PreferencesPopup implementation
|
||||
//**********************************************************************************
|
||||
|
@ -437,14 +484,16 @@ void PreferencesPopup::onPathAliasPriorityChanged() {
|
|||
|
||||
void PreferencesPopup::onStyleSheetTypeChanged() {
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
QString currentStyle = m_pref->getCurrentStyleSheetPath();
|
||||
QString currentStyle = m_pref->getCurrentStyleSheet();
|
||||
QString iconThemeName = QIcon::themeName();
|
||||
std::string styleString = currentStyle.toStdString();
|
||||
std::string iconThemeString = iconThemeName.toStdString();
|
||||
qApp->setStyleSheet(currentStyle);
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
if (currentStyle.contains("Light") || currentStyle.contains("Neutral")) {
|
||||
if (currentStyle.contains("file:///") && (currentStyle.contains("Light") ||
|
||||
currentStyle.contains("Neutral")) ||
|
||||
currentStyle.contains("imgs/black")) {
|
||||
m_pref->setValue(iconTheme, true);
|
||||
if (iconThemeName != "dark") {
|
||||
// QIcon::setThemeName(Preferences::instance()->getIconTheme() ? "dark"
|
||||
|
@ -741,6 +790,25 @@ void PreferencesPopup::onAutoSavePeriodExternallyChanged() {
|
|||
//}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onEditAdditionalStyleSheet() {
|
||||
if (!m_additionalStyleEdit) {
|
||||
m_additionalStyleEdit = new AdditionalStyleEdit(this);
|
||||
|
||||
bool ret = connect(m_additionalStyleEdit, SIGNAL(additionalSheetEdited()),
|
||||
this, SLOT(onAdditionalStyleSheetEdited()));
|
||||
assert(ret);
|
||||
}
|
||||
m_additionalStyleEdit->show();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onAdditionalStyleSheetEdited() {
|
||||
onStyleSheetTypeChanged();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onPixelUnitExternallySelected(bool on) {
|
||||
CheckBox* pixelsOnlyCB = getUI<CheckBox*>(pixelsOnly);
|
||||
// call slot function onPixelsOnlyChanged() accordingly
|
||||
|
@ -1405,7 +1473,9 @@ inline T PreferencesPopup::getUI(PreferencesItemId id) {
|
|||
//**********************************************************************************
|
||||
|
||||
PreferencesPopup::PreferencesPopup()
|
||||
: QDialog(TApp::instance()->getMainWindow()), m_formatProperties() {
|
||||
: QDialog(TApp::instance()->getMainWindow())
|
||||
, m_formatProperties()
|
||||
, m_additionalStyleEdit(nullptr) {
|
||||
setWindowTitle(tr("Preferences"));
|
||||
setObjectName("PreferencesPopup");
|
||||
|
||||
|
@ -1585,12 +1655,16 @@ QWidget* PreferencesPopup::createInterfacePage() {
|
|||
|
||||
QPushButton* check30bitBtn = new QPushButton(tr("Check Availability"));
|
||||
|
||||
QPushButton* additionalStyleSheetBtn =
|
||||
new QPushButton(tr("Edit Additional Style Sheet.."));
|
||||
|
||||
QWidget* widget = new QWidget(this);
|
||||
QGridLayout* lay = new QGridLayout();
|
||||
setupLayout(lay);
|
||||
|
||||
insertUI(CurrentStyleSheetName, lay, styleSheetItemList);
|
||||
int row = lay->rowCount();
|
||||
// lay->addWidget(additionalStyleSheetBtn, row - 1, 3);
|
||||
|
||||
// lay->addWidget(new QLabel(tr("Icon Theme*:"), this), 2, 0,
|
||||
// Qt::AlignRight | Qt::AlignVCenter);
|
||||
|
@ -1642,6 +1716,8 @@ QWidget* PreferencesPopup::createInterfacePage() {
|
|||
ret = ret && connect(TApp::instance()->getCurrentScene(),
|
||||
SIGNAL(pixelUnitSelected(bool)), this,
|
||||
SLOT(onPixelUnitExternallySelected(bool)));
|
||||
ret = ret && connect(additionalStyleSheetBtn, SIGNAL(clicked()), this,
|
||||
SLOT(onEditAdditionalStyleSheet()));
|
||||
ret = ret && connect(check30bitBtn, SIGNAL(clicked()), this,
|
||||
SLOT(onCheck30bitDisplay()));
|
||||
assert(ret);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
// Qt includes
|
||||
#include <QComboBox>
|
||||
#include <QFontComboBox>
|
||||
#include <QTextEdit>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QOpenGLFunctions>
|
||||
|
@ -68,11 +69,13 @@ public:
|
|||
|
||||
private:
|
||||
class FormatProperties;
|
||||
class AdditionalStyleEdit;
|
||||
class Display30bitChecker;
|
||||
|
||||
private:
|
||||
Preferences* m_pref;
|
||||
FormatProperties* m_formatProperties;
|
||||
AdditionalStyleEdit* m_additionalStyleEdit;
|
||||
|
||||
// DVGui::CheckBox *m_projectRootDocuments, *m_projectRootDesktop,
|
||||
// *m_projectRootCustom;
|
||||
|
@ -175,6 +178,9 @@ private slots:
|
|||
void onAutoSaveExternallyChanged();
|
||||
void onAutoSavePeriodExternallyChanged();
|
||||
// void onProjectRootChanged();
|
||||
|
||||
void onEditAdditionalStyleSheet();
|
||||
void onAdditionalStyleSheetEdited();
|
||||
void onPixelUnitExternallySelected(bool on);
|
||||
void onInterfaceFontChanged(const QString& text);
|
||||
void onLutPathChanged();
|
||||
|
@ -251,4 +257,27 @@ protected:
|
|||
void paintGL() override;
|
||||
};
|
||||
|
||||
//**********************************************************************************
|
||||
// PreferencesPopup::AdditionalStyleEdit definition
|
||||
//**********************************************************************************
|
||||
|
||||
class PreferencesPopup::AdditionalStyleEdit final : public DVGui::Dialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AdditionalStyleEdit(PreferencesPopup* parent);
|
||||
|
||||
private:
|
||||
QTextEdit* m_edit;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* e) override;
|
||||
|
||||
private slots:
|
||||
void onOK();
|
||||
void onApply();
|
||||
signals:
|
||||
void additionalSheetEdited();
|
||||
};
|
||||
|
||||
#endif // PREFERENCESPOPUP_H
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QStringList>
|
||||
#include <QAction>
|
||||
#include <QColor>
|
||||
#include <QTextStream>
|
||||
#include <QStandardPaths>
|
||||
|
||||
// boost includes
|
||||
|
@ -401,6 +402,26 @@ void Preferences::definePreferenceItems() {
|
|||
// Interface
|
||||
define(CurrentStyleSheetName, "CurrentStyleSheetName", QMetaType::QString,
|
||||
"Dark");
|
||||
|
||||
// Qt has a bug in recent versions that Menu item Does not show correctly
|
||||
// (QTBUG-90242) Since the current OT is made to handle such issue, so we need
|
||||
// to apply an extra adjustment when it is run on the older versions (5.9.x)
|
||||
// of Qt
|
||||
// Update: confirmed that the bug does not appear at least in Qt 5.12.8
|
||||
QString defaultAditionalSheet = "";
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 9)
|
||||
defaultAditionalSheet = "QMenu::Item{ padding: 3 28 3 28; }";
|
||||
#endif
|
||||
|
||||
// Linux system font size appears a lot smaller than it should be despite
|
||||
// setting QApplication's setPixelSize = 12 in main.cpp. We'll correct it using
|
||||
// the additional stylesheet.
|
||||
#if defined(LINUX) || defined(FREEBSD)
|
||||
defaultAditionalSheet = "QWidget { font: 12px; }" + defaultAditionalSheet;
|
||||
#endif
|
||||
|
||||
define(additionalStyleSheet, "additionalStyleSheet", QMetaType::QString,
|
||||
defaultAditionalSheet);
|
||||
define(iconTheme, "iconTheme", QMetaType::Bool, false);
|
||||
define(pixelsOnly, "pixelsOnly", QMetaType::Bool, true);
|
||||
define(oldUnits, "oldUnits", QMetaType::QString, "mm");
|
||||
|
@ -993,13 +1014,40 @@ QString Preferences::getCurrentLanguage() const {
|
|||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
QString Preferences::getCurrentStyleSheetPath() const {
|
||||
QString Preferences::getCurrentStyleSheet() const {
|
||||
QString currentStyleSheetName = getStringValue(CurrentStyleSheetName);
|
||||
if (currentStyleSheetName.isEmpty()) return QString();
|
||||
TFilePath path(TEnv::getConfigDir() + "qss");
|
||||
QString string = currentStyleSheetName + QString("/") +
|
||||
currentStyleSheetName + QString(".qss");
|
||||
return QString("file:///" + path.getQString() + "/" + string);
|
||||
QString styleSheetPath = path.getQString() + "/" + string;
|
||||
|
||||
QString additionalSheetStr = getStringValue(additionalStyleSheet);
|
||||
// if there is no additional style sheet, return the path and let
|
||||
// Qt to load and parse it
|
||||
if (additionalSheetStr.isEmpty()) return QString("file:///" + styleSheetPath);
|
||||
|
||||
// if there is any additional style sheet, load the style sheet
|
||||
// from the file and combine with it
|
||||
QString styleSheetStr;
|
||||
QFile f(styleSheetPath);
|
||||
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QTextStream ts(&f);
|
||||
styleSheetStr = ts.readAll();
|
||||
}
|
||||
styleSheetStr += additionalSheetStr;
|
||||
|
||||
// here we will convert all relative paths to absolute paths
|
||||
// or Qt will look for images relative to the current working directory
|
||||
// since it has no idea where the style sheet comes from.
|
||||
|
||||
QString currentStyleFolderPath =
|
||||
path.getQString().replace("\\", "/") + "/" + currentStyleSheetName;
|
||||
|
||||
styleSheetStr.replace(QRegExp("url\\(['\"]([^'\"]+)['\"]\\)"),
|
||||
"url(\"" + currentStyleFolderPath + QString("/\\1\")"));
|
||||
|
||||
return styleSheetStr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue