Commit 21daa4c2 authored by Michael Reeves's avatar Michael Reeves

Merdge changes from Thomsen/Joachim*Fix QUrl handling*Fix preferance...

Merdge changes from Thomsen/Joachim*Fix QUrl handling*Fix preferance access*Use QKeySequence::Refresh*add missed code for print cancellation
parent ae04b798
......@@ -2026,7 +2026,7 @@ void DiffTextWindowFrame::slotBrowseButtonClicked()
{
QString current = d->m_pFileSelection->text();
QUrl newURL = QFileDialog::getOpenFileUrl(this, QString(), current, 0);
QUrl newURL = QFileDialog::getOpenFileUrl(this, QString(), QUrl::fromUserInput(current, QString(), QUrl::AssumeLocalFile), 0);
if ( !newURL.isEmpty() )
{
DiffTextWindow* pDTW = d->m_pDiffTextWindow;
......
......@@ -7,7 +7,6 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "stable.h"
#include "fileaccess.h"
#include "progress.h"
#include "common.h"
......@@ -52,7 +51,7 @@ public:
}
void reset()
{
m_url = QUrlFix();
m_url = QUrl();
m_bValidData = false;
m_name = QString();
//m_creationTime = QDateTime();
......@@ -65,7 +64,7 @@ public:
m_pParent = 0;
}
QUrlFix m_url;
QUrl m_url;
bool m_bLocal;
bool m_bValidData;
......@@ -234,6 +233,7 @@ void FileAccess::setFile( const QFileInfo& fi, FileAccess* pParent )
#ifdef _WIN32
d()->m_linkTarget = fi.readLink();
#else
// TODO: Update for Qt5.
// Unfortunately Qt4 readLink always returns an absolute path, even if the link is relative
char s[PATH_MAX+1];
int len = readlink(QFile::encodeName(fi.absoluteFilePath()).constData(), s, PATH_MAX);
......@@ -250,10 +250,10 @@ void FileAccess::setFile( const QFileInfo& fi, FileAccess* pParent )
}
d()->m_bLocal = true;
d()->m_bValidData = true;
d()->m_url = QUrlFix( fi.filePath() );
d()->m_url = QUrl::fromLocalFile( fi.filePath() );
if ( d()->m_url.isRelative() )
{
d()->m_url = QUrl::fromUserInput(absoluteFilePath());
d()->m_url.setPath( absoluteFilePath() );
}
if ( !m_bExists && absoluteFilePath().contains("@@") )
......@@ -306,8 +306,7 @@ void FileAccess::setFile( const QString& name, bool bWantToWrite )
// (This is a Win95-bug which has been corrected only in WinNT/2000/XP.)
if ( !name.isEmpty() )
{
QUrlFix url( name );
if(url.scheme().isEmpty()) url.setScheme("file");//so QUrlFix:isLocalFile: works as expected on QT5.
QUrl url = QUrl::fromUserInput(name, QString(), QUrl::AssumeLocalFile);
// FileAccess tries to detect if the given name is an URL or a local file.
// This is a problem if the filename looks like an URL (i.e. contains a colon ':').
......@@ -366,7 +365,7 @@ void FileAccess::addPath( const QString& txt )
{
if ( d()!=0 && d()->m_url.isValid() )
{
QUrlFix url = d()->m_url.adjusted(QUrlFix::StripTrailingSlash);
QUrl url = d()->m_url.adjusted(QUrl::StripTrailingSlash);
d()->m_url.setPath(url.path()+'/'+txt );
setFile( d()->m_url.url() ); // reinitialise
}
......@@ -511,16 +510,16 @@ qint64 FileAccess::size() const
return QFileInfo( absoluteFilePath() ).size();
}
QUrlFix FileAccess::url() const
QUrl FileAccess::url() const
{
if ( d()!=0 )
return d()->m_url;
else
{
QUrlFix url( m_filePath );
QUrl url = QUrl::fromLocalFile( m_filePath );
if ( url.isRelative() )
{
url = QUrlFix::fromLocalFile( absoluteFilePath() );
url.setPath( absoluteFilePath() );
}
return url;
}
......@@ -913,7 +912,7 @@ void FileAccess::setStatusText( const QString& s )
QString FileAccess::cleanPath( const QString& path ) // static
{
QUrlFix url(path);
QUrl url = QUrl::fromUserInput(path, QString(""), QUrl::AssumeLocalFile);
if ( url.isLocalFile() || ! url.isValid() )
{
return QDir().cleanPath( path );
......@@ -1100,8 +1099,7 @@ void FileAccessJobHandler::slotPutJobResult(KJob* pJob)
bool FileAccessJobHandler::mkDir( const QString& dirName )
{
QUrlFix dirURL = QUrlFix( dirName );
QUrl dirURL = QUrl::fromUserInput(dirName, QString(""), QUrl::AssumeLocalFile);
if ( dirName.isEmpty() )
return false;
else if ( dirURL.isLocalFile() || dirURL.isRelative() )
......@@ -1121,8 +1119,7 @@ bool FileAccessJobHandler::mkDir( const QString& dirName )
bool FileAccessJobHandler::rmDir( const QString& dirName )
{
QUrlFix dirURL = QUrlFix( dirName );
QUrl dirURL = QUrl::fromUserInput(dirName, QString(""), QUrl::AssumeLocalFile);
if ( dirName.isEmpty() )
return false;
else if ( dirURL.isLocalFile() )
......@@ -1176,10 +1173,9 @@ bool FileAccessJobHandler::rename( const QString& dest )
if ( dest.isEmpty() )
return false;
QUrlFix kurl( dest );
QUrl kurl = QUrl::fromUserInput(dest, QString(""), QUrl::AssumeLocalFile);
if ( kurl.isRelative() )
kurl = QUrlFix( QDir().absoluteFilePath(dest) ); // assuming that invalid means relative
kurl = QUrl::fromUserInput(QDir().absoluteFilePath(dest), QString(""), QUrl::AssumeLocalFile); // assuming that invalid means relative
if ( m_pFileAccess->isLocal() && kurl.isLocalFile() )
{
......@@ -1218,8 +1214,7 @@ void FileAccessJobHandler::slotSimpleJobResult(KJob* pJob)
bool FileAccessJobHandler::copyFile( const QString& dest )
{
ProgressProxyExtender pp;
QUrlFix destUrl( dest );
QUrl destUrl = QUrl::fromUserInput(dest, QString(""), QUrl::AssumeLocalFile);
m_pFileAccess->setStatusText( QString() );
if ( ! m_pFileAccess->isLocal() || !destUrl.isLocalFile() ) // if either url is nonlocal
{
......@@ -1253,9 +1248,6 @@ bool FileAccessJobHandler::copyFile( const QString& dest )
return false;
}
#if QT_VERSION==230
typedef long Q_LONG;
#endif
std::vector<char> buffer(100000);
qint64 bufSize = buffer.size();
qint64 srcSize = srcFile.size();
......@@ -1759,7 +1751,8 @@ bool FileAccessJobHandler::listDir( t_DirectoryList* pDirList, bool bRecursive,
void FileAccessJobHandler::slotListDirProcessNewEntries( KIO::Job*, const KIO::UDSEntryList& l )
{
QUrlFix parentUrl( QUrlFix::fromUserInput(m_pFileAccess->absoluteFilePath()) );
//This function is called for non-local urls. Don't use QUrl::fromLocalFile here as it does not handle these.
QUrl parentUrl = QUrl::fromUserInput( m_pFileAccess->absoluteFilePath(), QString(""), QUrl::AssumeLocalFile);
KIO::UDSEntryList::ConstIterator i;
for ( i=l.begin(); i!=l.end(); ++i )
......@@ -1773,7 +1766,7 @@ void FileAccessJobHandler::slotListDirProcessNewEntries( KIO::Job*, const KIO::U
if ( fa.fileName() != "." && fa.fileName() != ".." )
{
fa.d()->m_url = parentUrl;
QUrlFix url = fa.d()->m_url.adjusted(QUrlFix::StripTrailingSlash);
QUrl url = fa.d()->m_url.adjusted(QUrl::StripTrailingSlash);
fa.d()->m_url.setPath(url.path() + "/" + fa.fileName() );
//fa.d()->m_absoluteFilePath = fa.url().url();
m_pDirList->push_back( fa );
......
......@@ -15,11 +15,11 @@
#include <QDateTime>
#include <kio/job.h>
#include <kio/jobclasses.h>
#include "QUrlFix.h"
#include <list>
#include <KIO/UDSEntry>
namespace KIO {
class Job;
}
bool wildcardMultiMatch( const QString& wildcard, const QString& testString, bool bCaseSensitive );
......@@ -66,7 +66,7 @@ public:
QString fileName() const; // Just the name-part of the path, without parent directories
QString filePath() const; // The path-string that was used during construction
QString prettyAbsPath() const;
QUrlFix url() const;
QUrl url() const;
QString absoluteFilePath() const;
bool isLocal() const;
......
......@@ -165,7 +165,7 @@ KDiff3App::KDiff3App( QWidget* pParent, const char* /*name*/, KDiff3Part* pKDiff
// This is just a convenience variable to make code that accesses options more readable
m_pOptions = &m_pOptionDialog->m_options;
m_pOptionDialog->readOptions( KSharedConfig::openConfig() );
m_pOptionDialog->readOptions( isPart() ? KSharedConfig::openConfig(QStringLiteral("kdiff3_part.rc")) : KSharedConfig::openConfig(QStringLiteral("kdiff3_shell.rc")) );
// Option handling: Only when pParent==0 (no parent)
int argCount = KDiff3Shell::getParser()->optionNames().count() + KDiff3Shell::getParser()->positionalArguments().count();
......@@ -514,7 +514,7 @@ void KDiff3App::initActions( KActionCollection* ac )
fileOpen = KStandardAction::open( this, SLOT( slotFileOpen() ), ac );
fileOpen->setStatusTip( i18n( "Opens documents for comparison..." ) );
fileReload = KDiff3::createAction< QAction >( i18n( "Reload" ), QKeySequence( Qt::Key_F5 ), this, SLOT( slotReload() ), ac, "file_reload" );
fileReload = KDiff3::createAction< QAction >( i18n( "Reload" ), QKeySequence( QKeySequence::Refresh ), this, SLOT( slotReload() ), ac, "file_reload" );
fileSave = KStandardAction::save( this, SLOT( slotFileSave() ), ac );
fileSave->setStatusTip( i18n( "Saves the merge result. All conflicts must be solved!" ) );
......@@ -684,7 +684,7 @@ void KDiff3App::saveOptions( KSharedConfigPtr config )
bool KDiff3App::queryClose()
{
saveOptions( KSharedConfig::openConfig() );
saveOptions( isPart() ? KSharedConfig::openConfig(QStringLiteral("kdiff3_part.rc")) : KSharedConfig::openConfig(QStringLiteral("kdiff3_shell.rc")) );
if(m_bOutputModified)
{
......@@ -755,7 +755,7 @@ void KDiff3App::slotFileSaveAs()
{
slotStatusMsg( i18n( "Saving file with a new filename..." ) );
QString s = QFileDialog::getSaveFileUrl( this, i18n( "Save As..." ), QDir::currentPath(), 0 ).url();
QString s = QFileDialog::getSaveFileUrl( this, i18n( "Save As..." ), QDir::currentPath(), 0 ).url(QUrl::PreferLocalFile);
if( !s.isEmpty() ) {
m_outputFilename = s;
m_pMergeResultWindowTitle->setFileName( m_outputFilename );
......@@ -939,6 +939,13 @@ void KDiff3App::slotFilePrint()
pp.setMaxNofSteps(totalNofPages);
QList<int>::iterator pageListIt = pageList.begin();
for( ;; ) {
pp.setInformation(i18n("Printing page %1 of %2").arg(page).arg(totalNofPages),false);
pp.setCurrent(page - 1);
if (pp.wasCancelled())
{
printer.abort();
break;
}
if( !bPrintSelection ) {
if( pageListIt == pageList.end() )
break;
......
......@@ -119,9 +119,15 @@ static void showHelp()
QString getTranslationDir(const QString& locale)
{
#if defined(_WIN32) || defined(Q_OS_OS2)
QUNUSED(locale);
QString exePath;
exePath = QCoreApplication::applicationDirPath();
return exePath+"/translations";
#elif defined(__APPLE__)
QUNUSED(locale);
QString exePath = QCoreApplication::applicationDirPath();
return exePath+"/../Resources/translations";
#else
return (QString)"/usr/share/locale/" + locale + "/LC_MESSAGES";
#endif
......@@ -754,46 +760,6 @@ void KActionCollection::addAction( const QString& name, QAction* pAction )
initAction( pAction, 0,0,this,name,false,true);
}
KFontChooser::KFontChooser( QWidget* pParent )
: QWidget(pParent)
{
m_pParent = pParent;
QVBoxLayout* pLayout = new QVBoxLayout( this );
m_pSelectFont = new QPushButton(i18n("Select Font"), this );
connect(m_pSelectFont, SIGNAL(clicked()), this, SLOT(slotSelectFont()));
pLayout->addWidget(m_pSelectFont);
m_pLabel = new QLabel( "", this );
m_pLabel->setFont( m_font );
m_pLabel->setMinimumWidth(200);
QChar visualTab(0x2192);
QChar visualSpace((ushort)0xb7);
m_pLabel->setText( QString("The quick brown fox jumps over the river\n"
"but the little red hen escapes with a shiver.\n"
":-)")+visualTab+visualSpace);
pLayout->addWidget(m_pLabel);
}
QFont KFontChooser::font()
{
return m_font;//QFont("courier",10);
}
void KFontChooser::setFont( const QFont& font, bool )
{
m_font = font;
m_pLabel->setFont( m_font );
//update();
}
void KFontChooser::slotSelectFont()
{
bool bOk;
m_font = QFontDialog::getFont(&bOk, m_font );
m_pLabel->setFont( m_font );
}
KColorButton::KColorButton(QWidget* parent)
: QPushButton(parent)
{
......@@ -1015,7 +981,13 @@ KApplication::KApplication()
: QApplication( s_argc,s_argv )
{
kapp = this;
#if ! ( defined(_WIN32) || defined(Q_OS_OS2) )
parseOptions();
#endif
}
void KApplication::parseOptions()
{
//setStyle( new QWindowsStyle ); // doesn't show checkmarks on checkable icons in menu
int nofOptions=0;
......@@ -1044,7 +1016,7 @@ KApplication::KApplication()
}
m_config.readConfigFile(configFileName);
QStringList ignorableCmdLineOptionsList = m_config.readEntry("IgnorableCmdLineOptions", QStringList("-u;-query;-html;-abort"), ',');
QStringList ignorableCmdLineOptionsList = m_config.readEntry("IgnorableCmdLineOptions", QStringList("-u;-query;-html;-abort"), '|');
QString ignorableCmdLineOptions;
if ( !ignorableCmdLineOptionsList.isEmpty() )
ignorableCmdLineOptions = ignorableCmdLineOptionsList.front() + ";";
......
......@@ -360,21 +360,6 @@ public:
KIcon( const QString& ) {}
};
class KFontChooser : public QWidget
{
Q_OBJECT
QFont m_font;
QPushButton* m_pSelectFont;
QLabel* m_pLabel;
QWidget* m_pParent;
public:
KFontChooser( QWidget* pParent );
QFont font();
void setFont( const QFont&, bool );
private slots:
void slotSelectFont();
};
class KColorButton : public QPushButton
{
Q_OBJECT
......@@ -482,6 +467,7 @@ public:
KIconLoader* iconLoader();
KConfigGroup* config();
bool isRestored();
void parseOptions();
};
extern KApplication* kapp;
......
......@@ -228,6 +228,8 @@ bool OpenDialog::eventFilter(QObject* o, QEvent* e)
void OpenDialog::selectURL( QComboBox* pLine, bool bDir, int i, bool bSave )
{
QString current = pLine->currentText();
QUrl currentUrl;
if( current.isEmpty() && i > 3 ) {
current = m_pLineC->currentText();
}
......@@ -238,9 +240,10 @@ void OpenDialog::selectURL( QComboBox* pLine, bool bDir, int i, bool bSave )
current = m_pLineA->currentText();
}
QUrl newURL = bDir ? QFileDialog::getExistingDirectoryUrl( this, QString(""), QUrl::fromUserInput(current))
: bSave ? QFileDialog::getSaveFileUrl( this, QString(""), QUrl::fromUserInput(current), QLatin1Literal("all/allfiles") )
: QFileDialog::getOpenFileUrl( this, QString(""), QUrl::fromUserInput(current), QLatin1Literal("all/allfiles") );
currentUrl = QUrl::fromUserInput(current, QString(), QUrl::AssumeLocalFile);
QUrl newURL = bDir ? QFileDialog::getExistingDirectoryUrl( this, i18n("Open Directory"), currentUrl)
: bSave ? QFileDialog::getSaveFileUrl( this, i18n("Select Output File"), currentUrl, QLatin1Literal("all/allfiles") )
: QFileDialog::getOpenFileUrl( this, i18n("Open File"), currentUrl, QLatin1Literal("all/allfiles") );
if( !newURL.isEmpty() ) {
/*
Since we are selecting a directory open in the parent directory
......@@ -297,7 +300,7 @@ void OpenDialog::accept()
fixCurrentText( m_pLineA );
QString s = m_pLineA->currentText();
s = QUrl::fromLocalFile(s).toLocalFile();
s = QUrl::fromUserInput(s, QString(), QUrl::AssumeLocalFile).toLocalFile();
QStringList* sl = &m_pOptions->m_recentAFiles;
// If an item exist, remove it from the list and reinsert it at the beginning.
sl->removeAll(s);
......@@ -306,7 +309,7 @@ void OpenDialog::accept()
fixCurrentText( m_pLineB );
s = m_pLineB->currentText();
s = QUrl::fromLocalFile(s).toLocalFile();
s = QUrl::fromUserInput(s, QString(), QUrl::AssumeLocalFile).toLocalFile();
sl = &m_pOptions->m_recentBFiles;
sl->removeAll(s);
if ( !s.isEmpty() ) sl->prepend( s );
......@@ -314,7 +317,7 @@ void OpenDialog::accept()
fixCurrentText( m_pLineC );
s = m_pLineC->currentText();
s = QUrl::fromLocalFile(s).toLocalFile();
s = QUrl::fromUserInput(s, QString(), QUrl::AssumeLocalFile).toLocalFile();
sl = &m_pOptions->m_recentCFiles;
sl->removeAll(s);
if ( !s.isEmpty() ) sl->prepend( s );
......@@ -322,7 +325,7 @@ void OpenDialog::accept()
fixCurrentText( m_pLineOut );
s = m_pLineOut->currentText();
s = QUrl::fromLocalFile(s).toLocalFile();
s = QUrl::fromUserInput(s, QString(), QUrl::AssumeLocalFile).toLocalFile();
sl = &m_pOptions->m_recentOutputFiles;
sl->removeAll(s);
if ( !s.isEmpty() ) sl->prepend( s );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment