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 be shown:"), this); | ||||
114 | m_configureLabel->setWordWrap(true); | ||||
elvisangelaccio: Why split the i18n sentence into two lines? It looks weird imho. | |||||
115 | m_configureLabel->setVisible(false); | ||||
116 | | ||||
117 | m_configureButtons = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel); | ||||
118 | m_configureButtons->setVisible(false); | ||||
elvisangelaccio: Coding style: missing space before/after `|` | |||||
119 | connect(m_configureButtons, &QDialogButtonBox::accepted, this, [this]() { | ||||
120 | m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Accept); | ||||
121 | m_configureButtons->setVisible(false); | ||||
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_configureLabel->setVisible(false); | ||||
123 | emit configurationFinished(); | ||||
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 | m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Cancel); | ||||
elvisangelaccio: Same here | |||||
128 | m_configureButtons->setVisible(false); | ||||
129 | m_configureLabel->setVisible(false); | ||||
130 | emit configurationFinished(); | ||||
131 | } | ||||
132 | ); | ||||
133 | | ||||
110 | m_metaDataArea = new QScrollArea(parent); | 134 | m_metaDataArea = new QScrollArea(parent); | ||
111 | m_metaDataArea->setWidget(m_metaDataWidget); | 135 | m_metaDataArea->setWidget(m_metaDataWidget); | ||
112 | m_metaDataArea->setWidgetResizable(true); | 136 | m_metaDataArea->setWidgetResizable(true); | ||
113 | m_metaDataArea->setFrameShape(QFrame::NoFrame); | 137 | m_metaDataArea->setFrameShape(QFrame::NoFrame); | ||
114 | 138 | | |||
115 | QWidget* viewport = m_metaDataArea->viewport(); | 139 | QWidget* viewport = m_metaDataArea->viewport(); | ||
116 | viewport->installEventFilter(this); | 140 | viewport->installEventFilter(this); | ||
117 | 141 | | |||
118 | layout->addWidget(m_preview); | 142 | layout->addWidget(m_preview); | ||
119 | layout->addWidget(m_phononWidget); | 143 | layout->addWidget(m_phononWidget); | ||
120 | layout->addWidget(m_nameLabel); | 144 | layout->addWidget(m_nameLabel); | ||
121 | layout->addWidget(new KSeparator()); | 145 | layout->addWidget(new KSeparator()); | ||
146 | layout->addWidget(m_configureLabel); | ||||
122 | layout->addWidget(m_metaDataArea); | 147 | layout->addWidget(m_metaDataArea); | ||
148 | layout->addWidget(m_configureButtons); | ||||
123 | 149 | | |||
124 | m_placesItemModel = new PlacesItemModel(this); | 150 | m_placesItemModel = new PlacesItemModel(this); | ||
125 | } | 151 | } | ||
126 | 152 | | |||
127 | InformationPanelContent::~InformationPanelContent() | 153 | InformationPanelContent::~InformationPanelContent() | ||
128 | { | 154 | { | ||
129 | InformationPanelSettings::self()->save(); | 155 | InformationPanelSettings::self()->save(); | ||
130 | } | 156 | } | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 186 | } else { | |||
195 | } | 221 | } | ||
196 | } | 222 | } | ||
197 | } else { | 223 | } else { | ||
198 | m_preview->hide(); | 224 | m_preview->hide(); | ||
199 | m_phononWidget->hide(); | 225 | m_phononWidget->hide(); | ||
200 | } | 226 | } | ||
201 | } | 227 | } | ||
202 | 228 | | |||
229 | 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 ;-) | |||||
230 | { | ||||
231 | m_configureLabel->setVisible(true); | ||||
232 | m_configureButtons->setVisible(true); | ||||
233 | m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::ReStart); | ||||
234 | } | ||||
235 | | ||||
203 | void InformationPanelContent::refreshMetaData() | 236 | void InformationPanelContent::refreshMetaData() | ||
204 | { | 237 | { | ||
205 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 238 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
206 | m_metaDataWidget->show(); | 239 | m_metaDataWidget->show(); | ||
207 | m_metaDataWidget->setItems(KFileItemList() << m_item); | 240 | m_metaDataWidget->setItems(KFileItemList() << m_item); | ||
208 | } | 241 | } | ||
209 | 242 | | |||
210 | void InformationPanelContent::showItems(const KFileItemList& items) | 243 | void InformationPanelContent::showItems(const KFileItemList& items) | ||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |
Why split the i18n sentence into two lines? It looks weird imho.