| 127 | } |
| 128 | |
| 129 | MainWindow::MainWindow(QWidget* parent) |
| 130 | : SARibbonMainWindow(parent) |
| 131 | , m_splitter(nullptr) |
| 132 | , m_templateEdit(nullptr) |
| 133 | , m_tabWidget(nullptr) |
| 134 | , m_builtinQssEdit(nullptr) |
| 135 | , m_customJsonEdit(nullptr) |
| 136 | , m_customQssEdit(nullptr) |
| 137 | , m_currentBaseTheme(SARibbonTheme::RibbonThemeOffice2021Blue) |
| 138 | , m_contextCategory(nullptr) |
| 139 | { |
| 140 | setWindowTitle(tr("Theme Designer Example")); |
| 141 | setMinimumSize(1000, 700); |
| 142 | |
| 143 | m_splitter = new QSplitter(Qt::Horizontal, this); |
| 144 | |
| 145 | m_templateEdit = new QTextEdit(); |
| 146 | m_templateEdit->setReadOnly(true); |
| 147 | m_templateEdit->setFont(QFont("Consolas", 10)); |
| 148 | m_templateEdit->setPlaceholderText(tr("QSS Template")); |
| 149 | new QssSyntaxHighlighter(m_templateEdit->document()); |
| 150 | |
| 151 | m_tabWidget = new QTabWidget(); |
| 152 | m_builtinQssEdit = new QTextEdit(); |
| 153 | m_builtinQssEdit->setReadOnly(true); |
| 154 | m_builtinQssEdit->setFont(QFont("Consolas", 10)); |
| 155 | new QssSyntaxHighlighter(m_builtinQssEdit->document()); |
| 156 | m_tabWidget->addTab(m_builtinQssEdit, tr("Built-in QSS")); |
| 157 | |
| 158 | m_splitter->addWidget(m_templateEdit); |
| 159 | m_splitter->addWidget(m_tabWidget); |
| 160 | m_splitter->setStretchFactor(0, 1); |
| 161 | m_splitter->setStretchFactor(1, 1); |
| 162 | setCentralWidget(m_splitter); |
| 163 | |
| 164 | SARibbonBar* bar = ribbonBar(); |
| 165 | |
| 166 | SARibbonBar* rb = ribbonBar(); |
| 167 | rb->applicationButton()->setText(tr("&File")); |
| 168 | |
| 169 | SARibbonCategory* catDesigner = bar->addCategoryPage(tr("Designer")); |
| 170 | createCategoryDesigner(catDesigner); |
| 171 | |
| 172 | SARibbonCategory* catPreview = bar->addCategoryPage(tr("Preview")); |
| 173 | createCategoryPreview(catPreview); |
| 174 | |
| 175 | createQuickAccessBar(); |
| 176 | createRightButtonGroup(); |
| 177 | |
| 178 | statusBar()->showMessage(tr("Note: Some color tokens only apply to specific templates (e.g. Win7 gradients, Office 2013 specific colors).")); |
| 179 | |
| 180 | applyBuiltinTheme(m_currentBaseTheme); |
| 181 | updateTemplateDisplay(m_currentBaseTheme); |
| 182 | updateBuiltinQssDisplay(m_currentBaseTheme); |
| 183 | } |
| 184 | |
| 185 | void MainWindow::createCategoryDesigner(SARibbonCategory* category) |
| 186 | { |
nothing calls this directly
no test coverage detected