Example #1
0
void MainWindow::loadStyleSheet() {
    QString filename = QFileDialog::getOpenFileName(this, tr("What Qt style sheet file should I load?"), QString(), tr("Style sheets (*.qss *.css);;All Files(*)"));

    if (filename.isEmpty()) {
        if (QMessageBox::question(this, tr("Question"), tr("Do you want me to load an empty style sheet?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
            setStyleSheetFile(filename);
        }
    } else {
        if (!setStyleSheetFile(filename)) {
            QMessageBox::critical(this, tr("Error"), tr("File %1 could not be opened for reading.").arg(filename));
        }
    }
}
Example #2
0
        Application::Application(int& ac, char **av) :
            QApplication(ac, av)
        {
            QCoreApplication::setApplicationName("Omnidome");
            QCoreApplication::setApplicationVersion(OMNIDOME_VERSION_STRING);
            QCoreApplication::setOrganizationName("Michael Winkelmann");
            QCoreApplication::setOrganizationDomain("Michael Winkelmann.org / omnido.me");
            loadPlugins();

            std::vector<QString> _fonts = {
                ":/fonts/SourceSansPro-Bold.ttf",
                ":/fonts/SourceSansPro-Light.ttf",
                ":/fonts/SourceSansPro-Regular.ttf"
            };

            for (auto& _font : _fonts) {
                int id = QFontDatabase::addApplicationFont(_font);
#ifdef DEBUG
                QString family = QFontDatabase::applicationFontFamilies(id).at(0);
                qDebug() << family;
#endif
            }

            setStyleSheetFile(":/stylesheet.qss");

            installEventFilter(this);
        }
Example #3
0
        bool Application::eventFilter(QObject *object, QEvent *event)
        {
#ifdef DEBUG // Reload style sheet in debug mode when pressing F5
            if (event->type() == QEvent::KeyPress)
            {
                auto *keyEvent = static_cast<QKeyEvent*>(event);
                if (keyEvent->key() == Qt::Key_F5) {
                    setStyleSheetFile(styleSheetFile_);
                }
            }
#endif // ifdef DEBUG
            return QObject::eventFilter(object, event);
        }
Example #4
0
void MainWindow::loadSettings() {
    setStyleSheetFile(settings_->value("styleSheetFile", QString()).toString());
    if (parent() == nullptr) {
        restoreGeometry(settings_->value("geometry", saveGeometry()).toByteArray());
    }
    restoreState(settings_->value("windowState", saveState()).toByteArray());
    setDecompileAutomatically(settings_->value("decompileAutomatically", true).toBool());

    foreach (QObject *child, children()) {
        if (auto textView = qobject_cast<TextView *>(child)) {
            if (!textView->objectName().isEmpty()) {
                textView->setDocumentFont(settings_->value(textView->objectName() + ".font", textView->documentFont()).value<QFont>());
            }
        } else if (auto treeView = qobject_cast<TreeView *>(child)) {
            if (!treeView->objectName().isEmpty()) {
                treeView->setDocumentFont(settings_->value(treeView->objectName() + ".font", treeView->documentFont()).value<QFont>());
            }
        }
    }
}