Big refactorings.

This commit is contained in:
Martin Rotter 2020-05-06 12:56:24 +02:00
parent 0fc62ef28a
commit a136de363e
62 changed files with 270 additions and 317 deletions

View File

@ -26,7 +26,7 @@ FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget* parent) : QDialo
selectFolder(qApp->documentsFolder());
m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + QL1S("_") +
QDateTime::currentDateTime().toString(QSL("yyyyMMddHHmm")));
m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
if (qApp->database()->activeDatabaseDriver() != DatabaseFactory::UsedDriver::SQLITE &&
qApp->database()->activeDatabaseDriver() != DatabaseFactory::UsedDriver::SQLITE_MEMORY) {
@ -42,12 +42,12 @@ void FormBackupDatabaseSettings::performBackup() {
try {
qApp->backupDatabaseSettings(m_ui->m_checkBackupDatabase->isChecked(), m_ui->m_checkBackupSettings->isChecked(),
m_ui->m_lblSelectFolder->label()->text(), m_ui->m_txtBackupName->lineEdit()->text());
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok,
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Backup was created successfully and stored in target directory."),
tr("Backup was created successfully."));
}
catch (const ApplicationException& ex) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(), tr("Backup failed."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, ex.message(), tr("Backup failed."));
}
}
@ -61,17 +61,17 @@ void FormBackupDatabaseSettings::selectFolder(QString path) {
}
if (!path.isEmpty()) {
m_ui->m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(path),
m_ui->m_lblSelectFolder->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(path),
tr("Good destination directory is specified."));
}
}
void FormBackupDatabaseSettings::checkBackupNames(const QString& name) {
if (name.simplified().isEmpty()) {
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty."));
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::StatusType::Error, tr("Backup name cannot be empty."));
}
else {
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Ok, tr("Backup name looks okay."));
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::StatusType::Ok, tr("Backup name looks okay."));
}
}

View File

@ -25,7 +25,7 @@ FormDatabaseCleanup::FormDatabaseCleanup(QWidget* parent) : QDialog(parent), m_u
connect(&m_cleaner, &DatabaseCleaner::purgeFinished, this, &FormDatabaseCleanup::onPurgeFinished);
m_ui->m_spinDays->setValue(DEFAULT_DAYS_TO_DELETE_MSG);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Information, tr("I am ready."), tr("I am ready."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Information, tr("I am ready."), tr("I am ready."));
loadDatabaseInfo();
}
@ -49,7 +49,7 @@ void FormDatabaseCleanup::keyPressEvent(QKeyEvent* event) {
}
void FormDatabaseCleanup::updateDaysSuffix(int number) {
m_ui->m_spinDays->setSuffix(tr(" day(s)", 0, number));
m_ui->m_spinDays->setSuffix(tr(" day(s)", nullptr, number));
}
void FormDatabaseCleanup::startPurging() {
@ -61,6 +61,7 @@ void FormDatabaseCleanup::startPurging() {
orders.m_removeReadMessages = m_ui->m_checkRemoveReadMessages->isChecked();
orders.m_shrinkDatabase = m_ui->m_checkShrink->isEnabled() && m_ui->m_checkShrink->isChecked();
orders.m_removeStarredMessages = m_ui->m_checkRemoveStarredMessages->isChecked();
emit purgeRequested(orders);
}
@ -68,12 +69,13 @@ void FormDatabaseCleanup::onPurgeStarted() {
m_ui->m_progressBar->setValue(0);
m_ui->m_progressBar->setEnabled(true);
m_ui->m_btnBox->setEnabled(false);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Information, tr("Database cleanup is running."), tr("Database cleanup is running."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Information, tr("Database cleanup is running."),
tr("Database cleanup is running."));
}
void FormDatabaseCleanup::onPurgeProgress(int progress, const QString& description) {
m_ui->m_progressBar->setValue(progress);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Information, description, description);
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Information, description, description);
}
void FormDatabaseCleanup::onPurgeFinished(bool finished) {
@ -82,10 +84,12 @@ void FormDatabaseCleanup::onPurgeFinished(bool finished) {
m_ui->m_btnBox->setEnabled(true);
if (finished) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Database cleanup is completed."), tr("Database cleanup is completed."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Database cleanup is completed."),
tr("Database cleanup is completed."));
}
else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Database cleanup failed."), tr("Database cleanup failed."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Database cleanup failed."), tr("Database cleanup failed."));
}
loadDatabaseInfo();

View File

