Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*********************************************************************
- //**** main.cppp *****
- //*********************************************************************
- #include <KApplication>
- #include <KAboutData>
- #include <KCmdLineArgs>
- #include <KLocale>
- #include "kbackupview.h"
- static const char version[] = "0.1";
- int main(int argc, char *argv[])
- {
- KAboutData aboutData([...]);
- KCmdLineArgs::init(argc, argv, &aboutData);
- KApplication app;
- Kbackupview* window = new Kbackupview();
- window->show();
- return app.exec();
- }
- //*********************************************************************
- //**** kbackupview.h ****
- //*********************************************************************
- #ifndef KBACKUPVIEW_H
- #define KBACKUPVIEW_H
- #include <KDialog>
- #include <KApplication>
- #include <KAction>
- #include <KLocale>
- #include <KActionCollection>
- #include <KStandardAction>
- #include <KFileDialog>
- #include <KMessageBox>
- #include <KIO/NetAccess>
- #include <QTextStream>
- // include the automatically generated header file for the ui-file
- #include "ui_kbackup.h"
- class Kbackupview : public KDialog
- {
- Q_OBJECT
- public:
- Kbackupview(QMainWindow *parent=0);
- // ~Kbackupview();
- private slots:
- void kdeCfgSlctKdeDestDir();
- private:
- Ui::Kbackup ui;
- QString kdeDestDir; // KDE directory on destination
- };
- #endif
- //*********************************************************************
- //**** kbackupview.cpp ****
- //*********************************************************************
- // include the header file of the dialog
- #include "kbackupview.h"
- Kbackupview::Kbackupview(QMainWindow* parent)
- : KDialog(parent),
- kdeDestDir(QString())
- {
- QMainWindow *widget = new QMainWindow(this);
- // create the user interface, the parent widget is "widget"
- ui.setupUi(widget); // this is the important part
- // set the widget with all its gui elements as the dialog's main widget
- setMainWidget(widget);
- // other KDialog options
- setCaption(i18nc("", "The main window of Kbackup"));
- setButtons(KDialog::Close);
- // Example Signal/Slot connection using widgets in your UI.
- // Note that you have to prepend "ui." when referring to your UI elements.
- connect(ui.kdeCfgSlctKdeDestDir, SIGNAL(clicked()), this, SLOT(kdeCfgSlctKdeDestDir()));
- }
- //Kbackupview::~Kbackupview() {
- //
- //}
- void Kbackupview::kdeCfgSlctKdeDestDir()
- {
- // ask the user to select a directory
- QString dirNameFromDialog = KFileDialog::getExistingDirectory(KUrl::fromPath("~/"), this, i18nc("", "Select Destination KDE Directory"));
- // check of availability of selected directory
- // if available:
- if (!dirNameFromDialog.isEmpty()) {
- // save the selected directory in our variable
- kdeDestDir = dirNameFromDialog;
- // display the selected directory in the LineEdit
- ui.kdeCfgKdeDestDir->setText(kdeDestDir);
- // else:
- } else {
- // display error message
- KMessageBox::error(this, i18nc("", "Could not find the selected directory."));
- }
- }
- //*********************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement