From aab70a611daebc4b6764447c813fbff6af019b66 Mon Sep 17 00:00:00 2001 From: Christian Kaiser Date: Sun, 20 Mar 2016 21:32:10 -0300 Subject: [PATCH] More code style and some argument tweaks to functions. --- dialogs/areadialog.h | 24 +++++++++---------- dialogs/historydialog.cpp | 2 +- dialogs/historydialog.h | 42 ++++++++++++++++---------------- dialogs/namingdialog.cpp | 2 +- dialogs/namingdialog.h | 6 ++--- dialogs/optionsdialog.h | 46 +++++++++++++++++------------------ dialogs/previewdialog.h | 48 ++++++++++++++++++------------------- dialogs/updaterdialog.h | 8 +++---- lightscreenwindow.cpp | 2 +- lightscreenwindow.h | 2 +- tools/os.cpp | 2 +- tools/os.h | 5 +--- tools/screenshot.cpp | 4 ++-- tools/screenshot.h | 4 ++-- tools/screenshotmanager.cpp | 8 +++---- tools/screenshotmanager.h | 8 +++---- tools/windowpicker.h | 2 +- widgets/hotkeywidget.cpp | 2 +- widgets/hotkeywidget.h | 2 +- 19 files changed, 108 insertions(+), 111 deletions(-) diff --git a/dialogs/areadialog.h b/dialogs/areadialog.h index b3f355d..9b58bc3 100644 --- a/dialogs/areadialog.h +++ b/dialogs/areadialog.h @@ -42,7 +42,7 @@ class AreaDialog : public QDialog Q_OBJECT public: - AreaDialog(Screenshot* screenshot); + AreaDialog(Screenshot *screenshot); QRect &resultRect(); protected slots: @@ -52,22 +52,22 @@ protected slots: void grabRect(); signals: - void regionGrabbed( const QPixmap & ); + void regionGrabbed(const QPixmap &); protected: - void keyPressEvent( QKeyEvent* e ); - void mouseDoubleClickEvent( QMouseEvent* ); - void mouseMoveEvent( QMouseEvent* e ); - void mousePressEvent( QMouseEvent* e ); - void mouseReleaseEvent( QMouseEvent* e ); - void paintEvent( QPaintEvent* e ); - void resizeEvent( QResizeEvent* e ); - void showEvent( QShowEvent* e ); + void keyPressEvent(QKeyEvent *e); + void mouseDoubleClickEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void paintEvent(QPaintEvent *e); + void resizeEvent(QResizeEvent *e); + void showEvent(QShowEvent *e); void updateHandles(); QRegion handleMask() const; - QPoint limitPointToRect( const QPoint &p, const QRect &r ) const; + QPoint limitPointToRect(const QPoint &p, const QRect &r) const; bool mAutoclose; QPoint mDragStartPoint; @@ -92,7 +92,7 @@ protected slots: QRect mTLHandle, mTRHandle, mBLHandle, mBRHandle; QRect mLHandle, mTHandle, mRHandle, mBHandle; - QVector mHandles; + QVector mHandles; QPointer mAcceptWidget; }; diff --git a/dialogs/historydialog.cpp b/dialogs/historydialog.cpp index a8099a0..87dae6c 100644 --- a/dialogs/historydialog.cpp +++ b/dialogs/historydialog.cpp @@ -117,7 +117,7 @@ void HistoryDialog::clear() close(); } -void HistoryDialog::contextMenu(QPoint point) +void HistoryDialog::contextMenu(const QPoint &point) { mContextIndex = ui->tableView->indexAt(point);; diff --git a/dialogs/historydialog.h b/dialogs/historydialog.h index 2321d69..01ffe19 100644 --- a/dialogs/historydialog.h +++ b/dialogs/historydialog.h @@ -5,7 +5,7 @@ #include namespace Ui { - class HistoryDialog; +class HistoryDialog; } class QSqlTableModel; @@ -15,32 +15,32 @@ class HistoryDialog : public QDialog Q_OBJECT public: - explicit HistoryDialog(QWidget *parent = 0); - ~HistoryDialog(); + explicit HistoryDialog(QWidget *parent = 0); + ~HistoryDialog(); private slots: - void clear(); - void contextMenu(QPoint point); - void copy(); - void deleteImage(); - void location(); - void removeHistoryEntry(); - void refresh(); - void open(const QModelIndex &index); - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); - void upload(); - void uploadProgress(int progress); + void clear(); + void contextMenu(const QPoint &point); + void copy(); + void deleteImage(); + void location(); + void removeHistoryEntry(); + void refresh(); + void open(const QModelIndex &index); + void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void upload(); + void uploadProgress(int progress); protected: - bool eventFilter(QObject *object, QEvent *event); - bool event(QEvent *event); + bool eventFilter(QObject *object, QEvent *event); + bool event(QEvent *event); private: - Ui::HistoryDialog *ui; - QSqlTableModel *mModel; - QSortFilterProxyModel *mFilterModel; - QString mSelectedScreenshot; - QModelIndex mContextIndex; + Ui::HistoryDialog *ui; + QSqlTableModel *mModel; + QSortFilterProxyModel *mFilterModel; + QString mSelectedScreenshot; + QModelIndex mContextIndex; }; #endif // UPLOADDIALOG_H diff --git a/dialogs/namingdialog.cpp b/dialogs/namingdialog.cpp index ebe61c8..0baa369 100644 --- a/dialogs/namingdialog.cpp +++ b/dialogs/namingdialog.cpp @@ -61,7 +61,7 @@ NamingDialog::NamingDialog(Screenshot::Naming naming, QWidget *parent) : resize(minimumSizeHint()); } -void NamingDialog::openUrl(QString url) +void NamingDialog::openUrl(const QString &url) { QDesktopServices::openUrl(QUrl(url)); } diff --git a/dialogs/namingdialog.h b/dialogs/namingdialog.h index 501f04b..b19a9f8 100644 --- a/dialogs/namingdialog.h +++ b/dialogs/namingdialog.h @@ -32,11 +32,11 @@ class NamingDialog : public QDialog explicit NamingDialog(Screenshot::Naming naming, QWidget *parent = 0); private slots: - void openUrl(QString url); - void saveSettings(); + void openUrl(const QString &url); + void saveSettings(); protected: - bool eventFilter(QObject *object, QEvent *event); + bool eventFilter(QObject *object, QEvent *event); private: Ui::NamingDialog ui; diff --git a/dialogs/optionsdialog.h b/dialogs/optionsdialog.h index 9d30ac7..2c5c39e 100644 --- a/dialogs/optionsdialog.h +++ b/dialogs/optionsdialog.h @@ -33,38 +33,38 @@ class OptionsDialog : public QDialog OptionsDialog(QWidget *parent = 0); public slots: - void accepted(); - void checkUpdatesNow(); - void exportSettings(); - void imgurAlbumList(); - void imgurAuthorize(); - void imgurRequestAlbumList(); - void imgurToken(); - void importSettings(); - void loadSettings(); - void openUrl(QString url); - void restoreDefaults(); - void saveSettings(); - void updatePreview(); - void viewHistory(); + void accepted(); + void checkUpdatesNow(); + void exportSettings(); + void imgurAlbumList(); + void imgurAuthorize(); + void imgurRequestAlbumList(); + void imgurToken(); + void importSettings(); + void loadSettings(); + void openUrl(QString url); + void restoreDefaults(); + void saveSettings(); + void updatePreview(); + void viewHistory(); protected: - bool event(QEvent *event); + bool event(QEvent *event); #ifdef Q_OS_WIN - bool nativeEvent(const QByteArray &eventType, void *message, long *result); + bool nativeEvent(const QByteArray &eventType, void *message, long *result); #endif private slots: - void browse(); - void dialogButtonClicked(QAbstractButton *button); - void flipToggled(bool checked); - void init(); - void namingOptions(); + void browse(); + void dialogButtonClicked(QAbstractButton *button); + void flipToggled(bool checked); + void init(); + void namingOptions(); private: - bool hotkeyCollision(); - QSettings *settings() const; + bool hotkeyCollision(); + QSettings *settings() const; private: Ui::OptionsDialog ui; diff --git a/dialogs/previewdialog.h b/dialogs/previewdialog.h index c77994d..a9765f4 100644 --- a/dialogs/previewdialog.h +++ b/dialogs/previewdialog.h @@ -29,41 +29,41 @@ class PreviewDialog : public QDialog Q_OBJECT public: - PreviewDialog(QWidget *parent); + PreviewDialog(QWidget *parent); - void add(Screenshot* screenshot); - int count() const; + void add(Screenshot *screenshot); + int count() const; public slots: - void setWidth(int w) { resize(w, height()); } - void setHeight(int h) { resize(width(), h); } + void setWidth(int w) { resize(w, height()); } + void setHeight(int h) { resize(width(), h); } signals: - void acceptAll(); - void rejectAll(); - void uploadAll(); + void acceptAll(); + void rejectAll(); + void uploadAll(); private slots: - void closePreview(); - void enlargePreview(); - void indexChanged(int i); - void next(); - void previous(); - void relocate(); + void closePreview(); + void enlargePreview(); + void indexChanged(int i); + void next(); + void previous(); + void relocate(); protected: - bool event(QEvent *event); - void timerEvent(QTimerEvent *event); + bool event(QEvent *event); + void timerEvent(QTimerEvent *event); private: - int mAutoclose; - int mAutocloseAction; - int mAutocloseReset; - int mPosition; //0: top left, 1: top right, 2: bottom left, 3: bottom rigth (default) - int mSize; - QPushButton* mNextButton; - QPushButton* mPrevButton; - QStackedLayout* mStack; + int mAutoclose; + int mAutocloseAction; + int mAutocloseReset; + int mPosition; //0: top left, 1: top right, 2: bottom left, 3: bottom rigth (default) + int mSize; + QPushButton *mNextButton; + QPushButton *mPrevButton; + QStackedLayout *mStack; }; #endif // PREVIEWDIALOG_H diff --git a/dialogs/updaterdialog.h b/dialogs/updaterdialog.h index b40da44..6703d89 100644 --- a/dialogs/updaterdialog.h +++ b/dialogs/updaterdialog.h @@ -23,16 +23,16 @@ class UpdaterDialog : public QProgressDialog { - Q_OBJECT + Q_OBJECT public: - UpdaterDialog(QWidget* parent = 0); + UpdaterDialog(QWidget *parent = 0); public slots: - void updateDone(bool result); + void updateDone(bool result); private slots: - void link(QString url); + void link(QString url); }; diff --git a/lightscreenwindow.cpp b/lightscreenwindow.cpp index ac0628d..3040ed6 100644 --- a/lightscreenwindow.cpp +++ b/lightscreenwindow.cpp @@ -675,7 +675,7 @@ void LightscreenWindow::showUploaderError(const QString &error) notify(Screenshot::Fail); } -void LightscreenWindow::showUploaderMessage(QString fileName, QString url) +void LightscreenWindow::showUploaderMessage(const QString &fileName, const QString &url) { if (mTrayIcon && settings()->value("options/message").toBool() && !url.isEmpty()) { QString screenshot = QFileInfo(fileName).fileName(); diff --git a/lightscreenwindow.h b/lightscreenwindow.h index cf2b7f9..75bbb75 100644 --- a/lightscreenwindow.h +++ b/lightscreenwindow.h @@ -67,7 +67,7 @@ public slots: void showOptions(); void showScreenshotMessage(const Screenshot::Result &result, const QString &fileName); void showUploaderError(const QString &error); - void showUploaderMessage(QString fileName, QString url); + void showUploaderMessage(const QString &fileName, const QString &url); void toggleVisibility(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::DoubleClick); void updateStatus(); void updaterDone(bool result); diff --git a/tools/os.cpp b/tools/os.cpp index 8529e44..30627b7 100644 --- a/tools/os.cpp +++ b/tools/os.cpp @@ -291,7 +291,7 @@ QGraphicsEffect *os::shadow(QColor color, int blurRadius, int offset) return shadowEffect; } -QIcon os::icon(QString name, QColor backgroundColor) +QIcon os::icon(const QString &name, QColor backgroundColor) { if (!backgroundColor.isValid()) { backgroundColor = qApp->palette().color(QPalette::Button); diff --git a/tools/os.h b/tools/os.h index 4eef6de..ce90d95 100644 --- a/tools/os.h +++ b/tools/os.h @@ -55,11 +55,8 @@ void setStartup(bool startup, bool hide); // Creates a new QGraphicsDropShadowEffect to apply to widgets. QGraphicsEffect *shadow(QColor color = Qt::black, int blurRadius = 6, int offset = 1); -// Translates the ui to the given language name. -void translate(QString language); - // Returns a QIcon for the given icon name (taking into account color schemes and whatnot). -QIcon icon(QString name, QColor backgroundColor = QColor()); +QIcon icon(const QString &name, QColor backgroundColor = QColor()); // X11-specific functions for the Window Picker #if defined(Q_OS_LINUX) diff --git a/tools/screenshot.cpp b/tools/screenshot.cpp index 888a99f..096bac3 100644 --- a/tools/screenshot.cpp +++ b/tools/screenshot.cpp @@ -286,7 +286,7 @@ void Screenshot::save() } } -void Screenshot::setPixmap(QPixmap pixmap) +void Screenshot::setPixmap(const QPixmap &pixmap) { mPixmap = pixmap; @@ -339,7 +339,7 @@ void Screenshot::upload() } } -void Screenshot::uploadDone(QString url) +void Screenshot::uploadDone(const QString &url) { if (mOptions.imgurClipboard && !url.isEmpty()) { QApplication::clipboard()->setText(url, QClipboard::Clipboard); diff --git a/tools/screenshot.h b/tools/screenshot.h index c713cfe..27dc26e 100644 --- a/tools/screenshot.h +++ b/tools/screenshot.h @@ -104,10 +104,10 @@ public slots: void optimize(); void optimizationDone(); void save(); - void setPixmap(QPixmap pixmap); + void setPixmap(const QPixmap &pixmap); void take(); void upload(); - void uploadDone(QString url); + void uploadDone(const QString &url); signals: void askConfirmation(); diff --git a/tools/screenshotmanager.cpp b/tools/screenshotmanager.cpp index 2117b02..f978a89 100644 --- a/tools/screenshotmanager.cpp +++ b/tools/screenshotmanager.cpp @@ -83,7 +83,7 @@ bool ScreenshotManager::portableMode() return mPortableMode; } -void ScreenshotManager::saveHistory(QString fileName, QString url, QString deleteHash) +void ScreenshotManager::saveHistory(const QString &fileName, const QString &url, const QString &deleteHash) { if (!mSettings->value("/options/history", true).toBool()) { return; @@ -104,7 +104,7 @@ void ScreenshotManager::saveHistory(QString fileName, QString url, QString delet query.exec(); } -void ScreenshotManager::updateHistory(QString fileName, QString url, QString deleteHash) +void ScreenshotManager::updateHistory(const QString &fileName, const QString &url, const QString &deleteHash) { if (!mSettings->value("/options/history", true).toBool() || url.isEmpty()) { return; @@ -129,7 +129,7 @@ void ScreenshotManager::updateHistory(QString fileName, QString url, QString del } } -void ScreenshotManager::removeHistory(QString fileName, qint64 time) +void ScreenshotManager::removeHistory(const QString &fileName, qint64 time) { QSqlQuery removeQuery; removeQuery.prepare("DELETE FROM history WHERE fileName = ? AND time = ?"); @@ -181,7 +181,7 @@ void ScreenshotManager::take(Screenshot::Options &options) newScreenshot->take(); } -void ScreenshotManager::uploadDone(QString fileName, QString url, QString deleteHash) +void ScreenshotManager::uploadDone(const QString &fileName, const QString &url, const QString &deleteHash) { foreach (Screenshot *screenshot, mScreenshots) { if (screenshot->options().fileName == fileName diff --git a/tools/screenshotmanager.h b/tools/screenshotmanager.h index e114fb0..c08bb6f 100644 --- a/tools/screenshotmanager.h +++ b/tools/screenshotmanager.h @@ -44,9 +44,9 @@ class ScreenshotManager : public QObject void initHistory(); int activeCount() const; bool portableMode(); - void saveHistory(QString fileName, QString url = "", QString deleteHash = ""); - void updateHistory(QString fileName, QString url, QString deleteHash); - void removeHistory(QString fileName, qint64 time); + void saveHistory(const QString &fileName, const QString &url = "", const QString &deleteHash = ""); + void updateHistory(const QString &fileName, const QString &url, const QString &deleteHash); + void removeHistory(const QString &fileName, qint64 time); void clearHistory(); QSettings *settings() const { return mSettings; } @@ -55,7 +55,7 @@ public slots: void cleanup(); void finished(); void take(Screenshot::Options &options); - void uploadDone(QString fileName, QString url, QString deleteHash); + void uploadDone(const QString &fileName, const QString &url, const QString &deleteHash); signals: void confirm(Screenshot *screenshot); diff --git a/tools/windowpicker.h b/tools/windowpicker.h index f08b7f3..43ef45b 100644 --- a/tools/windowpicker.h +++ b/tools/windowpicker.h @@ -33,7 +33,7 @@ class WindowPicker : public QWidget ~WindowPicker(); signals: - void pixmap(QPixmap pixmap); + void pixmap(const QPixmap &pixmap); protected: void closeEvent(QCloseEvent *); diff --git a/widgets/hotkeywidget.cpp b/widgets/hotkeywidget.cpp index 418e66a..f4c6eec 100644 --- a/widgets/hotkeywidget.cpp +++ b/widgets/hotkeywidget.cpp @@ -41,7 +41,7 @@ HotkeyWidget::HotkeyWidget(QWidget *parent) : } } -void HotkeyWidget::setHotkey(QString hotkeyString) +void HotkeyWidget::setHotkey(const QString &hotkeyString) { mHotkey = QKeySequence().fromString(hotkeyString, QKeySequence::NativeText); setHotkeyText(); diff --git a/widgets/hotkeywidget.h b/widgets/hotkeywidget.h index 1c1f756..b56d4a2 100644 --- a/widgets/hotkeywidget.h +++ b/widgets/hotkeywidget.h @@ -28,7 +28,7 @@ class HotkeyWidget : public QPushButton public: HotkeyWidget(QWidget *parent = 0); - void setHotkey(QString hotkey); + void setHotkey(const QString &hotkey); QString hotkey() const; signals: