Exemple #1
0
void MessageWidget::setMessage(const QString &msg, bool isError)
{
    if (msg.isEmpty() && isVisible()) {
        setVisible(false);
        return;
    }
    QString text=msg;
    if (text.length()>154) {
        text=text.left(150)+QLatin1String("...");
    }
    if (msg.length()>500) {
        setToolTip(msg.left(500)+QLatin1String("..."));
    } else {
        setToolTip(msg);
    }
    setText(text);
    setMessageType(isError ? Error : Information);
    #if defined NO_ANIMATED_SHOW
    setVisible(true);
    #else
    if (!parentWidget()->isVisible()) {
        show();
        setVisible(true);
    } else {
        animatedShow();
    }
    #endif
}
Exemple #2
0
void MessageWidget::setMessage(const QString &msg, MessageType type, bool showCloseButton)
{
    if (isActive() && !msg.isEmpty() && type!=msgType) {
        setVisible(false);
    }
    msgType=type;
    if (msg.isEmpty() && isVisible()) {
        setVisible(false);
        return;
    }
//    QString text=msg;
//    if (text.length()>154) {
//        text=text.left(150)+QLatin1String("...");
//    }
//    if (msg.length()>500) {
//        setToolTip(msg.left(500)+QLatin1String("..."));
//    } else {
//        setToolTip(msg);
//    }
//    setText(text);
    setText(msg);
    setToolTip(msg);
    setMessageType(type);
    setCloseButtonVisible(showCloseButton);
    #if defined NO_ANIMATED_SHOW
    setVisible(true);
    #else
    if (!parentWidget()->isVisible()) {
        show();
        setVisible(true);
    } else {
        animatedShow();
    }
    #endif
}
void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module)
{
    pref_ = pref;
    module_ = module;

    if (!pref || !module) {
        hide();
        return;
    }

    ui->modulePreferencesToolButton->setText(tr("Open %1 preferences").arg(module_->title));

    pref_stash(pref_, NULL);
    ui->preferenceTitleLabel->setText(pref->title);

    // Convert the pref description from plain text to rich text.
    QString description;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    description = Qt::escape(pref->description);
#else
    description = QString(pref->description).toHtmlEscaped();
#endif
    description.replace('\n', "<br>");
    QString tooltip = QString("<span>%1</span>").arg(description);
    ui->preferenceTitleLabel->setToolTip(tooltip);
    ui->preferenceLineEdit->setToolTip(tooltip);

    ui->preferenceLineEdit->clear();
    ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
    disconnect(ui->preferenceLineEdit);

    bool show = false;

    switch (pref_->type) {
    case PREF_UINT:
        new_uint_ = pref->stashed_val.uint;
        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
                this, SLOT(uintLineEditTextEdited(QString)));
        show = true;
        break;
    case PREF_STRING:
        new_str_ = pref->stashed_val.string;
        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
                this, SLOT(stringLineEditTextEdited(QString)));
        show = true;
        break;
    case PREF_RANGE:
        g_free(new_range_);
        new_range_ = range_copy(pref->stashed_val.range);
        connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
                this, SLOT(rangeLineEditTextEdited(QString)));
        show = true;
        break;
    default:
        break;
    }

    if (show) {
        ui->preferenceLineEdit->setText(gchar_free_to_qstring(prefs_pref_to_str(pref_, pref_stashed)).remove(QRegExp("\n\t")));
        animatedShow();
    }
}
// system-config-printer --setup-printer='file:/tmp/printout' --devid='MFG:Ricoh;MDL:Aficio SP C820DN'
PageDestinations::PageDestinations(const QVariantHash &args, QWidget *parent) :
    GenericPage(parent),
    ui(new Ui::PageDestinations),
    m_chooseLpd(new ChooseLpd(this)),
    m_chooseSamba(new ChooseSamba(this)),
    m_chooseSerial(new ChooseSerial(this)),
    m_chooseSocket(new ChooseSocket(this)),
    m_chooseUri(new ChooseUri(this)),
    m_chooseLabel(new QLabel(this))
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);

    ui->stackedWidget->addWidget(m_chooseLpd);
    connect(m_chooseLpd, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSamba);
    connect(m_chooseSamba, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSerial);
    connect(m_chooseSerial, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSocket);
    connect(m_chooseSocket, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseUri);
    connect(m_chooseUri, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    m_chooseLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->stackedWidget->addWidget(m_chooseLabel);

    // Hide the message widget
    ui->messageWidget->setMessageType(KMessageWidget::Error);
    ui->messageWidget->hide();

    // setup default options
    setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
    m_model = new DevicesModel(this);
    ui->devicesTV->setModel(m_model);
    ui->devicesTV->setItemDelegate(new NoSelectionRectDelegate(this));
    connect(ui->devicesTV->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(deviceChanged()));
    connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(setText(QString)));
    connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(animatedShow()));

    // Expand when a parent is added
    connect(m_model, SIGNAL(parentAdded(QModelIndex)),
            ui->devicesTV, SLOT(expand(QModelIndex)));

    // Update the view when the device URI combo box changed
    connect(ui->connectionsCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(deviceUriChanged()));
    ui->connectionsGB->setVisible(false);

    // Setup the busy cursor
    working();
    connect(m_model, SIGNAL(loaded()), this, SLOT(notWorking()));

    if (!args.isEmpty()) {
        // set our args
        setValues(args);
    }
}
void NotificationWidget::showMessage(const QString &msg) {
    m_label->setText(msg);
    m_label->show();
    animatedShow();
}