Changeset View
Changeset View
Standalone View
Standalone View
kcms/activities/imports/dialog.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 53 | public: | |||
---|---|---|---|---|---|
63 | { | 63 | { | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | Dialog *const q; | 66 | Dialog *const q; | ||
67 | QVBoxLayout *layout; | 67 | QVBoxLayout *layout; | ||
68 | QTabWidget *tabs; | 68 | QTabWidget *tabs; | ||
69 | 69 | | |||
70 | QQuickWidget *tabGeneral; | 70 | QQuickWidget *tabGeneral; | ||
71 | QQuickWidget *tabOther; | | |||
72 | KMessageWidget *message; | 71 | KMessageWidget *message; | ||
73 | QDialogButtonBox *buttons; | 72 | QDialogButtonBox *buttons; | ||
74 | QString defaultOKText; | 73 | QString defaultOKText; | ||
75 | 74 | | |||
76 | QQuickWidget *createTab(const QString &title, const QString &file) | 75 | QQuickWidget *createTab(const QString &title, const QString &file) | ||
77 | { | 76 | { | ||
78 | auto view = new QQuickWidget(); | 77 | auto view = new QQuickWidget(); | ||
79 | 78 | | |||
80 | view->setResizeMode(QQuickWidget::SizeRootObjectToView); | 79 | view->setResizeMode(QQuickWidget::SizeRootObjectToView); | ||
81 | 80 | | |||
82 | view->setClearColor(QGuiApplication::palette().window().color()); | 81 | view->setClearColor(QGuiApplication::palette().window().color()); | ||
83 | 82 | | |||
84 | view->rootContext()->setContextProperty(QStringLiteral("dialog"), q); | 83 | view->rootContext()->setContextProperty(QStringLiteral("dialog"), q); | ||
85 | 84 | | |||
86 | if (setViewSource(view, QStringLiteral("/qml/activityDialog/") + file)) { | 85 | if (setViewSource(view, QStringLiteral("/qml/activityDialog/") + file)) { | ||
87 | tabs->addTab(view, title); | 86 | tabs->addTab(view, title); | ||
88 | | ||||
89 | auto root = view->rootObject(); | | |||
90 | Q_ASSERT(root); | | |||
91 | QMetaObject::invokeMethod(root, "load", Qt::DirectConnection); | | |||
92 | | ||||
93 | } else { | 87 | } else { | ||
94 | message->setText(i18n("Error loading the QML files. Check your installation.\nMissing %1", | 88 | message->setText(i18n("Error loading the QML files. Check your installation.\nMissing %1", | ||
95 | QStringLiteral(KAMD_KCM_DATADIR) + QStringLiteral("/qml/activityDialog/") + file)); | 89 | QStringLiteral(KAMD_KCM_DATADIR) + QStringLiteral("/qml/activityDialog/") + file)); | ||
96 | message->setVisible(true); | 90 | message->setVisible(true); | ||
97 | } | 91 | } | ||
98 | 92 | | |||
99 | return view; | 93 | return view; | ||
100 | } | 94 | } | ||
Show All 36 Lines | 122 | { | |||
137 | dialog->init(id); | 131 | dialog->init(id); | ||
138 | dialog->show(); | 132 | dialog->show(); | ||
139 | } | 133 | } | ||
140 | 134 | | |||
141 | Dialog::Dialog(QObject *parent) | 135 | Dialog::Dialog(QObject *parent) | ||
142 | : QDialog() | 136 | : QDialog() | ||
143 | , d(this) | 137 | , d(this) | ||
144 | { | 138 | { | ||
145 | resize(600, 500); | 139 | resize(550, 400); | ||
146 | 140 | | |||
147 | d->layout = new QVBoxLayout(this); | 141 | d->layout = new QVBoxLayout(this); | ||
148 | 142 | | |||
149 | // Message widget for showing errors | 143 | // Message widget for showing errors | ||
150 | d->message = new KMessageWidget(this); | 144 | d->message = new KMessageWidget(this); | ||
151 | d->message->setMessageType(KMessageWidget::Error); | 145 | d->message->setMessageType(KMessageWidget::Error); | ||
152 | d->message->setVisible(false); | 146 | d->message->setVisible(false); | ||
153 | d->layout->addWidget(d->message); | 147 | d->layout->addWidget(d->message); | ||
154 | 148 | | |||
155 | // Tabs | 149 | // Tabs | ||
156 | d->tabs = new QTabWidget(this); | 150 | d->tabs = new QTabWidget(this); | ||
157 | d->layout->addWidget(d->tabs); | 151 | d->layout->addWidget(d->tabs); | ||
158 | d->tabGeneral = d->createTab(i18n("General"), QStringLiteral("GeneralTab.qml")); | 152 | d->tabGeneral = d->createTab(i18n("General"), QStringLiteral("GeneralTab.qml")); | ||
159 | d->tabOther = d->createTab(i18n("Other"), QStringLiteral("OtherTab.qml")); | | |||
160 | 153 | | |||
161 | // Buttons | 154 | // Buttons | ||
162 | d->buttons = new QDialogButtonBox( | 155 | d->buttons = new QDialogButtonBox( | ||
163 | QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | 156 | QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | ||
164 | d->layout->QLayout::addWidget(d->buttons); | 157 | d->layout->QLayout::addWidget(d->buttons); | ||
165 | 158 | | |||
166 | connect(d->buttons->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, | 159 | connect(d->buttons->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, | ||
167 | this, &Dialog::save); | 160 | this, &Dialog::save); | ||
Show All 12 Lines | 172 | d->buttons->button(QDialogButtonBox::Ok)->setText( | |||
180 | activityId.isEmpty() ? i18nc("@action:button", "Create") | 173 | activityId.isEmpty() ? i18nc("@action:button", "Create") | ||
181 | : d->defaultOKText); | 174 | : d->defaultOKText); | ||
182 | 175 | | |||
183 | d->tabs->setCurrentIndex(0); | 176 | d->tabs->setCurrentIndex(0); | ||
184 | 177 | | |||
185 | setActivityId(activityId); | 178 | setActivityId(activityId); | ||
186 | setActivityName(QString()); | 179 | setActivityName(QString()); | ||
187 | setActivityDescription(QString()); | 180 | setActivityDescription(QString()); | ||
188 | setActivityIcon(QString()); | 181 | setActivityIcon(QStringLiteral("preferences-activities")); | ||
189 | setActivityIsPrivate(false); | 182 | setActivityIsPrivate(false); | ||
190 | 183 | | |||
191 | setActivityShortcut(QKeySequence()); | 184 | setActivityShortcut(QKeySequence()); | ||
192 | 185 | | |||
193 | if (!activityId.isEmpty()) { | 186 | if (!activityId.isEmpty()) { | ||
194 | KActivities::Info activityInfo(activityId); | 187 | KActivities::Info activityInfo(activityId); | ||
195 | 188 | | |||
196 | setActivityName(activityInfo.name()); | 189 | setActivityName(activityInfo.name()); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 237 | { \ | |||
252 | root->setProperty("activity" #PropName, value); \ | 245 | root->setProperty("activity" #PropName, value); \ | ||
253 | } | 246 | } | ||
254 | 247 | | |||
255 | IMPLEMENT_PROPERTY(General, QString, const QString &, Id) | 248 | IMPLEMENT_PROPERTY(General, QString, const QString &, Id) | ||
256 | IMPLEMENT_PROPERTY(General, QString, const QString &, Name) | 249 | IMPLEMENT_PROPERTY(General, QString, const QString &, Name) | ||
257 | IMPLEMENT_PROPERTY(General, QString, const QString &, Description) | 250 | IMPLEMENT_PROPERTY(General, QString, const QString &, Description) | ||
258 | IMPLEMENT_PROPERTY(General, QString, const QString &, Icon) | 251 | IMPLEMENT_PROPERTY(General, QString, const QString &, Icon) | ||
259 | IMPLEMENT_PROPERTY(General, QString, const QString &, Wallpaper) | 252 | IMPLEMENT_PROPERTY(General, QString, const QString &, Wallpaper) | ||
260 | IMPLEMENT_PROPERTY(Other, QKeySequence, const QKeySequence &, Shortcut) | 253 | IMPLEMENT_PROPERTY(General, QKeySequence, const QKeySequence &, Shortcut) | ||
261 | IMPLEMENT_PROPERTY(Other, bool, bool, IsPrivate) | 254 | IMPLEMENT_PROPERTY(General, bool, bool, IsPrivate) | ||
262 | #undef IMPLEMENT_PROPERTY | 255 | #undef IMPLEMENT_PROPERTY | ||
263 | 256 | | |||
264 | void Dialog::save() | 257 | void Dialog::save() | ||
265 | { | 258 | { | ||
266 | if (activityId().isEmpty()) { | 259 | if (activityId().isEmpty()) { | ||
267 | create(); | 260 | create(); | ||
268 | 261 | | |||
269 | } else { | 262 | } else { | ||
Show All 38 Lines |