mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-16 19:03:25 +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 <QDialogButtonBox>
|
||||
#include <QToolButton>
|
||||
#include "QComboBox"
|
||||
|
||||
|
||||
FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
|
||||
@ -24,16 +23,23 @@ FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent)
|
||||
loadCategories(model->allCategories().values(),
|
||||
model->rootItem());
|
||||
|
||||
connect(m_ui->m_buttonBox, SIGNAL(accepted()),
|
||||
this, SLOT(apply()));
|
||||
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)),
|
||||
this, SLOT(onTitleChanged(QString)));
|
||||
createConnections();
|
||||
|
||||
// Initialize text boxes.
|
||||
onTitleChanged(QString());
|
||||
}
|
||||
|
||||
FormCategoryDetails::~FormCategoryDetails() {
|
||||
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) {
|
||||
m_editableCategory = editable_category;
|
||||
|
||||
@ -86,7 +92,7 @@ void FormCategoryDetails::apply() {
|
||||
}
|
||||
|
||||
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."));
|
||||
}
|
||||
else {
|
||||
|
@ -32,6 +32,9 @@ class FormCategoryDetails : public QDialog {
|
||||
// Destructor.
|
||||
virtual ~FormCategoryDetails();
|
||||
|
||||
// Creates needed connections.
|
||||
void createConnections();
|
||||
|
||||
public slots:
|
||||
// Start dialog execution. If result is QDialog::Accepted,
|
||||
// then output_item contains added or edited category
|
||||
|
@ -199,6 +199,10 @@ bool FormSettings::doSaveCheck() {
|
||||
resulting_information.replaceInStrings(QRegExp("^"),
|
||||
QString::fromUtf8(" • "));
|
||||
|
||||
// TODO: dedit qmessagebox
|
||||
// MessageBox a tam pretizit setIcon
|
||||
// a setStandardButtons atp
|
||||
|
||||
// Some critical errors occurred, display warnings.
|
||||
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."));
|
||||
|
@ -15,9 +15,9 @@ LineEditWithStatus::LineEditWithStatus(QWidget *parent)
|
||||
|
||||
// TODO: nastavit korektni ikony
|
||||
m_iconInformation = IconThemeFactory::instance()->fromTheme("help-about");
|
||||
m_iconWarning = IconThemeFactory::instance()->fromTheme("application-exit");
|
||||
m_iconError = IconThemeFactory::instance()->fromTheme("application-exit");
|
||||
m_iconOk = IconThemeFactory::instance()->fromTheme("application-exit");
|
||||
m_iconWarning = IconThemeFactory::instance()->fromTheme("dialog-warning");
|
||||
m_iconError = IconThemeFactory::instance()->fromTheme("dialog-error");
|
||||
m_iconOk = IconThemeFactory::instance()->fromTheme("dialog-yes");
|
||||
|
||||
// Set correct size for the tool button.
|
||||
int txt_input_height = m_txtInput->sizeHint().height();
|
||||
|
@ -1,49 +1,89 @@
|
||||
#include "gui/messagebox.h"
|
||||
|
||||
#include "gui/iconthemefactory.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QtGlobal>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QStyle>
|
||||
#include <QApplication>
|
||||
|
||||
MessageBox::MessageBox() {
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton MessageBox:: showMessageBox(QWidget *parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
|
||||
QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
|
||||
|
||||
uint mask = QMessageBox::FirstButton;
|
||||
while (mask <= QMessageBox::LastButton) {
|
||||
uint sb = buttons & mask;
|
||||
mask <<= 1;
|
||||
if (!sb)
|
||||
continue;
|
||||
|
||||
// TODO: tady podle hodnoty masky switchnout prave pridanej button a podle toho mu dat ikonu.
|
||||
// neco jako
|
||||
switch (mask) {
|
||||
case QMessageBox::Ok:
|
||||
// TODO: nastav ikonu "ok"
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
|
||||
|
||||
// Choose the first accept role as the default
|
||||
if (msgBox.defaultButton())
|
||||
continue;
|
||||
if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
|
||||
|| (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
|
||||
msgBox.setDefaultButton(button);
|
||||
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,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
// Create and find needed components.
|
||||
QMessageBox msg_box(parent);
|
||||
QDialogButtonBox *button_box = msg_box.findChild<QDialogButtonBox*>();
|
||||
|
||||
// Initialize message box properties.
|
||||
msg_box.setWindowTitle(title);
|
||||
msg_box.setText(text);
|
||||
msg_box.setStandardButtons(buttons);
|
||||
msg_box.setDefaultButton(defaultButton);
|
||||
|
||||
iconify(button_box);
|
||||
|
||||
// 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));
|
||||
|
||||
// Display it.
|
||||
if (msg_box.exec() == -1) {
|
||||
return QMessageBox::Cancel;
|
||||
}
|
||||
else {
|
||||
return msg_box.standardButton(msg_box.clickedButton());
|
||||
}
|
||||
if (msgBox.exec() == -1)
|
||||
return QMessageBox::Cancel;
|
||||
return msgBox.standardButton(msgBox.clickedButton());
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MESSAGEBOX_H
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
|
||||
class MessageBox {
|
||||
@ -15,11 +16,19 @@ class MessageBox {
|
||||
// se spravnejma parametrama
|
||||
// a napsat taky metodu iconifyMessageButtonBox(qmessabebuttonbox)
|
||||
// ktera nahraje do daneho boxu aktualni ikony
|
||||
static QMessageBox::StandardButton showMessageBox(QWidget *parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
|
||||
// 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,
|
||||
const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
};
|
||||
|
||||
#endif // MESSAGEBOX_H
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
|
||||
@ -222,28 +221,25 @@ void MessagesView::openSelectedSourceArticlesExternally() {
|
||||
"%1").toString();
|
||||
|
||||
if (browser.isEmpty() || arguments.isEmpty()) {
|
||||
MessageBox::showMessageBox(this, QMessageBox::Information,
|
||||
"aa", "bb", QMessageBox::Ok, QMessageBox::Ok);
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("External browser not set"),
|
||||
tr("External browser is not set, head to application settings and set it up to use this feature."),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
QMessageBox::critical(this,
|
||||
tr("External browser not set"),
|
||||
tr("External browser is not set, head to application settings and set it up to use this feature."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||
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) + "\"")) {
|
||||
#endif
|
||||
QMessageBox::critical(this,
|
||||
tr("Problem with starting external web browser"),
|
||||
tr("External web browser could not be started."),
|
||||
QMessageBox::Ok);
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("Problem with starting external web browser"),
|
||||
tr("External web browser could not be started."),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -254,9 +250,12 @@ void MessagesView::openSelectedSourceMessagesInternally() {
|
||||
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
|
||||
|
||||
if (message.m_url.isEmpty()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Meesage without URL"),
|
||||
tr("Message '%s' does not contain URL.").arg(message.m_title));
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Warning,
|
||||
tr("Meesage without URL"),
|
||||
tr("Message '%s' does not contain URL.").arg(message.m_title),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
else {
|
||||
emit openLinkNewTab(message.m_url);
|
||||
|
Loading…
Reference in New Issue
Block a user