@ -51,7 +51,7 @@
#endif
FormMain::FormMain(QWidget* parent, Qt::WindowFlags f)
: QMainWindow(parent, f), m_ui(new Ui::FormMain) {
: QMainWindow(parent, f), m_ui(new Ui::FormMain), m_trayMenu(nullptr), m_statusBar(nullptr) {
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
m_ui->setupUi(this);
@ -358,7 +358,7 @@ void FormMain::updateAccountsMenu() {
m_ui->m_menuAccounts->addMenu(root_menu);
}
if (m_ui->m_menuAccounts->actions().size() > 0) {
if (!m_ui->m_menuAccounts->actions().isEmpty()) {
m_ui->m_menuAccounts->addSeparator();
}
@ -767,7 +767,7 @@ void FormMain::restoreDatabaseSettings() {
void FormMain::changeEvent(QEvent* event) {
switch (event->type()) {
case QEvent::WindowStateChange: {
if (windowState() & Qt::WindowMinimized &&
if ((windowState() & Qt::WindowState::WindowMinimized) == Qt::WindowState::WindowMinimized &&
SystemTrayIcon::isSystemTrayActivated() &&
qApp->settings()->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool()) {
event->ignore();

View File

@ -10,10 +10,10 @@
#include "QFileDialog"
FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget& parent) : QDialog(&parent),
m_shouldRestart(false) {
m_shouldRestart(false) {
m_ui.setupUi(this);
m_btnRestart = m_ui.m_buttonBox->addButton(tr("Restart"), QDialogButtonBox::ActionRole);
m_ui.m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
m_ui.m_lblResult->setStatus(WidgetWithStatus::StatusType::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
setWindowIcon(qApp->icons()->fromTheme(QSL("document-import")));
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
connect(m_btnRestart, &QPushButton::clicked, this, [=]() {
@ -42,11 +42,11 @@ void FormRestoreDatabaseSettings::performRestoration() {
m_ui.m_listSettings->currentRow() >= 0 ? m_ui.m_listSettings->currentItem()->data(
Qt::UserRole).toString() : QString());
m_btnRestart->setEnabled(true);
m_ui.m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Restoration was initiated. Restart to proceed."),
m_ui.m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok, tr("Restoration was initiated. Restart to proceed."),
tr("You need to restart application for restoration process to finish."));
}
catch (const ApplicationException& ex) {
m_ui.m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(),
m_ui.m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, ex.message(),
tr("Database and/or settings were not copied to restoration directory successully."));
}
}
@ -70,7 +70,8 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
}
if (!folder.isEmpty()) {
m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder), tr("Good source directory is specified."));
m_ui.m_lblSelectFolder->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(folder),
tr("Good source directory is specified."));
}
else {
return;

View File

@ -18,7 +18,7 @@
#include "gui/settings/settingsshortcuts.h"
FormSettings::FormSettings(QWidget& parent)
: QDialog(&parent), m_panels(QList<SettingsPanel*>()), m_settings(*qApp->settings()) {
: QDialog(&parent), m_settings(*qApp->settings()) {
m_ui.setupUi(this);
// Set flags and attributes.

View File

@ -43,8 +43,6 @@ FormUpdate::FormUpdate(QWidget* parent)
checkForUpdates();
}
FormUpdate::~FormUpdate() {}
bool FormUpdate::isSelfUpdateSupported() const {
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
return true;
@ -54,7 +52,10 @@ bool FormUpdate::isSelfUpdateSupported() const {
}
void FormUpdate::checkForUpdates() {
connect(qApp->system(), &SystemFactory::updatesChecked, this, [this](QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> update) {
connect(qApp->system(),
&SystemFactory::updatesChecked,
this,
[this](const QPair<QList<UpdateInfo>, QNetworkReply::NetworkError>& update) {
m_ui.m_buttonBox->setEnabled(true);
disconnect(qApp->system(), &SystemFactory::updatesChecked, nullptr, nullptr);
@ -65,7 +66,7 @@ void FormUpdate::checkForUpdates() {
//: Unknown release.
m_ui.m_lblAvailableRelease->setText(tr("unknown"));
m_ui.m_txtChanges->clear();
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Error,
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Error,
tr("Error: '%1'.").arg(NetworkFactory::networkErrorText(update.second)),
tr("List with updates was not\ndownloaded successfully."));
}
@ -78,7 +79,7 @@ void FormUpdate::checkForUpdates() {
if (SystemFactory::isVersionNewer(m_updateInfo.m_availableVersion, APP_VERSION)) {
m_btnUpdate->setVisible(true);
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Ok,
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Ok,
tr("New release available."),
tr("This is new version which can be\ndownloaded."));
@ -87,7 +88,7 @@ void FormUpdate::checkForUpdates() {
}
}
else {
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Warning,
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Warning,
tr("No new release available."),
tr("This release is not newer than\ncurrently installed one."));
}
@ -98,13 +99,13 @@ void FormUpdate::checkForUpdates() {
void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) {
if (bytes_received - m_lastDownloadedBytes > 500000 || m_lastDownloadedBytes == 0) {
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Information,
tr("Downloaded %1% (update size is %2 kB).").arg(QString::number(bytes_total ==
0 ? 0 : (bytes_received * 100.0) /
bytes_total,
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Information,
tr("Downloaded %1% (update size is %2 kB).").arg(QString::number(bytes_total == 0L
? 0L
: (bytes_received * 100.0) / bytes_total,
'f',
2),
QString::number(bytes_total / 1000,
QString::number(bytes_total / 1000.0,
'f',
2)),
tr("Downloading update..."));
@ -165,20 +166,21 @@ void FormUpdate::loadAvailableFiles() {
m_ui.m_tabInfo->setCurrentIndex(1);
}
void FormUpdate::updateCompleted(QNetworkReply::NetworkError status, QByteArray contents) {
void FormUpdate::updateCompleted(QNetworkReply::NetworkError status, const QByteArray& contents) {
qDebug("Download of application update file was completed with code '%d'.", status);
switch (status) {
case QNetworkReply::NoError:
saveUpdateFile(contents);
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Ok, tr("Downloaded successfully"),
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Ok, tr("Downloaded successfully"),
tr("Package was downloaded successfully.\nYou can install it now."));
m_btnUpdate->setText(tr("Install"));
m_btnUpdate->setEnabled(true);
break;
default:
m_ui.m_lblStatus->setStatus(WidgetWithStatus::Error, tr("Error occured"), tr("Error occured during downloading of the package."));
m_ui.m_lblStatus->setStatus(WidgetWithStatus::StatusType::Error, tr("Error occured"),
tr("Error occured during downloading of the package."));
m_btnUpdate->setText(tr("Error occured"));
break;
}
@ -207,7 +209,7 @@ void FormUpdate::startUpdate() {
nullptr,
SW_NORMAL);
if (exec_result <= (HINSTANCE)32) {
if (exec_result <= HINSTANCE(32)) {
qDebug("External updater was not launched due to error.");
qApp->showGuiMessage(tr("Cannot update application"),
tr("Cannot launch external updater. Update application manually."),

View File

@ -20,7 +20,6 @@ class RSSGUARD_DLLSPEC FormUpdate : public QDialog {
// Constructors and destructors.
explicit FormUpdate(QWidget* parent);
virtual ~FormUpdate();
// Returns true if application can self-update
// on current platform.
@ -33,7 +32,7 @@ class RSSGUARD_DLLSPEC FormUpdate : public QDialog {
void startUpdate();
void updateProgress(qint64 bytes_received, qint64 bytes_total);
void updateCompleted(QNetworkReply::NetworkError status, QByteArray contents);
void updateCompleted(QNetworkReply::NetworkError status, const QByteArray& contents);
void saveUpdateFile(const QByteArray& file_contents);
private:

View File

@ -7,7 +7,7 @@
EditTableView::EditTableView(QWidget* parent) : QTableView(parent) {}
void EditTableView::keyPressEvent(QKeyEvent* event) {
if (model() && event->key() == Qt::Key_Delete) {
if (model() != nullptr && event->key() == Qt::Key::Key_Delete) {
removeSelected();
event->accept();
}
@ -17,7 +17,7 @@ void EditTableView::keyPressEvent(QKeyEvent* event) {
}
void EditTableView::removeSelected() {
if (!model() || !selectionModel() || !selectionModel()->hasSelection()) {
if (model() != nullptr || selectionModel() != nullptr || !selectionModel()->hasSelection()) {
return;
}

View File

@ -157,7 +157,7 @@ void FeedMessageViewer::setListHeadersEnabled(bool enable) {
}
void FeedMessageViewer::switchFeedComponentVisibility() {
QAction* sen = qobject_cast<QAction*>(sender());
auto* sen = qobject_cast<QAction*>(sender());
if (sen != nullptr) {
m_feedsWidget->setVisible(sen->isChecked());
@ -237,9 +237,9 @@ void FeedMessageViewer::initializeViews() {
m_messageSplitter = new QSplitter(Qt::Vertical, this);
// Instantiate needed components.
QVBoxLayout* central_layout = new QVBoxLayout(this);
QVBoxLayout* feed_layout = new QVBoxLayout(m_feedsWidget);
QVBoxLayout* message_layout = new QVBoxLayout(m_messagesWidget);
auto* central_layout = new QVBoxLayout(this);
auto* feed_layout = new QVBoxLayout(m_feedsWidget);
auto* message_layout = new QVBoxLayout(m_messagesWidget);
// Set layout properties.
central_layout->setMargin(0);

View File

@ -16,8 +16,6 @@ FeedsToolBar::FeedsToolBar(const QString& title, QWidget* parent) : BaseToolBar(
setContentsMargins(margins);
}
FeedsToolBar::~FeedsToolBar() {}
QList<QAction*> FeedsToolBar::availableActions() const {
return qApp->userActions();
}
@ -45,17 +43,17 @@ QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList& actions) {
}
else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator.
QAction* act = new QAction(this);
auto* act = new QAction(this);
act->setSeparator(true);
spec_actions.append(act);
}
else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer.
QWidget* spacer = new QWidget(this);
auto* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidgetAction* action = new QWidgetAction(this);
auto* action = new QWidgetAction(this);
action->setDefaultWidget(spacer);
action->setIcon(qApp->icons()->fromTheme(QSL("system-search")));
@ -71,17 +69,16 @@ QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList& actions) {
void FeedsToolBar::loadSpecificActions(const QList<QAction*>& actions) {
clear();
foreach (QAction* act, actions) {
for (QAction* act : actions) {
addAction(act);
}
}
QStringList FeedsToolBar::defaultActions() const {
return QString(GUI::FeedsToolbarActionsDef).split(',',
QString::SkipEmptyParts);
return QString(GUI::FeedsToolbarActionsDef).split(',', QString::SkipEmptyParts);
}
QStringList FeedsToolBar::savedActions() const {
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::FeedsToolbarActions)).toString().split(',',
QString::SkipEmptyParts);
return qApp->settings()->value(GROUP(GUI),
SETTING(GUI::FeedsToolbarActions)).toString().split(',', QString::SkipEmptyParts);
}

View File

@ -9,10 +9,7 @@ class FeedsToolBar : public BaseToolBar {
Q_OBJECT
public:
// Constructors and destructors.
explicit FeedsToolBar(const QString& title, QWidget* parent = 0);
virtual ~FeedsToolBar();
explicit FeedsToolBar(const QString& title, QWidget* parent = nullptr);
QList<QAction*> availableActions() const;
QList<QAction*> changeableActions() const;

View File

@ -20,8 +20,6 @@ LabelWithStatus::LabelWithStatus(QWidget* parent)
m_layout->addWidget(m_btnStatus);
}
LabelWithStatus::~LabelWithStatus() {}
void LabelWithStatus::setStatus(WidgetWithStatus::StatusType status,
const QString& label_text,
const QString& status_text) {

View File

@ -11,18 +11,16 @@ class LabelWithStatus : public WidgetWithStatus {
Q_OBJECT
public:
// Constructors and destructors.
explicit LabelWithStatus(QWidget* parent = 0);
virtual ~LabelWithStatus();
explicit LabelWithStatus(QWidget* parent = nullptr);
void setStatus(StatusType status, const QString& label_text, const QString& status_text);
// Access to label.
inline QLabel* label() const {
return static_cast<QLabel*>(m_wdgInput);
}
QLabel* label() const;
};
inline QLabel* LabelWithStatus::label() const {
return static_cast<QLabel*>(m_wdgInput);
}
#endif // LABELWITHSTATUS_H

View File

@ -21,5 +21,3 @@ LineEditWithStatus::LineEditWithStatus(QWidget* parent)
m_layout->addWidget(m_wdgInput);
m_layout->addWidget(m_btnStatus);
}
LineEditWithStatus::~LineEditWithStatus() {}

View File

@ -11,16 +11,14 @@ class LineEditWithStatus : public WidgetWithStatus {
Q_OBJECT
public:
// Constructors and destructors.
explicit LineEditWithStatus(QWidget* parent = 0);
virtual ~LineEditWithStatus();
explicit LineEditWithStatus(QWidget* parent = nullptr);
// Access to line edit.
inline BaseLineEdit* lineEdit() const {
return static_cast<BaseLineEdit*>(m_wdgInput);
}
BaseLineEdit* lineEdit() const;
};
inline BaseLineEdit* LineEditWithStatus::lineEdit() const {
return static_cast<BaseLineEdit*>(m_wdgInput);
}
#endif // LINEEDITWITHSTATUS_H

View File

@ -14,11 +14,9 @@
MessageBox::MessageBox(QWidget* parent) : QMessageBox(parent) {}
MessageBox::~MessageBox() {}
void MessageBox::setIcon(QMessageBox::Icon icon) {
// Determine correct status icon size.
const int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this);
const int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, this);
// Setup status icon.
setIconPixmap(iconForStatus(icon).pixmap(icon_size, icon_size));
@ -26,7 +24,7 @@ void MessageBox::setIcon(QMessageBox::Icon icon) {
void MessageBox::setCheckBox(QMessageBox* msg_box, const QString& text, bool* data) {
// Add "don't show this again checkbox.
QCheckBox* check_box = new QCheckBox(msg_box);
auto* check_box = new QCheckBox(msg_box);
check_box->setChecked(*data);
check_box->setText(text);
@ -50,7 +48,6 @@ QIcon MessageBox::iconForStatus(QMessageBox::Icon status) {
case QMessageBox::Question:
return qApp->icons()->fromTheme(QSL("dialog-question"));
case QMessageBox::NoIcon:
default:
return QIcon();
}

View File

@ -12,8 +12,7 @@ class MessageBox : public QMessageBox {
public:
// Constructors and destructors.
explicit MessageBox(QWidget* parent = 0);
virtual ~MessageBox();
explicit MessageBox(QWidget* parent = nullptr);
// Custom icon setting.
void setIcon(Icon icon);

View File

@ -102,7 +102,7 @@ void MessagePreviewer::createConnections() {
});
}
MessagePreviewer::MessagePreviewer(QWidget* parent) : QWidget(parent), m_pictures(QStringList()) {
MessagePreviewer::MessagePreviewer(QWidget* parent) : QWidget(parent) {
m_ui.setupUi(this);
m_ui.m_txtMessage->viewport()->setAutoFillBackground(true);
m_toolBar = new QToolBar(this);
@ -203,8 +203,8 @@ void MessagePreviewer::switchMessageImportance(bool checked) {
bool MessagePreviewer::eventFilter(QObject* watched, QEvent* event) {
Q_UNUSED(watched)
if (event->type() == QEvent::KeyPress) {
QKeyEvent* key_event = static_cast<QKeyEvent*>(event);
if (event->type() == QEvent::Type::KeyPress) {
auto* key_event = static_cast<QKeyEvent*>(event);
if (key_event->matches(QKeySequence::StandardKey::Find)) {
m_ui.m_searchWidget->clear();

View File

@ -3,5 +3,3 @@
#include "gui/messagessearchlineedit.h"
MessagesSearchLineEdit::MessagesSearchLineEdit(QWidget* parent) : BaseLineEdit(parent) {}
MessagesSearchLineEdit::~MessagesSearchLineEdit() {}

View File

@ -11,10 +11,7 @@ class MessagesSearchLineEdit : public BaseLineEdit {
Q_OBJECT
public:
// Constructors and destructors.
explicit MessagesSearchLineEdit(QWidget* parent = 0);
virtual ~MessagesSearchLineEdit();
explicit MessagesSearchLineEdit(QWidget* parent = nullptr);
};
#endif // MESSAGESEARCHLINEEDIT_H

View File

@ -18,8 +18,6 @@ MessagesToolBar::MessagesToolBar(const QString& title, QWidget* parent)
initializeHighlighter();
}
MessagesToolBar::~MessagesToolBar() {}
QList<QAction*> MessagesToolBar::availableActions() const {
QList<QAction*> available_actions = qApp->userActions();
available_actions.append(m_actionSearchMessages);
@ -47,7 +45,7 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
// Iterate action names and add respectable actions into the toolbar.
foreach (const QString& action_name, actions) {
QAction* matching_action = findMatchingAction(action_name, available_actions);
auto* matching_action = findMatchingAction(action_name, available_actions);
if (matching_action != nullptr) {
// Add existing standard action.
@ -55,7 +53,7 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
}
else if (action_name == SEPARATOR_ACTION_NAME) {
// Add new separator.
QAction* act = new QAction(this);
auto* act = new QAction(this);
act->setSeparator(true);
spec_actions.append(act);
@ -70,10 +68,10 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
}
else if (action_name == SPACER_ACTION_NAME) {
// Add new spacer.
QWidget* spacer = new QWidget(this);
auto* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidgetAction* action = new QWidgetAction(this);
auto* action = new QWidgetAction(this);
action->setDefaultWidget(spacer);
action->setIcon(qApp->icons()->fromTheme(QSL("go-jump")));

View File

@ -16,15 +16,10 @@ class MessagesToolBar : public BaseToolBar {
Q_OBJECT
public:
// Constructors and destructors.
explicit MessagesToolBar(const QString& title, QWidget* parent = 0);
virtual ~MessagesToolBar();
explicit MessagesToolBar(const QString& title, QWidget* parent = nullptr);
// External access to search line edit.
inline MessagesSearchLineEdit* searchLineEdit() {
return m_txtSearchMessages;
}
inline MessagesSearchLineEdit* searchLineEdit();
// Implementation of BaseToolBar interface.
QList<QAction*> availableActions() const;
@ -65,4 +60,8 @@ class MessagesToolBar : public BaseToolBar {
MessagesSearchLineEdit* m_txtSearchMessages;
};
inline MessagesSearchLineEdit* MessagesToolBar::searchLineEdit() {
return m_txtSearchMessages;
}
#endif // NEWSTOOLBAR_H

View File

@ -520,7 +520,7 @@ void MessagesView::selectNextUnreadItem() {
void MessagesView::searchMessages(const QString& pattern) {
m_proxyModel->setFilterRegExp(pattern);
if (selectionModel()->selectedRows().size() == 0) {
if (selectionModel()->selectedRows().isEmpty()) {
emit currentMessageRemoved();
}
else {
@ -534,7 +534,7 @@ void MessagesView::filterMessages(MessagesModel::MessageHighlighter filter) {
}
void MessagesView::openSelectedMessagesWithExternalTool() {
QAction* sndr = qobject_cast<QAction*>(sender());
auto* sndr = qobject_cast<QAction*>(sender());
if (sndr != nullptr) {
auto tool = sndr->data().value<ExternalTool>();

View File

@ -9,21 +9,19 @@
#include <QScrollBar>
NewspaperPreviewer::NewspaperPreviewer(RootItem* root, QList<Message> messages, QWidget* parent)
: TabContent(parent), m_ui(new Ui::NewspaperPreviewer), m_root(root), m_messages(messages) {
: TabContent(parent), m_ui(new Ui::NewspaperPreviewer), m_root(root), m_messages(std::move(messages)) {
m_ui->setupUi(this);
connect(m_ui->m_btnShowMoreMessages, &QPushButton::clicked, this, &NewspaperPreviewer::showMoreMessages);
showMoreMessages();
}
NewspaperPreviewer::~NewspaperPreviewer() {}
void NewspaperPreviewer::showMoreMessages() {
if (!m_root.isNull()) {
int current_scroll = m_ui->scrollArea->verticalScrollBar()->value();
for (int i = 0; i < 10 && !m_messages.isEmpty(); i++) {
Message msg = m_messages.takeFirst();
MessagePreviewer* prev = new MessagePreviewer(this);
auto* prev = new MessagePreviewer(this);
QMargins margins = prev->layout()->contentsMargins();
connect(prev, &MessagePreviewer::requestMessageListReload, this, &NewspaperPreviewer::requestMessageListReload);

View File

@ -24,8 +24,7 @@ class NewspaperPreviewer : public TabContent {
Q_OBJECT
public:
explicit NewspaperPreviewer(RootItem* root, QList<Message> messages, QWidget* parent = 0);
virtual ~NewspaperPreviewer();
explicit NewspaperPreviewer(RootItem* root, QList<Message> messages, QWidget* parent = nullptr);
private slots:
void showMoreMessages();

View File

@ -11,8 +11,6 @@
PlainToolButton::PlainToolButton(QWidget* parent) : QToolButton(parent), m_padding(0) {}
PlainToolButton::~PlainToolButton() {}
void PlainToolButton::paintEvent(QPaintEvent* e) {
Q_UNUSED(e)
QPainter p(this);

View File

@ -9,10 +9,7 @@ class PlainToolButton : public QToolButton {
Q_OBJECT
public:
// Contructors and destructors.
explicit PlainToolButton(QWidget* parent = 0);
virtual ~PlainToolButton();
explicit PlainToolButton(QWidget* parent = nullptr);
// Padding changers.
int padding() const;

View File

@ -54,48 +54,48 @@ void SettingsDatabase::mysqlTestConnection() {
switch (error_code) {
case DatabaseFactory::MySQLError::MySQLOk:
case DatabaseFactory::MySQLError::MySQLUnknownDatabase:
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Ok, interpretation, interpretation);
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::StatusType::Ok, interpretation, interpretation);
break;
default:
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Error, interpretation, interpretation);
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::StatusType::Error, interpretation, interpretation);
break;
}
}
void SettingsDatabase::onMysqlHostnameChanged(const QString& new_hostname) {
if (new_hostname.isEmpty()) {
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Warning, tr("Hostname is empty."));
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::StatusType::Warning, tr("Hostname is empty."));
}
else {
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Ok, tr("Hostname looks ok."));
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::StatusType::Ok, tr("Hostname looks ok."));
}
}
void SettingsDatabase::onMysqlUsernameChanged(const QString& new_username) {
if (new_username.isEmpty()) {
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Warning, tr("Username is empty."));
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::StatusType::Warning, tr("Username is empty."));
}
else {
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Ok, tr("Username looks ok."));
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::StatusType::Ok, tr("Username looks ok."));
}
}
void SettingsDatabase::onMysqlPasswordChanged(const QString& new_password) {
if (new_password.isEmpty()) {
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Warning, tr("Password is empty."));
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::StatusType::Warning, tr("Password is empty."));
}
else {
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Ok, tr("Password looks ok."));
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::StatusType::Ok, tr("Password looks ok."));
}
}
void SettingsDatabase::onMysqlDatabaseChanged(const QString& new_database) {
if (new_database.isEmpty()) {
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Warning, tr("Working database is empty."));
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::StatusType::Warning, tr("Working database is empty."));
}
else {
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Ok, tr("Working database is ok."));
m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::StatusType::Ok, tr("Working database is ok."));
}
}
@ -120,7 +120,7 @@ void SettingsDatabase::switchMysqlPasswordVisiblity(bool visible) {
void SettingsDatabase::loadSettings() {
onBeginLoadSettings();
m_ui->m_checkUseTransactions->setChecked(qApp->settings()->value(GROUP(Database), SETTING(Database::UseTransactions)).toBool());
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information, tr("No connection test triggered so far."),
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::StatusType::Information, tr("No connection test triggered so far."),
tr("You did not executed any connection test yet."));
// Load SQLite.

View File

@ -66,8 +66,8 @@ SettingsGui::~SettingsGui() {
bool SettingsGui::eventFilter(QObject* obj, QEvent* e) {
Q_UNUSED(obj)
if (e->type() == QEvent::Drop) {
QDropEvent* drop_event = static_cast<QDropEvent*>(e);
if (e->type() == QEvent::Type::Drop) {
auto* drop_event = static_cast<QDropEvent*>(e);
if (drop_event->keyboardModifiers() != Qt::NoModifier) {
drop_event->setDropAction(Qt::MoveAction);
@ -118,7 +118,7 @@ void SettingsGui::loadSettings() {
m_ui->m_checkMonochromeIcons->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::MonochromeTrayIcon)).toBool());
// Mark active theme.
if (current_theme == QSL(APP_NO_THEME)) {
if (current_theme == QL1S(APP_NO_THEME)) {
// Because "no icon theme" lies at the index 0.
m_ui->m_cmbIconTheme->setCurrentIndex(0);
}

View File

@ -29,7 +29,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="m_tabIconSkin">
<attribute name="title">
@ -216,7 +216,7 @@
<item row="0" column="0">
<widget class="QCheckBox" name="m_checkCloseTabsDoubleClick">
<property name="text">
<string>Right mouse button double-click</string>
<string>Left mouse button double-click</string>
</property>
</widget>
</item>

View File

@ -33,7 +33,7 @@ void SettingsLocalization::loadSettings() {
onBeginLoadSettings();
foreach (const Language& language, qApp->localization()->installedLanguages()) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
auto* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
item->setText(0, language.m_name);
item->setText(1, language.m_code);

View File

@ -135,7 +135,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
}
else if (matching_action != nullptr) {
// Add originally toolbar action.
PlainToolButton* tool_button = new PlainToolButton(this);
auto* tool_button = new PlainToolButton(this);
tool_button->reactOnActionChange(matching_action);
widget_to_add = tool_button;

View File

@ -4,14 +4,12 @@
StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(QObject* parent) : QStyledItemDelegate(parent) {}
StyledItemDelegateWithoutFocus::~StyledItemDelegateWithoutFocus() {}
void StyledItemDelegateWithoutFocus::paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const {
QStyleOptionViewItem itemOption(option);
if (itemOption.state & QStyle::State_HasFocus) {
itemOption.state = itemOption.state ^ QStyle::State_HasFocus;
if ((itemOption.state & QStyle::StateFlag::State_HasFocus) == QStyle::StateFlag::State_HasFocus) {
itemOption.state = itemOption.state ^ QStyle::StateFlag::State_HasFocus;
}
QStyledItemDelegate::paint(painter, itemOption, index);

View File

@ -10,27 +10,24 @@ class StyledItemDelegateWithoutFocus : public QStyledItemDelegate {
Q_OBJECT
public:
explicit StyledItemDelegateWithoutFocus(QObject* parent = nullptr);
// Constructors.
explicit StyledItemDelegateWithoutFocus(QObject* parent = 0);
virtual ~StyledItemDelegateWithoutFocus();
QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
QSize siz = QStyledItemDelegate::sizeHint(option, index);
};
/* QStyleOptionViewItem opt = option;
inline QSize StyledItemDelegateWithoutFocus::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
QSize siz = QStyledItemDelegate::sizeHint(option, index);
/* QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
QStyle* style = widget ? widget->style() : QApplication::style();
return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), widget);*/
return siz;
}
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
};
return siz;
}
#endif // STYLEDITEMDELEGATEWITHOUTFOCUS_H

View File

@ -14,8 +14,6 @@
#if defined(Q_OS_WIN)
TrayIconMenu::TrayIconMenu(const QString& title, QWidget* parent) : QMenu(title, parent) {}
TrayIconMenu::~TrayIconMenu() {}
bool TrayIconMenu::event(QEvent* event) {
if (event->type() == QEvent::Show && Application::activeModalWidget() != nullptr) {
QTimer::singleShot(0, this, SLOT(hide()));
@ -159,7 +157,7 @@ void SystemTrayIcon::setNumber(int number, bool any_new_message) {
void SystemTrayIcon::showMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon icon,
int milliseconds_timeout_hint, std::function<void()> functor) {
if (m_connection) {
if (m_connection != nullptr) {
// Disconnect previous bubble click signalling.
disconnect(m_connection);
}

View File

@ -24,7 +24,6 @@ class TrayIconMenu : public QMenu {
// Constructors and destructors.
explicit TrayIconMenu(const QString& title, QWidget* parent);
virtual ~TrayIconMenu();
protected:
bool event(QEvent* event);

View File

@ -20,14 +20,14 @@ TabBar::~TabBar() {
}
void TabBar::setTabType(int index, const TabBar::TabType& type) {
const QTabBar::ButtonPosition button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
0,
this));
const auto button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
nullptr,
this));
switch (type) {
case TabBar::DownloadManager:
case TabBar::Closable: {
PlainToolButton* close_button = new PlainToolButton(this);
auto* close_button = new PlainToolButton(this);
close_button->setIcon(qApp->icons()->fromTheme(QSL("application-exit")));
close_button->setToolTip(tr("Close this tab."));
@ -40,10 +40,8 @@ void TabBar::setTabType(int index, const TabBar::TabType& type) {
break;
}
case TabBar::NonClosable:
case TabBar::FeedReader:
default:
setTabButton(index, button_position, 0);
setTabButton(index, button_position, nullptr);
break;
}
@ -51,10 +49,10 @@ void TabBar::setTabType(int index, const TabBar::TabType& type) {
}
void TabBar::closeTabViaButton() {
const QAbstractButton* close_button = qobject_cast<QAbstractButton*>(sender());
const QTabBar::ButtonPosition button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
0,
this));
const auto* close_button = qobject_cast<QAbstractButton*>(sender());
const auto button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition,
nullptr,
this));
if (close_button != nullptr) {
// Find index of tab for this close button.
@ -91,6 +89,7 @@ void TabBar::wheelEvent(QWheelEvent* event) {
void TabBar::mousePressEvent(QMouseEvent* event) {
QTabBar::mousePressEvent(event);
const int tab_index = tabAt(event->pos());
// Check if user clicked on some tab or on empty space.
@ -98,7 +97,8 @@ void TabBar::mousePressEvent(QMouseEvent* event) {
// Check if user clicked tab with middle button.
// NOTE: This needs to be done here because
// destination does not know the original event.
if (event->button() & Qt::MiddleButton && qApp->settings()->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool()) {
if ((event->button() & Qt::MiddleButton) == Qt::MiddleButton &&
qApp->settings()->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool()) {
if (tabType(tab_index) == TabBar::Closable || tabType(tab_index) == TabBar::DownloadManager) {
// This tab is closable, so we can close it.
emit tabCloseRequested(tab_index);
@ -116,7 +116,8 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) {
// Check if user clicked tab with middle button.
// NOTE: This needs to be done here because
// destination does not know the original event.
if (event->button() & Qt::LeftButton && qApp->settings()->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool()) {
if ((event->button() & Qt::LeftButton) == Qt::LeftButton &&
qApp->settings()->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool()) {
if ((tabType(tab_index) & (TabBar::Closable | TabBar::DownloadManager)) > 0) {
// This tab is closable, so we can close it.
emit tabCloseRequested(tab_index);

View File

@ -27,7 +27,7 @@ class TabBar : public QTabBar {
void setTabType(int index, const TabBar::TabType& type);
inline TabBar::TabType tabType(int index) const {
return static_cast<TabBar::TabType>(tabData(index).value<int>());
return static_cast<TabBar::TabType>(tabData(index).toInt());
}
private slots:

View File

@ -3,5 +3,3 @@
#include "gui/tabcontent.h"
TabContent::TabContent(QWidget* parent) : QWidget(parent), m_index(-1) {}
TabContent::~TabContent() {}

View File

@ -14,21 +14,13 @@ class TabContent : public QWidget {
Q_OBJECT
public:
// Contructors.
explicit TabContent(QWidget* parent = 0);
virtual ~TabContent();
explicit TabContent(QWidget* parent = nullptr);
// Gets/sets current index of this TabContent.
// NOTE: This is the index under which this object lies
// in parent tab widget.
inline virtual int index() const {
return m_index;
}
inline virtual void setIndex(int index) {
m_index = index;
}
virtual int index() const;
virtual void setIndex(int index);
#if defined(USE_WEBENGINE)
@ -41,4 +33,12 @@ class TabContent : public QWidget {
int m_index;
};
inline int TabContent::index() const {
return m_index;
}
inline void TabContent::setIndex(int index) {
m_index = index;
}
#endif // TABCONTENT_H

View File

@ -89,8 +89,8 @@ void TabWidget::checkTabBarVisibility() {
m_btnMainMenu->setVisible(true);
}
else {
setCornerWidget(0, Qt::TopLeftCorner);
setCornerWidget(0, Qt::TopRightCorner);
setCornerWidget(nullptr, Qt::TopLeftCorner);
setCornerWidget(nullptr, Qt::TopRightCorner);
m_btnMainMenu->setVisible(false);
}
@ -348,7 +348,7 @@ void TabWidget::fixContentsAfterMove(int from, int to) {
to = qMax(from, to);
for (; from <= to; from++) {
TabContent* content = static_cast<TabContent*>(widget(from));
auto* content = static_cast<TabContent*>(widget(from));
content->setIndex(from);
}

View File

@ -11,8 +11,6 @@ TimeSpinBox::TimeSpinBox(QWidget* parent) : QDoubleSpinBox(parent) {
setMaximum(10000000.0);
}
TimeSpinBox::~TimeSpinBox() {}
double TimeSpinBox::valueFromText(const QString& text) const {
bool ok;
double value = text.toDouble(&ok);

View File

@ -9,8 +9,7 @@ class TimeSpinBox : public QDoubleSpinBox {
Q_OBJECT
public:
explicit TimeSpinBox(QWidget* parent = 0);
virtual ~TimeSpinBox();
explicit TimeSpinBox(QWidget* parent = nullptr);
double valueFromText(const QString& text) const;
QString textFromValue(double val) const;

View File

@ -8,7 +8,7 @@
#include <QKeyEvent>
ToolBarEditor::ToolBarEditor(QWidget* parent)
: QWidget(parent), m_ui(new Ui::ToolBarEditor) {
: QWidget(parent), m_ui(new Ui::ToolBarEditor), m_toolBar(nullptr) {
m_ui->setupUi(this);
// Create connections.
@ -35,10 +35,6 @@ ToolBarEditor::ToolBarEditor(QWidget* parent)
m_ui->m_btnReset->setIcon(qApp->icons()->fromTheme(QSL("reload")));
}
ToolBarEditor::~ToolBarEditor() {
qDebug("Destroying ToolBarEditor instance.");
}
void ToolBarEditor::loadFromToolBar(BaseBar* tool_bar) {
m_toolBar = tool_bar;
@ -116,18 +112,18 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
bool ToolBarEditor::eventFilter(QObject* object, QEvent* event) {
if (object == m_ui->m_listActivatedActions) {
if (event->type() == QEvent::KeyPress) {
const QKeyEvent* key_event = static_cast<QKeyEvent*>(event);
if (event->type() == QEvent::Type::KeyPress) {
const auto* key_event = static_cast<QKeyEvent*>(event);
if (key_event->key() == Qt::Key_Delete) {
deleteSelectedAction();
return true;
}
else if (key_event->key() == Qt::Key_Down && key_event->modifiers() & Qt::ControlModifier) {
else if (key_event->key() == Qt::Key_Down && (key_event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
moveActionDown();
return true;
}
else if (key_event->key() == Qt::Key_Up && key_event->modifiers() & Qt::ControlModifier) {
else if (key_event->key() == Qt::Key_Up && (key_event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
moveActionUp();
return true;
}
@ -149,7 +145,7 @@ void ToolBarEditor::updateActionsAvailability() {
void ToolBarEditor::insertSpacer() {
const int current_row = m_ui->m_listActivatedActions->currentRow();
QListWidgetItem* item = new QListWidgetItem(tr("Toolbar spacer"));
auto* item = new QListWidgetItem(tr("Toolbar spacer"));
item->setIcon(qApp->icons()->fromTheme(QSL("go-jump")));
item->setData(Qt::UserRole, SPACER_ACTION_NAME);
@ -239,7 +235,7 @@ void ToolBarEditor::deleteAllActions() {
QListWidgetItem* taken_item;
QString data_item;
while ((taken_item = m_ui->m_listActivatedActions->takeItem(0)) != 0) {
while ((taken_item = m_ui->m_listActivatedActions->takeItem(0)) != nullptr) {
data_item = taken_item->data(Qt::UserRole).toString();
if (data_item != SEPARATOR_ACTION_NAME && data_item != SPACER_ACTION_NAME) {

View File

@ -19,20 +19,14 @@ class ToolBarEditor : public QWidget {
public:
// Constructors and destructors.
explicit ToolBarEditor(QWidget* parent = 0);
virtual ~ToolBarEditor();
explicit ToolBarEditor(QWidget* parent = nullptr);
// Toolbar operations.
void loadFromToolBar(BaseBar* tool_bar);
void saveToolBar();
inline QListWidget* activeItemsWidget() const {
return m_ui->m_listActivatedActions;
}
inline QListWidget* availableItemsWidget() const {
return m_ui->m_listAvailableActions;
}
QListWidget* activeItemsWidget() const;
QListWidget* availableItemsWidget() const;
protected:
bool eventFilter(QObject* object, QEvent* event);
@ -63,4 +57,12 @@ class ToolBarEditor : public QWidget {
BaseBar* m_toolBar;
};
inline QListWidget* ToolBarEditor::activeItemsWidget() const {
return m_ui->m_listActivatedActions;
}
inline QListWidget* ToolBarEditor::availableItemsWidget() const {
return m_ui->m_listAvailableActions;
}
#endif // TOOLBAREDITOR_H

View File

@ -8,8 +8,6 @@ TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView* parent) : QMenu(parent) {
connect(this, &TreeViewColumnsMenu::aboutToShow, this, &TreeViewColumnsMenu::prepareMenu);
}
TreeViewColumnsMenu::~TreeViewColumnsMenu() {}
void TreeViewColumnsMenu::prepareMenu() {
QHeaderView* header_view = header();
@ -24,9 +22,11 @@ void TreeViewColumnsMenu::prepareMenu() {
}
void TreeViewColumnsMenu::actionTriggered(bool toggle) {
Q_UNUSED(toggle)
QAction * send_act = qobject_cast<QAction*>(sender());
auto* send_act = qobject_cast<QAction*>(sender());
header()->setSectionHidden(send_act->data().toInt(), !send_act->isChecked());
Q_UNUSED(toggle)
}
QHeaderView* TreeViewColumnsMenu::header() {

View File

@ -10,7 +10,6 @@ class QHeaderView;
class TreeViewColumnsMenu : public QMenu {
public:
explicit TreeViewColumnsMenu(QHeaderView* parent);
virtual ~TreeViewColumnsMenu();
private slots:
void prepareMenu();

View File

@ -21,32 +21,30 @@ WidgetWithStatus::WidgetWithStatus(QWidget* parent)
// Set layout properties.
m_layout->setMargin(0);
setLayout(m_layout);
setStatus(Information, QString());
setStatus(StatusType::Information, QString());
}
WidgetWithStatus::~WidgetWithStatus() {}
void WidgetWithStatus::setStatus(WidgetWithStatus::StatusType status, const QString& tooltip_text) {
m_status = status;
switch (status) {
case Information:
case StatusType::Information:
m_btnStatus->setIcon(m_iconInformation);
break;
case Progress:
case StatusType::Progress:
m_btnStatus->setIcon(m_iconProgress);
break;
case Warning:
case StatusType::Warning:
m_btnStatus->setIcon(m_iconWarning);
break;
case Error:
case StatusType::Error:
m_btnStatus->setIcon(m_iconError);
break;
case Ok:
case StatusType::Ok:
m_btnStatus->setIcon(m_iconOk);
break;

View File

@ -13,7 +13,7 @@ class WidgetWithStatus : public QWidget {
Q_OBJECT
public:
enum StatusType {
enum class StatusType {
Information,
Warning,
Error,
@ -21,16 +21,10 @@ class WidgetWithStatus : public QWidget {
Progress
};
// Constructors and destructors.
explicit WidgetWithStatus(QWidget* parent);
virtual ~WidgetWithStatus();
// Sets custom status for this control.
void setStatus(StatusType status, const QString& tooltip_text);
inline StatusType status() const {
return m_status;
}
StatusType status() const;
protected:
StatusType m_status;
@ -44,4 +38,8 @@ class WidgetWithStatus : public QWidget {
QIcon m_iconOk;
};
inline WidgetWithStatus::StatusType WidgetWithStatus::status() const {
return m_status;
}
#endif // WIDGETWITHSTATUS_H

View File

@ -146,11 +146,11 @@ MessagesModel* FeedReader::messagesModel() const {
void FeedReader::executeNextAutoUpdate() {
if (qApp->mainFormWidget()->isActiveWindow() && m_globalAutoUpdateOnlyUnfocused) {
qDebug("Delaying scheduled feed auto-update for one minute since window is focused and updates"
"while focused are disabled by the user.");
qDebug("Delaying scheduled feed auto-update for one minute since window is focused and updates"
"while focused are disabled by the user.");
// Cannot update, quit.
return;
// Cannot update, quit.
return;
}
if (!qApp->feedUpdateLock()->tryLock()) {
@ -203,7 +203,7 @@ void FeedReader::checkServicesForAsyncOperations() {
void FeedReader::asyncCacheSaveFinished() {
qDebug("I will start next check for cached service data in 30 seconds.");
QTimer::singleShot(60000, [&] {
QTimer::singleShot(60000, this, [&] {
qDebug("Starting next check for cached service data in NOW.");
checkServicesForAsyncOperations();
});

View File

@ -373,8 +373,8 @@ DVALUE(QStringList) Browser::ExternalToolsDef = QStringList();
// Categories.
DKEY CategoriesExpandStates::ID = "categories_expand_states";
Settings::Settings(const QString& file_name, Format format, const SettingsProperties::SettingsType& status, QObject* parent)
: QSettings(file_name, format, parent), m_initializationStatus(status) {}
Settings::Settings(const QString& file_name, Format format, const SettingsProperties::SettingsType& type, QObject* parent)
: QSettings(file_name, format, parent), m_initializationStatus(type) {}
Settings::~Settings() = default;

View File

@ -90,35 +90,35 @@ int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, c
void FormFeedDetails::onTitleChanged(const QString& new_title) {
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Feed name is ok."));
m_ui->m_txtTitle->setStatus(LineEditWithStatus::StatusType::Ok, tr("Feed name is ok."));
}
else {
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Error, tr("Feed name is too short."));
m_ui->m_txtTitle->setStatus(LineEditWithStatus::StatusType::Error, tr("Feed name is too short."));
}
}
void FormFeedDetails::onDescriptionChanged(const QString& new_description) {
if (new_description.simplified().isEmpty()) {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
m_ui->m_txtDescription->setStatus(LineEditWithStatus::StatusType::Warning, tr("Description is empty."));
}
else {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok."));
m_ui->m_txtDescription->setStatus(LineEditWithStatus::StatusType::Ok, tr("The description is ok."));
}
}
void FormFeedDetails::onUrlChanged(const QString& new_url) {
if (QRegularExpression(URL_REGEXP).match(new_url).hasMatch()) {
// New url is well-formed.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Ok, tr("The URL is ok."));
m_ui->m_txtUrl->setStatus(LineEditWithStatus::StatusType::Ok, tr("The URL is ok."));
}
else if (!new_url.simplified().isEmpty()) {
// New url is not well-formed but is not empty on the other hand.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Warning,
m_ui->m_txtUrl->setStatus(LineEditWithStatus::StatusType::Warning,
tr(R"(The URL does not meet standard pattern. Does your URL start with "http://" or "https://" prefix.)"));
}
else {
// New url is empty.
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Error, tr("The URL is empty."));
m_ui->m_txtUrl->setStatus(LineEditWithStatus::StatusType::Error, tr("The URL is empty."));
}
}
@ -126,8 +126,8 @@ void FormFeedDetails::onUsernameChanged(const QString& new_username) {
bool is_username_ok = !m_ui->m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
m_ui->m_txtUsername->setStatus(is_username_ok ?
LineEditWithStatus::Ok :
LineEditWithStatus::Warning,
LineEditWithStatus::StatusType::Ok :
LineEditWithStatus::StatusType::Warning,
is_username_ok ?
tr("Username is ok or it is not needed.") :
tr("Username is empty."));
@ -137,8 +137,8 @@ void FormFeedDetails::onPasswordChanged(const QString& new_password) {
bool is_password_ok = !m_ui->m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
m_ui->m_txtPassword->setStatus(is_password_ok ?
LineEditWithStatus::Ok :
LineEditWithStatus::Warning,
LineEditWithStatus::StatusType::Ok :
LineEditWithStatus::StatusType::Warning,
is_password_ok ?
tr("Password is ok or it is not needed.") :
tr("Password is empty."));
@ -158,7 +158,6 @@ void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) {
m_ui->m_spinAutoUpdateInterval->setEnabled(false);
break;
case Feed::SpecificAutoUpdate:
default:
m_ui->m_spinAutoUpdateInterval->setEnabled(true);
}
@ -213,12 +212,12 @@ void FormFeedDetails::guessFeed() {
}
if (result.second == QNetworkReply::NoError) {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Ok,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Ok,
tr("All metadata fetched successfully."),
tr("Feed and icon metadata fetched."));
}
else {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Warning,
tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)),
tr("Feed or icon metadata not fetched."));
}
@ -228,7 +227,7 @@ void FormFeedDetails::guessFeed() {
}
else {
// No feed guessed, even no icon available.
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
tr("Error: %1.").arg(NetworkFactory::networkErrorText(result.second)),
tr("No metadata fetched."));
}
@ -244,12 +243,12 @@ void FormFeedDetails::guessIconOnly() {
m_ui->m_btnIcon->setIcon(result.first->icon());
if (result.second == QNetworkReply::NoError) {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Ok,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Icon fetched successfully."),
tr("Icon metadata fetched."));
}
else {
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Warning,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Warning,
tr("Result: %1.").arg(NetworkFactory::networkErrorText(result.second)),
tr("Icon metadata not fetched."));
}
@ -259,7 +258,7 @@ void FormFeedDetails::guessIconOnly() {
}
else {
// No feed guessed, even no icon available.
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Error,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
tr("Error: %1.").arg(NetworkFactory::networkErrorText(result.second)),
tr("No icon fetched."));
}
@ -353,7 +352,7 @@ void FormFeedDetails::initialize() {
m_ui->m_btnIcon->setMenu(m_iconMenu);
// Set feed metadata fetch label.
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::Information,
m_ui->m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Information,
tr("No metadata fetched so far."),
tr("No metadata fetched so far."));

View File

@ -12,7 +12,7 @@
#include <QVariant>
RootItem::RootItem(RootItem* parent_item)
: QObject(nullptr), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), m_customId(QSL("")),
: QObject(nullptr), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), m_customId(QL1S("")),
m_title(QString()), m_description(QString()), m_keepOnTop(false), m_parentItem(parent_item) {}
RootItem::RootItem(const RootItem& other) : RootItem(nullptr) {

View File

@ -12,7 +12,7 @@
#include <QLineEdit>
EmailRecipientControl::EmailRecipientControl(const QString& recipient, QWidget* parent) : QWidget(parent) {
QHBoxLayout* lay = new QHBoxLayout(this);
auto* lay = new QHBoxLayout(this);
lay->addWidget(m_cmbRecipientType = new QComboBox(this));
lay->addWidget(m_txtRecipient = new QLineEdit(this), 1);

View File

@ -27,7 +27,7 @@ void FormAddEditEmail::execForAdd() {
}
void FormAddEditEmail::removeRecipientRow() {
EmailRecipientControl* sndr = static_cast<EmailRecipientControl*>(sender());
auto* sndr = static_cast<EmailRecipientControl*>(sender());
m_ui.m_layout->takeRow(sndr);
m_recipientControls.removeOne(sndr);

View File

@ -21,7 +21,7 @@ FormDownloadAttachment::FormDownloadAttachment(const QString& target_file, Downl
connect(downloader,
&Downloader::completed,
this,
[this, downloader, target_file](QNetworkReply::NetworkError status, QByteArray contents) {
[this, downloader, target_file](QNetworkReply::NetworkError status, const QByteArray& contents) {
if (status == QNetworkReply::NetworkError::NoError) {
QString data = QJsonDocument::fromJson(contents).object()["data"].toString();

View File

@ -185,10 +185,10 @@ void FormEditGmailAccount::checkOAuthValue(const QString& value) {
if (line_edit != nullptr) {
if (value.isEmpty()) {
line_edit->setStatus(WidgetWithStatus::Error, tr("Empty value is entered."));
line_edit->setStatus(WidgetWithStatus::StatusType::Error, tr("Empty value is entered."));
}
else {
line_edit->setStatus(WidgetWithStatus::Ok, tr("Some value is entered."));
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Some value is entered."));
}
}
}

View File

@ -182,10 +182,10 @@ void FormEditInoreaderAccount::checkOAuthValue(const QString& value) {
if (line_edit != nullptr) {
if (value.isEmpty()) {
line_edit->setStatus(WidgetWithStatus::Error, tr("Empty value is entered."));
line_edit->setStatus(WidgetWithStatus::StatusType::Error, tr("Empty value is entered."));
}
else {
line_edit->setStatus(WidgetWithStatus::Ok, tr("Some value is entered."));
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Some value is entered."));
}
}
}

View File

@ -23,7 +23,7 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent)
m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your ownCloud account"));
m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username for your ownCloud account"));
m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("URL of your ownCloud server, without any API path"));
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Information,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
tr("No test done yet."),
tr("Here, results of connection test are shown."));
m_ui->m_lblLimitMessages->setText(
@ -106,7 +106,7 @@ void FormEditOwnCloudAccount::performTest() {
if (result.isLoaded()) {
if (!SystemFactory::isVersionEqualOrNewer(result.version(), OWNCLOUD_MIN_VERSION)) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr(
"Selected ownCloud News server is running unsupported version (%1). At least version %2 is required.").arg(
result.version(),
@ -114,7 +114,7 @@ void FormEditOwnCloudAccount::performTest() {
tr("Selected ownCloud News server is running unsupported version."));
}
else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr(
"ownCloud News server is okay, running with version %1, while at least version %2 is required.").arg(
result.version(),
@ -123,12 +123,12 @@ void FormEditOwnCloudAccount::performTest() {
}
}
else if (factory.lastError() != QNetworkReply::NoError) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())),
tr("Network error, have you entered correct ownCloud endpoint and password?"));
}
else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Unspecified error, did you enter correct URL?"),
tr("Unspecified error, did you enter correct URL?"));
}
@ -166,10 +166,10 @@ void FormEditOwnCloudAccount::onUsernameChanged() {
const QString username = m_ui->m_txtUsername->lineEdit()->text();
if (username.isEmpty()) {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty."));
m_ui->m_txtUsername->setStatus(WidgetWithStatus::StatusType::Error, tr("Username cannot be empty."));
}
else {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay."));
m_ui->m_txtUsername->setStatus(WidgetWithStatus::StatusType::Ok, tr("Username is okay."));
}
}
@ -177,10 +177,10 @@ void FormEditOwnCloudAccount::onPasswordChanged() {
const QString password = m_ui->m_txtPassword->lineEdit()->text();
if (password.isEmpty()) {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty."));
m_ui->m_txtPassword->setStatus(WidgetWithStatus::StatusType::Error, tr("Password cannot be empty."));
}
else {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay."));
m_ui->m_txtPassword->setStatus(WidgetWithStatus::StatusType::Ok, tr("Password is okay."));
}
}
@ -188,10 +188,10 @@ void FormEditOwnCloudAccount::onUrlChanged() {
const QString url = m_ui->m_txtUrl->lineEdit()->text();
if (url.isEmpty()) {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty."));
m_ui->m_txtUrl->setStatus(WidgetWithStatus::StatusType::Error, tr("URL cannot be empty."));
}
else {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay."));
m_ui->m_txtUrl->setStatus(WidgetWithStatus::StatusType::Ok, tr("URL is okay."));
}
}

View File

@ -136,20 +136,20 @@ void FormStandardCategoryDetails::apply() {
void FormStandardCategoryDetails::onTitleChanged(const QString& new_title) {
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok."));
m_ui->m_txtTitle->setStatus(WidgetWithStatus::StatusType::Ok, tr("Category name is ok."));
}
else {
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Error, tr("Category name is too short."));
m_ui->m_txtTitle->setStatus(WidgetWithStatus::StatusType::Error, tr("Category name is too short."));
}
}
void FormStandardCategoryDetails::onDescriptionChanged(const QString& new_description) {
if (new_description.simplified().isEmpty()) {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
m_ui->m_txtDescription->setStatus(LineEditWithStatus::StatusType::Warning, tr("Description is empty."));
}
else {
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Ok, tr("The description is ok."));
m_ui->m_txtDescription->setStatus(LineEditWithStatus::StatusType::Ok, tr("The description is ok."));
}
}

View File

@ -24,9 +24,9 @@ FormStandardImportExport::FormStandardImportExport(StandardServiceRoot* service_
connect(m_model, &FeedsImportExportModel::parsingFinished, this, &FormStandardImportExport::onParsingFinished);
connect(m_model, &FeedsImportExportModel::parsingProgress, this, &FormStandardImportExport::onParsingProgress);
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::Error, tr("No file is selected."), tr("No file is selected."));
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Error, tr("No file is selected."), tr("No file is selected."));
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->disconnect();
m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &FormStandardImportExport::performAction);
connect(m_ui->m_btnSelectFile, &QPushButton::clicked, this, &FormStandardImportExport::selectFile);
connect(m_ui->m_btnCheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::checkAllItems);
@ -92,7 +92,7 @@ void FormStandardImportExport::selectFile() {
}
void FormStandardImportExport::onParsingStarted() {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Progress, tr("Parsing data..."), tr("Parsing data..."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Progress, tr("Parsing data..."), tr("Parsing data..."));
m_ui->m_btnSelectFile->setEnabled(false);
m_ui->m_groupFeeds->setEnabled(false);
m_ui->m_progressBar->setValue(0);
@ -108,7 +108,7 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc
m_model->checkAllItems();
if (!parsing_error) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were loaded."), tr("Feeds were loaded."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok, tr("Feeds were loaded."), tr("Feeds were loaded."));
m_ui->m_groupFeeds->setEnabled(true);
m_ui->m_btnSelectFile->setEnabled(true);
m_ui->m_treeFeeds->setModel(m_model);
@ -116,7 +116,7 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc
}
else {
m_ui->m_groupFeeds->setEnabled(false);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Error, file is not well-formed. Select another file."),
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Error, file is not well-formed. Select another file."),
tr("Error occurred. File is not well-formed. Select another file."));
}
@ -157,10 +157,10 @@ void FormStandardImportExport::selectExportFile() {
}
}
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
}
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_ui->m_lblSelectFile->status() == WidgetWithStatus::Ok);
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_ui->m_lblSelectFile->status() == WidgetWithStatus::StatusType::Ok);
}
void FormStandardImportExport::selectImportFile() {
@ -184,7 +184,7 @@ void FormStandardImportExport::selectImportFile() {
m_conversionType = TXTUrlPerLine;
}
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
QMessageBox::StandardButton answer = MessageBox::show(this,
QMessageBox::Warning,
tr("Get online metadata"),
@ -207,7 +207,7 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe
input_file.close();
}
else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot open source file."), tr("Cannot open source file."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Cannot open source file."), tr("Cannot open source file."));
return;
}
@ -260,14 +260,15 @@ void FormStandardImportExport::exportFeeds() {
if (result_export) {
try {
IOFactory::writeFile(m_ui->m_lblSelectFile->label()->text(), result_data);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were exported successfully."), tr("Feeds were exported successfully."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok, tr("Feeds were exported successfully."),
tr("Feeds were exported successfully."));
}
catch (IOException& ex) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Cannot write into destination file: '%1'."), ex.message());
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Cannot write into destination file: '%1'."), ex.message());
}
}
else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Critical error occurred."), tr("Critical error occurred."));
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Critical error occurred."), tr("Critical error occurred."));
}
}
@ -277,10 +278,10 @@ void FormStandardImportExport::importFeeds() {
if (m_serviceRoot->mergeImportExportModel(m_model, parent, output_message)) {
m_serviceRoot->requestItemExpand(parent->getSubTree(), true);
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message);
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok, output_message, output_message);
}
else {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, output_message, output_message);
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, output_message, output_message);
}
}

View File

@ -25,7 +25,7 @@ FormEditTtRssAccount::FormEditTtRssAccount(QWidget* parent)
m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your TT-RSS account"));
m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username for your TT-RSS account"));
m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("URL of your TT-RSS instance WITHOUT trailing \"/api/\" string"));
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Information,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
tr("No test done yet."),
tr("Here, results of connection test are shown."));
@ -115,23 +115,23 @@ void FormEditTtRssAccount::performTest() {
QString error = result.error();
if (error == TTRSS_API_DISABLED) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("API access on selected server is not enabled."),
tr("API access on selected server is not enabled."));
}
else if (error == TTRSS_LOGIN_ERROR) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Entered credentials are incorrect."),
tr("Entered credentials are incorrect."));
}
else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Other error occurred, contact developers."),
tr("Other error occurred, contact developers."));
}
}
else if (result.apiLevel() < TTRSS_MINIMAL_API_LEVEL) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr(
"Selected Tiny Tiny RSS server is running unsupported version of API (%1). At least API level %2 is required.").arg(
QString::number(
@ -144,7 +144,7 @@ void FormEditTtRssAccount::performTest() {
tr("Selected Tiny Tiny RSS server is running unsupported version of API."));
}
else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr(
"Tiny Tiny RSS server is okay, running with API level %1, while at least API level %2 is required.").arg(
QString::number(
@ -158,12 +158,12 @@ void FormEditTtRssAccount::performTest() {
}
}
else if (factory.lastError() != QNetworkReply::NoError) {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())),
tr("Network error, have you entered correct Tiny Tiny RSS API endpoint and password?"));
}
else {
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Unspecified error, did you enter correct URL?"),
tr("Unspecified error, did you enter correct URL?"));
}
@ -204,10 +204,10 @@ void FormEditTtRssAccount::onUsernameChanged() {
const QString username = m_ui->m_txtUsername->lineEdit()->text();
if (username.isEmpty()) {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty."));
m_ui->m_txtUsername->setStatus(WidgetWithStatus::StatusType::Error, tr("Username cannot be empty."));
}
else {
m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay."));
m_ui->m_txtUsername->setStatus(WidgetWithStatus::StatusType::Ok, tr("Username is okay."));
}
}
@ -215,10 +215,10 @@ void FormEditTtRssAccount::onPasswordChanged() {
const QString password = m_ui->m_txtPassword->lineEdit()->text();
if (password.isEmpty()) {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty."));
m_ui->m_txtPassword->setStatus(WidgetWithStatus::StatusType::Error, tr("Password cannot be empty."));
}
else {
m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay."));
m_ui->m_txtPassword->setStatus(WidgetWithStatus::StatusType::Ok, tr("Password is okay."));
}
}
@ -226,8 +226,8 @@ void FormEditTtRssAccount::onHttpUsernameChanged() {
const bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpUsername->lineEdit()->text().isEmpty();
m_ui->m_txtHttpUsername->setStatus(is_username_ok ?
LineEditWithStatus::Ok :
LineEditWithStatus::Warning,
LineEditWithStatus::StatusType::Ok :
LineEditWithStatus::StatusType::Warning,
is_username_ok ?
tr("Username is ok or it is not needed.") :
tr("Username is empty."));
@ -237,8 +237,8 @@ void FormEditTtRssAccount::onHttpPasswordChanged() {
const bool is_username_ok = !m_ui->m_gbHttpAuthentication->isChecked() || !m_ui->m_txtHttpPassword->lineEdit()->text().isEmpty();
m_ui->m_txtHttpPassword->setStatus(is_username_ok ?
LineEditWithStatus::Ok :
LineEditWithStatus::Warning,
LineEditWithStatus::StatusType::Ok :
LineEditWithStatus::StatusType::Warning,
is_username_ok ?
tr("Password is ok or it is not needed.") :
tr("Password is empty."));
@ -248,13 +248,13 @@ void FormEditTtRssAccount::onUrlChanged() {
const QString url = m_ui->m_txtUrl->lineEdit()->text();
if (url.isEmpty()) {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty."));
m_ui->m_txtUrl->setStatus(WidgetWithStatus::StatusType::Error, tr("URL cannot be empty."));
}
else if (url.endsWith(QL1S("/api/")) || url.endsWith(QL1S("/api"))) {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Warning, tr("URL should NOT end with \"/api/\"."));
m_ui->m_txtUrl->setStatus(WidgetWithStatus::StatusType::Warning, tr("URL should NOT end with \"/api/\"."));
}
else {
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay."));
m_ui->m_txtUrl->setStatus(WidgetWithStatus::StatusType::Ok, tr("URL is okay."));
}
}