mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 09:04:52 +01:00
Works on message boxes.
This commit is contained in:
parent
5ae43964cc
commit
56dd8c66d5
BIN
resources/graphics/icons/mini-kfaenza/dialog-error.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
resources/graphics/icons/mini-kfaenza/dialog-no.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-no.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
resources/graphics/icons/mini-kfaenza/dialog-ok.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
resources/graphics/icons/mini-kfaenza/dialog-question.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-question.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/graphics/icons/mini-kfaenza/dialog-warning.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-warning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
resources/graphics/icons/mini-kfaenza/dialog-yes.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/dialog-yes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -13,7 +13,6 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include "QComboBox"
|
|
||||||
|
|
||||||
|
|
||||||
FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
|
FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
|
||||||
@ -24,16 +23,23 @@ FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
|
|||||||
loadCategories(model->allCategories().values(),
|
loadCategories(model->allCategories().values(),
|
||||||
model->rootItem());
|
model->rootItem());
|
||||||
|
|
||||||
connect(m_ui->m_buttonBox, SIGNAL(accepted()),
|
createConnections();
|
||||||
this, SLOT(apply()));
|
|
||||||
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)),
|
// Initialize text boxes.
|
||||||
this, SLOT(onTitleChanged(QString)));
|
onTitleChanged(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCategoryDetails::~FormCategoryDetails() {
|
FormCategoryDetails::~FormCategoryDetails() {
|
||||||
qDebug("Destroying FormCategoryDetails instance.");
|
qDebug("Destroying FormCategoryDetails instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormCategoryDetails::createConnections() {
|
||||||
|
connect(m_ui->m_buttonBox, SIGNAL(accepted()),
|
||||||
|
this, SLOT(apply()));
|
||||||
|
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)),
|
||||||
|
this, SLOT(onTitleChanged(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
void FormCategoryDetails::setEditableCategory(FeedsModelCategory *editable_category) {
|
void FormCategoryDetails::setEditableCategory(FeedsModelCategory *editable_category) {
|
||||||
m_editableCategory = editable_category;
|
m_editableCategory = editable_category;
|
||||||
|
|
||||||
@ -86,7 +92,7 @@ void FormCategoryDetails::apply() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
||||||
if (m_ui->m_txtTitle->lineEdit()->text().size() >= MIN_CATEGORY_NAME_LENGTH) {
|
if (new_title.size() >= MIN_CATEGORY_NAME_LENGTH) {
|
||||||
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("This category name is ok."));
|
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("This category name is ok."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -32,6 +32,9 @@ class FormCategoryDetails : public QDialog {
|
|||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~FormCategoryDetails();
|
virtual ~FormCategoryDetails();
|
||||||
|
|
||||||
|
// Creates needed connections.
|
||||||
|
void createConnections();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Start dialog execution. If result is QDialog::Accepted,
|
// Start dialog execution. If result is QDialog::Accepted,
|
||||||
// then output_item contains added or edited category
|
// then output_item contains added or edited category
|
||||||
|
@ -199,6 +199,10 @@ bool FormSettings::doSaveCheck() {
|
|||||||
resulting_information.replaceInStrings(QRegExp("^"),
|
resulting_information.replaceInStrings(QRegExp("^"),
|
||||||
QString::fromUtf8(" • "));
|
QString::fromUtf8(" • "));
|
||||||
|
|
||||||
|
// TODO: dedit qmessagebox
|
||||||
|
// MessageBox a tam pretizit setIcon
|
||||||
|
// a setStandardButtons atp
|
||||||
|
|
||||||
// Some critical errors occurred, display warnings.
|
// Some critical errors occurred, display warnings.
|
||||||
QPointer<QMessageBox> msg_error = new QMessageBox(this);
|
QPointer<QMessageBox> msg_error = new QMessageBox(this);
|
||||||
msg_error.data()->setText(tr("Some critical settings are not set. You must fix these settings in order confirm new settings."));
|
msg_error.data()->setText(tr("Some critical settings are not set. You must fix these settings in order confirm new settings."));
|
||||||
|
@ -15,9 +15,9 @@ LineEditWithStatus::LineEditWithStatus(QWidget *parent)
|
|||||||
|
|
||||||
// TODO: nastavit korektni ikony
|
// TODO: nastavit korektni ikony
|
||||||
m_iconInformation = IconThemeFactory::instance()->fromTheme("help-about");
|
m_iconInformation = IconThemeFactory::instance()->fromTheme("help-about");
|
||||||
m_iconWarning = IconThemeFactory::instance()->fromTheme("application-exit");
|
m_iconWarning = IconThemeFactory::instance()->fromTheme("dialog-warning");
|
||||||
m_iconError = IconThemeFactory::instance()->fromTheme("application-exit");
|
m_iconError = IconThemeFactory::instance()->fromTheme("dialog-error");
|
||||||
m_iconOk = IconThemeFactory::instance()->fromTheme("application-exit");
|
m_iconOk = IconThemeFactory::instance()->fromTheme("dialog-yes");
|
||||||
|
|
||||||
// Set correct size for the tool button.
|
// Set correct size for the tool button.
|
||||||
int txt_input_height = m_txtInput->sizeHint().height();
|
int txt_input_height = m_txtInput->sizeHint().height();
|
||||||
|
@ -1,49 +1,89 @@
|
|||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
|
|
||||||
|
#include "gui/iconthemefactory.h"
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
MessageBox::MessageBox() {
|
MessageBox::MessageBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox::StandardButton MessageBox:: showMessageBox(QWidget *parent,
|
void MessageBox::iconify(QDialogButtonBox *button_box) {
|
||||||
|
foreach (QAbstractButton *button, button_box->buttons()) {
|
||||||
|
button->setIcon(iconForRole(button_box->standardButton(button)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon MessageBox::iconForRole(QDialogButtonBox::StandardButton button) {
|
||||||
|
switch (button) {
|
||||||
|
case QMessageBox::Ok:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-ok");
|
||||||
|
|
||||||
|
case QMessageBox::Yes:
|
||||||
|
case QMessageBox::YesToAll:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-yes");
|
||||||
|
|
||||||
|
case QMessageBox::No:
|
||||||
|
case QMessageBox::NoToAll:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-no");
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon MessageBox::iconForStatus(QMessageBox::Icon status) {
|
||||||
|
switch (status) {
|
||||||
|
case QMessageBox::Information:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("help-about");
|
||||||
|
|
||||||
|
case QMessageBox::Warning:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-warning");
|
||||||
|
|
||||||
|
case QMessageBox::Critical:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-error");
|
||||||
|
|
||||||
|
case QMessageBox::Question:
|
||||||
|
return IconThemeFactory::instance()->fromTheme("dialog-question");
|
||||||
|
|
||||||
|
case QMessageBox::NoIcon:
|
||||||
|
default:
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::StandardButton MessageBox::show(QWidget *parent,
|
||||||
QMessageBox::Icon icon,
|
QMessageBox::Icon icon,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
QMessageBox::StandardButtons buttons,
|
QMessageBox::StandardButtons buttons,
|
||||||
QMessageBox::StandardButton defaultButton) {
|
QMessageBox::StandardButton defaultButton) {
|
||||||
QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
|
// Create and find needed components.
|
||||||
QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
|
QMessageBox msg_box(parent);
|
||||||
|
QDialogButtonBox *button_box = msg_box.findChild<QDialogButtonBox*>();
|
||||||
|
|
||||||
uint mask = QMessageBox::FirstButton;
|
// Initialize message box properties.
|
||||||
while (mask <= QMessageBox::LastButton) {
|
msg_box.setWindowTitle(title);
|
||||||
uint sb = buttons & mask;
|
msg_box.setText(text);
|
||||||
mask <<= 1;
|
msg_box.setStandardButtons(buttons);
|
||||||
if (!sb)
|
msg_box.setDefaultButton(defaultButton);
|
||||||
continue;
|
|
||||||
|
|
||||||
// TODO: tady podle hodnoty masky switchnout prave pridanej button a podle toho mu dat ikonu.
|
iconify(button_box);
|
||||||
// neco jako
|
|
||||||
switch (mask) {
|
|
||||||
case QMessageBox::Ok:
|
|
||||||
// TODO: nastav ikonu "ok"
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
|
// Setup status icon.
|
||||||
|
int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, &msg_box);
|
||||||
|
msg_box.setIconPixmap(iconForStatus(icon).pixmap(icon_size,
|
||||||
|
icon_size));
|
||||||
|
|
||||||
// Choose the first accept role as the default
|
// Display it.
|
||||||
if (msgBox.defaultButton())
|
if (msg_box.exec() == -1) {
|
||||||
continue;
|
|
||||||
if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
|
|
||||||
|| (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
|
|
||||||
msgBox.setDefaultButton(button);
|
|
||||||
}
|
|
||||||
if (msgBox.exec() == -1)
|
|
||||||
return QMessageBox::Cancel;
|
return QMessageBox::Cancel;
|
||||||
return msgBox.standardButton(msgBox.clickedButton());
|
}
|
||||||
|
else {
|
||||||
|
return msg_box.standardButton(msg_box.clickedButton());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MESSAGEBOX_H
|
#define MESSAGEBOX_H
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
|
|
||||||
class MessageBox {
|
class MessageBox {
|
||||||
@ -15,7 +16,15 @@ class MessageBox {
|
|||||||
// se spravnejma parametrama
|
// se spravnejma parametrama
|
||||||
// a napsat taky metodu iconifyMessageButtonBox(qmessabebuttonbox)
|
// a napsat taky metodu iconifyMessageButtonBox(qmessabebuttonbox)
|
||||||
// ktera nahraje do daneho boxu aktualni ikony
|
// ktera nahraje do daneho boxu aktualni ikony
|
||||||
static QMessageBox::StandardButton showMessageBox(QWidget *parent,
|
|
||||||
|
// Performs icon replacements for given button box.
|
||||||
|
static void iconify(QDialogButtonBox *button_box);
|
||||||
|
|
||||||
|
// Returns icons for standard roles/statuses.
|
||||||
|
static QIcon iconForRole(QDialogButtonBox::StandardButton button);
|
||||||
|
static QIcon iconForStatus(QMessageBox::Icon status);
|
||||||
|
|
||||||
|
static QMessageBox::StandardButton show(QWidget *parent,
|
||||||
QMessageBox::Icon icon,
|
QMessageBox::Icon icon,
|
||||||
const QString& title, const QString& text,
|
const QString& title, const QString& text,
|
||||||
QMessageBox::StandardButtons buttons,
|
QMessageBox::StandardButtons buttons,
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
@ -222,27 +221,24 @@ void MessagesView::openSelectedSourceArticlesExternally() {
|
|||||||
"%1").toString();
|
"%1").toString();
|
||||||
|
|
||||||
if (browser.isEmpty() || arguments.isEmpty()) {
|
if (browser.isEmpty() || arguments.isEmpty()) {
|
||||||
MessageBox::showMessageBox(this, QMessageBox::Information,
|
MessageBox::show(this,
|
||||||
"aa", "bb", QMessageBox::Ok, QMessageBox::Ok);
|
QMessageBox::Critical,
|
||||||
|
|
||||||
QMessageBox::critical(this,
|
|
||||||
tr("External browser not set"),
|
tr("External browser not set"),
|
||||||
tr("External browser is not set, head to application settings and set it up to use this feature."),
|
tr("External browser is not set, head to application settings and set it up to use this feature."),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||||
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
|
||||||
if (!QProcess::startDetached(browser + ' ' + arguments.arg(link))) {
|
|
||||||
#else
|
|
||||||
if (!QProcess::startDetached('\"' + browser + "\" \"" + arguments.arg(link) + "\"")) {
|
if (!QProcess::startDetached('\"' + browser + "\" \"" + arguments.arg(link) + "\"")) {
|
||||||
#endif
|
MessageBox::show(this,
|
||||||
QMessageBox::critical(this,
|
QMessageBox::Critical,
|
||||||
tr("Problem with starting external web browser"),
|
tr("Problem with starting external web browser"),
|
||||||
tr("External web browser could not be started."),
|
tr("External web browser could not be started."),
|
||||||
|
QMessageBox::Ok,
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -254,9 +250,12 @@ void MessagesView::openSelectedSourceMessagesInternally() {
|
|||||||
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
|
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
|
||||||
|
|
||||||
if (message.m_url.isEmpty()) {
|
if (message.m_url.isEmpty()) {
|
||||||
QMessageBox::warning(this,
|
MessageBox::show(this,
|
||||||
|
QMessageBox::Warning,
|
||||||
tr("Meesage without URL"),
|
tr("Meesage without URL"),
|
||||||
tr("Message '%s' does not contain URL.").arg(message.m_title));
|
tr("Message '%s' does not contain URL.").arg(message.m_title),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit openLinkNewTab(message.m_url);
|
emit openLinkNewTab(message.m_url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user