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 name="GridHeight" type="Int">
|
||||
<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 name="GridWidth" type="Int">
|
||||
<label>Grid width</label>
|
||||
|
@ -44,7 +44,7 @@
|
|||
</entry>
|
||||
<entry name="NumberOfTextlines" type="Int">
|
||||
<label>Number of textlines</label>
|
||||
<default>2</default>
|
||||
<default>1</default>
|
||||
</entry>
|
||||
<entry name="Preview" type="Bool">
|
||||
<label>Show preview</label>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
DolphinController::DolphinController(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_showPreview(false),
|
||||
m_showAdditionalInfo(false),
|
||||
m_zoomInPossible(false),
|
||||
m_zoomOutPossible(false)
|
||||
{
|
||||
|
@ -60,11 +61,19 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
|
|||
emit sortOrderChanged(order);
|
||||
}
|
||||
|
||||
void DolphinController::setShowPreview(bool showPreview)
|
||||
void DolphinController::setShowPreview(bool show)
|
||||
{
|
||||
if (m_showPreview != showPreview) {
|
||||
m_showPreview = showPreview;
|
||||
emit showPreviewChanged(showPreview);
|
||||
if (m_showPreview != show) {
|
||||
m_showPreview = show;
|
||||
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);
|
||||
virtual ~DolphinController();
|
||||
|
||||
void setUrl(const KUrl& url)
|
||||
{
|
||||
m_url = url;
|
||||
}
|
||||
const KUrl& url() const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
inline void setUrl(const KUrl& url);
|
||||
inline const KUrl& url() const;
|
||||
|
||||
void triggerContextMenuRequest(const QPoint& pos);
|
||||
|
||||
|
@ -75,31 +69,19 @@ public:
|
|||
|
||||
void indicateSortOrderChange(Qt::SortOrder order);
|
||||
|
||||
void setShowPreview(bool showPreview);
|
||||
bool showPreview() const
|
||||
{
|
||||
return m_showPreview;
|
||||
}
|
||||
void setShowPreview(bool show);
|
||||
inline bool showPreview() const;
|
||||
|
||||
void setShowAdditionalInfo(bool show);
|
||||
inline bool showAdditionalInfo() const;
|
||||
|
||||
void triggerZoomIn();
|
||||
void setZoomInPossible(bool possible)
|
||||
{
|
||||
m_zoomInPossible = possible;
|
||||
}
|
||||
bool isZoomInPossible() const
|
||||
{
|
||||
return m_zoomInPossible;
|
||||
}
|
||||
inline void setZoomInPossible(bool possible);
|
||||
inline bool isZoomInPossible() const;
|
||||
|
||||
void triggerZoomOut();
|
||||
void setZoomOutPossible(bool possible)
|
||||
{
|
||||
m_zoomOutPossible = possible;
|
||||
}
|
||||
bool isZoomOutPossible() const
|
||||
{
|
||||
return m_zoomOutPossible;
|
||||
}
|
||||
inline void setZoomOutPossible(bool possible);
|
||||
inline bool isZoomOutPossible() const;
|
||||
|
||||
public slots:
|
||||
void triggerItem(const QModelIndex& index);
|
||||
|
@ -137,9 +119,15 @@ signals:
|
|||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -159,9 +147,50 @@ signals:
|
|||
|
||||
private:
|
||||
bool m_showPreview;
|
||||
bool m_showAdditionalInfo;
|
||||
bool m_zoomInPossible;
|
||||
bool m_zoomOutPossible;
|
||||
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
|
||||
|
|
|
@ -52,7 +52,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
|||
connect(this, SIGNAL(activated(const QModelIndex&)),
|
||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
||||
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()),
|
||||
this, SLOT(zoomIn()));
|
||||
connect(controller, SIGNAL(zoomOut()),
|
||||
|
@ -69,8 +71,12 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
|||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
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) {
|
||||
setFlow(QListView::LeftToRight);
|
||||
|
@ -121,30 +127,14 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
|
|||
KListView::dropEvent(event);
|
||||
}
|
||||
|
||||
void DolphinIconsView::updateGridSize(bool showPreview)
|
||||
void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
|
||||
{
|
||||
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
||||
Q_ASSERT(settings != 0);
|
||||
updateGridSize(showPreview, m_controller->showAdditionalInfo());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
m_viewOptions.decorationSize = QSize(size, size);
|
||||
setGridSize(QSize(gridWidth, gridHeight));
|
||||
|
||||
m_controller->setZoomInPossible(isZoomInPossible());
|
||||
m_controller->setZoomOutPossible(isZoomOutPossible());
|
||||
void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo)
|
||||
{
|
||||
updateGridSize(m_controller->showPreview(), showAdditionalInfo);
|
||||
}
|
||||
|
||||
void DolphinIconsView::zoomIn()
|
||||
|
@ -173,7 +163,7 @@ void DolphinIconsView::zoomIn()
|
|||
settings->setGridWidth(settings->gridWidth() + 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->setGridHeight(settings->gridHeight() - diff);
|
||||
|
||||
updateGridSize(showPreview);
|
||||
updateGridSize(showPreview, m_controller->showAdditionalInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,4 +242,34 @@ int DolphinIconsView::decreasedIconSize(int size) const
|
|||
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"
|
||||
|
|
|
@ -51,12 +51,8 @@ protected:
|
|||
virtual void dropEvent(QDropEvent* event);
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* Updates the size of the grid
|
||||
* depending on the state of \a showPreview.
|
||||
*/
|
||||
void updateGridSize(bool showPreview);
|
||||
|
||||
void slotShowPreviewChanged(bool show);
|
||||
void slotShowAdditionalInfoChanged(bool show);
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
|
@ -70,9 +66,15 @@ private:
|
|||
/** Returns the decreased icon size for the size \a size. */
|
||||
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:
|
||||
DolphinController* m_controller;
|
||||
QStyleOptionViewItem m_viewOptions;
|
||||
QStyleOptionViewItemV2 m_viewOptions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -460,6 +460,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation inf
|
|||
ViewProperties props(m_urlNavigator->url());
|
||||
props.setAdditionalInfo(info);
|
||||
|
||||
m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
|
||||
m_fileItemDelegate->setAdditionalInformation(info);
|
||||
|
||||
emit additionalInfoChanged(info);
|
||||
|
@ -701,8 +702,8 @@ void DolphinView::changeDirectory(const KUrl& url)
|
|||
|
||||
KFileItemDelegate::AdditionalInformation info = props.additionalInfo();
|
||||
if (info != m_fileItemDelegate->additionalInformation()) {
|
||||
m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
|
||||
m_fileItemDelegate->setAdditionalInformation(info);
|
||||
|
||||
emit additionalInfoChanged(info);
|
||||
}
|
||||
|
||||
|
|
|
@ -161,13 +161,15 @@ void IconsViewSettingsPage::applySettings()
|
|||
QListView::TopToBottom;
|
||||
settings->setArrangement(arrangement);
|
||||
|
||||
const int numberOfTextlines = m_textlinesCountBox->value();
|
||||
|
||||
const int defaultSize = settings->iconSize();
|
||||
int gridWidth = defaultSize;
|
||||
int gridHeight = defaultSize;
|
||||
const int textSizeIndex = m_textWidthBox->currentIndex();
|
||||
if (arrangement == QListView::TopToBottom) {
|
||||
gridWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
|
||||
gridHeight += fontSize * 6;
|
||||
gridHeight += fontSize * (2 + numberOfTextlines);
|
||||
} else {
|
||||
gridWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
|
||||
}
|
||||
|
@ -180,7 +182,7 @@ void IconsViewSettingsPage::applySettings()
|
|||
settings->setItalicFont(font.italic());
|
||||
settings->setBoldFont(font.bold());
|
||||
|
||||
settings->setNumberOfTextlines(m_textlinesCountBox->value());
|
||||
settings->setNumberOfTextlines(numberOfTextlines);
|
||||
|
||||
settings->setGridSpacing(GridSpacingBase +
|
||||
m_gridSpacingBox->currentIndex() * GridSpacingInc);
|
||||
|
|
Loading…
Reference in a new issue