Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Show All 34 Lines | |||||
35 | 35 | | |||
36 | #include <panels/places/placesitem.h> | 36 | #include <panels/places/placesitem.h> | ||
37 | #include <panels/places/placesitemmodel.h> | 37 | #include <panels/places/placesitemmodel.h> | ||
38 | 38 | | |||
39 | #include <Phonon/BackendCapabilities> | 39 | #include <Phonon/BackendCapabilities> | ||
40 | #include <Phonon/MediaObject> | 40 | #include <Phonon/MediaObject> | ||
41 | 41 | | |||
42 | #include <QLabel> | 42 | #include <QLabel> | ||
43 | #include <QDialogButtonBox> | ||||
43 | #include <QScrollArea> | 44 | #include <QScrollArea> | ||
44 | #include <QTextLayout> | 45 | #include <QTextLayout> | ||
45 | #include <QTimer> | 46 | #include <QTimer> | ||
46 | #include <QVBoxLayout> | 47 | #include <QVBoxLayout> | ||
47 | #include <QStyle> | 48 | #include <QStyle> | ||
48 | 49 | | |||
49 | #include "dolphin_informationpanelsettings.h" | 50 | #include "dolphin_informationpanelsettings.h" | ||
50 | #include "phononwidget.h" | 51 | #include "phononwidget.h" | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 65 | { | |||
102 | 103 | | |||
103 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | 104 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | ||
104 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 105 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
105 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | 106 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | ||
106 | this, &InformationPanelContent::urlActivated); | 107 | this, &InformationPanelContent::urlActivated); | ||
107 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | 108 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||
108 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 109 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
109 | 110 | | |||
111 | // Configuration | ||||
112 | m_configureLabel = new QLabel(i18nc("@label::textbox", | ||||
113 | "Select which data should " | ||||
114 | "be shown:"), this); | ||||
elvisangelaccio: Why split the i18n sentence into two lines? It looks weird imho. | |||||
115 | m_configureLabel->setWordWrap(true); | ||||
116 | m_configureLabel->setVisible(false); | ||||
117 | | ||||
118 | m_configureButtons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); | ||||
elvisangelaccio: Coding style: missing space before/after `|` | |||||
119 | m_configureButtons->setVisible(false); | ||||
120 | connect(m_configureButtons, &QDialogButtonBox::accepted, this, [this]() { | ||||
121 | this->m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Accept); | ||||
Why this-> only on this line? (I'd just remove it as it's unnecessary) elvisangelaccio: Why `this->` only on this line? (I'd just remove it as it's unnecessary) | |||||
122 | m_configureButtons->setVisible(false); | ||||
123 | m_configureLabel->setVisible(false); | ||||
124 | } | ||||
These 3 lines could go in a dedicated function which we could call from both lambdas, to avoid code duplication. Or it could even be a private slot connected to QDialogButtonBox::clicked. elvisangelaccio: These 3 lines could go in a dedicated function which we could call from both lambdas, to avoid… | |||||
I don't think an extra level of indirection makes the code easier to understand ... bruns: I don't think an extra level of indirection makes the code easier to understand ... | |||||
125 | ); | ||||
126 | connect(m_configureButtons, &QDialogButtonBox::rejected, this, [this]() { | ||||
127 | this->m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Cancel); | ||||
elvisangelaccio: Same here | |||||
128 | m_configureButtons->setVisible(false); | ||||
129 | m_configureLabel->setVisible(false); | ||||
130 | } | ||||
131 | ); | ||||
132 | | ||||
110 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | 133 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | ||
111 | // at the bottom. This prevents that the meta data widget gets vertically stretched | 134 | // at the bottom. This prevents that the meta data widget gets vertically stretched | ||
112 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | 135 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | ||
113 | QWidget* metaDataWidgetContainer = new QWidget(parent); | 136 | QWidget* metaDataWidgetContainer = new QWidget(parent); | ||
114 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | 137 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | ||
115 | containerLayout->setContentsMargins(0, 0, 0, 0); | 138 | containerLayout->setContentsMargins(0, 0, 0, 0); | ||
116 | containerLayout->setSpacing(0); | 139 | containerLayout->setSpacing(0); | ||
117 | containerLayout->addWidget(m_metaDataWidget); | 140 | containerLayout->addWidget(m_metaDataWidget); | ||
118 | containerLayout->addStretch(); | 141 | containerLayout->addStretch(); | ||
119 | 142 | | |||
120 | m_metaDataArea = new QScrollArea(parent); | 143 | m_metaDataArea = new QScrollArea(parent); | ||
121 | m_metaDataArea->setWidget(metaDataWidgetContainer); | 144 | m_metaDataArea->setWidget(metaDataWidgetContainer); | ||
122 | m_metaDataArea->setWidgetResizable(true); | 145 | m_metaDataArea->setWidgetResizable(true); | ||
123 | m_metaDataArea->setFrameShape(QFrame::NoFrame); | 146 | m_metaDataArea->setFrameShape(QFrame::NoFrame); | ||
124 | 147 | | |||
125 | QWidget* viewport = m_metaDataArea->viewport(); | 148 | QWidget* viewport = m_metaDataArea->viewport(); | ||
126 | viewport->installEventFilter(this); | 149 | viewport->installEventFilter(this); | ||
127 | 150 | | |||
128 | layout->addWidget(m_preview); | 151 | layout->addWidget(m_preview); | ||
129 | layout->addWidget(m_phononWidget); | 152 | layout->addWidget(m_phononWidget); | ||
130 | layout->addWidget(m_nameLabel); | 153 | layout->addWidget(m_nameLabel); | ||
131 | layout->addWidget(new KSeparator()); | 154 | layout->addWidget(new KSeparator()); | ||
155 | layout->addWidget(m_configureLabel); | ||||
132 | layout->addWidget(m_metaDataArea); | 156 | layout->addWidget(m_metaDataArea); | ||
157 | layout->addWidget(m_configureButtons); | ||||
133 | 158 | | |||
134 | m_placesItemModel = new PlacesItemModel(this); | 159 | m_placesItemModel = new PlacesItemModel(this); | ||
135 | } | 160 | } | ||
136 | 161 | | |||
137 | InformationPanelContent::~InformationPanelContent() | 162 | InformationPanelContent::~InformationPanelContent() | ||
138 | { | 163 | { | ||
139 | InformationPanelSettings::self()->save(); | 164 | InformationPanelSettings::self()->save(); | ||
140 | } | 165 | } | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 194 | } else { | |||
204 | } | 229 | } | ||
205 | } | 230 | } | ||
206 | } else { | 231 | } else { | ||
207 | m_preview->hide(); | 232 | m_preview->hide(); | ||
208 | m_phononWidget->hide(); | 233 | m_phononWidget->hide(); | ||
209 | } | 234 | } | ||
210 | } | 235 | } | ||
211 | 236 | | |||
237 | void InformationPanelContent::configureShownProperties() { | ||||
Coding style: brace should go to next line (the function below is also wrong...) elvisangelaccio: Coding style: brace should go to next line (the function below is also wrong...) | |||||
bruns: The glory of copy and paste ;-) | |||||
238 | m_configureLabel->setVisible(true); | ||||
239 | m_configureButtons->setVisible(true); | ||||
240 | m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::ReStart); | ||||
241 | } | ||||
242 | | ||||
212 | void InformationPanelContent::refreshMetaData() { | 243 | void InformationPanelContent::refreshMetaData() { | ||
213 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 244 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
214 | m_metaDataWidget->show(); | 245 | m_metaDataWidget->show(); | ||
215 | m_metaDataWidget->setItems(KFileItemList() << m_item); | 246 | m_metaDataWidget->setItems(KFileItemList() << m_item); | ||
216 | } | 247 | } | ||
217 | 248 | | |||
218 | void InformationPanelContent::showItems(const KFileItemList& items) | 249 | void InformationPanelContent::showItems(const KFileItemList& items) | ||
219 | { | 250 | { | ||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |
Why split the i18n sentence into two lines? It looks weird imho.