mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
layout improvements in the icons view:
* do a text wrapping if the number of lines is > 1 (TODO: bugfix of KFileItemDelegate necessary, currently the text might overlap with the icon) * increase the height for the text area if an additional information like type, date, ... is shown svn path=/trunk/KDE/kdebase/apps/; revision=663320
This commit is contained in:
parent
6ab84fbd61
commit
d03b27f288
|
@ -28,7 +28,7 @@
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="GridHeight" type="Int">
|
<entry name="GridHeight" type="Int">
|
||||||
<label>Grid height</label>
|
<label>Grid height</label>
|
||||||
<default code="true">K3Icon::SizeMedium + (KGlobalSettings::generalFont().pointSize() * 6)</default>
|
<default code="true">K3Icon::SizeMedium + (KGlobalSettings::generalFont().pointSize() * 3)</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="GridWidth" type="Int">
|
<entry name="GridWidth" type="Int">
|
||||||
<label>Grid width</label>
|
<label>Grid width</label>
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="NumberOfTextlines" type="Int">
|
<entry name="NumberOfTextlines" type="Int">
|
||||||
<label>Number of textlines</label>
|
<label>Number of textlines</label>
|
||||||
<default>2</default>
|
<default>1</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="Preview" type="Bool">
|
<entry name="Preview" type="Bool">
|
||||||
<label>Show preview</label>
|
<label>Show preview</label>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
DolphinController::DolphinController(QObject* parent) :
|
DolphinController::DolphinController(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_showPreview(false),
|
m_showPreview(false),
|
||||||
|
m_showAdditionalInfo(false),
|
||||||
m_zoomInPossible(false),
|
m_zoomInPossible(false),
|
||||||
m_zoomOutPossible(false)
|
m_zoomOutPossible(false)
|
||||||
{
|
{
|
||||||
|
@ -60,11 +61,19 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
|
||||||
emit sortOrderChanged(order);
|
emit sortOrderChanged(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::setShowPreview(bool showPreview)
|
void DolphinController::setShowPreview(bool show)
|
||||||
{
|
{
|
||||||
if (m_showPreview != showPreview) {
|
if (m_showPreview != show) {
|
||||||
m_showPreview = showPreview;
|
m_showPreview = show;
|
||||||
emit showPreviewChanged(showPreview);
|
emit showPreviewChanged(show);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DolphinController::setShowAdditionalInfo(bool show)
|
||||||
|
{
|
||||||
|
if (m_showAdditionalInfo != show) {
|
||||||
|
m_showAdditionalInfo = show;
|
||||||
|
emit showAdditionalInfoChanged(show);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,8 @@ public:
|
||||||
explicit DolphinController(QObject* parent);
|
explicit DolphinController(QObject* parent);
|
||||||
virtual ~DolphinController();
|
virtual ~DolphinController();
|
||||||
|
|
||||||
void setUrl(const KUrl& url)
|
inline void setUrl(const KUrl& url);
|
||||||
{
|
inline const KUrl& url() const;
|
||||||
m_url = url;
|
|
||||||
}
|
|
||||||
const KUrl& url() const
|
|
||||||
{
|
|
||||||
return m_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void triggerContextMenuRequest(const QPoint& pos);
|
void triggerContextMenuRequest(const QPoint& pos);
|
||||||
|
|
||||||
|
@ -75,31 +69,19 @@ public:
|
||||||
|
|
||||||
void indicateSortOrderChange(Qt::SortOrder order);
|
void indicateSortOrderChange(Qt::SortOrder order);
|
||||||
|
|
||||||
void setShowPreview(bool showPreview);
|
void setShowPreview(bool show);
|
||||||
bool showPreview() const
|
inline bool showPreview() const;
|
||||||
{
|
|
||||||
return m_showPreview;
|
void setShowAdditionalInfo(bool show);
|
||||||
}
|
inline bool showAdditionalInfo() const;
|
||||||
|
|
||||||
void triggerZoomIn();
|
void triggerZoomIn();
|
||||||
void setZoomInPossible(bool possible)
|
inline void setZoomInPossible(bool possible);
|
||||||
{
|
inline bool isZoomInPossible() const;
|
||||||
m_zoomInPossible = possible;
|
|
||||||
}
|
|
||||||
bool isZoomInPossible() const
|
|
||||||
{
|
|
||||||
return m_zoomInPossible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void triggerZoomOut();
|
void triggerZoomOut();
|
||||||
void setZoomOutPossible(bool possible)
|
inline void setZoomOutPossible(bool possible);
|
||||||
{
|
inline bool isZoomOutPossible() const;
|
||||||
m_zoomOutPossible = possible;
|
|
||||||
}
|
|
||||||
bool isZoomOutPossible() const
|
|
||||||
{
|
|
||||||
return m_zoomOutPossible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void triggerItem(const QModelIndex& index);
|
void triggerItem(const QModelIndex& index);
|
||||||
|
@ -137,9 +119,15 @@ signals:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the state for showing previews has been
|
* Is emitted if the state for showing previews has been
|
||||||
* changed to \a showPreview.
|
* changed to \a show.
|
||||||
*/
|
*/
|
||||||
void showPreviewChanged(bool showPreview);
|
void showPreviewChanged(bool show);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted if the state for showing additional info has been
|
||||||
|
* changed to \a show.
|
||||||
|
*/
|
||||||
|
void showAdditionalInfoChanged(bool show);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the item with the index \a index should be triggered.
|
* Is emitted if the item with the index \a index should be triggered.
|
||||||
|
@ -159,9 +147,50 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_showPreview;
|
bool m_showPreview;
|
||||||
|
bool m_showAdditionalInfo;
|
||||||
bool m_zoomInPossible;
|
bool m_zoomInPossible;
|
||||||
bool m_zoomOutPossible;
|
bool m_zoomOutPossible;
|
||||||
KUrl m_url;
|
KUrl m_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void DolphinController::setUrl(const KUrl& url)
|
||||||
|
{
|
||||||
|
m_url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const KUrl& DolphinController::url() const
|
||||||
|
{
|
||||||
|
return m_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DolphinController::showPreview() const
|
||||||
|
{
|
||||||
|
return m_showPreview;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DolphinController::showAdditionalInfo() const
|
||||||
|
{
|
||||||
|
return m_showAdditionalInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DolphinController::setZoomInPossible(bool possible)
|
||||||
|
{
|
||||||
|
m_zoomInPossible = possible;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DolphinController::isZoomInPossible() const
|
||||||
|
{
|
||||||
|
return m_zoomInPossible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DolphinController::setZoomOutPossible(bool possible)
|
||||||
|
{
|
||||||
|
m_zoomOutPossible = possible;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DolphinController::isZoomOutPossible() const
|
||||||
|
{
|
||||||
|
return m_zoomOutPossible;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,7 +52,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
||||||
connect(this, SIGNAL(activated(const QModelIndex&)),
|
connect(this, SIGNAL(activated(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
controller, SLOT(triggerItem(const QModelIndex&)));
|
||||||
connect(controller, SIGNAL(showPreviewChanged(bool)),
|
connect(controller, SIGNAL(showPreviewChanged(bool)),
|
||||||
this, SLOT(updateGridSize(bool)));
|
this, SLOT(slotShowPreviewChanged(bool)));
|
||||||
|
connect(controller, SIGNAL(showAdditionalInfoChanged(bool)),
|
||||||
|
this, SLOT(slotShowAdditionalInfoChanged(bool)));
|
||||||
connect(controller, SIGNAL(zoomIn()),
|
connect(controller, SIGNAL(zoomIn()),
|
||||||
this, SLOT(zoomIn()));
|
this, SLOT(zoomIn()));
|
||||||
connect(controller, SIGNAL(zoomOut()),
|
connect(controller, SIGNAL(zoomOut()),
|
||||||
|
@ -69,8 +71,12 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
||||||
font.setItalic(settings->italicFont());
|
font.setItalic(settings->italicFont());
|
||||||
font.setBold(settings->boldFont());
|
font.setBold(settings->boldFont());
|
||||||
m_viewOptions.font = font;
|
m_viewOptions.font = font;
|
||||||
|
if (settings->numberOfTextlines() > 1) {
|
||||||
|
m_viewOptions.textElideMode = Qt::ElideNone;
|
||||||
|
m_viewOptions.features = QStyleOptionViewItemV2::WrapText;
|
||||||
|
}
|
||||||
|
|
||||||
updateGridSize(controller->showPreview());
|
updateGridSize(controller->showPreview(), controller->showAdditionalInfo());
|
||||||
|
|
||||||
if (settings->arrangement() == QListView::TopToBottom) {
|
if (settings->arrangement() == QListView::TopToBottom) {
|
||||||
setFlow(QListView::LeftToRight);
|
setFlow(QListView::LeftToRight);
|
||||||
|
@ -121,30 +127,14 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
|
||||||
KListView::dropEvent(event);
|
KListView::dropEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::updateGridSize(bool showPreview)
|
void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
|
||||||
{
|
{
|
||||||
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
updateGridSize(showPreview, m_controller->showAdditionalInfo());
|
||||||
Q_ASSERT(settings != 0);
|
}
|
||||||
|
|
||||||
int gridWidth = settings->gridWidth();
|
void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo)
|
||||||
int gridHeight = settings->gridHeight();
|
{
|
||||||
int size = settings->iconSize();
|
updateGridSize(m_controller->showPreview(), showAdditionalInfo);
|
||||||
|
|
||||||
if (showPreview) {
|
|
||||||
const int previewSize = settings->previewSize();
|
|
||||||
const int diff = previewSize - size;
|
|
||||||
Q_ASSERT(diff >= 0);
|
|
||||||
gridWidth += diff;
|
|
||||||
gridHeight += diff;
|
|
||||||
|
|
||||||
size = previewSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_viewOptions.decorationSize = QSize(size, size);
|
|
||||||
setGridSize(QSize(gridWidth, gridHeight));
|
|
||||||
|
|
||||||
m_controller->setZoomInPossible(isZoomInPossible());
|
|
||||||
m_controller->setZoomOutPossible(isZoomOutPossible());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::zoomIn()
|
void DolphinIconsView::zoomIn()
|
||||||
|
@ -173,7 +163,7 @@ void DolphinIconsView::zoomIn()
|
||||||
settings->setGridWidth(settings->gridWidth() + diff);
|
settings->setGridWidth(settings->gridWidth() + diff);
|
||||||
settings->setGridHeight(settings->gridHeight() + diff);
|
settings->setGridHeight(settings->gridHeight() + diff);
|
||||||
|
|
||||||
updateGridSize(showPreview);
|
updateGridSize(showPreview, m_controller->showAdditionalInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +194,7 @@ void DolphinIconsView::zoomOut()
|
||||||
settings->setGridWidth(settings->gridWidth() - diff);
|
settings->setGridWidth(settings->gridWidth() - diff);
|
||||||
settings->setGridHeight(settings->gridHeight() - diff);
|
settings->setGridHeight(settings->gridHeight() - diff);
|
||||||
|
|
||||||
updateGridSize(showPreview);
|
updateGridSize(showPreview, m_controller->showAdditionalInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,4 +242,34 @@ int DolphinIconsView::decreasedIconSize(int size) const
|
||||||
return decSize;
|
return decSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
|
||||||
|
{
|
||||||
|
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
||||||
|
Q_ASSERT(settings != 0);
|
||||||
|
|
||||||
|
int gridWidth = settings->gridWidth();
|
||||||
|
int gridHeight = settings->gridHeight();
|
||||||
|
int size = settings->iconSize();
|
||||||
|
|
||||||
|
if (showPreview) {
|
||||||
|
const int previewSize = settings->previewSize();
|
||||||
|
const int diff = previewSize - size;
|
||||||
|
Q_ASSERT(diff >= 0);
|
||||||
|
gridWidth += diff;
|
||||||
|
gridHeight += diff;
|
||||||
|
|
||||||
|
size = previewSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showAdditionalInfo) {
|
||||||
|
gridHeight += m_viewOptions.font.pointSize() * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_viewOptions.decorationSize = QSize(size, size);
|
||||||
|
setGridSize(QSize(gridWidth, gridHeight));
|
||||||
|
|
||||||
|
m_controller->setZoomInPossible(isZoomInPossible());
|
||||||
|
m_controller->setZoomOutPossible(isZoomOutPossible());
|
||||||
|
}
|
||||||
|
|
||||||
#include "dolphiniconsview.moc"
|
#include "dolphiniconsview.moc"
|
||||||
|
|
|
@ -51,12 +51,8 @@ protected:
|
||||||
virtual void dropEvent(QDropEvent* event);
|
virtual void dropEvent(QDropEvent* event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
void slotShowPreviewChanged(bool show);
|
||||||
* Updates the size of the grid
|
void slotShowAdditionalInfoChanged(bool show);
|
||||||
* depending on the state of \a showPreview.
|
|
||||||
*/
|
|
||||||
void updateGridSize(bool showPreview);
|
|
||||||
|
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
|
||||||
|
@ -70,9 +66,15 @@ private:
|
||||||
/** Returns the decreased icon size for the size \a size. */
|
/** Returns the decreased icon size for the size \a size. */
|
||||||
int decreasedIconSize(int size) const;
|
int decreasedIconSize(int size) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the size of the grid depending on the state
|
||||||
|
* of \a showPreview and \a showAdditionalInfo.
|
||||||
|
*/
|
||||||
|
void updateGridSize(bool showPreview, bool showAdditionalInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinController* m_controller;
|
DolphinController* m_controller;
|
||||||
QStyleOptionViewItem m_viewOptions;
|
QStyleOptionViewItemV2 m_viewOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -460,6 +460,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation inf
|
||||||
ViewProperties props(m_urlNavigator->url());
|
ViewProperties props(m_urlNavigator->url());
|
||||||
props.setAdditionalInfo(info);
|
props.setAdditionalInfo(info);
|
||||||
|
|
||||||
|
m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
|
||||||
m_fileItemDelegate->setAdditionalInformation(info);
|
m_fileItemDelegate->setAdditionalInformation(info);
|
||||||
|
|
||||||
emit additionalInfoChanged(info);
|
emit additionalInfoChanged(info);
|
||||||
|
@ -701,8 +702,8 @@ void DolphinView::changeDirectory(const KUrl& url)
|
||||||
|
|
||||||
KFileItemDelegate::AdditionalInformation info = props.additionalInfo();
|
KFileItemDelegate::AdditionalInformation info = props.additionalInfo();
|
||||||
if (info != m_fileItemDelegate->additionalInformation()) {
|
if (info != m_fileItemDelegate->additionalInformation()) {
|
||||||
|
m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
|
||||||
m_fileItemDelegate->setAdditionalInformation(info);
|
m_fileItemDelegate->setAdditionalInformation(info);
|
||||||
|
|
||||||
emit additionalInfoChanged(info);
|
emit additionalInfoChanged(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,13 +161,15 @@ void IconsViewSettingsPage::applySettings()
|
||||||
QListView::TopToBottom;
|
QListView::TopToBottom;
|
||||||
settings->setArrangement(arrangement);
|
settings->setArrangement(arrangement);
|
||||||
|
|
||||||
|
const int numberOfTextlines = m_textlinesCountBox->value();
|
||||||
|
|
||||||
const int defaultSize = settings->iconSize();
|
const int defaultSize = settings->iconSize();
|
||||||
int gridWidth = defaultSize;
|
int gridWidth = defaultSize;
|
||||||
int gridHeight = defaultSize;
|
int gridHeight = defaultSize;
|
||||||
const int textSizeIndex = m_textWidthBox->currentIndex();
|
const int textSizeIndex = m_textWidthBox->currentIndex();
|
||||||
if (arrangement == QListView::TopToBottom) {
|
if (arrangement == QListView::TopToBottom) {
|
||||||
gridWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
|
gridWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
|
||||||
gridHeight += fontSize * 6;
|
gridHeight += fontSize * (2 + numberOfTextlines);
|
||||||
} else {
|
} else {
|
||||||
gridWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
|
gridWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +182,7 @@ void IconsViewSettingsPage::applySettings()
|
||||||
settings->setItalicFont(font.italic());
|
settings->setItalicFont(font.italic());
|
||||||
settings->setBoldFont(font.bold());
|
settings->setBoldFont(font.bold());
|
||||||
|
|
||||||
settings->setNumberOfTextlines(m_textlinesCountBox->value());
|
settings->setNumberOfTextlines(numberOfTextlines);
|
||||||
|
|
||||||
settings->setGridSpacing(GridSpacingBase +
|
settings->setGridSpacing(GridSpacingBase +
|
||||||
m_gridSpacingBox->currentIndex() * GridSpacingInc);
|
m_gridSpacingBox->currentIndex() * GridSpacingInc);
|
||||||
|
|
Loading…
Reference in a new issue