Commit 2498bd63 authored by Anthony Fieroni's avatar Anthony Fieroni
Browse files

Use parent widget for better positioning in Wayland


Signed-off-by: Anthony Fieroni's avatarAnthony Fieroni <bvbfan@abv.bg>
parent eedf1e31
Pipeline #148637 failed with stage
in 32 seconds
......@@ -25,6 +25,7 @@
#include <QTextCodec>
#include <QDir>
#include <QTextBrowser>
#include <QVBoxLayout>
K_PLUGIN_CLASS_WITH_JSON(FileViewGitPlugin, "fileviewgitplugin.json")
......@@ -41,6 +42,8 @@ FileViewGitPlugin::FileViewGitPlugin(QObject* parent, const QList<QVariant>& arg
{
Q_UNUSED(args);
m_parentWidget = qobject_cast<QWidget*>(parent);
m_revertAction = new QAction(this);
m_revertAction->setIcon(QIcon::fromTheme("document-revert"));
m_revertAction->setText(xi18nd("@action:inmenu", "<application>Git</application> Revert"));
......@@ -487,9 +490,13 @@ void FileViewGitPlugin::log()
palette.link().color().name(),
palette.linkVisited().color().name());
auto view = new QTextBrowser();
view->setAttribute(Qt::WA_DeleteOnClose);
view->setWindowTitle(xi18nd("@title:window", "<application>Git</application> Log"));
QDialog* dlg = new QDialog(m_parentWidget);
QVBoxLayout* layout = new QVBoxLayout;
auto view = new QTextBrowser(dlg);
layout->addWidget(view);
dlg->setLayout(layout);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setWindowTitle(xi18nd("@title:window", "<application>Git</application> Log"));
view->setOpenLinks(false);
view->setOpenExternalLinks(false);
connect(view, &QTextBrowser::anchorClicked, this, &FileViewGitPlugin::showDiff);
......@@ -511,8 +518,8 @@ void FileViewGitPlugin::log()
i18nc("Git commit author", "Author"),
gitOutput));
view->resize(QSize(720, 560));
view->show();
dlg->resize(QSize(720, 560));
dlg->show();
}
void FileViewGitPlugin::merge()
......@@ -524,7 +531,7 @@ void FileViewGitPlugin::merge()
void FileViewGitPlugin::checkout()
{
CheckoutDialog dialog;
CheckoutDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted){
QProcess process;
process.setWorkingDirectory(m_contextDir);
......@@ -581,7 +588,7 @@ void FileViewGitPlugin::checkout()
void FileViewGitPlugin::commit()
{
CommitDialog dialog;
CommitDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted) {
QTemporaryFile tmpCommitMessageFile;
tmpCommitMessageFile.open();
......@@ -615,7 +622,7 @@ void FileViewGitPlugin::commit()
void FileViewGitPlugin::createTag()
{
TagDialog dialog;
TagDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted) {
QTemporaryFile tempTagMessageFile;
tempTagMessageFile.open();
......@@ -652,7 +659,7 @@ void FileViewGitPlugin::createTag()
void FileViewGitPlugin::push()
{
PushDialog dialog;
PushDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted) {
m_process.setWorkingDirectory(m_contextDir);
......@@ -678,7 +685,7 @@ void FileViewGitPlugin::push()
void FileViewGitPlugin::pull()
{
PullDialog dialog;
PullDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted) {
m_process.setWorkingDirectory(m_contextDir);
......
......@@ -117,6 +117,8 @@ private:
QString m_operationCompletedMsg;
QString m_errorMsg;
QWidget* m_parentWidget;
//Current targets. m_contextItems is used if and only if m_contextDir is empty.
mutable QString m_contextDir;
mutable KFileItemList m_contextItems;
......
......@@ -86,6 +86,8 @@ FileViewHgPlugin::FileViewHgPlugin(QObject *parent, const QList<QVariant> &args)
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
m_parentWidget = qobject_cast<QWidget*>(parent);
m_addAction = new QAction(this);
m_addAction->setIcon(QIcon::fromTheme("list-add"));
m_addAction->setText(xi18nc("@action:inmenu",
......@@ -529,7 +531,7 @@ void FileViewHgPlugin::renameFile()
Q_EMIT infoMessage(xi18nc("@info:status",
"Renaming file in <application>Hg</application> repository."));
HgRenameDialog dialog(m_contextItems.first());
HgRenameDialog dialog(m_contextItems.first(), m_parentWidget);
dialog.exec();
m_contextItems.clear();
}
......@@ -549,7 +551,7 @@ void FileViewHgPlugin::commit()
Q_EMIT infoMessage(xi18nc("@info:status",
"Commit <application>Hg</application> repository."));
HgCommitDialog dialog;
HgCommitDialog dialog(m_parentWidget);
if (dialog.exec() == QDialog::Accepted) {
Q_EMIT itemVersionsChanged();
};
......@@ -564,7 +566,7 @@ void FileViewHgPlugin::tag()
Q_EMIT infoMessage(xi18nc("@info:status",
"Tagging operation in <application>Hg</application> repository."));
HgTagDialog dialog;
HgTagDialog dialog(m_parentWidget);
dialog.exec();
}
......@@ -577,7 +579,7 @@ void FileViewHgPlugin::update()
Q_EMIT infoMessage(xi18nc("@info:status",
"Updating <application>Hg</application> working directory."));
HgUpdateDialog dialog;
HgUpdateDialog dialog(m_parentWidget);
dialog.exec();
}
......@@ -590,63 +592,63 @@ void FileViewHgPlugin::branch()
Q_EMIT infoMessage(xi18nc("@info:status",
"Branch operation on <application>Hg</application> repository."));
HgBranchDialog dialog;
HgBranchDialog dialog(m_parentWidget);
dialog.exec();
}
void FileViewHgPlugin::clone()
{
clearMessages();
HgCloneDialog dialog(m_universalCurrentDirectory);
HgCloneDialog dialog(m_universalCurrentDirectory, m_parentWidget);
dialog.exec();
}
void FileViewHgPlugin::create()
{
clearMessages();
HgCreateDialog dialog(m_universalCurrentDirectory);
HgCreateDialog dialog(m_universalCurrentDirectory, m_parentWidget);
dialog.exec();
}
void FileViewHgPlugin::global_config()
{
clearMessages();
HgConfigDialog diag(HgConfig::GlobalConfig);
HgConfigDialog diag(HgConfig::GlobalConfig, m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::repo_config()
{
clearMessages();
HgConfigDialog diag(HgConfig::RepoConfig);
HgConfigDialog diag(HgConfig::RepoConfig, m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::push()
{
clearMessages();
HgPushDialog diag;
HgPushDialog diag(m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::pull()
{
clearMessages();
HgPullDialog diag;
HgPullDialog diag(m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::merge()
{
clearMessages();
HgMergeDialog diag;
HgMergeDialog diag(m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::bundle()
{
clearMessages();
HgBundleDialog diag;
HgBundleDialog diag(m_parentWidget);
diag.exec();
}
......@@ -670,14 +672,14 @@ void FileViewHgPlugin::unbundle()
void FileViewHgPlugin::importChangesets()
{
clearMessages();
HgImportDialog diag;
HgImportDialog diag(m_parentWidget);
diag.exec();
}
void FileViewHgPlugin::exportChangesets()
{
clearMessages();
HgExportDialog diag;
HgExportDialog diag(m_parentWidget);
diag.exec();
}
......@@ -749,7 +751,7 @@ void FileViewHgPlugin::diff()
void FileViewHgPlugin::serve()
{
clearMessages();
HgServeDialog diag;
HgServeDialog diag(m_parentWidget);
diag.exec();
}
......@@ -763,7 +765,7 @@ void FileViewHgPlugin::backout()
return;
}
HgBackoutDialog diag;
HgBackoutDialog diag(m_parentWidget);
diag.exec();
}
......
......@@ -119,6 +119,8 @@ private:
QAction *m_serveAction;
QAction *m_backoutAction;
QWidget* m_parentWidget;
mutable KFileItemList m_contextItems;
mutable QString m_universalCurrentDirectory;
mutable QString m_currentDir;
......
......@@ -64,6 +64,8 @@ FileViewSvnPlugin::FileViewSvnPlugin(QObject* parent, const QList<QVariant>& arg
{
Q_UNUSED(args);
m_parentWidget = qobject_cast<QWidget*>(parent);
m_updateAction = new QAction(this);
m_updateAction->setIcon(QIcon::fromTheme("view-refresh"));
m_updateAction->setText(i18nc("@item:inmenu", "SVN Update"));
......@@ -351,7 +353,7 @@ QList<QAction*> FileViewSvnPlugin::outOfVersionControlActions(const KFileItemLis
void FileViewSvnPlugin::updateFiles()
{
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Update"), m_contextDir);
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Update"), m_contextDir, m_parentWidget);
progressDialog->connectToProcess(&m_process);
execSvnCommand(QLatin1String("update"), QStringList(),
......@@ -414,7 +416,7 @@ void FileViewSvnPlugin::commitDialog()
}
}
SvnCommitDialog *svnCommitDialog = new SvnCommitDialog(&m_versionInfoHash, context);
SvnCommitDialog *svnCommitDialog = new SvnCommitDialog(&m_versionInfoHash, context, m_parentWidget);
connect(this, &FileViewSvnPlugin::versionInfoUpdated, svnCommitDialog, &SvnCommitDialog::refreshChangesList);
......@@ -460,7 +462,7 @@ void FileViewSvnPlugin::revertFiles()
root = SvnCommands::localRoot( m_contextItems.last().localPath() );
}
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Revert"), root);
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Revert"), root, m_parentWidget);
progressDialog->connectToProcess(&m_process);
execSvnCommand(QStringLiteral("revert"), arguments,
......@@ -471,7 +473,7 @@ void FileViewSvnPlugin::revertFiles()
void FileViewSvnPlugin::logDialog()
{
SvnLogDialog *svnLogDialog = new SvnLogDialog(m_contextDir);
SvnLogDialog *svnLogDialog = new SvnLogDialog(m_contextDir, m_parentWidget);
connect(svnLogDialog, &SvnLogDialog::errorMessage, this, &FileViewSvnPlugin::errorMessage);
connect(svnLogDialog, &SvnLogDialog::operationCompletedMessage, this, &FileViewSvnPlugin::operationCompletedMessage);
......@@ -484,7 +486,7 @@ void FileViewSvnPlugin::logDialog()
void FileViewSvnPlugin::checkoutDialog()
{
SvnCheckoutDialog *svnCheckoutDialog = new SvnCheckoutDialog(m_contextDir);
SvnCheckoutDialog *svnCheckoutDialog = new SvnCheckoutDialog(m_contextDir, m_parentWidget);
connect(svnCheckoutDialog, &SvnCheckoutDialog::infoMessage, this, &FileViewSvnPlugin::infoMessage);
connect(svnCheckoutDialog, &SvnCheckoutDialog::errorMessage, this, &FileViewSvnPlugin::errorMessage);
......@@ -496,7 +498,7 @@ void FileViewSvnPlugin::checkoutDialog()
void FileViewSvnPlugin::cleanupDialog()
{
SvnCleanupDialog *svnCleanupDialog = new SvnCleanupDialog(m_contextDir);
SvnCleanupDialog *svnCleanupDialog = new SvnCleanupDialog(m_contextDir, m_parentWidget);
connect(svnCleanupDialog, &SvnCleanupDialog::errorMessage, this, &FileViewSvnPlugin::errorMessage);
connect(svnCleanupDialog, &SvnCleanupDialog::operationCompletedMessage, this, &FileViewSvnPlugin::operationCompletedMessage);
......@@ -546,7 +548,7 @@ void FileViewSvnPlugin::revertFiles(const QStringList& filesPath)
}
m_contextDir.clear();
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Revert"), SvnCommands::localRoot(filesPath.first()));
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Revert"), SvnCommands::localRoot(filesPath.first()), m_parentWidget);
progressDialog->connectToProcess(&m_process);
execSvnCommand(QLatin1String("revert"), QStringList() << filesPath,
......@@ -656,7 +658,7 @@ void FileViewSvnPlugin::commitFiles(const QStringList& context, const QString& m
m_contextDir.clear();
m_contextItems.clear();
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Commit"), SvnCommands::localRoot(context.first()));
SvnProgressDialog *progressDialog = new SvnProgressDialog(i18nc("@title:window", "SVN Commit"), SvnCommands::localRoot(context.first()), m_parentWidget);
progressDialog->connectToProcess(&m_process);
execSvnCommand(QLatin1String("commit"), arguments,
......
......@@ -114,6 +114,8 @@ private:
QString m_errorMsg;
QString m_operationCompletedMsg;
QWidget* m_parentWidget;
mutable QString m_contextDir;
mutable KFileItemList m_contextItems;
......
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