confirmshutdowndlg.ui cleanup

shutdownconfirm.cpp cleanup
This commit is contained in:
Chocobo1 2016-03-21 16:17:14 +08:00 committed by sledgehammer999
parent 18ee87f586
commit 5c5b007618
2 changed files with 76 additions and 95 deletions

View file

@ -6,40 +6,67 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>463</width> <width>407</width>
<height>128</height> <height>103</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>20</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="topMargin"> <property name="topMargin">
<number>6</number> <number>15</number>
</property> </property>
<item> <item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="warningLabel"> <widget class="QLabel" name="warningLabel">
<property name="text">
<string notr="true">warning icon</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QLabel" name="shutdownText">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">warning icon goes here</string> <string notr="true">shutdown message goes here</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2">
<widget class="QCheckBox" name="neverShowAgainCheckbox">
<property name="text">
<string>Don't show again</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -47,65 +74,19 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>0</width>
<height>40</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="topMargin"> <property name="standardButtons">
<number>6</number> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<item>
<widget class="QLabel" name="shutdownText">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">shutdown message goes here</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="neverShowAgainCheckbox">
<property name="text">
<string>Don't show again</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox"/>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View file

@ -52,30 +52,30 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownAction &action)
{ {
ui->setupUi(this); ui->setupUi(this);
QIcon warningIcon(style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, this)); QIcon warningIcon(style()->standardIcon(QStyle::SP_MessageBoxWarning));
ui->warningLabel->setPixmap(warningIcon.pixmap(warningIcon.actualSize(QSize(32, 32)))); ui->warningLabel->setPixmap(warningIcon.pixmap(32));
updateText(); updateText();
// Never show again checkbox, Title, and button // Never show again checkbox, Title, and button
QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
if (m_action == ShutdownAction::None) { if (m_action == ShutdownAction::None) {
setWindowTitle(tr("Exit confirmation")); setWindowTitle(tr("Exit confirmation"));
ui->buttonBox->addButton(new QPushButton(tr("Exit Now"), this), QDialogButtonBox::AcceptRole); okButton->setText(tr("E&xit Now"));
} }
else { else {
setWindowTitle(tr("Shutdown confirmation")); setWindowTitle(tr("Shutdown confirmation"));
ui->buttonBox->addButton(new QPushButton(tr("Shutdown Now"), this), QDialogButtonBox::AcceptRole); okButton->setText(tr("&Shutdown Now"));
ui->neverShowAgainCheckbox->setVisible(false); ui->neverShowAgainCheckbox->setVisible(false);
} }
// Cancel Button // Cancel Button
QPushButton *cancelButton = ui->buttonBox->addButton(QDialogButtonBox::Cancel); QPushButton *cancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel);
cancelButton->setFocus();
cancelButton->setDefault(true); cancelButton->setDefault(true);
// Always on top // Always on top
setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint); setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint);
// Set 'Cancel' as default button.
m_timer.setInterval(1000); // 1sec m_timer.setInterval(1000); // 1sec
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
// Move to center // Move to center
move(Utils::Misc::screenCenter(this)); move(Utils::Misc::screenCenter(this));
cancelButton->setFocus();
} }
void ShutdownConfirmDlg::showEvent(QShowEvent *event) void ShutdownConfirmDlg::showEvent(QShowEvent *event)