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 91 Lines • ▼ Show 20 Line(s) | 119 | { | |||
142 | mConfigureButton->setText(i18n("Configure...")); | 143 | mConfigureButton->setText(i18n("Configure...")); | ||
143 | mConfigureButton->setToolTip(i18n("Change Spectacle's settings.")); | 144 | mConfigureButton->setToolTip(i18n("Change Spectacle's settings.")); | ||
144 | mConfigureButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 145 | mConfigureButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
145 | mDialogButtonBox->addButton(mConfigureButton, QDialogButtonBox::ResetRole); | 146 | mDialogButtonBox->addButton(mConfigureButton, QDialogButtonBox::ResetRole); | ||
146 | 147 | | |||
147 | KGuiItem::assign(mToolsButton, KGuiItem(i18n("Tools"))); | 148 | KGuiItem::assign(mToolsButton, KGuiItem(i18n("Tools"))); | ||
148 | mToolsButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | 149 | mToolsButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | ||
149 | mDialogButtonBox->addButton(mToolsButton, QDialogButtonBox::ActionRole); | 150 | mDialogButtonBox->addButton(mToolsButton, QDialogButtonBox::ActionRole); | ||
150 | mToolsMenu->addAction(KStandardAction::print(this, SLOT(showPrintDialog()), this)); | | |||
151 | mToolsButton->setMenu(mToolsMenu); | 151 | mToolsButton->setMenu(mToolsMenu); | ||
152 | 152 | | |||
153 | KGuiItem::assign(mSendToButton, KGuiItem(i18n("Export"))); | 153 | KGuiItem::assign(mSendToButton, KGuiItem(i18n("Export"))); | ||
154 | mSendToButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | 154 | mSendToButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | ||
155 | mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole); | 155 | mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole); | ||
156 | 156 | | |||
157 | mClipboardButton->setDefaultAction(KStandardAction::copy(this, SLOT(sendToClipboard()), this)); | 157 | mClipboardButton->setDefaultAction(KStandardAction::copy(this, SLOT(sendToClipboard()), this)); | ||
158 | mClipboardButton->setText(i18n("Copy To Clipboard")); | 158 | mClipboardButton->setText(i18n("Copy To Clipboard")); | ||
159 | mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard.")); | 159 | mClipboardButton->setToolTip(i18n("Copy the current screenshot image to the clipboard.")); | ||
160 | mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 160 | mClipboardButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
161 | mDialogButtonBox->addButton(mClipboardButton, QDialogButtonBox::ActionRole); | 161 | mDialogButtonBox->addButton(mClipboardButton, QDialogButtonBox::ActionRole); | ||
162 | 162 | | |||
163 | mSaveButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 163 | mSaveButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
164 | mSaveButton->setMenu(mSaveMenu); | 164 | mSaveButton->setMenu(mSaveMenu); | ||
165 | mSaveButton->setPopupMode(QToolButton::MenuButtonPopup); | 165 | mSaveButton->setPopupMode(QToolButton::MenuButtonPopup); | ||
166 | buildSaveMenu(); | 166 | buildSaveMenu(); | ||
167 | mDialogButtonBox->addButton(mSaveButton, QDialogButtonBox::ActionRole); | 167 | mDialogButtonBox->addButton(mSaveButton, QDialogButtonBox::ActionRole); | ||
168 | 168 | | |||
169 | // the help menu | 169 | // the help menu | ||
170 | 170 | | |||
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 | // 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 | // message widget | 181 | // message widget | ||
175 | connect(mMessageWidget, &KMessageWidget::linkActivated, this, [](const QString &str) { QDesktopServices::openUrl(QUrl(str)); } ); | 182 | connect(mMessageWidget, &KMessageWidget::linkActivated, this, [](const QString &str) { QDesktopServices::openUrl(QUrl(str)); } ); | ||
176 | 183 | | |||
177 | // layouts | 184 | // layouts | ||
178 | 185 | | |||
179 | mDivider->setFrameShape(QFrame::HLine); | 186 | mDivider->setFrameShape(QFrame::HLine); | ||
180 | mDivider->setLineWidth(2); | 187 | mDivider->setLineWidth(2); | ||
181 | 188 | | |||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 289 | { | |||
284 | QPrintDialog printDialog(printer, this); | 291 | QPrintDialog printDialog(printer, this); | ||
285 | if (printDialog.exec() == QDialog::Accepted) { | 292 | if (printDialog.exec() == QDialog::Accepted) { | ||
286 | ExportManager::instance()->doPrint(printer); | 293 | ExportManager::instance()->doPrint(printer); | ||
287 | return; | 294 | return; | ||
288 | } | 295 | } | ||
289 | delete printer; | 296 | delete printer; | ||
290 | } | 297 | } | ||
291 | 298 | | |||
299 | void KSMainWindow::openScreenshotsFolder() | ||||
300 | { | ||||
301 | // Highlight last screenshot in file manager if user saved at least once, | ||||
302 | // or open default directory as determined by save button | ||||
303 | QUrl location = ExportManager::instance()->lastSavePath(); | ||||
304 | if (!ExportManager::instance()->isFileExists(location)) { | ||||
305 | switch(saveButtonMode()) { | ||||
306 | case SaveMode::Save: | ||||
307 | location = QUrl::fromLocalFile(ExportManager::instance()->saveLocation() + QStringLiteral("/")); | ||||
308 | break; | ||||
309 | case SaveMode::SaveAs: | ||||
310 | location = SpectacleConfig::instance()->lastSaveAsLocation(); | ||||
311 | break; | ||||
312 | } | ||||
313 | if (!ExportManager::instance()->isFileExists(location)) { | ||||
314 | location = QUrl(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QStringLiteral("/")); | ||||
315 | } | ||||
316 | } | ||||
317 | KIO::highlightInFileManager({location}); | ||||
318 | } | ||||
319 | | ||||
292 | void KSMainWindow::showImageSharedFeedback(bool error, const QString &message) | 320 | void KSMainWindow::showImageSharedFeedback(bool error, const QString &message) | ||
293 | { | 321 | { | ||
294 | if (error) { | 322 | if (error) { | ||
295 | mMessageWidget->setMessageType(KMessageWidget::Error); | 323 | mMessageWidget->setMessageType(KMessageWidget::Error); | ||
296 | mMessageWidget->setText(i18n("There was a problem sharing the image: %1", message)); | 324 | mMessageWidget->setText(i18n("There was a problem sharing the image: %1", message)); | ||
297 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | 325 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | ||
298 | } else { | 326 | } else { | ||
299 | mMessageWidget->setMessageType(KMessageWidget::Positive); | 327 | mMessageWidget->setMessageType(KMessageWidget::Positive); | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |