Changeset View
Changeset View
Standalone View
Standalone View
krusader/DiskUsage/diskusagegui.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
48 | #include "../krglobal.h" | 48 | #include "../krglobal.h" | ||
49 | #include "../FileSystem/filesystem.h" | 49 | #include "../FileSystem/filesystem.h" | ||
50 | #include "../Dialogs/krdialogs.h" | 50 | #include "../Dialogs/krdialogs.h" | ||
51 | 51 | | |||
52 | DiskUsageGUI::DiskUsageGUI(QUrl openDir, QWidget* parent) | 52 | DiskUsageGUI::DiskUsageGUI(QUrl openDir, QWidget* parent) | ||
53 | : QDialog(parent), exitAtFailure(true) | 53 | : QDialog(parent), exitAtFailure(true) | ||
54 | { | 54 | { | ||
55 | setWindowTitle(i18n("Krusader::Disk Usage")); | 55 | setWindowTitle(i18n("Krusader::Disk Usage")); | ||
56 | setAttribute(Qt::WA_DeleteOnClose); | ||||
57 | duCanceled = false; | ||||
56 | 58 | | |||
57 | baseDirectory = openDir; | 59 | baseDirectory = openDir; | ||
58 | if (!newSearch()) | 60 | if (!newSearch()) { | ||
59 | return; | 61 | duCanceled = true; | ||
60 | 62 | } | |||
61 | QVBoxLayout *mainLayout = new QVBoxLayout; | 63 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
62 | setLayout(mainLayout); | 64 | setLayout(mainLayout); | ||
63 | 65 | | |||
64 | QGridLayout *duGrid = new QGridLayout(); | 66 | QGridLayout *duGrid = new QGridLayout(); | ||
65 | duGrid->setSpacing(6); | 67 | duGrid->setSpacing(6); | ||
66 | duGrid->setContentsMargins(11, 11, 11, 11); | 68 | duGrid->setContentsMargins(11, 11, 11, 11); | ||
67 | 69 | | |||
68 | QWidget *duTools = new QWidget(this); | 70 | QWidget *duTools = new QWidget(this); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
121 | status = new KSqueezedTextLabel(this); | 123 | status = new KSqueezedTextLabel(this); | ||
122 | duGrid->addWidget(status, 2, 0); | 124 | duGrid->addWidget(status, 2, 0); | ||
123 | 125 | | |||
124 | mainLayout->addLayout(duGrid); | 126 | mainLayout->addLayout(duGrid); | ||
125 | 127 | | |||
126 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); | 128 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); | ||
127 | mainLayout->addWidget(buttonBox); | 129 | mainLayout->addWidget(buttonBox); | ||
128 | 130 | | |||
129 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | 131 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); | ||
130 | connect(diskUsage, SIGNAL(status(QString)), this, SLOT(setStatus(QString))); | 132 | connect(diskUsage, SIGNAL(status(QString)), this, SLOT(setStatus(QString))); | ||
131 | connect(diskUsage, SIGNAL(viewChanged(int)), this, SLOT(slotViewChanged(int))); | 133 | connect(diskUsage, SIGNAL(viewChanged(int)), this, SLOT(slotViewChanged(int))); | ||
132 | connect(diskUsage, SIGNAL(newSearch()), this, SLOT(newSearch())); | 134 | connect(diskUsage, SIGNAL(newSearch()), this, SLOT(newSearch())); | ||
133 | connect(diskUsage, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); | 135 | connect(diskUsage, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); | ||
134 | connect(btnNewSearch, SIGNAL(clicked()), this, SLOT(newSearch())); | 136 | connect(btnNewSearch, SIGNAL(clicked()), this, SLOT(newSearch())); | ||
135 | connect(btnRefresh, SIGNAL(clicked()), this, SLOT(loadUsageInfo())); | 137 | connect(btnRefresh, SIGNAL(clicked()), this, SLOT(loadUsageInfo())); | ||
136 | connect(btnDirUp, SIGNAL(clicked()), diskUsage, SLOT(dirUp())); | 138 | connect(btnDirUp, SIGNAL(clicked()), diskUsage, SLOT(dirUp())); | ||
137 | connect(btnLines, SIGNAL(clicked()), this, SLOT(selectLinesView())); | 139 | connect(btnLines, SIGNAL(clicked()), this, SLOT(selectLinesView())); | ||
138 | connect(btnDetailed, SIGNAL(clicked()), this, SLOT(selectListView())); | 140 | connect(btnDetailed, SIGNAL(clicked()), this, SLOT(selectListView())); | ||
139 | connect(btnFilelight, SIGNAL(clicked()), this, SLOT(selectFilelightView())); | 141 | connect(btnFilelight, SIGNAL(clicked()), this, SLOT(selectFilelightView())); | ||
140 | 142 | | |||
141 | KConfigGroup group(krConfig, "DiskUsage"); | 143 | KConfigGroup group(krConfig, "DiskUsage"); | ||
142 | 144 | | |||
143 | int view = group.readEntry("View", VIEW_LINES); | 145 | int view = group.readEntry("View", VIEW_LINES); | ||
144 | if (view < VIEW_LINES || view > VIEW_FILELIGHT) | 146 | if (view < VIEW_LINES || view > VIEW_FILELIGHT) | ||
145 | view = VIEW_LINES; | 147 | view = VIEW_LINES; | ||
146 | diskUsage->setView(view); | 148 | diskUsage->setView(view); | ||
147 | 149 | | |||
148 | sizeX = group.readEntry("Window Width", QFontMetrics(font()).width("W") * 70); | 150 | sizeX = group.readEntry("Window Width", QFontMetrics(font()).width("W") * 70); | ||
149 | sizeY = group.readEntry("Window Height", QFontMetrics(font()).height() * 25); | 151 | sizeY = group.readEntry("Window Height", QFontMetrics(font()).height() * 25); | ||
150 | resize(sizeX, sizeY); | 152 | resize(sizeX, sizeY); | ||
151 | 153 | | |||
152 | if (group.readEntry("Window Maximized", false)) | 154 | if (group.readEntry("Window Maximized", false)) { | ||
153 | showMaximized(); | 155 | setWindowState(windowState() | Qt::WindowMaximized); | ||
154 | else | 156 | } | ||
155 | show(); | | |||
156 | | ||||
157 | exec(); | | |||
158 | } | 157 | } | ||
martinkostolny: This show() here is redundant. I'd remove it. | |||||
159 | 158 | | |||
160 | DiskUsageGUI::~DiskUsageGUI() | 159 | DiskUsageGUI::~DiskUsageGUI() | ||
161 | { | 160 | { | ||
162 | } | 161 | } | ||
163 | 162 | | |||
164 | void DiskUsageGUI::slotLoadFinished(bool result) | 163 | void DiskUsageGUI::slotLoadFinished(bool result) | ||
165 | { | 164 | { | ||
166 | if (exitAtFailure && !result) | 165 | if (exitAtFailure && !result) | ||
Show All 16 Lines | |||||
183 | { | 182 | { | ||
184 | if (!isMaximized()) { | 183 | if (!isMaximized()) { | ||
185 | sizeX = e->size().width(); | 184 | sizeX = e->size().width(); | ||
186 | sizeY = e->size().height(); | 185 | sizeY = e->size().height(); | ||
187 | } | 186 | } | ||
188 | QDialog::resizeEvent(e); | 187 | QDialog::resizeEvent(e); | ||
189 | } | 188 | } | ||
190 | 189 | | |||
191 | void DiskUsageGUI::reject() | 190 | void DiskUsageGUI::closeEvent(QCloseEvent *event) | ||
192 | { | 191 | { | ||
193 | KConfigGroup group(krConfig, "DiskUsage"); | 192 | KConfigGroup group(krConfig, "DiskUsage"); | ||
194 | group.writeEntry("Window Width", sizeX); | 193 | group.writeEntry("Window Width", sizeX); | ||
195 | group.writeEntry("Window Height", sizeY); | 194 | group.writeEntry("Window Height", sizeY); | ||
196 | group.writeEntry("Window Maximized", isMaximized()); | 195 | group.writeEntry("Window Maximized", isMaximized()); | ||
197 | group.writeEntry("View", diskUsage->getActiveView()); | 196 | group.writeEntry("View", diskUsage->getActiveView()); | ||
198 | 197 | | |||
199 | QDialog::reject(); | 198 | event->accept(); | ||
200 | } | 199 | } | ||
201 | 200 | | |||
202 | void DiskUsageGUI::loadUsageInfo() | 201 | void DiskUsageGUI::loadUsageInfo() | ||
203 | { | 202 | { | ||
204 | diskUsage->load(baseDirectory); | 203 | diskUsage->load(baseDirectory); | ||
205 | } | 204 | } | ||
206 | 205 | | |||
207 | void DiskUsageGUI::setStatus(QString stat) | 206 | void DiskUsageGUI::setStatus(QString stat) | ||
Show All 34 Lines | 239 | { | |||
242 | 241 | | |||
243 | QUrl tmp = KChooseDir::getDir(i18n("Viewing the usage of folder:"), baseDirectory, baseDirectory); | 242 | QUrl tmp = KChooseDir::getDir(i18n("Viewing the usage of folder:"), baseDirectory, baseDirectory); | ||
244 | if (tmp.isEmpty()) return false; | 243 | if (tmp.isEmpty()) return false; | ||
245 | baseDirectory = tmp; | 244 | baseDirectory = tmp; | ||
246 | 245 | | |||
247 | QTimer::singleShot(0, this, SLOT(loadUsageInfo())); | 246 | QTimer::singleShot(0, this, SLOT(loadUsageInfo())); | ||
248 | return true; | 247 | return true; | ||
249 | } | 248 | } | ||
250 | 249 | void DiskUsageGUI::showConditional() | |||
250 | { | ||||
251 | if (duCanceled) { | ||||
252 | emit close(); | ||||
253 | } else { | ||||
254 | show(); | ||||
255 | } | ||||
256 | } |
This show() here is redundant. I'd remove it.