예제 #1
0
MainWindow::MainWindow() : model_(new DicModel(dic_, freq_))
{
    ui_.setupUi(this);
    ui_.tableView->setModel(model_.get());
    ui_.statusbar->insertPermanentWidget(0, ui_.frmInfo);

    QSettings settings("Ensisoft", "Pinyin-Translator");
    const auto wwidth  = settings.value("window/width", width()).toInt();
    const auto wheight = settings.value("window/height", height()).toInt();
    const auto xpos   = settings.value("window/xpos", x()).toInt();
    const auto ypos   = settings.value("window/ypos", y()).toInt();
    const auto traditional = settings.value("window/traditional", true).toBool();
    const auto font = settings.value("window/font").toString();
    if (!font.isEmpty())
    {
        QFont f;
        if (f.fromString(font))
            setFont(f);
    }

    ui_.actionTraditional->setChecked(traditional);
    ui_.actionSimplified->setChecked(!traditional);
    ui_.editInput->installEventFilter(this);    
    model_->toggleTraditional(traditional);

    move(xpos, ypos);
    resize(wwidth, wheight);

    QStyle* style = QApplication::setStyle("Cleanlooks");
    if (style)
    {
        QApplication::setPalette(style->standardPalette());
    }
}
예제 #2
0
void KStyleComboBox::chooseStyle(const QString &style)
{
    QStyle *st = QStyleFactory::create(style);
    if (st) {
        qApp->setStyle( st );
        qApp->setPalette(st->standardPalette());
    }
}
예제 #3
0
void Appearance::applySettings(SettingsWidget* gui) 
{
    const auto mine = dynamic_cast<MySettings*>(gui);    
    const auto name = mine->getStyleName();

    current_style_name_ = name;

    if (current_style_name_ == "Default")
        return;

    QStyle* style = QApplication::setStyle(current_style_name_);
    QApplication::setPalette(style->standardPalette());
}
예제 #4
0
void StyleInspector::styleSelected(const QItemSelection &selection)
{
  if (selection.isEmpty())
    return;
  const QModelIndex index = selection.first().topLeft();
  QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
  QStyle *style = qobject_cast<QStyle*>(obj);
  m_primitiveModel->setStyle(style);
  m_controlModel->setStyle(style);
  m_complexControlModel->setStyle(style);
  m_pixelMetricModel->setStyle(style);
  m_standardIconModel->setStyle(style);
  m_standardPaletteModel->setPalette(style ? style->standardPalette() : qApp->palette());
}
예제 #5
0
EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *networkManager):
    QWebView(parent), m_scrollParent(0L), m_resizeInProgress(0)
{
    // set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint!
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setFocusPolicy(Qt::StrongFocus); // not by the wheel
    setPage(new ErrorCheckingPage(this));
    page()->setNetworkAccessManager(networkManager);

    QWebSettings *s = settings();
    s->setAttribute(QWebSettings::JavascriptEnabled, false);
    s->setAttribute(QWebSettings::JavaEnabled, false);
    s->setAttribute(QWebSettings::PluginsEnabled, false);
    s->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
    s->setAttribute(QWebSettings::JavaEnabled, false);
    s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false);
    s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false);
    s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, false);
    s->clearMemoryCaches();

    page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(slotLinkClicked(QUrl)));
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(handlePageLoadFinished()));
    connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(handlePageLoadFinished()));

    // Scrolling is implemented on upper layers
    page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);

    // Setup shortcuts for standard actions
    QAction *copyAction = page()->action(QWebPage::Copy);
    copyAction->setShortcut(tr("Ctrl+C"));
    addAction(copyAction);

    // Redmine#3, the QWebView uses black text color when rendering stuff on dark background
    QPalette palette = QApplication::palette();
    if (palette.background().color().lightness() < 50) {
        QStyle *style = QStyleFactory::create(QLatin1String("windows"));
        Q_ASSERT(style);
        palette = style->standardPalette();
        setPalette(palette);
    }

    setContextMenuPolicy(Qt::NoContextMenu);
    findScrollParent();
}
예제 #6
0
void Appearance::loadState(app::Settings& s)
{
    current_style_name_ = s.get("theme", "name", "Default");
    if (current_style_name_ == "Default")
        return;

    QStyle* style = QApplication::setStyle(current_style_name_);
    if (!style)
    {
        WARN("No such style %1", current_style_name_);
        WARN("Style set to Default");
        current_style_name_ = "Default";
        return;
    }
    QApplication::setPalette(style->standardPalette());

    DEBUG("Qt style %1", current_style_name_);
}