示例#1
0
bool Document::fileClose()
{
	if ( isModified() )
	{
		// If the filename is empty then it must  be an untitled file.
		QString name = m_url.fileName().isEmpty() ? caption() : m_url.fileName();
		
		if ( ViewContainer * viewContainer = (activeView() ? activeView()->viewContainer() : 0l) )
			KTechlab::self()->tabWidget()->setCurrentPage( KTechlab::self()->tabWidget()->indexOf(viewContainer) );
		
		KGuiItem saveItem = KStandardGuiItem::yes();
		saveItem.setText( i18n("Save") );
		saveItem.setIconName( "filesave" );
		
		KGuiItem discardItem = KStandardGuiItem::no();
		discardItem.setText( i18n("Discard") );
		
		int choice = KMessageBox::warningYesNoCancel( KTechlab::self(),
				i18n("The document \'%1\' has been modified.\nDo you want to save it?").arg(name),
				i18n("Save Document?"),
				saveItem,
				discardItem );
		
		if ( choice == KMessageBox::Cancel )
			return false;
		if ( choice == KMessageBox::Yes )
			fileSave();
	}
	
	deleteLater();
	return true;
}
void ReportAssistantDialog::closeEvent(QCloseEvent * event)
{
    //Handle the close event
    if (!m_canClose) {
        //If the assistant didn't finished yet, offer the user the possibilities to
        //Close, Cancel, or Save the bug report and Close"

        KGuiItem closeItem = KStandardGuiItem::close();
        closeItem.setText(i18nc("@action:button", "Close the assistant"));

        KGuiItem keepOpenItem = KStandardGuiItem::cancel();
        keepOpenItem.setText(i18nc("@action:button", "Cancel"));

        BacktraceParser::Usefulness use =
                DrKonqi::debuggerManager()->backtraceGenerator()->parser()->backtraceUsefulness();
        if (use == BacktraceParser::ReallyUseful || use == BacktraceParser::MayBeUseful) {
            //Backtrace is still useful, let the user save it.
            KGuiItem saveBacktraceItem = KStandardGuiItem::save();
            saveBacktraceItem.setText(i18nc("@action:button", "Save information and close"));

            int ret = KMessageBox::questionYesNoCancel(this,
                           xi18nc("@info","Do you really want to close the bug reporting assistant? "
                           "<note>The crash information is still valid, so "
                           "you can save the report before closing if you want.</note>"),
                           i18nc("@title:window","Close the Assistant"),
                           closeItem, saveBacktraceItem, keepOpenItem, QString(), KMessageBox::Dangerous);
            if(ret == KMessageBox::Yes)
            {
                event->accept();
            } else if (ret == KMessageBox::No) {
                //Save backtrace and accept event (dialog will be closed)
                DrKonqi::saveReport(reportInterface()->generateReportFullText(false));
                event->accept();
            } else {
                event->ignore();
            }
        } else {
            if (KMessageBox::questionYesNo(this, i18nc("@info","Do you really want to close the bug "
                                                   "reporting assistant?"),
                                       i18nc("@title:window","Close the Assistant"),
                                           closeItem, keepOpenItem, QString(), KMessageBox::Dangerous)
                                        == KMessageBox::Yes) {
                event->accept();
            } else {
                event->ignore();
            }
        }
    } else {
        event->accept();
    }
}
示例#3
0
//-----------------------------------------------------------------------------
SolvingRateDialog::SolvingRateDialog(const BaseField &field, QWidget *parent)
    : KDialogBase(Plain, i18n("Compute Solving Rate"), Ok|Close,
                  Close, parent, "compute_solving_rate", true, true),
      _refField(field)
{
    connect(&_solver, SIGNAL(solvingDone(bool)), SLOT(solvingDone(bool)));

    KGuiItem item = KStdGuiItem::ok();
    item.setText(i18n("Start"));
    setButtonOK(item);

    QVBoxLayout *top = new QVBoxLayout(plainPage(), 0, spacingHint());
    QLabel *label = new QLabel(i18n("Width: %1").arg(field.width()),
                               plainPage());
    top->addWidget(label);
    label = new QLabel(i18n("Height: %1").arg(field.height()), plainPage());
    top->addWidget(label);
    label = new QLabel(i18n("Mines: %1 (%2%)").arg(field.nbMines())
                       .arg( field.nbMines() * 100.0 / field.size()),
                       plainPage());
    top->addWidget(label);

    top->addSpacing(spacingHint());

    _progress = new KProgress(NB_STEPS, plainPage());
    _progress->setTextEnabled(true);
    _progress->setFormat("%v");
    top->addWidget(_progress);

    _label = new QLabel(i18n("Success rate:"), plainPage());
    top->addWidget(_label);
}
示例#4
0
ProgrammerDlg::ProgrammerDlg( const QString & picID, QWidget *parent, const char *name )
	: KDialogBase( parent, name, true, i18n("PIC Programmer"), Ok|Cancel )
{
	// Change the "Ok" button to a "Burn" button
	KGuiItem burnItem = KStdGuiItem::ok();
	burnItem.setText( i18n("Burn") );
	setButtonOK( burnItem );
	
	m_bAccepted = false;
	m_pProgrammerWidget = new ProgrammerWidget( this );
	m_pProgrammerSettings = new PicProgrammerSettings;
	
	// Setup the list of programmers
	KComboBox * programmerCombo = m_pProgrammerWidget->m_pProgrammerProgram;
	QStringList programmerNames = m_pProgrammerSettings->configNames( false );
	programmerCombo->insertStringList( programmerNames );
	programmerCombo->setSizeLimit( programmerNames.size() );
	programmerCombo->setCurrentText( KTLConfig::picProgrammerProgram() );
	
	// Sets up the list of ports
	m_pProgrammerWidget->m_pPicProgrammerPort->insertStringList( Port::ports( Port::ExistsAndRW ) );
	m_pProgrammerWidget->m_pPicProgrammerPort->setCurrentText( KTLConfig::picProgrammerPort() );
	
	// Set the pic type to the one requested
	if ( !picID.isEmpty() )
		m_pProgrammerWidget->m_pMicroSelect->setMicro( picID );
	
	setMainWidget( m_pProgrammerWidget );
}
示例#5
0
void ContextHelp::slotEditReset()
{
	if ( isEditChanged() )
	{
		KGuiItem continueItem = KStandardGuiItem::cont(); //KStandardGuiItem::cont();
		continueItem.setText( i18n("Reset") );
		int answer = KMessageBox::warningContinueCancel( this, i18n("Reset item help to last saved changes?"), i18n("Reset"), continueItem );
		if ( answer == KMessageBox::Cancel )
			return;
	}
	
	m_pWidgetStack->raiseWidget( 0 );
}
ChooseProvidersPage::ChooseProvidersPage( QWidget *parent, Qt::WindowFlags f )
    : QWidget( parent, f )
    , m_providersModel( 0 )
{
    setupUi( this );
    KGuiItem configure = KStandardGuiItem::configure();
    configure.setText( i18n( "Configure Synchronization..." ) );
    buttonBox->addButton( configure, QDialogButtonBox::ActionRole, this, SLOT(openConfiguration()) );
    buttonBox->addButton( KGuiItem( i18n( "Next" ), "go-next" ), QDialogButtonBox::AcceptRole );
    connect( buttonBox, SIGNAL(accepted()), SIGNAL(accepted()) );
    connect( buttonBox, SIGNAL(rejected()), SIGNAL(rejected()) );
    progressBar->hide();
}
示例#7
0
CharacterSelectDialog::CharacterSelectDialog(QWidget *parent, const QString &name, const QChar &_chr, const QString &_font, bool _modal)
        : KoDialog(parent),
        d(new Private())
{
    setCaption(i18n("Select Character"));
    setModal(_modal);
    setButtons(Ok | Cancel);
    setDefaultButton(Ok);
    setObjectName(name);

    initDialog(_chr, _font);

    KGuiItem okItem = KStandardGuiItem::ok(); // start from std item to keep the OK icon...
    okItem.setText(i18n("&Insert"));
    okItem.setWhatsThis(i18n("Insert the selected character in the text"));
    setButtonGuiItem(KoDialog::Ok, okItem);
}
示例#8
0
void ConfigDialog::removeSlot()
{
    KGuiItem gi = KStandardGuiItem::clear();
    gi.setText(i18n("Remove"));
    int res = KMessageBox::warningContinueCancel(this,
                               i18n("This will permanently remove your "
                               "registration key. You will not be able to use "
                               "the currently registered nickname anymore."),
                               QString(), gi);
    if ( res==KMessageBox::Continue ) {
        internal->playerInfos().removeKey();
        _registeredName->clear();
        _key->clear();
        _removeButton->setEnabled(false);
        _WWHEnabled->setChecked(false);
        modifiedSlot();
    }
}
示例#9
0
void HighscoresDialog::slotUser2()
{
//   kDebug(11001) ;
    QUrl url = QFileDialog::getSaveFileUrl(this, tr("HighscoresDialog"), QUrl(), QString());
    if ( url.isEmpty() ) return;
    if ( KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this) ) {
        KGuiItem gi = KStandardGuiItem::save();
        gi.setText(i18n("Overwrite"));
        int res = KMessageBox::warningContinueCancel(this,
                                 i18n("The file already exists. Overwrite?"),
                                 i18n("Export"), gi);
        if ( res==KMessageBox::Cancel ) return;
    }
    QTemporaryFile tmp;
    tmp.open();
    QTextStream stream(&tmp);
    internal->exportHighscores(stream);
    stream.flush();
    KIO::NetAccess::upload(tmp.fileName(), url, this);
}
示例#10
0
void GvCore::slotSaveResult(KJob* _job)
{
    SaveJob* job = static_cast<SaveJob*>(_job);
    KUrl oldUrl = job->oldUrl();
    KUrl newUrl = job->newUrl();

    if (job->error()) {
        QString name = newUrl.fileName().isEmpty() ? newUrl.pathOrUrl() : newUrl.fileName();
        QString msg = i18nc("@info", "<b>Saving <filename>%1</filename> failed:</b><br>%2",
                            name, job->errorString());

        int result = KMessageBox::warningContinueCancel(
                         d->mMainWindow, msg,
                         QString() /* caption */,
                         KStandardGuiItem::saveAs());

        if (result == KMessageBox::Continue) {
            saveAs(newUrl);
        }
        return;
    }

    if (oldUrl != newUrl) {
        d->mMainWindow->goToUrl(newUrl);

        ViewMainPage* page = d->mMainWindow->viewMainPage();
        if (page->isVisible()) {
            HudMessageBubble* bubble = new HudMessageBubble();
            bubble->setText(i18n("You are now viewing the new document."));
            KGuiItem item = KStandardGuiItem::back();
            item.setText(i18n("Go back to the original"));
            HudButton* button = bubble->addButton(item);

            BinderRef<MainWindow, KUrl>::bind(button, SIGNAL(clicked()), d->mMainWindow, &MainWindow::goToUrl, oldUrl);
            connect(button, SIGNAL(clicked()),
                bubble, SLOT(deleteLater()));

            page->showMessageWidget(bubble);
        }
    }
}
示例#11
0
AddAppletDialog::AddAppletDialog(ContainerArea* cArea,
                                 QWidget* parent,
                                 const char* name)
    : KDialogBase(parent, name, false, i18n("Add Applet"), 0),
      m_selectedApplet(0),
      m_containerArea(cArea),
      m_insertionPoint(Kicker::the()->insertionPoint()),
      m_closing(false),
      m_searchDelay(new QTimer(this))
{
    m_mainWidget = new AppletView(this, "AddAppletDialog::m_mainWidget");
    m_mainWidget->appletScrollView->setResizePolicy(QScrollView::Manual);
    m_mainWidget->appletScrollView->setHScrollBarMode(QScrollView::AlwaysOff);
    m_mainWidget->appletScrollView->viewport()->setPaletteBackgroundColor(KGlobalSettings::baseColor());

    setMainWidget(m_mainWidget);

    resize(configDialogSize("AddAppletDialog Settings"));
    centerOnScreen(this);

    KGuiItem addGuiItem = KStdGuiItem::add();
    addGuiItem.setText(m_mainWidget->appletInstall->text());
    m_mainWidget->appletInstall->setEnabled(false);
    m_mainWidget->appletInstall->setGuiItem(addGuiItem);
    m_mainWidget->closeButton->setGuiItem(KStdGuiItem::close());

    connect(m_mainWidget->appletSearch, SIGNAL(textChanged(const QString&)), this, SLOT(delayedSearch()));
    connect(m_searchDelay, SIGNAL(timeout()), this, SLOT(search()));
    connect(m_mainWidget->appletFilter, SIGNAL(activated(int)), this, SLOT(filter(int)));
    connect(m_mainWidget->appletInstall, SIGNAL(clicked()), this, SLOT(addCurrentApplet()));
    connect(m_mainWidget->closeButton, SIGNAL(clicked()), this, SLOT(close()));

    m_selectedType = AppletInfo::Undefined;
    m_appletBox = 0;

    QTimer::singleShot(0, this, SLOT(populateApplets()));
}
示例#12
0
void GvCore::save(const KUrl& url)
{
    Document::Ptr doc = DocumentFactory::instance()->load(url);
    QByteArray format = doc->format();
    const QStringList availableTypes = KImageIO::types(KImageIO::Writing);
    if (availableTypes.contains(QString(format))) {
        DocumentJob* job = doc->save(url, format);
        connect(job, SIGNAL(result(KJob*)), SLOT(slotSaveResult(KJob*)));
    } else {
        // We don't know how to save in 'format', ask the user for a format we can
        // write to.
        KGuiItem saveUsingAnotherFormat = KStandardGuiItem::saveAs();
        saveUsingAnotherFormat.setText(i18n("Save using another format"));
        int result = KMessageBox::warningContinueCancel(
                         d->mMainWindow,
                         i18n("Gwenview cannot save images in '%1' format.", QString(format)),
                         QString() /* caption */,
                         saveUsingAnotherFormat
                     );
        if (result == KMessageBox::Continue) {
            saveAs(url);
        }
    }
}
示例#13
0
//-----------------------------------------------------------------------------
ConfigDialog::ConfigDialog(QWidget *parent)
    : QDialog(parent),
      _saved(false), _WWHEnabled(0)
{
//     kDebug(11001) << ": ConfigDialog";
    
    setWindowTitle( i18n("Configure Highscores") );
    setModal( true );
    
    QWidget *page = 0;
    QTabWidget *tab = 0;
    
    QVBoxLayout *layout = new QVBoxLayout;
    setLayout(layout);
    
    if ( internal->isWWHSAvailable() ) {
        tab = new QTabWidget(this);
        layout->addWidget(tab);
        page = new QWidget;
        tab->addTab(page, i18n("Main"));
    } 
    
    else {
        page = new QWidget(this);
        layout->addWidget(page);
    }

    QGridLayout *pageTop =
        new QGridLayout(page);
    //pageTop->setMargin(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
    //pageTop->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
    
    layout->addLayout(pageTop);

    QLabel *label = new QLabel(i18n("Nickname:"), page);
    pageTop->addWidget(label, 0, 0);
    _nickname = new QLineEdit(page);
    connect(_nickname, SIGNAL(textChanged(QString)),
            SLOT(modifiedSlot()));
    connect(_nickname, SIGNAL(textChanged(QString)),
            SLOT(nickNameChanged(QString)));

    _nickname->setMaxLength(16);
    pageTop->addWidget(_nickname, 0, 1);

    label = new QLabel(i18n("Comment:"), page);
    pageTop->addWidget(label, 1, 0);
    _comment = new QLineEdit(page);
    connect(_comment, SIGNAL(textChanged(QString)),
            SLOT(modifiedSlot()));
    _comment->setMaxLength(50);
    pageTop->addWidget(_comment, 1, 1);

    if (tab) {
        _WWHEnabled
            = new QCheckBox(i18n("World-wide highscores enabled"), page);
        connect(_WWHEnabled, SIGNAL(toggled(bool)),
                SLOT(modifiedSlot()));
        pageTop->addWidget(_WWHEnabled, 2, 0, 1, 2 );

        // advanced tab
        QWidget *page = new QWidget;
        tab->addTab(page, i18n("Advanced"));
        QVBoxLayout *pageTop = new QVBoxLayout(page);
        //pageTop->setMargin(QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin));
        //pageTop->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));

        QGroupBox *group = new QGroupBox(page);
        group->setTitle( i18n("Registration Data") );
        pageTop->addWidget(group);
        QGridLayout *groupLayout = new QGridLayout(group);
        //groupLayout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));

        label = new QLabel(i18n("Nickname:"), group);
        groupLayout->addWidget(label, 0, 0);
        _registeredName = new KLineEdit(group);
        _registeredName->setReadOnly(true);
        groupLayout->addWidget(_registeredName, 0, 1);

        label = new QLabel(i18n("Key:"), group);
        groupLayout->addWidget(label, 1, 0);
        _key = new KLineEdit(group);
        _key->setReadOnly(true);
        groupLayout->addWidget(_key, 1, 1);

        KGuiItem gi = KStandardGuiItem::clear();
        gi.setText(i18n("Remove"));
        _removeButton = new QPushButton(group);
	KGuiItem::assign(_removeButton, gi);
	groupLayout->addWidget(_removeButton, 2, 0);
        connect(_removeButton, SIGNAL(clicked()), SLOT(removeSlot()));
    }
    
    buttonBox = new QDialogButtonBox(this);
    
    buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel); 
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    // TODO mapping for Apply button
    pageTop->addWidget(buttonBox);

    load();
    buttonBox->button(QDialogButtonBox::Ok)->setEnabled( !_nickname->text().isEmpty() );
    buttonBox->button(QDialogButtonBox::Apply)->setEnabled( false );
    
}