AlternativeWMDialog ported to QDialog

This commit is contained in:
Martin Gräßlin 2013-08-15 12:52:37 +02:00
parent 9706da58e3
commit 3cb4e0322f

View file

@ -32,21 +32,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kcmdlineargs.h> #include <kcmdlineargs.h>
#include <k4aboutdata.h> #include <k4aboutdata.h>
#include <kcrash.h> #include <kcrash.h>
#include <KDE/KConfigGroup>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <QX11Info> #include <QX11Info>
#include <stdio.h> #include <stdio.h>
#include <fixx11h.h> #include <fixx11h.h>
#include <QtDBus/QtDBus> #include <QtDBus/QtDBus>
#include <QMessageBox>
#include <QEvent> #include <QEvent>
#include <kdialog.h>
#include <QStandardPaths> #include <QStandardPaths>
#include <kdebug.h> #include <kdebug.h>
#include <kde_file.h> #include <kde_file.h>
#include <QComboBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLabel> #include <QLabel>
#include <KComboBox> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <KGlobalSettings> #include <KGlobalSettings>
@ -147,13 +149,11 @@ bool KWinSelectionOwner::genericReply(xcb_atom_t target_P, xcb_atom_t property_P
Atom KWinSelectionOwner::xa_version = None; Atom KWinSelectionOwner::xa_version = None;
class AlternativeWMDialog : public KDialog class AlternativeWMDialog : public QDialog
{ {
public: public:
AlternativeWMDialog() AlternativeWMDialog()
: KDialog() { : QDialog() {
setButtons(KDialog::Ok | KDialog::Cancel);
QWidget* mainWidget = new QWidget(this); QWidget* mainWidget = new QWidget(this);
QVBoxLayout* layout = new QVBoxLayout(mainWidget); QVBoxLayout* layout = new QVBoxLayout(mainWidget);
QString text = i18n( QString text = i18n(
@ -162,7 +162,7 @@ public:
"You can select another window manager to run:"); "You can select another window manager to run:");
QLabel* textLabel = new QLabel(text, mainWidget); QLabel* textLabel = new QLabel(text, mainWidget);
layout->addWidget(textLabel); layout->addWidget(textLabel);
wmList = new KComboBox(mainWidget); wmList = new QComboBox(mainWidget);
wmList->setEditable(true); wmList->setEditable(true);
layout->addWidget(wmList); layout->addWidget(wmList);
@ -171,10 +171,15 @@ public:
addWM(QStringLiteral("fvwm2")); addWM(QStringLiteral("fvwm2"));
addWM(QStringLiteral(KWIN_NAME)); addWM(QStringLiteral(KWIN_NAME));
setMainWidget(mainWidget); QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(mainWidget);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttons->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
mainLayout->addWidget(buttons);
raise(); raise();
centerOnScreen(this);
} }
void addWM(const QString& wm) { void addWM(const QString& wm) {
@ -187,7 +192,7 @@ public:
} }
private: private:
KComboBox* wmList; QComboBox* wmList;
}; };
int Application::crashes = 0; int Application::crashes = 0;