Advanced boxes.
This commit is contained in:
parent
c763a62e06
commit
8f2c44bcf3
@ -36,6 +36,9 @@ QIcon MessageBox::iconForRole(QDialogButtonBox::StandardButton button) {
|
||||
case QMessageBox::Ok:
|
||||
return IconThemeFactory::instance()->fromTheme("dialog-ok");
|
||||
|
||||
case QMessageBox::Cancel:
|
||||
return IconThemeFactory::instance()->fromTheme("edit-delete");
|
||||
|
||||
case QMessageBox::Yes:
|
||||
case QMessageBox::YesToAll:
|
||||
return IconThemeFactory::instance()->fromTheme("dialog-yes");
|
||||
@ -73,8 +76,9 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
const QString &informative_text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
QMessageBox::StandardButton default_button) {
|
||||
// Create and find needed components.
|
||||
MessageBox msg_box(parent);
|
||||
QDialogButtonBox *button_box = msg_box.findChild<QDialogButtonBox*>();
|
||||
@ -82,14 +86,14 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent,
|
||||
// Initialize message box properties.
|
||||
msg_box.setWindowTitle(title);
|
||||
msg_box.setText(text);
|
||||
msg_box.setInformativeText(informative_text);
|
||||
msg_box.setIcon(icon);
|
||||
msg_box.setStandardButtons(buttons);
|
||||
msg_box.setDefaultButton(defaultButton);
|
||||
msg_box.setDefaultButton(default_button);
|
||||
|
||||
// Setup button box icons.
|
||||
iconify(button_box);
|
||||
|
||||
|
||||
|
||||
// Display it.
|
||||
if (msg_box.exec() == -1) {
|
||||
return QMessageBox::Cancel;
|
||||
|
@ -13,26 +13,25 @@ class MessageBox : public QMessageBox {
|
||||
explicit MessageBox(QWidget *parent = 0);
|
||||
virtual ~MessageBox();
|
||||
|
||||
// Custom icon setting.
|
||||
void setIcon(Icon icon);
|
||||
|
||||
// TODO: tudle metodu udelat private a udelat public
|
||||
// metody information, warning atd a ty budou tudle volat
|
||||
// se spravnejma parametrama
|
||||
// a napsat taky metodu iconifyMessageButtonBox(qmessabebuttonbox)
|
||||
// ktera nahraje do daneho boxu aktualni ikony
|
||||
// Displays custom message box.
|
||||
static QMessageBox::StandardButton show(QWidget *parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString &title,
|
||||
const QString &text,
|
||||
const QString &informative_text = QString(),
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton default_button = QMessageBox::Ok);
|
||||
|
||||
private:
|
||||
// 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
|
||||
|
@ -224,8 +224,7 @@ void MessagesView::openSelectedSourceArticlesExternally() {
|
||||
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);
|
||||
tr("External browser is not set, head to application settings and set it up to use this feature."));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -237,9 +236,7 @@ void MessagesView::openSelectedSourceArticlesExternally() {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("Problem with starting external web browser"),
|
||||
tr("External web browser could not be started."),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::Ok);
|
||||
tr("External web browser could not be started."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -253,9 +250,7 @@ void MessagesView::openSelectedSourceMessagesInternally() {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Warning,
|
||||
tr("Meesage without URL"),
|
||||
tr("Message '%s' does not contain URL.").arg(message.m_title),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::Ok);
|
||||
tr("Message '%s' does not contain URL.").arg(message.m_title));
|
||||
}
|
||||
else {
|
||||
emit openLinkNewTab(message.m_url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user