~ubuntu-branches/ubuntu/saucy/mountmanager/saucy

« back to all changes in this revision

Viewing changes to sources/gui/widgetformount.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2008-08-20 10:22:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080820102214-fv93myu0ncb1503r
Tags: upstream-0.2.4
ImportĀ upstreamĀ versionĀ 0.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//MountManager - the program for easy mounting of storage devices in Linux
 
2
//Copyright (C) 2007-2008 Tikhonov Sergey
 
3
//
 
4
//This file is part of MountManager Gui
 
5
//
 
6
//This program is free software; you can redistribute it and/or
 
7
//modify it under the terms of the GNU General Public License
 
8
//as published by the Free Software Foundation; either version 2
 
9
//of the License, or (at your option) any later version.
 
10
//
 
11
//This program is distributed in the hope that it will be useful,
 
12
//but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//GNU General Public License for more details.
 
15
//
 
16
//You should have received a copy of the GNU General Public License
 
17
//along with this program; if not, write to the Free Software
 
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
#include <QtGui/QLabel>
 
20
#include <QtGui/QLineEdit>
 
21
#include <QtGui/QPushButton>
 
22
#include <QtGui/QIcon>
 
23
#include <QtGui/QGridLayout>
 
24
#include <QDebug>
 
25
#include "../core/diskcore.h"
 
26
#include "../core/diskdevice.h"
 
27
#include "const.h"
 
28
#include "choosemountpointwidget.h"
 
29
#include "widgetformount.h"
 
30
 
 
31
WidgetForMount::WidgetForMount(DiskCore *diskCore) {
 
32
        core = diskCore;
 
33
 
 
34
        headerLabel = new QLabel;
 
35
        
 
36
        mountPointLabel = new QLabel(tr("Choose mount point, please") + ":");
 
37
        mountPointLine = new ChooseMountPointWidget;
 
38
        mountPointLine->setReadOnly(false);
 
39
        
 
40
        optionsLabel = new QLabel(tr("Options") + ":");
 
41
        optionsLine = new QLineEdit;
 
42
 
 
43
        hideButton = new QPushButton;
 
44
        hideButton->setIcon(QIcon(ICONS_PATH"cancel.png"));
 
45
        hideButton->setFlat(true);
 
46
        connect(hideButton,SIGNAL(clicked()),this,SLOT(hide()));
 
47
        
 
48
        mountButton = new QPushButton(tr("Mount"));
 
49
        mountButton->setIcon(QIcon(ICONS_PATH"mount.png"));
 
50
        connect(mountButton,SIGNAL(clicked()),this,SLOT(mount()));
 
51
        connect(mountPointLine,SIGNAL(mountPointValidSignal(bool)),mountButton,SLOT(setEnabled(bool)));
 
52
        mountButton->setEnabled(false);
 
53
        
 
54
        QGridLayout *mainLayout = new QGridLayout;
 
55
        mainLayout->setMargin(0);
 
56
 
 
57
        QHBoxLayout *buttonsLayout = new QHBoxLayout;
 
58
        buttonsLayout->addStretch();
 
59
        buttonsLayout->addWidget(mountButton);
 
60
 
 
61
        QHBoxLayout *hideButtonLayout = new QHBoxLayout;
 
62
        hideButtonLayout->setMargin(0);
 
63
        hideButtonLayout->addWidget(headerLabel);
 
64
        hideButtonLayout->addStretch();
 
65
        hideButtonLayout->addWidget(hideButton);
 
66
 
 
67
        mainLayout->addLayout(hideButtonLayout,0,0,1,2);
 
68
        mainLayout->addWidget(mountPointLabel,1,0);
 
69
        mainLayout->addWidget(mountPointLine,1,1);
 
70
        mainLayout->addWidget(optionsLabel,2,0);
 
71
        mainLayout->addWidget(optionsLine,2,1);
 
72
        mainLayout->addLayout(buttonsLayout,3,0,1,2);
 
73
        mainLayout->addWidget(new QLabel("<hr>"),4,0,1,2);
 
74
        mainLayout->setColumnStretch(1,1);
 
75
        
 
76
        setLayout(mainLayout);
 
77
}
 
78
 
 
79
WidgetForMount::~WidgetForMount() {
 
80
        delete mountPointLabel;
 
81
        delete mountPointLine;
 
82
        delete optionsLabel;
 
83
        delete optionsLine;
 
84
 
 
85
        delete hideButton;
 
86
        delete mountButton;
 
87
}
 
88
 
 
89
void WidgetForMount::setOptionsForMount(const QString& blockName,const QString& mountPoint,const QString& fileSystem,const QString& options) {
 
90
        headerLabel->setText("<b><font size=4>" + tr("Mounting of partition %1").arg(blockName) + "</font></b>");
 
91
        mountPointLine->setMountPoint(mountPoint);
 
92
        if (options.isEmpty())
 
93
                optionsLine->setText("defaults");
 
94
        else
 
95
                optionsLine->setText(options);
 
96
        currentFileSystem = fileSystem;
 
97
        currentBlockName = blockName;
 
98
}
 
99
 
 
100
void WidgetForMount::mount() {  
 
101
        qDebug() << "[I] Mount the partition" << currentBlockName << "with options" << optionsLine->text() << "to" << mountPointLine->mountPoint();
 
102
        core->mount(currentBlockName,mountPointLine->mountPoint(),currentFileSystem,optionsLine->text());
 
103
        hide();
 
104
}