Permalink
Browse files

Clean up the Appcafe error dialog. Just use the built in Qmessagebox …

…functionality for displaying detailed (but optional) info instead of the custom class I wrote before.
  • Loading branch information...
1 parent 58b73e1 commit 867747aa360e42527e4aa489833dfb7b0c13a92b Ken Moore committed Aug 2, 2013
@@ -1,72 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2011 - iXsystems *
- * kris@pcbsd.org *
- * tim@pcbsd.org *
- * ken@pcbsd.org *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining *
- * a copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, sublicense, and/or sell copies of the Software, and to *
- * permit persons to whom the Software is furnished to do so, subject to *
- * the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be *
- * included in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
- * OTHER DEALINGS IN THE SOFTWARE. *
- ***************************************************************************/
-#include "ErrorDialog.h"
-#include "ui_ErrorDialog.h"
-
-ErrorDialog::ErrorDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ErrorDialog){
- ui->setupUi(this);
- connect(ui->checkBox, SIGNAL(stateChanged(int)), this, SLOT(updateUI()) );
-}
-
-ErrorDialog::~ErrorDialog(){
- delete ui;
-}
-
-void ErrorDialog::setDLGTitle(QString title){
- this->setWindowTitle(title);
- updateUI();
-}
-
-void ErrorDialog::setDLGMessage(QString message){
- ui->label->setText(message);
- updateUI();
-}
-
-void ErrorDialog::setDLGLog(QStringList log){
- ui->textEdit->clear();
- ui->textEdit->setText(log.join("\n"));
- updateUI();
-}
-
-
-void ErrorDialog::updateUI(){
- if(ui->textEdit->toPlainText().isEmpty()){
- ui->checkBox->setVisible(FALSE);
- ui->textEdit->setVisible(FALSE);
- }else{
- ui->checkBox->setVisible(TRUE);
- if(ui->checkBox->isChecked()){ui->textEdit->setVisible(TRUE);}
- else{ui->textEdit->setVisible(FALSE);}
- }
-}
-
-void ErrorDialog::on_buttonBox_accepted(){
- this->close();
-}
-
-void ErrorDialog::on_buttonBox_rejected(){
- this->close();
-}
@@ -1,59 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2011 - iXsystems *
- * kris@pcbsd.org *
- * tim@pcbsd.org *
- * ken@pcbsd.org *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining *
- * a copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, sublicense, and/or sell copies of the Software, and to *
- * permit persons to whom the Software is furnished to do so, subject to *
- * the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be *
- * included in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
- * OTHER DEALINGS IN THE SOFTWARE. *
- ***************************************************************************/
-#ifndef _APPCAFE_ERROR_DIALOG_H
-#define _APPCAFE_ERROR_DIALOG_H
-
-#include <QDialog>
-#include <QString>
-#include <QStringList>
-
-namespace Ui {
- class ErrorDialog;
-}
-
-class ErrorDialog : public QDialog{
- Q_OBJECT
-
-public:
- ErrorDialog(QWidget* parent = 0);
- ~ErrorDialog();
-
- void setDLGTitle(QString);
- void setDLGMessage(QString);
- void setDLGLog(QStringList);
-
-private:
- Ui::ErrorDialog *ui;
-
-private slots:
- void updateUI();
- void on_buttonBox_accepted();
- void on_buttonBox_rejected();
-
-};
-
-#endif
-
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ErrorDialog</class>
- <widget class="QDialog" name="ErrorDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>404</width>
- <height>171</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <property name="windowIcon">
- <iconset resource="SoftwareManager.qrc">
- <normaloff>:/icons/dialog-cancel.png</normaloff>:/icons/dialog-cancel.png</iconset>
- </property>
- <property name="modal">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label_icon">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="SoftwareManager.qrc">:/icons/dialog-cancel.png</pixmap>
- </property>
- <property name="scaledContents">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string notr="true">Error Message</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox">
- <property name="text">
- <string>Show Error Log</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTextEdit" name="textEdit">
- <property name="lineWrapMode">
- <enum>QTextEdit::NoWrap</enum>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="SoftwareManager.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>ErrorDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>ErrorDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
@@ -935,12 +935,11 @@ void MainUI::clearScrollArea(QScrollArea* area){
}
void MainUI::slotDisplayError(QString title,QString message,QStringList log){
- ErrorDialog *dlg = new ErrorDialog(this);
- dlg->setDLGTitle(title);
- dlg->setDLGMessage(message);
- dlg->setDLGLog(log);
+ QMessageBox *dlg = new QMessageBox(this);
+ dlg->setWindowTitle(title);
+ dlg->setText(message);
+ dlg->setDetailedText(log.join("\n"));
dlg->exec();
- //QMessageBox::warning(this,title,message+"\n\n"+log.join("\n"));
}
void MainUI::slotDisplayStats(){
@@ -26,7 +26,6 @@
#include "extras.h"
#include "largeItemWidget.h"
#include "smallItemWidget.h"
-#include "ErrorDialog.h"
namespace Ui {
class MainUI;
@@ -15,22 +15,19 @@ HEADERS += mainUI.h \
extras.h \
pbiDBAccess.h \
processManager.h \
- configDialog.h \
- ErrorDialog.h
+ configDialog.h
SOURCES += main.cpp \
mainUI.cpp \
pbiBackend.cpp \
pbiDBAccess.cpp \
processManager.cpp \
- configDialog.cpp \
- ErrorDialog.cpp
+ configDialog.cpp
RESOURCES += SoftwareManager.qrc
FORMS = mainUI.ui \
- configDialog.ui \
- ErrorDialog.ui
+ configDialog.ui
TARGET = pc-softwaremanager
target.path = /usr/local/bin/

0 comments on commit 867747a

Please sign in to comment.