diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qss index 4a76256d..824803c3 100644 --- a/stuff/config/qss/Dark/Dark.qss +++ b/stuff/config/qss/Dark/Dark.qss @@ -310,7 +310,6 @@ QMenu { } QMenu::item { border: 0; - padding: 3 28; } QMenu::item:selected { background-color: #a35293; @@ -2239,7 +2238,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: #9fdaff; qproperty-CurrentRowBgColor: rgba(163, 82, 147, 0.7); qproperty-OnionSkinAreaBgColor: #282828; - qproperty-CellFocusColor: #000; qproperty-ColumnIconLineColor: #111111; qproperty-EmptyColumnHeadColor: #303030; qproperty-ColumnHeadPastelizer: rgba(0, 0, 0, 0); diff --git a/stuff/config/qss/Darker/Darker.qss b/stuff/config/qss/Darker/Darker.qss index 36d85ab2..cd3b71c0 100644 --- a/stuff/config/qss/Darker/Darker.qss +++ b/stuff/config/qss/Darker/Darker.qss @@ -310,7 +310,6 @@ QMenu { } QMenu::item { border: 0; - padding: 3 28; } QMenu::item:selected { background-color: #a35293; @@ -2239,7 +2238,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: #9fdaff; qproperty-CurrentRowBgColor: rgba(163, 82, 147, 0.7); qproperty-OnionSkinAreaBgColor: #1b1b1b; - qproperty-CellFocusColor: #000; qproperty-ColumnIconLineColor: #060606; qproperty-EmptyColumnHeadColor: #343434; qproperty-ColumnHeadPastelizer: rgba(0, 0, 0, 0); diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qss index adef9c2c..c85f2a48 100644 --- a/stuff/config/qss/Light/Light.qss +++ b/stuff/config/qss/Light/Light.qss @@ -310,7 +310,6 @@ QMenu { } QMenu::item { border: 0; - padding: 3 28; } QMenu::item:selected { background-color: #d97fbe; @@ -2239,7 +2238,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: #2d42b9; qproperty-CurrentRowBgColor: rgba(216, 87, 177, 0.7); qproperty-OnionSkinAreaBgColor: #c2c2c2; - qproperty-CellFocusColor: #000; qproperty-ColumnIconLineColor: #707070; qproperty-EmptyColumnHeadColor: #DBDBDB; qproperty-ColumnHeadPastelizer: rgba(0, 0, 0, 0); diff --git a/stuff/config/qss/Medium/Medium.qss b/stuff/config/qss/Medium/Medium.qss index 8173787e..a09a9753 100644 --- a/stuff/config/qss/Medium/Medium.qss +++ b/stuff/config/qss/Medium/Medium.qss @@ -310,7 +310,6 @@ QMenu { } QMenu::item { border: 0; - padding: 3 28; } QMenu::item:selected { background-color: #a35293; @@ -2239,7 +2238,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: #9fdaff; qproperty-CurrentRowBgColor: rgba(163, 82, 147, 0.7); qproperty-OnionSkinAreaBgColor: #393939; - qproperty-CellFocusColor: #000; qproperty-ColumnIconLineColor: #2c2c2c; qproperty-EmptyColumnHeadColor: #484848; qproperty-ColumnHeadPastelizer: rgba(0, 0, 0, 0); diff --git a/stuff/config/qss/Medium/less/layouts/mainwindow.less b/stuff/config/qss/Medium/less/layouts/mainwindow.less index 822f164a..990a26ea 100644 --- a/stuff/config/qss/Medium/less/layouts/mainwindow.less +++ b/stuff/config/qss/Medium/less/layouts/mainwindow.less @@ -140,7 +140,6 @@ QMenu { padding: 2 0; &::item { border: 0; - padding: 3 28; &:selected { background-color: @menu-item-bg-color-selected; color: @menu-item-text-color-selected; diff --git a/stuff/config/qss/Medium/less/layouts/xsheet.less b/stuff/config/qss/Medium/less/layouts/xsheet.less index 8846e81a..147834c9 100644 --- a/stuff/config/qss/Medium/less/layouts/xsheet.less +++ b/stuff/config/qss/Medium/less/layouts/xsheet.less @@ -83,7 +83,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: @xsheet-PreviewFrameText-color; qproperty-CurrentRowBgColor: @xsheet-CurrentRowBG-color; qproperty-OnionSkinAreaBgColor: @xsheet-OnionSkinAreaBG-color; - qproperty-CellFocusColor: @xsheet-CellFocus-color; qproperty-ColumnIconLineColor: @xsheet-ColumnIconLine-color; qproperty-EmptyColumnHeadColor: @xsheet-EmptyColumnHead-color; qproperty-ColumnHeadPastelizer: @xsheet-ColumnHeadPastelizer-color; diff --git a/stuff/config/qss/Neutral/Neutral.qss b/stuff/config/qss/Neutral/Neutral.qss index f6ccac09..11ec210a 100644 --- a/stuff/config/qss/Neutral/Neutral.qss +++ b/stuff/config/qss/Neutral/Neutral.qss @@ -310,7 +310,6 @@ QMenu { } QMenu::item { border: 0; - padding: 3 28; } QMenu::item:selected { background-color: #c16099; @@ -2239,7 +2238,6 @@ XsheetViewer { qproperty-PreviewFrameTextColor: #17239c; qproperty-CurrentRowBgColor: rgba(251, 140, 205, 0.7); qproperty-OnionSkinAreaBgColor: #6c6c6c; - qproperty-CellFocusColor: #000; qproperty-ColumnIconLineColor: #4d4d4d; qproperty-EmptyColumnHeadColor: #808080; qproperty-ColumnHeadPastelizer: rgba(0, 0, 0, 0); diff --git a/toonz/sources/common/psdlib/psd.cpp b/toonz/sources/common/psdlib/psd.cpp index 7703fe7e..5366d629 100644 --- a/toonz/sources/common/psdlib/psd.cpp +++ b/toonz/sources/common/psdlib/psd.cpp @@ -220,8 +220,8 @@ bool TPSDReader::doLayersInfo() { m_headerInfo.layersCount = -m_headerInfo.layersCount; } if (!m_headerInfo.linfoBlockEmpty) { - m_headerInfo.linfo = (TPSDLayerInfo *)mymalloc( - m_headerInfo.layersCount * sizeof(struct TPSDLayerInfo)); + m_headerInfo.linfo = (TPSDLayerInfo *)mycalloc( + m_headerInfo.layersCount, sizeof(struct TPSDLayerInfo)); int i = 0; for (i = 0; i < m_headerInfo.layersCount; i++) { readLayerInfo(i); @@ -306,6 +306,9 @@ bool TPSDReader::readLayerInfo(int i) { } // process layer's 'additional info' + // Assumption: File will provide all layerIds or none at all. + // Set layer id, for now, knowing it may be overwritten if found in file + li->layerId = i + 1; li->additionalpos = ftell(m_file); li->additionallen = extrastart + extralen - li->additionalpos; diff --git a/toonz/sources/common/psdlib/psdutils.cpp b/toonz/sources/common/psdlib/psdutils.cpp index 059bfc94..881be2fe 100644 --- a/toonz/sources/common/psdlib/psdutils.cpp +++ b/toonz/sources/common/psdlib/psdutils.cpp @@ -136,6 +136,15 @@ void *mymalloc(long n) { return NULL; } +void *mycalloc(long n, int size) { + void *p = calloc(n, size); + if (p) + return p; + else { + // ALLOCATION ERROR + } + return NULL; +} // ZIP COMPRESSION // ZIP WITHOUT PREDICTION diff --git a/toonz/sources/common/psdlib/psdutils.h b/toonz/sources/common/psdlib/psdutils.h index 714d4d81..1ac2960f 100644 --- a/toonz/sources/common/psdlib/psdutils.h +++ b/toonz/sources/common/psdlib/psdutils.h @@ -36,6 +36,7 @@ void readrow(FILE *psd, TPSDChannelInfo *chan, psdPixel rowIndex, void skipBlock(FILE *f); void *mymalloc(long n); +void *mycalloc(long n, int size); unsigned read2UBytes(FILE *f); int read2Bytes(FILE *f); long read4Bytes(FILE *f); diff --git a/toonz/sources/include/orientation.h b/toonz/sources/include/orientation.h index 5da5ba9d..29777a47 100644 --- a/toonz/sources/include/orientation.h +++ b/toonz/sources/include/orientation.h @@ -172,6 +172,7 @@ enum class PredefinedPath { VOLUME_SLIDER_TRACK, //! slider track VOLUME_SLIDER_HEAD, //! slider head TIME_INDICATOR_HEAD, //! current time indicator head + FRAME_MARKER_DIAMOND_SMALL, FRAME_MARKER_DIAMOND, FRAME_MARKER_DIAMOND_LARGE, NAVIGATION_TAG diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index 63b419f6..48f4785f 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -200,7 +200,10 @@ public: QStringList getLanguageList() const { return m_languageList; } QMap 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); } diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h index e0fbbf6e..034497fa 100644 --- a/toonz/sources/include/toonz/preferencesitemids.h +++ b/toonz/sources/include/toonz/preferencesitemids.h @@ -24,6 +24,7 @@ enum PreferencesItemId { //---------- // Interface CurrentStyleSheetName, + additionalStyleSheet, iconTheme, pixelsOnly, oldUnits, diff --git a/toonz/sources/include/tproperty.h b/toonz/sources/include/tproperty.h index fd1f4372..9782c527 100644 --- a/toonz/sources/include/tproperty.h +++ b/toonz/sources/include/tproperty.h @@ -440,6 +440,7 @@ private: class DVAPI TColorChipProperty final : public TProperty { public: + typedef std::vector Range; struct ColorChip { QString UIName; TPixel32 pixelColor; @@ -455,12 +456,8 @@ public: TProperty *clone() const override { return new TColorChipProperty(*this); } int indexOf(const std::wstring &value) { - ColorChips::const_iterator it; - for (it = m_chips.begin(); it != m_chips.end(); it++) { - ColorChip chip = *it; - if (chip.UIName == QString::fromStdWString(value)) break; - } - return (it == m_chips.end()) ? -1 : it - m_chips.begin(); + Range::const_iterator it = std::find(m_range.begin(), m_range.end(), value); + return (it == m_range.end()) ? -1 : it - m_range.begin(); } int indexOf(TPixel32 color) { @@ -472,10 +469,15 @@ public: return (it == m_chips.end()) ? -1 : it - m_chips.begin(); } - bool isValue(const std::wstring &value) { return (indexOf(value) != -1); } + bool isValue(const std::wstring &value) { + bool ret = + std::find(m_range.begin(), m_range.end(), value) != m_range.end(); + return ret; + } void addValue(std::wstring value, const TPixel32 &color) { if (m_index == -1) m_index = 0; + m_range.push_back(value); m_chips.push_back(ColorChip(QString::fromStdWString(value), color)); } @@ -486,6 +488,7 @@ public: } void deleteAllValues() { + m_range.clear(); m_chips.clear(); m_index = -1; } @@ -509,13 +512,14 @@ public: int getCount() const { return (int)m_chips.size(); } + const Range &getRange() const { return m_range; } const ColorChips &getColorChips() const { return m_chips; } std::wstring getValue() const { - return (m_index < 0) ? L"" : m_chips[m_index].UIName.toStdWString(); + return (m_index < 0) ? L"" : m_range[m_index]; } std::string getValueAsString() override { - return (m_index < 0) ? "" : m_chips[m_index].UIName.toStdString(); + return ::to_string(m_range[m_index]); } TPixel32 getColorValue() const { return (m_index < 0) ? TPixel32(0, 0, 0) : m_chips[m_index].pixelColor; @@ -528,6 +532,7 @@ public: void assignUIName(TProperty *refP) override; private: + Range m_range; ColorChips m_chips; int m_index; }; diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp index c7662b9b..71ea38b7 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.cpp +++ b/toonz/sources/tnztools/tooloptionscontrols.cpp @@ -602,10 +602,10 @@ void ColorChipCombo::updateStatus() { //----------------------------------------------------------------------------- void ColorChipCombo::onActivated(int index) { - const TColorChipProperty::ColorChips &chips = m_property->getColorChips(); - if (index < 0 || index >= (int)chips.size()) return; + const TColorChipProperty::Range &range = m_property->getRange(); + if (index < 0 || index >= (int)range.size()) return; - std::wstring item = chips[index].UIName.toStdWString(); + std::wstring item = range[index]; m_property->setValue(item); notifyTool(); } diff --git a/toonz/sources/toonz/Resources/key.svg b/toonz/sources/toonz/Resources/key.svg deleted file mode 100644 index 6302d47a..00000000 --- a/toonz/sources/toonz/Resources/key.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/toonz/sources/toonz/Resources/selected_key.svg b/toonz/sources/toonz/Resources/selected_key.svg deleted file mode 100644 index 09feb87a..00000000 --- a/toonz/sources/toonz/Resources/selected_key.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/toonz/sources/toonz/filebrowserversioncontrol.cpp b/toonz/sources/toonz/filebrowserversioncontrol.cpp index 8f74eb64..535d68e4 100644 --- a/toonz/sources/toonz/filebrowserversioncontrol.cpp +++ b/toonz/sources/toonz/filebrowserversioncontrol.cpp @@ -495,6 +495,7 @@ void FileBrowser::getRevisionHistory() { timelineDialog->show(); timelineDialog->raise(); + timelineDialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -573,6 +574,7 @@ void FileBrowser::showLockInformation() { SVNLockInfoDialog *dialog = new SVNLockInfoDialog(this, status); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/fileselection.cpp b/toonz/sources/toonz/fileselection.cpp index 50831994..bf3e0e5f 100644 --- a/toonz/sources/toonz/fileselection.cpp +++ b/toonz/sources/toonz/fileselection.cpp @@ -532,6 +532,7 @@ void FileSelection::separateFilesByColors() { popup->setFiles(files); popup->show(); popup->raise(); + popup->activateWindow(); // popup->exec(); } diff --git a/toonz/sources/toonz/flipbook.cpp b/toonz/sources/toonz/flipbook.cpp index f56678fb..a88a46f7 100644 --- a/toonz/sources/toonz/flipbook.cpp +++ b/toonz/sources/toonz/flipbook.cpp @@ -909,8 +909,9 @@ FlipBook *FlipBookPool::pop() { // The panel need to be added to currentRoom's layout control. currentRoom->addDockWidget(panel); - panel->raise(); panel->show(); + panel->raise(); + panel->activateWindow(); return flipbook; } diff --git a/toonz/sources/toonz/floatingpanelcommand.cpp b/toonz/sources/toonz/floatingpanelcommand.cpp index 26e2f201..4886772a 100644 --- a/toonz/sources/toonz/floatingpanelcommand.cpp +++ b/toonz/sources/toonz/floatingpanelcommand.cpp @@ -126,6 +126,7 @@ TPanel *OpenFloatingPanel::getOrOpenFloatingPanel( currentRoom->addDockWidget(panel); panel->show(); panel->raise(); + panel->activateWindow(); return panel; } else lastFloatingPos = panel->pos(); @@ -141,6 +142,7 @@ TPanel *OpenFloatingPanel::getOrOpenFloatingPanel( panel->setFloating(true); panel->show(); panel->raise(); + panel->activateWindow(); if (!lastFloatingPos.isNull()) panel->move(QPoint(lastFloatingPos.x() + 30, lastFloatingPos.y() + 30)); diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index 1dcf2e3f..06e62212 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -12,6 +12,7 @@ #include "cleanupsettingspopup.h" #include "filebrowsermodel.h" #include "expressionreferencemanager.h" +#include "startuppopup.h" // TnzTools includes #include "tools/tool.h" @@ -230,7 +231,7 @@ project->setUseScenePath(TProject::Extras, false); // Imposto la rootDir per ImageCache /*-- TOONZCACHEROOTの設定 --*/ - TFilePath cacheDir = ToonzFolder::getCacheRootFolder(); + TFilePath cacheDir = ToonzFolder::getCacheRootFolder(); if (cacheDir.isEmpty()) cacheDir = TEnv::getStuffDir() + "cache"; TImageCache::instance()->setRootDir(cacheDir); @@ -338,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" @@ -761,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 @@ -812,6 +813,13 @@ int main(int argc, char *argv[]) { // Show floating panels only after the main window has been shown w.startupFloatingPanels(); + if (Preferences::instance()->isStartupPopupEnabled()) { + StartupPopup *startupPopup = new StartupPopup(); + startupPopup->show(); + startupPopup->raise(); + startupPopup->activateWindow(); + } + CommandManager::instance()->execute(T_Hand); if (!loadFilePath.isEmpty()) { splash.showMessage( diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index f2787423..e781c75c 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -12,7 +12,6 @@ #include "iocommand.h" #include "tapp.h" #include "viewerpane.h" -#include "startuppopup.h" #include "tooloptionsshortcutinvoker.h" #include "statusbar.h" #include "aboutpopup.h" @@ -1264,7 +1263,7 @@ void MainWindow::onMenuCheckboxChanged() { FieldGuideToggleAction = isChecked; else if (cm->getAction(MI_RasterizePli) == action) { if (!QGLPixelBuffer::hasOpenGLPbuffers()) isChecked = 0; - RasterizePliToggleAction = isChecked; + RasterizePliToggleAction = isChecked; } else if (cm->getAction(MI_SafeArea) == action) SafeAreaToggleAction = isChecked; else if (cm->getAction(MI_ViewColorcard) == action) @@ -1308,12 +1307,6 @@ void MainWindow::onMenuCheckboxChanged() { void MainWindow::showEvent(QShowEvent *event) { getCurrentRoom()->layout()->setEnabled(true); // See main function in // main.cpp - if (Preferences::instance()->isStartupPopupEnabled() && - !m_startupPopupShown) { - StartupPopup *startupPopup = new StartupPopup(); - startupPopup->show(); - m_startupPopupShown = true; - } } extern const char *applicationName; extern const char *applicationVersion; @@ -3165,7 +3158,7 @@ void MainWindow::clearCacheFolder() { // 1. $CACHE/[Current ProcessID] // 2. $CACHE/temp/[Current scene folder] if the current scene is untitled - TFilePath cacheRoot = ToonzFolder::getCacheRootFolder(); + TFilePath cacheRoot = ToonzFolder::getCacheRootFolder(); if (cacheRoot.isEmpty()) cacheRoot = TEnv::getStuffDir() + "cache"; TFilePathSet filesToBeRemoved; @@ -3317,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; diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.h index c5a8e2a2..df6ecb0c 100644 --- a/toonz/sources/toonz/mainwindow.h +++ b/toonz/sources/toonz/mainwindow.h @@ -60,7 +60,6 @@ class MainWindow final : public QMainWindow { Q_OBJECT bool m_saveSettingsOnQuit; - bool m_startupPopupShown = false; bool m_shownOnce = false; int m_oldRoomIndex; QString m_currentRoomsChoice; diff --git a/toonz/sources/toonz/meshifypopup.cpp b/toonz/sources/toonz/meshifypopup.cpp index b77a2c11..28ed1817 100644 --- a/toonz/sources/toonz/meshifypopup.cpp +++ b/toonz/sources/toonz/meshifypopup.cpp @@ -1322,8 +1322,9 @@ public: static MeshifyPopup *thePopup = 0; if (!thePopup) thePopup = new MeshifyPopup; - thePopup->raise(); thePopup->show(); + thePopup->raise(); + thePopup->activateWindow(); } } meshifyCommand; diff --git a/toonz/sources/toonz/messagepanel.cpp b/toonz/sources/toonz/messagepanel.cpp index 7f0abd6d..9df0d5fb 100644 --- a/toonz/sources/toonz/messagepanel.cpp +++ b/toonz/sources/toonz/messagepanel.cpp @@ -172,6 +172,7 @@ public: pane->getPanelType() == "Message") { pane->show(); pane->raise(); + pane->activateWindow(); return; } } @@ -180,6 +181,7 @@ public: pane->setFloating(true); pane->show(); pane->raise(); + pane->activateWindow(); } } } openFloatingLogPanelCommand; diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 570ad6a4..13fc575c 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -108,7 +108,7 @@ SizeField::SizeField(QSize min, QSize max, QSize value, QWidget* parent) bool ret = true; ret = ret && connect(m_fieldX, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); - ret = ret && connect(m_fieldY, SIGNAL(editingFinished()), this, + ret = ret && connect(m_fieldY, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); assert(ret); } @@ -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(pixelsOnly); // call slot function onPixelsOnlyChanged() accordingly @@ -760,7 +828,7 @@ void PreferencesPopup::onInterfaceFontChanged(const QString& text) { for (ComboBoxItem& item : newStyleItems) fontStyleCombo->addItem(item.first, item.second); if (!oldTypeface.isEmpty()) { - int newIndex = fontStyleCombo->findText(oldTypeface); + int newIndex = fontStyleCombo->findText(oldTypeface); if (newIndex < 0) newIndex = 0; fontStyleCombo->setCurrentIndex(newIndex); } @@ -887,7 +955,7 @@ QWidget* PreferencesPopup::createUI(PreferencesItemId id, for (const ComboBoxItem& item : comboItems) combo->addItem(item.first, item.second); combo->setCurrentIndex(combo->findData(item.value)); - ret = connect(combo, SIGNAL(currentIndexChanged(int)), this, + ret = connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange())); widget = combo; } else { // create IntLineEdit @@ -924,7 +992,7 @@ QWidget* PreferencesPopup::createUI(PreferencesItemId id, if (id == interfaceFont) { // create QFontComboBox QFontComboBox* combo = new QFontComboBox(this); combo->setCurrentText(item.value.toString()); - ret = connect(combo, SIGNAL(currentIndexChanged(const QString&)), this, + ret = connect(combo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onInterfaceFontChanged(const QString&))); widget = combo; } else if (!comboItems.isEmpty()) { // create QComboBox @@ -932,7 +1000,7 @@ QWidget* PreferencesPopup::createUI(PreferencesItemId id, for (const ComboBoxItem& item : comboItems) combo->addItem(item.first, item.second); combo->setCurrentIndex(combo->findData(item.value)); - ret = connect(combo, SIGNAL(currentIndexChanged(int)), this, + ret = connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange())); widget = combo; } else { // create FileField @@ -955,7 +1023,7 @@ QWidget* PreferencesPopup::createUI(PreferencesItemId id, { ColorField* field = new ColorField(this, false, colorToTPixel(item.value.value())); - ret = connect(field, SIGNAL(colorChanged(const TPixel32&, bool)), this, + ret = connect(field, SIGNAL(colorChanged(const TPixel32&, bool)), this, SLOT(onColorFieldChanged(const TPixel32&, bool))); widget = field; } break; @@ -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"); @@ -1546,9 +1616,9 @@ QWidget* PreferencesPopup::createGeneralPage() { bool ret = true; ret = ret && connect(m_pref, SIGNAL(stopAutoSave()), this, SLOT(onAutoSaveExternallyChanged())); - ret = ret && connect(m_pref, SIGNAL(startAutoSave()), this, + ret = ret && connect(m_pref, SIGNAL(startAutoSave()), this, SLOT(onAutoSaveExternallyChanged())); - ret = ret && connect(m_pref, SIGNAL(autoSavePeriodChanged()), this, + ret = ret && connect(m_pref, SIGNAL(autoSavePeriodChanged()), this, SLOT(onAutoSavePeriodExternallyChanged())); // ret = ret && connect(m_projectRootDocuments, SIGNAL(stateChanged(int)), @@ -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); diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index fb0bcd00..a233e733 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -17,6 +17,7 @@ // Qt includes #include #include +#include #include #include #include @@ -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 diff --git a/toonz/sources/toonz/scenesettingspopup.cpp b/toonz/sources/toonz/scenesettingspopup.cpp index 28563468..1c21e924 100644 --- a/toonz/sources/toonz/scenesettingspopup.cpp +++ b/toonz/sources/toonz/scenesettingspopup.cpp @@ -546,6 +546,7 @@ void SceneSettingsPopup::onEditCellMarksButtonClicked() { if (!m_cellMarksPopup) m_cellMarksPopup = new CellMarksPopup(this); m_cellMarksPopup->show(); m_cellMarksPopup->raise(); + m_cellMarksPopup->activateWindow(); } //============================================================================= diff --git a/toonz/sources/toonz/testpanel.cpp b/toonz/sources/toonz/testpanel.cpp index e7d1989a..2a2928f9 100644 --- a/toonz/sources/toonz/testpanel.cpp +++ b/toonz/sources/toonz/testpanel.cpp @@ -127,6 +127,7 @@ public: pane->getPanelType() == "Test") { pane->show(); pane->raise(); + pane->activateWindow(); return; } } @@ -136,6 +137,7 @@ public: pane->setFloating(true); pane->show(); pane->raise(); + pane->activateWindow(); } } } openFloatingTestPanelCommand; diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc index 38c3e453..e6c5ac0d 100644 --- a/toonz/sources/toonz/toonz.qrc +++ b/toonz/sources/toonz/toonz.qrc @@ -597,7 +597,6 @@ Resources/iron.png Resources/iconplay.png Resources/iconpause.png - Resources/key.svg Resources/magnet.png Resources/motionpath.svg Resources/motionpath_delete.svg @@ -634,7 +633,6 @@ Resources/schematic_spin_arrows.svg Resources/schematic_spline_aim_rhomb.svg Resources/schematic_spline_aim_square.svg - Resources/selected_key.svg Resources/selection_add.png Resources/selection_convert.png Resources/shear.png diff --git a/toonz/sources/toonz/versioncontrol.cpp b/toonz/sources/toonz/versioncontrol.cpp index f22677a0..8380411a 100644 --- a/toonz/sources/toonz/versioncontrol.cpp +++ b/toonz/sources/toonz/versioncontrol.cpp @@ -652,6 +652,7 @@ void VersionControl::commit(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -665,6 +666,7 @@ void VersionControl::revert(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -680,6 +682,7 @@ void VersionControl::update(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -693,6 +696,7 @@ void VersionControl::updateAndLock(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -705,6 +709,7 @@ void VersionControl::lock(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -718,6 +723,7 @@ void VersionControl::unlock(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -730,6 +736,7 @@ void VersionControl::lockFrameRange(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -742,6 +749,7 @@ void VersionControl::lockFrameRange(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -755,6 +763,7 @@ void VersionControl::unlockFrameRange(QWidget *parent, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -768,6 +777,7 @@ void VersionControl::unlockFrameRange(QWidget *parent, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -779,6 +789,7 @@ void VersionControl::showFrameRangeLockInfo(QWidget *parent, new SVNFrameRangeLockInfoDialog(parent, workingDir, file); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -790,6 +801,7 @@ void VersionControl::showFrameRangeLockInfo(QWidget *parent, new SVNMultiFrameRangeLockInfoDialog(parent, workingDir, files); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -803,6 +815,7 @@ void VersionControl::commitFrameRange(QWidget *parent, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -817,6 +830,7 @@ void VersionControl::revertFrameRange(QWidget *parent, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -830,6 +844,7 @@ void VersionControl::deleteFiles(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -842,6 +857,7 @@ void VersionControl::deleteFolder(QWidget *parent, const QString &workingDir, SIGNAL(commandDone(const QStringList &))); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -850,6 +866,7 @@ void VersionControl::cleanupFolder(QWidget *parent, const QString &workingDir) { SVNCleanupDialog *dialog = new SVNCleanupDialog(parent, workingDir); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- @@ -858,6 +875,7 @@ void VersionControl::purgeFolder(QWidget *parent, const QString &workingDir) { SVNPurgeDialog *dialog = new SVNPurgeDialog(parent, workingDir); dialog->show(); dialog->raise(); + dialog->activateWindow(); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index 79d238c1..4acc19b6 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -1898,16 +1898,17 @@ void CellArea::drawFrameMarker(QPainter &p, const QPoint &xy, QColor color, ->rect(PredefinedRect::FRAME_MARKER_AREA) .translated(xy) .translated(-frameAdj / 2); + bool useSmall = + m_viewer->getFrameZoomFactor() <= + m_viewer->orientation()->dimension(PredefinedDimension::SCALE_THRESHOLD); if (isKeyFrame) { - if (isCamera && !m_viewer->orientation()->isVerticalTimeline() && - m_viewer->getFrameZoomFactor() <= - m_viewer->orientation()->dimension( - PredefinedDimension::SCALE_THRESHOLD)) + if (isCamera && !m_viewer->orientation()->isVerticalTimeline()) dotRect.adjust(0, -3, 0, -3); PredefinedPath diamondPath = keyHighlight ? PredefinedPath::FRAME_MARKER_DIAMOND_LARGE - : PredefinedPath::FRAME_MARKER_DIAMOND; + : useSmall ? PredefinedPath::FRAME_MARKER_DIAMOND_SMALL + : PredefinedPath::FRAME_MARKER_DIAMOND; m_viewer->drawPredefinedPath(p, diamondPath, dotRect.adjusted(1, 1, 1, 1).center(), color, outlineColor); @@ -3068,8 +3069,6 @@ void CellArea::drawKeyframe(QPainter &p, const QRect toBeUpdated) { c0 = visible.from().layer(); c1 = visible.to().layer(); - static QPixmap selectedKey = svgToPixmap(":Resources/selected_key.svg"); - static QPixmap key = svgToPixmap(":Resources/key.svg"); QPoint frameAdj = m_viewer->getFrameZoomAdjustment(); const QRect &keyRect = o->rect(PredefinedRect::KEY_ICON).translated(-frameAdj / 2); @@ -3150,46 +3149,27 @@ void CellArea::drawKeyframe(QPainter &p, const QRect toBeUpdated) { if (pegbar->isKeyframe(row)) { QPoint xy = m_viewer->positionToXY(CellPosition(row, col)); QPoint target = tmpKeyRect.translated(xy).topLeft(); + + QColor color = Qt::white; + if (m_viewer->getKeyframeSelection() && + m_viewer->getKeyframeSelection()->isSelected(row, col)) + color = QColor(85, 157, 255); + + int x = xy.x(); + int y = xy.y(); + if (m_viewer->getFrameZoomFactor() <= o->dimension(PredefinedDimension::SCALE_THRESHOLD)) { - QColor color = Qt::white; - int x = xy.x(); - int y = xy.y(); if (row == 0) { if (o->isVerticalTimeline()) xy.setY(xy.y() + 1); else xy.setX(xy.x() + 1); } - - if (m_viewer->getKeyframeSelection() && - m_viewer->getKeyframeSelection()->isSelected(row, col)) - color = QColor(85, 157, 255); - - drawFrameMarker(p, QPoint(x, y), color, true, (col < 0), - (m_keyHighlight == QPoint(row, col))); - - } else { - QPixmap keyPM; - if (o->isVerticalTimeline()) - target = QPoint(target.x() - 2, target.y() + 2); - - if (m_viewer->getKeyframeSelection() && - m_viewer->getKeyframeSelection()->isSelected(row, col)) { - // keyframe selected - keyPM = selectedKey; - } else { - // keyframe not selected - keyPM = key; - } - - if (m_keyHighlight == QPoint(row, col)) { - keyPM = keyPM.scaled(keyPM.width() + 10, keyPM.height() + 10); - target.setX(target.x() - 3); - target.setY(target.y() - 3); - } - p.drawPixmap(target, keyPM); } + + drawFrameMarker(p, QPoint(x, y), color, true, (col < 0), + (m_keyHighlight == QPoint(row, col))); } } diff --git a/toonz/sources/toonzlib/movierenderer.cpp b/toonz/sources/toonzlib/movierenderer.cpp index 8927a9a1..dd44345f 100644 --- a/toonz/sources/toonzlib/movierenderer.cpp +++ b/toonz/sources/toonzlib/movierenderer.cpp @@ -81,6 +81,12 @@ void getRange(ToonzScene *scene, bool isPreview, int &from, int &to) { int r0, r1; xs->getCellRange(k, r0, r1); + // Sound columns should be based on frame 0 for timing purposes + TXshColumn *col = xs->getColumn(k); + TXshSoundColumn *sndCol = col ? col->getSoundColumn() : 0; + + if (sndCol) r0 = 0; + from = std::min(from, r0), to = std::max(to, r1); } } diff --git a/toonz/sources/toonzlib/orientation.cpp b/toonz/sources/toonzlib/orientation.cpp index 0a9e18bf..370a27dd 100644 --- a/toonz/sources/toonzlib/orientation.cpp +++ b/toonz/sources/toonzlib/orientation.cpp @@ -16,8 +16,9 @@ const int PLAY_MARKER_SIZE = 10; const int PINNED_SIZE = 11; const int NAV_TAG_WIDTH = 7; const int NAV_TAG_HEIGHT = 13; -const int FRAME_MARKER_SIZE = 4; -const int FRAME_MARKER_SIZE_LARGE = FRAME_MARKER_SIZE + 2; +const int FRAME_MARKER_SIZE_SMALL = 4; +const int FRAME_MARKER_SIZE = FRAME_MARKER_SIZE_SMALL + 1; +const int FRAME_MARKER_SIZE_LARGE = FRAME_MARKER_SIZE_SMALL + 2; const int FOLDED_CELL_SIZE = 9; const int SHIFTTRACE_DOT_SIZE = 12; @@ -943,6 +944,13 @@ TopToBottomOrientation::TopToBottomOrientation() { corner.lineTo(QPointF(0, CELL_HEIGHT)); addPath(PredefinedPath::DRAG_HANDLE_CORNER, corner); + QPainterPath diamondSmall(QPointF(0, -FRAME_MARKER_SIZE_SMALL)); + diamondSmall.lineTo(FRAME_MARKER_SIZE_SMALL, 0); + diamondSmall.lineTo(0, FRAME_MARKER_SIZE_SMALL); + diamondSmall.lineTo(-FRAME_MARKER_SIZE_SMALL, 0); + diamondSmall.lineTo(0, -FRAME_MARKER_SIZE_SMALL); + addPath(PredefinedPath::FRAME_MARKER_DIAMOND_SMALL, diamondSmall); + QPainterPath diamond(QPointF(0, -FRAME_MARKER_SIZE)); diamond.lineTo(FRAME_MARKER_SIZE, 0); diamond.lineTo(0, FRAME_MARKER_SIZE); @@ -1407,6 +1415,13 @@ LeftToRightOrientation::LeftToRightOrientation() { corner.lineTo(QPointF(CELL_WIDTH, 0)); addPath(PredefinedPath::DRAG_HANDLE_CORNER, corner); + QPainterPath diamondSmall(QPointF(0, -FRAME_MARKER_SIZE_SMALL)); + diamondSmall.lineTo(FRAME_MARKER_SIZE_SMALL, 0); + diamondSmall.lineTo(0, FRAME_MARKER_SIZE_SMALL); + diamondSmall.lineTo(-FRAME_MARKER_SIZE_SMALL, 0); + diamondSmall.lineTo(0, -FRAME_MARKER_SIZE_SMALL); + addPath(PredefinedPath::FRAME_MARKER_DIAMOND_SMALL, diamondSmall); + QPainterPath diamond(QPointF(0, -FRAME_MARKER_SIZE)); diamond.lineTo(FRAME_MARKER_SIZE, 0); diamond.lineTo(0, FRAME_MARKER_SIZE); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index c71229bf..419ccb17 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include // boost includes @@ -401,6 +402,7 @@ void Preferences::definePreferenceItems() { // Interface define(CurrentStyleSheetName, "CurrentStyleSheetName", QMetaType::QString, "Dark"); + define(additionalStyleSheet, "additionalStyleSheet", QMetaType::QString, ""); define(iconTheme, "iconTheme", QMetaType::Bool, false); define(pixelsOnly, "pixelsOnly", QMetaType::Bool, true); define(oldUnits, "oldUnits", QMetaType::QString, "mm"); @@ -993,13 +995,61 @@ 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; + + // Set base stylesheet settings. This is used to correct QT styling + // issues between different versions/OSes. Stylesheets and Additional + // stylesheets can override these settings. + QString baseSheetStr = ""; + + // 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 +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 9) + baseSheetStr += "QMenu::Item{ padding: 3 28 3 28; }"; +#else + baseSheetStr += "QMenu::Item{ padding: 3 28 3 8; }"; +#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) + baseSheetStr += "QWidget{ font: 12px; }QToolTip{ font: 12px; }"; +#endif + + + QString styleSheetStr = baseSheetStr; + + // Load style sheet from the file and add to base style sheet + QFile f(styleSheetPath); + if (f.open(QFile::ReadOnly | QFile::Text)) { + QTextStream ts(&f); + styleSheetStr += ts.readAll(); + } + + // If there is any additional style sheet, append to loaded stylesheet + styleSheetStr += getStringValue(additionalStyleSheet); + + // 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; } //-----------------------------------------------------------------