mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Allow to toggle word wrap in views
This commit is contained in:
@@ -188,20 +188,23 @@ namespace BlackGui
|
|||||||
//! View resizing
|
//! View resizing
|
||||||
static const QString &pathViewResize() { static const QString p("View.15.Resize"); return p; }
|
static const QString &pathViewResize() { static const QString p("View.15.Resize"); return p; }
|
||||||
|
|
||||||
|
//! View word wrap
|
||||||
|
static const QString &pathViewWordWrap() { static const QString p("View.16.WordWrap"); return p; }
|
||||||
|
|
||||||
//! View clear highlighting
|
//! View clear highlighting
|
||||||
static const QString &pathViewClearHighlighting() { static const QString p("View.16.ClearHighlight"); return p; }
|
static const QString &pathViewClearHighlighting() { static const QString p("View.17.ClearHighlight"); return p; }
|
||||||
|
|
||||||
//! View filter
|
//! View filter
|
||||||
static const QString &pathViewFilter() { static const QString p("View.17.Filter"); return p; }
|
static const QString &pathViewFilter() { static const QString p("View.18.Filter"); return p; }
|
||||||
|
|
||||||
//! View update
|
//! View update
|
||||||
static const QString &pathViewUpdates() { static const QString p("View.18.Updates"); return p; }
|
static const QString &pathViewUpdates() { static const QString p("View.19.Updates"); return p; }
|
||||||
|
|
||||||
//! View load/save
|
//! View load/save
|
||||||
static const QString &pathViewLoadSave() { static const QString p("View.18.LoadSave"); return p; }
|
static const QString &pathViewLoadSave() { static const QString p("View.19.LoadSave"); return p; }
|
||||||
|
|
||||||
//! View cut and paste
|
//! View cut and paste
|
||||||
static const QString &pathViewCutPaste() { static const QString p("View.18.CutPaste"); return p; }
|
static const QString &pathViewCutPaste() { static const QString p("View.19.CutPaste"); return p; }
|
||||||
|
|
||||||
// ---- nested dock widgets ----
|
// ---- nested dock widgets ----
|
||||||
|
|
||||||
|
|||||||
@@ -596,6 +596,9 @@ namespace BlackGui
|
|||||||
//! Toggle the resize mode
|
//! Toggle the resize mode
|
||||||
void toggleResizeMode(bool checked);
|
void toggleResizeMode(bool checked);
|
||||||
|
|
||||||
|
//! Toggle the resize mode
|
||||||
|
void toggleWordWrap(bool checked);
|
||||||
|
|
||||||
//! Set the filter widget internally
|
//! Set the filter widget internally
|
||||||
//! \remarks used for dialog and filter widget
|
//! \remarks used for dialog and filter widget
|
||||||
void setFilterWidgetImpl(QWidget *filterWidget);
|
void setFilterWidgetImpl(QWidget *filterWidget);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "blackgui/views/viewbase.h"
|
#include "blackgui/views/viewbase.h"
|
||||||
#include "blackgui/shortcut.h"
|
#include "blackgui/shortcut.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
|
#include "viewbase.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -85,7 +86,7 @@ namespace BlackGui
|
|||||||
copy->setContext(Qt::WidgetShortcut);
|
copy->setContext(Qt::WidgetShortcut);
|
||||||
|
|
||||||
QShortcut *resize = new QShortcut(CShortcut::keyResizeView(), this);
|
QShortcut *resize = new QShortcut(CShortcut::keyResizeView(), this);
|
||||||
connect(resize, &QShortcut::activated, this, &CViewBaseNonTemplate::fullResizeToContents);
|
connect(resize, &QShortcut::activated, this, &CViewBaseNonTemplate::resizeToContents);
|
||||||
resize->setObjectName("Resize view shortcut for " + this->objectName());
|
resize->setObjectName("Resize view shortcut for " + this->objectName());
|
||||||
resize->setContext(Qt::WidgetShortcut);
|
resize->setContext(Qt::WidgetShortcut);
|
||||||
}
|
}
|
||||||
@@ -436,13 +437,19 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *actionInteractiveResize = menuActions.addAction(CIcons::viewTile(), "Resize (auto)", CMenuAction::pathViewResize(), nullptr);
|
||||||
QAction *actionInteractiveResize = menuActions.addAction(CIcons::viewMultiColumn(), "Resize (auto)", CMenuAction::pathViewResize(), nullptr);
|
|
||||||
actionInteractiveResize->setObjectName(this->objectName().append("ActionResizing"));
|
actionInteractiveResize->setObjectName(this->objectName().append("ActionResizing"));
|
||||||
actionInteractiveResize->setCheckable(true);
|
actionInteractiveResize->setCheckable(true);
|
||||||
actionInteractiveResize->setChecked(autoResize);
|
actionInteractiveResize->setChecked(autoResize);
|
||||||
actionInteractiveResize->setEnabled(enabled);
|
actionInteractiveResize->setEnabled(enabled);
|
||||||
connect(actionInteractiveResize, &QAction::toggled, this, &CViewBaseNonTemplate::toggleResizeMode);
|
connect(actionInteractiveResize, &QAction::toggled, this, &CViewBaseNonTemplate::toggleResizeMode);
|
||||||
|
|
||||||
|
QAction *actionWordWrap = menuActions.addAction(CIcons::viewMultiColumn(), "Word wrap (multiline)", CMenuAction::pathViewResize(), nullptr);
|
||||||
|
actionWordWrap->setObjectName(this->objectName().append("ActionResizing"));
|
||||||
|
actionWordWrap->setCheckable(true);
|
||||||
|
actionWordWrap->setChecked(this->wordWrap());
|
||||||
|
actionWordWrap->setEnabled(true);
|
||||||
|
connect(actionWordWrap, &QAction::toggled, this, &CViewBaseNonTemplate::toggleWordWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::resizeEvent(QResizeEvent *event)
|
void CViewBaseNonTemplate::resizeEvent(QResizeEvent *event)
|
||||||
@@ -836,6 +843,13 @@ namespace BlackGui
|
|||||||
m_resizeMode = checked ? ResizingAuto : ResizingOff;
|
m_resizeMode = checked ? ResizingAuto : ResizingOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::toggleWordWrap(bool checked)
|
||||||
|
{
|
||||||
|
if (this->wordWrap() == checked) { return; }
|
||||||
|
this->setWordWrap(checked);
|
||||||
|
this->resizeRowsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::toggleAutoDisplay()
|
void CViewBaseNonTemplate::toggleAutoDisplay()
|
||||||
{
|
{
|
||||||
const QAction *a = qobject_cast<const QAction *>(QObject::sender());
|
const QAction *a = qobject_cast<const QAction *>(QObject::sender());
|
||||||
|
|||||||
Reference in New Issue
Block a user