Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
Show All 34 Lines | |||||
35 | 35 | | |||
36 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
37 | #include <KGuiItem> | 37 | #include <KGuiItem> | ||
38 | #include <KStandardAction> | 38 | #include <KStandardAction> | ||
39 | #include <KStandardGuiItem> | 39 | #include <KStandardGuiItem> | ||
40 | #include <KHelpMenu> | 40 | #include <KHelpMenu> | ||
41 | #include <KAboutData> | 41 | #include <KAboutData> | ||
42 | #include <KWindowSystem> | 42 | #include <KWindowSystem> | ||
43 | #include <KIO/OpenFileManagerWindowJob> | ||||
43 | 44 | | |||
44 | #include "SettingsDialog/SettingsDialog.h" | 45 | #include "SettingsDialog/SettingsDialog.h" | ||
45 | #include "ExportMenu.h" | 46 | #include "ExportMenu.h" | ||
46 | #include "ExportManager.h" | 47 | #include "ExportManager.h" | ||
47 | #include "SpectacleConfig.h" | 48 | #include "SpectacleConfig.h" | ||
48 | 49 | | |||
49 | static const int DEFAULT_WINDOW_HEIGHT = 420; | 50 | static const int DEFAULT_WINDOW_HEIGHT = 420; | ||
50 | static const int DEFAULT_WINDOW_WIDTH = 840; | 51 | static const int DEFAULT_WINDOW_WIDTH = 840; | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 121 | { | |||
144 | mConfigureButton->setText(i18n("Configure...")); | 145 | mConfigureButton->setText(i18n("Configure...")); | ||
145 | mConfigureButton->setToolTip(i18n("Change Spectacle's settings.")); | 146 | mConfigureButton->setToolTip(i18n("Change Spectacle's settings.")); | ||
146 | mConfigureButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 147 | mConfigureButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
147 | mDialogButtonBox->addButton(mConfigureButton, QDialogButtonBox::ResetRole); | 148 | mDialogButtonBox->addButton(mConfigureButton, QDialogButtonBox::ResetRole); | ||
148 | 149 | | |||
149 | KGuiItem::assign(mToolsButton, KGuiItem(i18n("Tools"))); | 150 | KGuiItem::assign(mToolsButton, KGuiItem(i18n("Tools"))); | ||
150 | mToolsButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | 151 | mToolsButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | ||
151 | mDialogButtonBox->addButton(mToolsButton, QDialogButtonBox::ActionRole); | 152 | mDialogButtonBox->addButton(mToolsButton, QDialogButtonBox::ActionRole); | ||
152 | mToolsMenu->addAction(KStandardAction::print(this, SLOT(showPrintDialog()), this)); | | |||
153 | mToolsButton->setMenu(mToolsMenu); | 153 | mToolsButton->setMenu(mToolsMenu); | ||
154 | 154 | | |||
155 | KGuiItem::assign(mSendToButton, KGuiItem(i18n("Export"))); | 155 | KGuiItem::assign(mSendToButton, KGuiItem(i18n("Export"))); | ||
156 | mSendToButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | 156 | mSendToButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | ||
157 | mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole); | 157 | mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole); | ||
158 | 158 | | |||
159 | mClipboardButton->setDefaultAction(KStandardAction::copy(this, SLOT(sendToClipboard()), this)); | 159 | mClipboardButton->setDefaultAction(KStandardAction::copy(this, SLOT(sendToClipboard()), this)); | ||
160 | mClipboardButton->setText(i18n("Copy To Clipboard")); | 160 | mClipboardButton->setText(i18n("Copy To Clipboard")); | ||
161 | mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard.")); | 161 | mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard.")); | ||
162 | mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 162 | mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
163 | mDialogButtonBox->addButton(mClipboardButton, QDialogButtonBox::ActionRole); | 163 | mDialogButtonBox->addButton(mClipboardButton, QDialogButtonBox::ActionRole); | ||
164 | 164 | | |||
165 | mSaveButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 165 | mSaveButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
166 | mSaveButton->setMenu(mSaveMenu); | 166 | mSaveButton->setMenu(mSaveMenu); | ||
167 | mSaveButton->setPopupMode(QToolButton::MenuButtonPopup); | 167 | mSaveButton->setPopupMode(QToolButton::MenuButtonPopup); | ||
168 | mDialogButtonBox->addButton(mSaveButton, QDialogButtonBox::ActionRole); | 168 | mDialogButtonBox->addButton(mSaveButton, QDialogButtonBox::ActionRole); | ||
169 | 169 | | |||
170 | // the help menu | 170 | // the help menu | ||
171 | KHelpMenu *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true); | 171 | KHelpMenu *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true); | ||
172 | mDialogButtonBox->button(QDialogButtonBox::Help)->setMenu(helpMenu->menu()); | 172 | mDialogButtonBox->button(QDialogButtonBox::Help)->setMenu(helpMenu->menu()); | ||
173 | 173 | | |||
174 | // the tools menu | ||||
175 | mToolsMenu->addAction(KStandardAction::print(this, &KSMainWindow::showPrintDialog, this)); | ||||
176 | mToolsMenu->addAction( | ||||
177 | QIcon::fromTheme(QStringLiteral("document-open-folder")), | ||||
178 | i18n("Open Screenshots Folder"), | ||||
179 | this, &KSMainWindow::openScreenshotsFolder); | ||||
180 | | ||||
174 | // the save menu | 181 | // the save menu | ||
175 | mSaveAsAction = KStandardAction::saveAs(this, &KSMainWindow::saveAs, this); | 182 | mSaveAsAction = KStandardAction::saveAs(this, &KSMainWindow::saveAs, this); | ||
176 | mSaveAction = KStandardAction::save(this, &KSMainWindow::save, this); | 183 | mSaveAction = KStandardAction::save(this, &KSMainWindow::save, this); | ||
177 | mSaveMenu->addAction(mSaveAsAction); | 184 | mSaveMenu->addAction(mSaveAsAction); | ||
178 | mSaveMenu->addAction(mSaveAction); | 185 | mSaveMenu->addAction(mSaveAction); | ||
179 | setDefaultSaveAction(); | 186 | setDefaultSaveAction(); | ||
180 | 187 | | |||
181 | // message widget | 188 | // message widget | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 286 | { | |||
281 | QPrintDialog printDialog(printer, this); | 288 | QPrintDialog printDialog(printer, this); | ||
282 | if (printDialog.exec() == QDialog::Accepted) { | 289 | if (printDialog.exec() == QDialog::Accepted) { | ||
283 | ExportManager::instance()->doPrint(printer); | 290 | ExportManager::instance()->doPrint(printer); | ||
284 | return; | 291 | return; | ||
285 | } | 292 | } | ||
286 | delete printer; | 293 | delete printer; | ||
287 | } | 294 | } | ||
288 | 295 | | |||
296 | void KSMainWindow::openScreenshotsFolder() | ||||
297 | { | ||||
298 | // Highlight last screenshot in file manager if user saved at least once, | ||||
299 | // or open default directory as determined by save button | ||||
300 | QUrl location = ExportManager::instance()->lastSavePath(); | ||||
301 | if (!ExportManager::instance()->isFileExists(location)) { | ||||
302 | switch(saveButtonMode()) { | ||||
303 | case SaveMode::Save: | ||||
304 | location = QUrl::fromLocalFile(ExportManager::instance()->saveLocation() + QStringLiteral("/")); | ||||
305 | break; | ||||
306 | case SaveMode::SaveAs: | ||||
307 | location = SpectacleConfig::instance()->lastSaveAsLocation(); | ||||
308 | break; | ||||
309 | } | ||||
310 | if (!ExportManager::instance()->isFileExists(location)) { | ||||
311 | location = QUrl(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QStringLiteral("/")); | ||||
312 | } | ||||
313 | } | ||||
314 | KIO::highlightInFileManager({location}); | ||||
315 | } | ||||
316 | | ||||
289 | void KSMainWindow::showImageSharedFeedback(bool error, const QString &message) | 317 | void KSMainWindow::showImageSharedFeedback(bool error, const QString &message) | ||
290 | { | 318 | { | ||
291 | if (error) { | 319 | if (error) { | ||
292 | mMessageWidget->setMessageType(KMessageWidget::Error); | 320 | mMessageWidget->setMessageType(KMessageWidget::Error); | ||
293 | mMessageWidget->setText(i18n("There was a problem sharing the image: %1", message)); | 321 | mMessageWidget->setText(i18n("There was a problem sharing the image: %1", message)); | ||
294 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | 322 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | ||
295 | } else { | 323 | } else { | ||
296 | mMessageWidget->setMessageType(KMessageWidget::Positive); | 324 | mMessageWidget->setMessageType(KMessageWidget::Positive); | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |