From 6fa1084bc8c0cb155a957df06ae757481c36b912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 5 Feb 2009 12:44:46 +0100 Subject: [PATCH 1/9] Use QActions to fix toolbar extension Instead of directly adding QToolButtons to the tool bar of the navigation subwidget, use QActions. This allows the tool bar extension to show them in a menu when necessary. The icons are inappropriate for in a menu, however. --- src/plugins/coreplugin/navigationwidget.cpp | 35 +++++++++------------ src/plugins/coreplugin/navigationwidget.h | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 6329f70ed94..3d4607a9269 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -354,35 +354,30 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget) m_navigationComboBox->setMaximumWidth(130); #endif - m_toolbar = new QToolBar(this); - m_toolbar->setContentsMargins(0, 0, 0, 0); - m_toolbar->addWidget(m_navigationComboBox); + m_toolBar = new QToolBar(this); + m_toolBar->setContentsMargins(0, 0, 0, 0); + m_toolBar->addWidget(m_navigationComboBox); - QToolButton *split = new QToolButton; - split->setProperty("type", QLatin1String("dockbutton")); - split->setIcon(QIcon(":/core/images/splitbutton_horizontal.png")); - split->setToolTip(tr("Split")); - connect(split, SIGNAL(clicked(bool)), this, SIGNAL(split())); - - QToolButton *close = new QToolButton; - close->setProperty("type", QLatin1String("dockbutton")); - close->setIcon(QIcon(":/core/images/closebutton.png")); - close->setToolTip(tr("Close")); - - connect(close, SIGNAL(clicked(bool)), this, SIGNAL(close())); + m_splitAction = new QAction(QIcon(":/core/images/splitbutton_horizontal.png"), tr("Split"), this); + QAction *close = new QAction(QIcon(":/core/images/closebutton.png"), tr("Close"), this); QWidget *spacerItem = new QWidget(this); spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - m_toolbar->addWidget(spacerItem); - m_splitAction = m_toolbar->addWidget(split); - m_toolbar->addWidget(close); + m_toolBar->addWidget(spacerItem); + m_toolBar->addAction(m_splitAction); + m_toolBar->addAction(close); + + m_toolBar->widgetForAction(m_splitAction)->setProperty("type", QLatin1String("dockbutton")); + m_toolBar->widgetForAction(close)->setProperty("type", QLatin1String("dockbutton")); QVBoxLayout *lay = new QVBoxLayout(); lay->setMargin(0); lay->setSpacing(0); setLayout(lay); - lay->addWidget(m_toolbar); + lay->addWidget(m_toolBar); + connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(split())); + connect(close, SIGNAL(triggered()), this, SIGNAL(close())); connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int))); @@ -417,7 +412,7 @@ void NavigationSubWidget::setCurrentIndex(int index) // Add Toolbutton m_additionalToolBarWidgets = n.doockToolBarWidgets; foreach (QToolButton *w, m_additionalToolBarWidgets) { - m_toolbar->insertWidget(m_splitAction, w); + m_toolBar->insertWidget(m_splitAction, w); } } diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h index 016fbcd0bda..d4998181589 100644 --- a/src/plugins/coreplugin/navigationwidget.h +++ b/src/plugins/coreplugin/navigationwidget.h @@ -151,7 +151,7 @@ private: NavigationWidget *m_parentWidget; QComboBox *m_navigationComboBox; QWidget *m_navigationWidget; - QToolBar *m_toolbar; + QToolBar *m_toolBar; QAction *m_splitAction; QList m_additionalToolBarWidgets; }; From 1483c9c0f8c6ed2853a39703cf530f8a00658ff2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 Feb 2009 12:04:07 +0100 Subject: [PATCH 2/9] Fixes: Remove dependencies to Qt private headers (shared resource editor) RevBy: Eike Details: Remove leftover defines/includes --- src/shared/qrceditor/qrceditor.pri | 8 -------- src/shared/qrceditor/resourcefile_p.h | 12 ++---------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/shared/qrceditor/qrceditor.pri b/src/shared/qrceditor/qrceditor.pri index 3efd26553f7..47e54c936e1 100644 --- a/src/shared/qrceditor/qrceditor.pri +++ b/src/shared/qrceditor/qrceditor.pri @@ -1,14 +1,7 @@ -QT_BUILD_TREE=$$(QT_BUILD_TREE) -isEmpty(QT_BUILD_TREE):QT_BUILD_TREE=$$(QTDIR) -QT_QRC_BUILD_TREE = $$fromfile($$QT_BUILD_TREE/.qmake.cache,QT_SOURCE_TREE) - -INCLUDEPATH *= $$QT_QRC_BUILD_TREE/tools/designer/src/lib/shared INCLUDEPATH *= $$PWD $$PWD/.. QT *= xml -DEFINES *= QT_NO_SHARED_EXPORT - # Input SOURCES += \ $$PWD/resourcefile.cpp \ @@ -21,7 +14,6 @@ HEADERS += \ $$PWD/resourceview.h \ $$PWD/qrceditor.h \ $$PWD/undocommands_p.h \ - \ $$PWD/../namespace_global.h \ FORMS += $$PWD/qrceditor.ui diff --git a/src/shared/qrceditor/resourcefile_p.h b/src/shared/qrceditor/resourcefile_p.h index 4a7d510dc48..2ec3fe47e4b 100644 --- a/src/shared/qrceditor/resourcefile_p.h +++ b/src/shared/qrceditor/resourcefile_p.h @@ -42,18 +42,10 @@ #include #include -#include "shared_global_p.h" - QT_BEGIN_NAMESPACE namespace qdesigner_internal { -#ifdef BUILD_VSIP -# define RESOURCE_EXPORT -#else -# define RESOURCE_EXPORT QDESIGNER_SHARED_EXPORT -#endif - struct File; struct Prefix; @@ -125,7 +117,7 @@ typedef QList PrefixList; Represents the structure of a Qt Resource File (.qrc) file. */ -class RESOURCE_EXPORT ResourceFile +class ResourceFile { public: ResourceFile(const QString &file_name = QString()); @@ -199,7 +191,7 @@ private: Wraps a \l ResourceFile as a single-column tree model. */ -class RESOURCE_EXPORT ResourceModel : public QAbstractItemModel +class ResourceModel : public QAbstractItemModel { Q_OBJECT From 1bb65685338fd30f116bd46a86103ce6fe980827 Mon Sep 17 00:00:00 2001 From: con Date: Mon, 9 Feb 2009 14:48:25 +0100 Subject: [PATCH 3/9] Fixes: - Disable codepaster plugin, since it's not available anymore RevBy: - hjk --- src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index bd7cbece15d..02edb9d61a8 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -24,7 +24,7 @@ SUBDIRS = plugin_coreplugin \ plugin_help \ # plugin_regexp \ # don't know what to do with this plugin_qtscripteditor \ - plugin_cpaster \ +# plugin_cpaster \ plugin_cmakeprojectmanager \ plugin_fakevim From 53fde645f9134b08ddfb19d97785d77395f9ad51 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 Feb 2009 17:33:31 +0100 Subject: [PATCH 4/9] Fixes: Add "Describe" to svn plugin. Details: Also remove unused change number dialog. --- src/plugins/subversion/changenumberdialog.cpp | 53 ------------- src/plugins/subversion/changenumberdialog.h | 58 -------------- src/plugins/subversion/changenumberdialog.ui | 79 ------------------- src/plugins/subversion/subversion.pro | 5 +- src/plugins/subversion/subversionplugin.cpp | 63 ++++++++++----- src/plugins/subversion/subversionplugin.h | 3 + 6 files changed, 49 insertions(+), 212 deletions(-) delete mode 100644 src/plugins/subversion/changenumberdialog.cpp delete mode 100644 src/plugins/subversion/changenumberdialog.h delete mode 100644 src/plugins/subversion/changenumberdialog.ui diff --git a/src/plugins/subversion/changenumberdialog.cpp b/src/plugins/subversion/changenumberdialog.cpp deleted file mode 100644 index dad23a7490c..00000000000 --- a/src/plugins/subversion/changenumberdialog.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** -** Non-Open Source Usage -** -** Licensees may use this file in accordance with the Qt Beta Version -** License Agreement, Agreement version 2.2 provided with the Software or, -** alternatively, in accordance with the terms contained in a written -** agreement between you and Nokia. -** -** GNU General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the packaging -** of this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt GPL Exception -** version 1.3, included in the file GPL_EXCEPTION.txt in this package. -** -***************************************************************************/ - -#include - -#include "changenumberdialog.h" - -using namespace Subversion::Internal; - -ChangeNumberDialog::ChangeNumberDialog(QWidget *parent) - : QDialog(parent) -{ - m_ui.setupUi(this); - m_ui.numberLineEdit->setValidator(new QIntValidator(0, 1000000, this)); -} - -int ChangeNumberDialog::number() const -{ - if (m_ui.numberLineEdit->text().isEmpty()) - return -1; - bool ok; - return m_ui.numberLineEdit->text().toInt(&ok); -} diff --git a/src/plugins/subversion/changenumberdialog.h b/src/plugins/subversion/changenumberdialog.h deleted file mode 100644 index 933860e45c2..00000000000 --- a/src/plugins/subversion/changenumberdialog.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** -** Non-Open Source Usage -** -** Licensees may use this file in accordance with the Qt Beta Version -** License Agreement, Agreement version 2.2 provided with the Software or, -** alternatively, in accordance with the terms contained in a written -** agreement between you and Nokia. -** -** GNU General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the packaging -** of this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt GPL Exception -** version 1.3, included in the file GPL_EXCEPTION.txt in this package. -** -***************************************************************************/ - -#ifndef CHANGENUMBERDIALOG_H -#define CHANGENUMBERDIALOG_H - -#include "ui_changenumberdialog.h" - -#include - -namespace Subversion { -namespace Internal { - -class ChangeNumberDialog : public QDialog -{ - Q_OBJECT -public: - ChangeNumberDialog(QWidget *parent = 0); - int number() const; - -private: - Ui::ChangeNumberDialog m_ui; -}; - -} // namespace Subversion -} // namespace Internal - -#endif // CHANGENUMBERDIALOG_H diff --git a/src/plugins/subversion/changenumberdialog.ui b/src/plugins/subversion/changenumberdialog.ui deleted file mode 100644 index ff3e6517508..00000000000 --- a/src/plugins/subversion/changenumberdialog.ui +++ /dev/null @@ -1,79 +0,0 @@ - - Subversion::Internal::ChangeNumberDialog - - - - 0 - 0 - 319 - 76 - - - - Change Number - - - - 9 - - - 6 - - - - - - - - Change Number: - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Subversion::Internal::ChangeNumberDialog - accept() - - - 59 - 24 - - - 160 - 38 - - - - - buttonBox - rejected() - Subversion::Internal::ChangeNumberDialog - reject() - - - 59 - 24 - - - 160 - 38 - - - - - diff --git a/src/plugins/subversion/subversion.pro b/src/plugins/subversion/subversion.pro index 7de5499fa76..993d22eb6a3 100644 --- a/src/plugins/subversion/subversion.pro +++ b/src/plugins/subversion/subversion.pro @@ -14,7 +14,6 @@ HEADERS += annotationhighlighter.h \ subversionoutputwindow.h \ settingspage.h \ subversioneditor.h \ - changenumberdialog.h \ subversionsubmiteditor.h \ subversionsettings.h @@ -24,11 +23,9 @@ SOURCES += annotationhighlighter.cpp \ subversionoutputwindow.cpp \ settingspage.cpp \ subversioneditor.cpp \ - changenumberdialog.cpp \ subversionsubmiteditor.cpp \ subversionsettings.cpp -FORMS += settingspage.ui \ - changenumberdialog.ui +FORMS += settingspage.ui RESOURCES += subversion.qrc diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 7f6ea476eb2..a41525fe19e 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -38,7 +38,6 @@ #include "subversionoutputwindow.h" #include "subversionsubmiteditor.h" -#include "changenumberdialog.h" #include "subversionconstants.h" #include "subversioncontrol.h" @@ -70,6 +69,9 @@ #include #include #include +#include + +#include using namespace Subversion::Internal; @@ -96,6 +98,7 @@ const char * const SubversionPlugin::ANNOTATE_CURRENT = "Subversion.AnnotateCu const char * const SubversionPlugin::SEPARATOR3 = "Subversion.Separator3"; const char * const SubversionPlugin::STATUS = "Subversion.Status"; const char * const SubversionPlugin::UPDATE = "Subversion.Update"; +const char * const SubversionPlugin::DESCRIBE = "Subversion.Describe"; static const VCSBase::VCSBaseEditorParameters editorParameters[] = { { @@ -186,6 +189,7 @@ SubversionPlugin::SubversionPlugin() : m_annotateCurrentAction(0), m_statusAction(0), m_updateProjectAction(0), + m_describeAction(0), m_submitCurrentLogAction(0), m_submitDiffAction(0), m_submitUndoAction(0), @@ -248,6 +252,16 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { Subversion::Constants::SUBVERSIONCOMMITEDITOR }; +static inline Core::Command *createSeparator(QObject *parent, + Core::ActionManager *ami, + const char*id, + const QList &globalcontext) +{ + QAction *tmpaction = new QAction(parent); + tmpaction->setSeparator(true); + return ami->registerAction(tmpaction, id, globalcontext); +} + bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments); @@ -330,10 +344,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); subversionMenu->addAction(command); - QAction *tmpaction = new QAction(this); - tmpaction->setSeparator(true); - subversionMenu->addAction(ami->registerAction(tmpaction, - SubversionPlugin::SEPARATOR0, globalcontext)); + subversionMenu->addAction(createSeparator(this, ami, SubversionPlugin::SEPARATOR0, globalcontext)); m_diffProjectAction = new QAction(tr("Diff Project"), this); command = ami->registerAction(m_diffProjectAction, SubversionPlugin::DIFF_PROJECT, @@ -349,10 +360,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); subversionMenu->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - subversionMenu->addAction(ami->registerAction(tmpaction, - SubversionPlugin::SEPARATOR1, globalcontext)); + subversionMenu->addAction(createSeparator(this, ami, SubversionPlugin::SEPARATOR1, globalcontext)); m_commitAllAction = new QAction(tr("Commit All Files"), this); command = ami->registerAction(m_commitAllAction, SubversionPlugin::COMMIT_ALL, @@ -368,10 +376,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile())); subversionMenu->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - subversionMenu->addAction(ami->registerAction(tmpaction, - SubversionPlugin::SEPARATOR2, globalcontext)); + subversionMenu->addAction(createSeparator(this, ami, SubversionPlugin::SEPARATOR2, globalcontext)); m_filelogCurrentAction = new QAction(tr("Filelog Current File"), this); command = ami->registerAction(m_filelogCurrentAction, @@ -389,10 +394,12 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe SLOT(annotateCurrentFile())); subversionMenu->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - subversionMenu->addAction(ami->registerAction(tmpaction, - SubversionPlugin::SEPARATOR3, globalcontext)); + m_describeAction = new QAction(tr("Describe..."), this); + command = ami->registerAction(m_describeAction, SubversionPlugin::DESCRIBE, globalcontext); + connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe())); + subversionMenu->addAction(command); + + subversionMenu->addAction(createSeparator(this, ami, SubversionPlugin::SEPARATOR3, globalcontext)); m_statusAction = new QAction(tr("Project Status"), this); command = ami->registerAction(m_statusAction, SubversionPlugin::STATUS, @@ -536,7 +543,7 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri void SubversionPlugin::updateActions() { - QString fileName = currentFileName(); + const QString fileName = currentFileName(); const bool hasFile = !fileName.isEmpty(); m_addAction->setEnabled(hasFile); @@ -549,6 +556,7 @@ void SubversionPlugin::updateActions() m_filelogCurrentAction->setEnabled(hasFile); m_annotateCurrentAction->setEnabled(hasFile); m_statusAction->setEnabled(true); + m_describeAction->setEnabled(true); QString baseName; if (hasFile) @@ -881,6 +889,25 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) } } +void SubversionPlugin::slotDescribe() +{ + const QStringList topLevels = currentProjectsTopLevels(); + if (topLevels.size() != 1) + return; + + QInputDialog inputDialog(Core::ICore::instance()->mainWindow()); + inputDialog.setWindowFlags(inputDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); + inputDialog.setInputMode(QInputDialog::IntInput); + inputDialog.setIntRange(2, INT_MAX); + inputDialog.setWindowTitle(tr("Describe")); + inputDialog.setLabelText(tr("Revision number:")); + if (inputDialog.exec() != QDialog::Accepted) + return; + + const int revision = inputDialog.intValue(); + describe(topLevels.front(), QString::number(revision)); +} + void SubversionPlugin::submitCurrentLog() { Core::EditorManager::instance()->closeEditors(QList() diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index f589468e40f..fc1c4063a88 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -119,6 +119,7 @@ private slots: void annotateCurrentFile(); void projectStatus(); void describe(const QString &source, const QString &changeNr); + void slotDescribe(); void updateProject(); void submitCurrentLog(); void diffFiles(const QStringList &); @@ -165,6 +166,7 @@ private: QAction *m_annotateCurrentAction; QAction *m_statusAction; QAction *m_updateProjectAction; + QAction *m_describeAction; QAction *m_submitCurrentLogAction; QAction *m_submitDiffAction; @@ -187,6 +189,7 @@ private: static const char * const SEPARATOR3; static const char * const STATUS; static const char * const UPDATE; + static const char * const DESCRIBE; static SubversionPlugin *m_subversionPluginInstance; From 8f03874bd73d04049848377a1365a3528e574140 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 Feb 2009 08:38:12 +0100 Subject: [PATCH 5/9] Fixes: Add log message to SVN description --- src/plugins/subversion/subversionplugin.cpp | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index a41525fe19e..f998332593a 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -864,7 +864,20 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) const int number = changeNr.toInt(&ok); if (!ok || number < 2) return; - QStringList args(QLatin1String("diff")); + // Run log to obtain message (local utf8) + QString description; + QStringList args(QLatin1String("log")); + args.push_back(QLatin1String("-r")); + args.push_back(changeNr); + args.push_back(topLevel); + const SubversionResponse logResponse = runSvn(args, subversionShortTimeOut, false); + if (logResponse.error) + return; + description = logResponse.stdOut; + + // Run diff (encoding via source codec) + args.clear(); + args.push_back(QLatin1String("diff")); args.push_back(QLatin1String("-r")); QString diffArg; QTextStream(&diffArg) << (number - 1) << ':' << number; @@ -875,16 +888,17 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr) const SubversionResponse response = runSvn(args, subversionShortTimeOut, false, codec); if (response.error) return; + description += response.stdOut; // Re-use an existing view if possible to support // the common usage pattern of continuously changing and diffing a file - const QString id = diffArg + source; + const QString id = diffArg + source; if (Core::IEditor *editor = locateEditor("describeChange", id)) { - editor->createNew(response.stdOut); + editor->createNew(description); Core::EditorManager::instance()->setCurrentEditor(editor); } else { const QString title = tr("svn describe %1#%2").arg(QFileInfo(source).fileName(), changeNr); - Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec); + Core::IEditor *newEditor = showOutputInEditor(title, description, VCSBase::DiffOutput, source, codec); newEditor->setProperty("describeChange", id); } } From acd5feafeaf337d31f2e037a7d52298f04436643 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 Feb 2009 10:56:22 +0100 Subject: [PATCH 6/9] Fixes: React to desktop file manager drop events. Task: 238143 --- src/plugins/coreplugin/mainwindow.cpp | 64 +++++++++++++++++++++++--- src/plugins/coreplugin/mainwindow.h | 6 ++- src/plugins/coreplugin/welcomemode.cpp | 1 + 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 91c2756d315..1c335c0af5e 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -77,6 +77,7 @@ #include #include #include +#include #include #include @@ -103,10 +104,9 @@ extern "C" void handleSigInt(int sig) using namespace Core; using namespace Core::Internal; -namespace { - enum { debugMainWindow = 0 }; -} +static const char *uriListMimeFormatC = "text/uri-list"; +enum { debugMainWindow = 0 }; MainWindow::MainWindow() : QMainWindow(), @@ -157,15 +157,15 @@ MainWindow::MainWindow() : QCoreApplication::setOrganizationName(QLatin1String("Nokia")); QSettings::setDefaultFormat(QSettings::IniFormat); QString baseName = qApp->style()->objectName(); -#ifdef Q_WS_X11 - if (baseName == "windows") { +#ifdef Q_WS_X11 + if (baseName == QLatin1String("windows")) { // Sometimes we get the standard windows 95 style as a fallback // e.g. if we are running on a KDE4 desktop QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION"); if (desktopEnvironment == "kde") - baseName = "plastique"; + baseName = QLatin1String("plastique"); else - baseName = "cleanlooks"; + baseName = QLatin1String("cleanlooks"); } #endif qApp->setStyle(new ManhattanStyle(baseName)); @@ -202,6 +202,7 @@ MainWindow::MainWindow() : #endif statusBar()->setProperty("p_styled", true); + setAcceptDrops(true); } void MainWindow::setSidebarVisible(bool visible) @@ -361,6 +362,55 @@ void MainWindow::closeEvent(QCloseEvent *event) event->accept(); } +// Check for desktop file manager file drop events + +static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0) +{ + if (files) + files->clear(); + // Extract dropped files from Mime data. + if (!d->hasFormat(QLatin1String(uriListMimeFormatC))) + return false; + const QList urls = d->urls(); + if (urls.empty()) + return false; + // Try to find local files + bool hasFiles = false; + const QList::const_iterator cend = urls.constEnd(); + for (QList::const_iterator it = urls.constBegin(); it != cend; ++it) { + const QString fileName = it->toLocalFile(); + if (!fileName.isEmpty()) { + hasFiles = true; + if (files) { + files->push_back(fileName); + } else { + break; // No result list, sufficient for checking + } + } + } + return hasFiles; +} + +void MainWindow::dragEnterEvent(QDragEnterEvent *event) +{ + if (isDesktopFileManagerDrop(event->mimeData())) { + event->accept(); + } else { + event->ignore(); + } +} + +void MainWindow::dropEvent(QDropEvent *event) +{ + QStringList files; + if (isDesktopFileManagerDrop(event->mimeData(), &files)) { + event->accept(); + openFiles(files); + } else { + event->ignore(); + } +} + IContext *MainWindow::currentContextObject() const { return m_activeContext; diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index c0203a2af37..912c84482fa 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -139,8 +139,10 @@ public slots: void showOptionsDialog(const QString &category = QString(), const QString &page = QString()); protected: - void changeEvent(QEvent *e); - void closeEvent(QCloseEvent *event); + virtual void changeEvent(QEvent *e); + virtual void closeEvent(QCloseEvent *event); + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); private slots: void openFile(); diff --git a/src/plugins/coreplugin/welcomemode.cpp b/src/plugins/coreplugin/welcomemode.cpp index 7cd17e3ddcd..21a25471101 100644 --- a/src/plugins/coreplugin/welcomemode.cpp +++ b/src/plugins/coreplugin/welcomemode.cpp @@ -150,6 +150,7 @@ WelcomeMode::WelcomeMode() : updateWelcomePage(welcomePageData); l->addWidget(m_d->m_webview); + m_d->m_webview->setAcceptDrops(false); #else m_d->m_label->setWordWrap(true); From 11cbfbda115516e9027c2df478ed0c74fc6ae84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 10 Feb 2009 10:52:28 +0100 Subject: [PATCH 7/9] Recognize .qs files as QScript Reviewed-by: Friedemann Kleint --- src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml b/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml index 45f6c0b00b8..fb2dc1afb69 100644 --- a/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml +++ b/src/plugins/qtscripteditor/QtScriptEditor.mimetypes.xml @@ -37,5 +37,6 @@ JavaScript 程序 JavaScript 程式 + From be38c9b4f02b1e58defa034b39d8e7bb98daf921 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 Feb 2009 11:38:04 +0100 Subject: [PATCH 8/9] Fixes: Prevent help view from accepting file manager drops RevBy: Eike --- src/shared/help/helpviewer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/help/helpviewer.cpp b/src/shared/help/helpviewer.cpp index ab95e62b8cd..b22726da610 100644 --- a/src/shared/help/helpviewer.cpp +++ b/src/shared/help/helpviewer.cpp @@ -167,7 +167,7 @@ private: HelpPage::HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent) : QWebPage(parent), centralWidget(central), helpEngine(engine) -{ +{ } QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) @@ -215,7 +215,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) : QWebView(parent), helpEngine(engine), parentWidget(parent) -{ +{ setPage(new HelpPage(parent, helpEngine, this)); page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this)); @@ -238,6 +238,7 @@ HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); + setAcceptDrops(false); } void HelpViewer::setSource(const QUrl &url) From 19670c5bebc09804ae43520492234f390773259f Mon Sep 17 00:00:00 2001 From: con Date: Tue, 10 Feb 2009 12:13:45 +0100 Subject: [PATCH 9/9] Fixes: - Crash on searching in "current project" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task: - 243147 RevBy: - Thorbjørn Details: - Crash occurred in case there actually is no "current project", e.g. because the current file doesn't appear in a project. --- src/plugins/find/findtoolwindow.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp index f9f23d0668f..8330a02065c 100644 --- a/src/plugins/find/findtoolwindow.cpp +++ b/src/plugins/find/findtoolwindow.cpp @@ -104,10 +104,17 @@ void FindToolWindow::setCurrentFilter(int index) QWidget *configWidget = m_configWidgets.at(i); if (!configWidget) continue; - if (i == index) + if (i == index) { m_ui.configWidget->layout()->addWidget(configWidget); - else + bool enabled = m_filters.at(i)->isEnabled(); + m_ui.matchCase->setEnabled(enabled); + m_ui.wholeWords->setEnabled(enabled); + m_ui.searchTerm->setEnabled(enabled); + m_ui.searchButton->setEnabled(enabled); + configWidget->setEnabled(enabled); + } else { configWidget->setParent(0); + } } }