SVN commit 527130 by dhaumann: * add ui file in subfolder ui/. I hope I got the CMake stuff right. This compiles for me. Maybe we have to change #include "modonhdwidget.h" to #include "ui_modonhdwidget.h" in katedialogs.cpp, as I'm not 100% up-to-date. * fix usage of QDialog::done(). Seems, that it can only return Accepted/Rejected=1/0, and no other int values at all. Thus, get the user's choice with decision(). * KateModOnHdPrompt's ui is based on the ui file now. * add option, to ignore whitespace changes for the diff. * fix crash: KUrl( a_KTempFile_object->name() ) --> KUrl::fromPathOrURL
CCMAIL: [email protected] M +6 -0 CMakeLists.txt M +41 -30 katedialogs.cpp M +17 -5 katedialogs.h M +4 -3 katedocument.cpp A ui (directory) A ui/modonhdwidget.ui --- trunk/KDE/kdelibs/kate/part/CMakeLists.txt #527129:527130 @@ -84,6 +84,12 @@ remove_definitions(-DQT3_SUPPORT_WARNINGS) remove_definitions(-DQT3_SUPPORT) +set( katepart_PART_UI +modonhdwidget.ui +) + +kde4_add_ui_files(katepart_PART_SRCS ui/${katepart_PART_UI} ) + kde4_add_dcop_skels(katepart_PART_SRCS ${katepart_DCOP_SKEL_SRCS}) kde4_add_plugin(katepart ${katepart_PART_SRCS}) --- trunk/KDE/kdelibs/kate/part/katedialogs.cpp #527129:527130 @@ -34,6 +34,8 @@ #include "katesyntaxdocument.h" #include "kateview.h" +#include "modonhdwidget.h" + #include <ktexteditor/plugin.h> #include <kio/job.h> @@ -1634,16 +1636,17 @@ //BEGIN KateModOnHdPrompt KateModOnHdPrompt::KateModOnHdPrompt( KateDocument *doc, - int modtype, + KTextEditor::ModificationInterface::ModifiedOnDiskReason modtype, const QString &reason, QWidget *parent ) - : KDialogBase( Swallow, 0, parent, "", true, "", Ok|Apply|Cancel|User1 ), + : KDialog( parent, "", Ok|Apply|Cancel|User1 ), + m_returnCode( Delay ), m_doc( doc ), m_modtype ( modtype ), m_tmpfile( 0 ) { QString title, btnOK, whatisok; - if ( modtype == 3 ) // deleted + if ( modtype == KTextEditor::ModificationInterface::OnDiskDeleted ) { title = i18n("File Was Deleted on Disk"); btnOK = i18n("&Save File As..."); @@ -1655,7 +1658,7 @@ "they will be lost."); } - setButtonText( Ok, btnOK); + setButtonText( Ok, btnOK ); setButtonText( Apply, i18n("&Ignore") ); setButtonWhatsThis( Ok, whatisok ); @@ -1666,34 +1669,31 @@ enableButtonSeparator( true ); setCaption( title ); - QFrame *w = makeMainWidget(); - QVBoxLayout *lo = new QVBoxLayout( w ); - QHBoxLayout *lo1 = new QHBoxLayout(); - lo->addItem(lo1); - QLabel *icon = new QLabel( w ); - icon->setPixmap( DesktopIcon("messagebox_warning" ) ); - lo1->addWidget( icon ); - lo1->addWidget( new QLabel( reason + "\n\n" + i18n("What do you want to do?"), w ) ); + QWidget *w = new QWidget(this); + ui = new Ui::ModOnHdWidget(); + ui->setupUi( w ); + setMainWidget( w ); + ui->lblIcon->setPixmap( DesktopIcon("messagebox_warning" ) ); + ui->lblText->setText( reason + "\n\n" + i18n("What do you want to do?") ); + // If the file isn't deleted, present a diff button, and a overwrite action. - if ( modtype != 3 ) + if ( modtype != KTextEditor::ModificationInterface::OnDiskDeleted ) { - QHBoxLayout *lo2 = new QHBoxLayout(); - lo->addItem(lo2); - QPushButton *btnDiff = new QPushButton( i18n("&View Difference"), w ); - lo2->addStretch( 1 ); - lo2->addWidget( btnDiff ); - connect( btnDiff, SIGNAL(clicked()), this, SLOT(slotDiff()) ); - btnDiff->setWhatsThis(i18n( - "Calculates the difference between the editor contents and the disk " - "file using diff(1) and opens the diff file with the default application " - "for that.") ); - setButtonText( User1, i18n("Overwrite") ); setButtonWhatsThis( User1, i18n("Overwrite the disk file with the editor content.") ); + connect( this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()) ); + connect( ui->btnDiff, SIGNAL(clicked()), this, SLOT(slotDiff()) ); } else + { + ui->chkIgnoreWhiteSpaces->setVisible( false ); + ui->btnDiff->setVisible( false ); showButton( User1, false ); + } + + connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()) ); + connect( this, SIGNAL(applyClicked()), this, SLOT(slotApply()) ); } KateModOnHdPrompt::~KateModOnHdPrompt() @@ -1705,11 +1705,15 @@ // Start a KProcess that creates a diff KProcIO *p = new KProcIO(); p->setComm( KProcess::All ); - *p << "diff" << "-ub" << "-" << m_doc->url().path(); + *p << "diff" << QString(ui->chkIgnoreWhiteSpaces->isChecked() ? "-ub" : "-u") + << "-" << m_doc->url().path(); connect( p, SIGNAL(processExited(KProcess*)), this, SLOT(slotPDone(KProcess*)) ); connect( p, SIGNAL(readReady(KProcIO*)), this, SLOT(slotPRead(KProcIO*)) ); setCursor( Qt::WaitCursor ); + // disable the button and checkbox, to hinder the user to run it twice. + ui->chkIgnoreWhiteSpaces->setEnabled( false ); + ui->btnDiff->setEnabled( false ); p->start( KProcess::NotifyOnExit, true ); @@ -1743,6 +1747,9 @@ void KateModOnHdPrompt::slotPDone( KProcess *p ) { setCursor( Qt::ArrowCursor ); + ui->chkIgnoreWhiteSpaces->setEnabled( true ); + ui->btnDiff->setEnabled( true ); + // dominik: whitespace changes lead to diff with 0 bytes, so that slotPRead is // never called. Thus, m_tmpfile can be NULL if( m_tmpfile ) @@ -1760,12 +1767,12 @@ if ( ! m_tmpfile ) { KMessageBox::information( this, - i18n("Besides white space changes the files are identical."), + i18n("Besides white space changes, the files are identical."), i18n("Diff Output") ); return; } - KRun::runURL( m_tmpfile->name(), "text/x-diff", true ); + KRun::runURL( KUrl::fromPathOrURL(m_tmpfile->name()), "text/x-diff", true ); delete m_tmpfile; m_tmpfile = 0; } @@ -1783,17 +1790,21 @@ "kate_ignore_modonhd" ) != KMessageBox::Continue ) return; - done(Ignore); + m_returnCode = Ignore; + done( Accepted ); } void KateModOnHdPrompt::slotOk() { - done( m_modtype == 3 ? Save : Reload ); + m_returnCode = (m_modtype == KTextEditor::ModificationInterface::OnDiskDeleted) ? + Save : Reload; + done( Accepted ); } void KateModOnHdPrompt::slotUser1() { - done( Overwrite ); + m_returnCode = Overwrite; + done( Accepted ); } //END KateModOnHdPrompt --- trunk/KDE/kdelibs/kate/part/katedialogs.h #527129:527130 @@ -26,6 +26,7 @@ #include "katehighlight.h" #include <ktexteditor/attribute.h> +#include <ktexteditor/modificationinterface.h> #include <ktexteditor/document.h> #include <ktexteditor/configpage.h> @@ -71,6 +72,11 @@ class QSpinBox; class QCheckBox; +namespace Ui +{ + class ModOnHdWidget; +} + class KateConfigPage : public KTextEditor::ConfigPage { Q_OBJECT @@ -380,18 +386,22 @@ * If the file wasn't deleted, it has a 'diff' button, which will create * a diff file (uing diff(1)) and launch that using KRun. */ -class KateModOnHdPrompt : public KDialogBase +class KateModOnHdPrompt : public KDialog { Q_OBJECT public: enum Status { - Reload=1, // 0 is KDialogBase::Cancel + Delay = 0, + Reload, Save, Overwrite, Ignore }; - KateModOnHdPrompt( KateDocument *doc, int modtype, const QString &reason, QWidget *parent ); + KateModOnHdPrompt( KateDocument *doc, + KTextEditor::ModificationInterface::ModifiedOnDiskReason modtype, + const QString &reason, QWidget *parent ); ~KateModOnHdPrompt(); + Status decision() const { return m_returnCode; } public Q_SLOTS: /** @@ -410,11 +420,13 @@ void slotPDone(KProcess*); ///< Runs the diff file when done private: + Status m_returnCode; + Ui::ModOnHdWidget* ui; KateDocument *m_doc; - int m_modtype; + KTextEditor::ModificationInterface::ModifiedOnDiskReason m_modtype; class KTempFile *m_tmpfile; ///< The diff file. Deleted by KRun when the viewer is exited. }; #endif -//kate: indent-spaces indent-width 2 +// kate: space-indent on; indent-width 2; replace-tabs on; --- trunk/KDE/kdelibs/kate/part/katedocument.cpp #527129:527130 @@ -3970,7 +3970,8 @@ m_isasking = 1; KateModOnHdPrompt p( this, m_modOnHdReason, reasonedMOHString(), widget() ); - switch ( p.exec() ) + p.exec(); // return code of exec() not important. Solved via decision() + switch ( p.decision() ) { case KateModOnHdPrompt::Save: { @@ -4020,8 +4021,8 @@ save(); break; - default: // cancel: ignore next focus event - m_isasking = -1; + default: // Delay: cancel: ignore next focus event + m_isasking = -1; } } } _______________________________________________ Kde-buildsystem mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-buildsystem
